added --run flag

This commit is contained in:
CZmisaCZ 2024-03-26 21:15:14 +01:00
parent 724aafa846
commit 363adbb741
2 changed files with 21 additions and 1 deletions

View file

@ -16,6 +16,7 @@ Run the script `builder.sh` with the following options:
- `-c, --clean` : Clean build. - `-c, --clean` : Clean build.
- `-u, --update` : Update Mozilla repository. - `-u, --update` : Update Mozilla repository.
- `-p, --patches` : Update patches. - `-p, --patches` : Update patches.
- `-r, --run` : Run the project after build using mach run in the browser directory
- `-h, --help` : Display usage instructions. - `-h, --help` : Display usage instructions.
For example: For example:

View file

@ -66,6 +66,13 @@ configure_and_build() {
./mach build || { echo "Build failed. Exiting."; exit 1; } ./mach build || { echo "Build failed. Exiting."; exit 1; }
} }
# Function to run the project after build
run_project() {
echo "Running the project..."
cd "$SOURCE_PATH" || { echo "Failed to navigate to browser directory. Exiting."; exit 1; }
./mach run || { echo "Failed to run the project. Exiting."; exit 1; }
}
# Function to print usage instructions # Function to print usage instructions
print_help() { print_help() {
echo "Usage: ./builder.sh [options]" echo "Usage: ./builder.sh [options]"
@ -75,6 +82,7 @@ print_help() {
echo " -c, --clean : Clean build" echo " -c, --clean : Clean build"
echo " -u, --update : Update Mozilla repository" echo " -u, --update : Update Mozilla repository"
echo " -p, --patches : Update patches" echo " -p, --patches : Update patches"
echo " -r, --run : Run the project after build using mach run in the browser directory"
echo " -h, --help : Display this help message" echo " -h, --help : Display this help message"
exit 1 exit 1
} }
@ -98,6 +106,9 @@ while [[ $# -gt 0 ]]; do
-p|--patches) -p|--patches)
patches=true patches=true
;; ;;
-r|--run)
run=true
;;
-h|--help) -h|--help)
print_help print_help
;; ;;
@ -117,9 +128,15 @@ if [ "$all" = true ]; then
update_repo update_repo
update_patches update_patches
configure_and_build configure_and_build
if [ "$run" = true ]; then
run_project
fi
echo "Spitfire build completed successfully." echo "Spitfire build completed successfully."
if [ "$build" = true ]; then elif [ "$build" = true ]; then
configure_and_build configure_and_build
if [ "$run" = true ]; then
run_project
fi
echo "Spitfire build completed successfully." echo "Spitfire build completed successfully."
elif [ "$clean" = true ]; then elif [ "$clean" = true ]; then
clean_build clean_build
@ -132,6 +149,8 @@ elif [ "$patches" = true ]; then
download_source download_source
update_patches update_patches
echo "Patches updated." echo "Patches updated."
elif [ "$run" = true ]; then
run_project
else else
print_help print_help
fi fi