summaryrefslogtreecommitdiffstats
path: root/.gitignore
blob: fbaa2da15ec1bf3e3e34ae6af7580952c77cebd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
amixer
autom4te.cache
config.log 
build/*
dist/*
!.gitignore
.dep.inc
CMakeFiles/
CMakeCache.txt
nbproject/private/*
Makefile
cmake_install.cmake
*.so
.vscode
stress-out*
#fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/bin/bash

function build {
	echo "ACTION: build"
	if [ ! -d "$1/$2" ]; then
		echo "INFO: build dir ($1/$2) doesn't exist, created it!"
		mkdir -p "$1/$2"
	fi
	pushd "$1/$2"
	#cd "$1/$2"
	cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$3 $1
	make
	popd
}

function clean {
	echo "ACTION: clean"
	if [ -d "$1/$2" ]; then
		rm -vrf "$1/$2"
	fi
}

function rebuild {
	clean $1 $2
	build $1 $2 $3
}

function printhelp {
	echo "Usage: build.sh <action> <subdir> [config]"
	echo "	action: can be one of the following"
	echo "		build: build this project."
	echo "		rebuild: rebuild this project."
	echo "		clean: clean the previous build."
	echo "		install: install the build result."
	echo "	subdir: the subdir into which the build is done."
	echo "	config: can be Debug or Release. Ignored if the action is 'clean'."
}

function checkparams {
	if [ "$#" -ne "$(($1+1))" ]; then
		echo "ERROR: Wrong number of parameters, expected $1 but got $(($#-1))"
		printhelp
		exit 1
	fi
}

function main {
	CURRENT_DIR=$( dirname "$(readlink -f "$0")" )
	echo "Current script: $CURRENT_DIR"

	if [ "$#" -lt "1" ]; then
		echo "ERROR: At least <action> must be specified!"
		exit 1
	fi

	case "$1" in
		"build")
			checkparams 3 $*
			build $CURRENT_DIR $2 $3
			;;
		"rebuild")
			checkparams 3 $*
			rebuild $CURRENT_DIR $2 $3
			;;
		"clean")
			checkparams 2 $*
			clean $CURRENT_DIR $2
			;;
		"install")
			checkparams 3 $*
			echo "ERROR: Not implemented yet!"
			;;
		*)
			echo "ERROR: Unknown action '$3'!"
			exit 1 
			;;
	esac
}

main $*