Skip to content

Commit

Permalink
Building Firmware from Git Commits (#96)
Browse files Browse the repository at this point in the history
* Firmware project build script in bash

* Minor fixes, removed python env init, changed to clean build

* Add firmware path check and exit error codes

* Print error code if make clean build fails

* Return exit code of make upon script exit
  • Loading branch information
Tegh25 authored Nov 14, 2024
1 parent dc782f4 commit 0847a22
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions scripts/build_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Author: Teghveer Singh Ateliey
# Date: 2024-10-30

# Check args
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <commit-hash> <repo-path> <project> <platform>"
exit 2
fi

# Assign inputs to variables
COMMIT_HASH=$1
RACECAR_PATH=$2
PROJECT=$3
PLATFORM=$4

# Checks if directory exists
FW_PATH=$RACECAR_PATH/firmware
if [ ! -d "$FW_PATH" ]; then
echo "Error: Firmware directory not found within repository path '$RACECAR_PATH'."
exit 2
fi

# Navigate to the racecar/firmware directory path
cd "$FW_PATH"

# Fetch latest changes and check out the specified commit
git fetch --all
git checkout "$COMMIT_HASH"

# Build command
make PROJECT="$PROJECT" PLATFORM="$PLATFORM" clean build
MAKE_ERR_CODE=$?

# Prints error code of make if command fails
if [ "$MAKE_ERR_CODE" -ne 0 ]; then
echo "Build failed with makefile error code: $MAKE_ERR_CODE"
else
echo "Build completed successfully!!"
fi

# Return to the main branch and return make exit code
git checkout main
exit $MAKE_ERR_CODE

0 comments on commit 0847a22

Please sign in to comment.