Skip to content

Instantly share code, notes, and snippets.

@harrisonturton
Last active September 16, 2018 12:07
Show Gist options
  • Save harrisonturton/b9f73093f3fbd1eac84205389e5d8932 to your computer and use it in GitHub Desktop.
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.
#!/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"
@harrisonturton
Copy link
Author

To build with Development flags:

$ ./autobuild

To build with Performance flags:

$ ./autobuild perf

To build with Production flags:

$ ./autobuild prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment