Last active
September 16, 2018 12:07
-
-
Save harrisonturton/b9f73093f3fbd1eac84205389e5d8932 to your computer and use it in GitHub Desktop.
Script to autobuild COMP2310 Assignment 1. It automatically detects your OS, and allows you to easily set the build mode from the commandline.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Harrison Turton 2018 | |
# -------------------------------------- | |
# This script will automatically detect your | |
# operating system, and build accordingly. | |
# | |
# A build mode flag can be included, wherein | |
# the script will supply the relevant build | |
# mode flags to gnatmake. Defaults to | |
# Development. | |
# | |
# Usage: | |
# ./autobuild [dev|prod|perf] | |
# -------------------------------------- | |
# Detect build mode flags | |
if [[ $# -ge 1 ]] ; then | |
case $1 in | |
prod) build_mode=Production ;; | |
dev) build_mode=Development ;; | |
perf) build_mode=Performance ;; | |
*) | |
echo "Unknown Build Mode. Aborting." | |
exit 1 | |
;; | |
esac | |
else | |
build_mode=Development | |
fi | |
echo "Building for $build_mode" | |
echo "Detecting OS..." | |
# Detect operating system | |
case $OSTYPE in | |
darwin*) os=mac ;; | |
cygwin*|msys|win32) os=windows ;; | |
linux*) os=linux ;; | |
*) | |
echo "Unknown OS. Aborting." | |
exit 1 | |
;; | |
esac | |
echo "Detected $os" | |
# Build for detected OS | |
case $os in | |
mac) gnatmake -Pswarm_mac_os.gpr -XSpecific_build_modes=$build_mode ;; | |
windows) gnatmake -Pswarm_windows.gpr -XSpecific_build_modes=$build_mode ;; | |
linux) gnatmake -Pswarm_linux.gpr -XSpecific_build_modes=$build_mode ;; | |
esac | |
# If build failed | |
if [[ $? -ne 0 ]] ; then | |
echo "Build failed." | |
exit 0 | |
fi | |
echo "Finished building for $os" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To build with
Development
flags:To build with
Performance
flags:To build with
Production
flags: