summaryrefslogtreecommitdiff
path: root/apps/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'apps/compiler')
-rwxr-xr-xapps/compiler/1-clean.sh5
-rwxr-xr-xapps/compiler/2-configure.sh5
-rwxr-xr-xapps/compiler/3-build.sh5
-rwxr-xr-xapps/compiler/compiler.sh74
-rw-r--r--apps/compiler/includes/functions.sh12
5 files changed, 61 insertions, 40 deletions
diff --git a/apps/compiler/1-clean.sh b/apps/compiler/1-clean.sh
deleted file mode 100755
index 558c093e3f..0000000000
--- a/apps/compiler/1-clean.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-bash "$CURRENT_PATH/compiler.sh" 1
diff --git a/apps/compiler/2-configure.sh b/apps/compiler/2-configure.sh
deleted file mode 100755
index 0d59b1caac..0000000000
--- a/apps/compiler/2-configure.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-bash "$CURRENT_PATH/compiler.sh" 2
diff --git a/apps/compiler/3-build.sh b/apps/compiler/3-build.sh
deleted file mode 100755
index 6956f82fd3..0000000000
--- a/apps/compiler/3-build.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-bash "$CURRENT_PATH/compiler.sh" 3
diff --git a/apps/compiler/compiler.sh b/apps/compiler/compiler.sh
index cb89bfb705..388ad41a32 100755
--- a/apps/compiler/compiler.sh
+++ b/apps/compiler/compiler.sh
@@ -4,41 +4,67 @@ CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_PATH/includes/includes.sh"
-function all() {
- comp_clean
- comp_configure
- comp_build
-}
-
function run_option() {
- if test "${comp_functions[$1-1]+'test'}"; then
+ re='^[0-9]+$'
+ if [[ $1 =~ $re ]] && test "${comp_functions[$1-1]+'test'}"; then
${comp_functions[$1-1]}
+ elif [ -n "$(type -t comp_$1)" ] && [ "$(type -t comp_$1)" = function ]; then
+ fun="comp_$1"
+ $fun
else
- echo "invalid option"
- fi
+ echo "invalid option, use --help option for the commands list"
+ fi
}
-comp_options=("Clean" "Configure" "Build" "All")
-comp_functions=("comp_clean" "comp_configure" "comp_build" "all")
+function comp_quit() {
+ exit 0
+}
-runHooks "ON_AFTER_OPTIONS" #you can create your custom options
+comp_options=(
+ "build: Configure and compile"
+ "clean: Clean build files"
+ "configure: Run CMake"
+ "compile: Compile only"
+ "all: clean, configure and compile"
+ "quit: Close this menu")
+comp_functions=(
+ "comp_build"
+ "comp_clean"
+ "comp_configure"
+ "comp_compile"
+ "comp_all"
+ "comp_quit")
-# push exit after custom options
-comp_options+=('Exit')
-comp_functions+=('exit 0')
+PS3='[ Please enter your choice ]: '
-# run option directly if specified in argument
-[ ! -z $1 ] && run_option $1 && exit 0
+runHooks "ON_AFTER_OPTIONS" #you can create your custom options
-PS3='[ Please enter your choice ]: '
-select opt in "${comp_options[@]}"
-do
- case $opt in
- 'Exit')
- break
+function _switch() {
+ _reply="$1"
+ _opt="$2"
+
+ case $_reply in
+ ""|"--help")
+ echo "Available commands:"
+ printf '%s\n' "${options[@]}"
;;
*)
- run_option $REPLY
+ run_option $_reply $_opt
;;
esac
+}
+
+
+while true
+do
+ # run option directly if specified in argument
+ [ ! -z $1 ] && _switch $@
+ [ ! -z $1 ] && exit 0
+
+ select opt in "${comp_options[@]}"
+ do
+ echo "==== ACORE COMPILER ===="
+ _switch $REPLY
+ break;
+ done
done
diff --git a/apps/compiler/includes/functions.sh b/apps/compiler/includes/functions.sh
index 4dfaa46038..947f9ff5fc 100644
--- a/apps/compiler/includes/functions.sh
+++ b/apps/compiler/includes/functions.sh
@@ -39,7 +39,7 @@ function comp_configure() {
}
-function comp_build() {
+function comp_compile() {
[ $MTHREADS == 0 ] && MTHREADS=`grep -c ^processor /proc/cpuinfo` && MTHREADS=$(($MTHREADS + 2))
echo "Using $MTHREADS threads"
@@ -55,3 +55,13 @@ function comp_build() {
runHooks "ON_AFTER_BUILD"
}
+
+function comp_build() {
+ comp_configure
+ comp_build
+}
+
+function comp_all() {
+ comp_clean
+ comp_build
+} \ No newline at end of file