From 276833e6e199e43bb1b8f2134b0b6c30316e3fe4 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 8 Aug 2019 19:41:12 -0500 Subject: [PATCH] Update: implement bash support in generate.sh The generate script now supports handling bash scripts. --- build/scripts/generate.sh | 49 ++++++++++++++---------- level_0/f_colors/data/build/settings | 1 + level_0/f_console/data/build/settings | 1 + level_0/f_conversion/data/build/settings | 1 + level_0/f_errors/data/build/settings | 1 + level_0/f_file/data/build/settings | 1 + level_0/f_fss/data/build/settings | 1 + level_0/f_memory/data/build/settings | 1 + level_0/f_paths/data/build/settings | 1 + level_0/f_pipe/data/build/settings | 1 + level_0/f_print/data/build/settings | 1 + level_0/f_serialized/data/build/settings | 1 + level_0/f_strings/data/build/settings | 1 + level_0/f_types/data/build/settings | 1 + level_1/fl_colors/data/build/settings | 1 + level_1/fl_console/data/build/settings | 1 + level_1/fl_directory/data/build/settings | 1 + level_1/fl_errors/data/build/settings | 1 + level_1/fl_file/data/build/settings | 1 + level_1/fl_fss/data/build/settings | 1 + level_1/fl_serialized/data/build/settings | 1 + level_1/fl_strings/data/build/settings | 1 + level_2/fll_colors/data/build/settings | 1 + level_2/fll_execute/data/build/settings | 1 + level_2/fll_fss/data/build/settings | 1 + level_3/firewall/data/build/settings | 1 + level_3/fss_basic_list_read/data/build/settings | 1 + level_3/fss_basic_list_write/data/build/settings | 1 + level_3/fss_basic_read/data/build/settings | 1 + level_3/fss_basic_write/data/build/settings | 1 + level_3/fss_extended_read/data/build/settings | 1 + level_3/fss_extended_write/data/build/settings | 1 + level_3/fss_return_code/data/build/settings | 1 + level_3/init/data/build/settings | 1 + level_3/return_code/data/build/settings | 1 + 35 files changed, 63 insertions(+), 20 deletions(-) diff --git a/build/scripts/generate.sh b/build/scripts/generate.sh index 989a496..7cc6a59 100644 --- a/build/scripts/generate.sh +++ b/build/scripts/generate.sh @@ -37,7 +37,7 @@ generate_main(){ local path_build_settings= local path_c=sources/c/ local path_settings=data/settings/ - local path_bash=sources/bash/ + local path_bash= local project_built= local work_directory= local defines_override= @@ -134,12 +134,13 @@ generate_main(){ generate_load_settings - # TODO: enable when bash support is implemented - #if [[ ! -d $path_bash ]] ; then - # echo -e "${c_error}ERROR: the bash path of $c_notice$path_bash$c_error is invalid.$c_reset" - # generate_cleanup - # exit 0 - #fi + if [[ $path_bash == "" ]] ; then + path_bash=sources/bash/ + elif [[ ! -d $path_bash ]] ; then + echo -e "${c_error}ERROR: the bash path of $c_notice$path_bash$c_error is not a valid directory.$c_reset" + generate_cleanup + exit 0 + fi if [[ $work_directory != "" && ! -d $work_directory ]] ; then echo -e "${c_error}ERROR: the work directory $c_notice$work_directory$c_error is not a valid directory.$c_reset" @@ -251,17 +252,18 @@ generate_id(){ "build_sources_library") echo -n 9;; "build_sources_program") echo -n 10;; "build_sources_headers") echo -n 11;; - "build_sources_settings") echo -n 12;; - "build_shared") echo -n 13;; - "build_static") echo -n 14;; - "defines_all") echo -n 15;; - "defines_shared") echo -n 16;; - "defines_static") echo -n 17;; - "flags_all") echo -n 18;; - "flags_shared") echo -n 19;; - "flags_static") echo -n 20;; - "flags_library") echo -n 21;; - "flags_program") echo -n 22;; + "build_sources_bash") echo -n 12;; + "build_sources_settings") echo -n 13;; + "build_shared") echo -n 14;; + "build_static") echo -n 15;; + "defines_all") echo -n 16;; + "defines_shared") echo -n 17;; + "defines_static") echo -n 18;; + "flags_all") echo -n 19;; + "flags_shared") echo -n 20;; + "flags_static") echo -n 21;; + "flags_library") echo -n 22;; + "flags_program") echo -n 23;; esac } @@ -300,7 +302,7 @@ generate_prepare_build(){ local level=${variables[$(generate_id project_level)]} local alt=$1 - mkdir -vp ${path_build}{includes,programs/{shared,static},libraries/{shared,static},objects,settings} || failure=1 + mkdir -vp ${path_build}{includes,programs/{shared,static},libraries/{shared,static},objects,bash,settings} || failure=1 if [[ $failure == "" && $level != "" ]] ; then mkdir -vp ${path_build}includes/level_$level || failure=1 @@ -343,6 +345,7 @@ generate_operation_build(){ local sources_library=${variables[$(generate_id build_sources_library)]} local sources_program=${variables[$(generate_id build_sources_program)]} local sources_headers=${variables[$(generate_id build_sources_headers)]} + local sources_bash=${variables[$(generate_id build_sources_bash)]} local sources_settings=${variables[$(generate_id build_sources_settings)]} local sources= local defines=${variables[$(generate_id defines_all)]} @@ -489,6 +492,12 @@ generate_operation_build(){ fi fi + if [[ $failure == "" && $sources_bash != "" ]] ; then + for i in $sources_bash ; do + cp -vf $path_bash$i ${path_build}bash/ || failure=1 + done + fi + if [[ $failure != "" ]] ; then echo -e "${c_error}ERROR: failed to build.$c_reset" generate_cleanup @@ -501,7 +510,7 @@ generate_operation_build(){ generate_operation_clean(){ local i= - for i in ${path_build}{includes,programs,libraries,settings} ; do + for i in ${path_build}{includes,programs,libraries,bash,settings} ; do if [[ -e $i ]] ; then rm -vRf $i fi diff --git a/level_0/f_colors/data/build/settings b/level_0/f_colors/data/build/settings index eb32c98..a4abe9d 100644 --- a/level_0/f_colors/data/build/settings +++ b/level_0/f_colors/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library build_sources_program build_sources_headers colors.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_console/data/build/settings b/level_0/f_console/data/build/settings index d63cc7b..7250d37 100644 --- a/level_0/f_console/data/build/settings +++ b/level_0/f_console/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library console.c build_sources_program build_sources_headers console.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_conversion/data/build/settings b/level_0/f_conversion/data/build/settings index 099ccb7..bec9cfb 100644 --- a/level_0/f_conversion/data/build/settings +++ b/level_0/f_conversion/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library conversion.c build_sources_program build_sources_headers conversion.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_errors/data/build/settings b/level_0/f_errors/data/build/settings index 05d2791..eaa1fea 100644 --- a/level_0/f_errors/data/build/settings +++ b/level_0/f_errors/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library build_sources_program build_sources_headers errors.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_file/data/build/settings b/level_0/f_file/data/build/settings index 38a4e54..7c05aa0 100644 --- a/level_0/f_file/data/build/settings +++ b/level_0/f_file/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library file.c build_sources_program build_sources_headers file.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_fss/data/build/settings b/level_0/f_fss/data/build/settings index adf2f0c..7c86d61 100644 --- a/level_0/f_fss/data/build/settings +++ b/level_0/f_fss/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library build_sources_program build_sources_headers fss.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_memory/data/build/settings b/level_0/f_memory/data/build/settings index 1778145..99265bf 100644 --- a/level_0/f_memory/data/build/settings +++ b/level_0/f_memory/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library memory.c build_sources_program build_sources_headers memory.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_paths/data/build/settings b/level_0/f_paths/data/build/settings index a6bd3a5..8b0414f 100644 --- a/level_0/f_paths/data/build/settings +++ b/level_0/f_paths/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library build_sources_program build_sources_headers fll_paths.h filesystem_paths.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_pipe/data/build/settings b/level_0/f_pipe/data/build/settings index 0fe52af..00b936a 100644 --- a/level_0/f_pipe/data/build/settings +++ b/level_0/f_pipe/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library pipe.c build_sources_program build_sources_headers pipe.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_print/data/build/settings b/level_0/f_print/data/build/settings index 4491e99..aec39ad 100644 --- a/level_0/f_print/data/build/settings +++ b/level_0/f_print/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library print.c build_sources_program build_sources_headers print.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_serialized/data/build/settings b/level_0/f_serialized/data/build/settings index 5e37bd8..7044f21 100644 --- a/level_0/f_serialized/data/build/settings +++ b/level_0/f_serialized/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library build_sources_program build_sources_headers serialized.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_strings/data/build/settings b/level_0/f_strings/data/build/settings index 4260270..7b1cc48 100644 --- a/level_0/f_strings/data/build/settings +++ b/level_0/f_strings/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library build_sources_program build_sources_headers strings.h +build_sources_bash build_shared yes build_static yes diff --git a/level_0/f_types/data/build/settings b/level_0/f_types/data/build/settings index 256c6fc..0a830df 100644 --- a/level_0/f_types/data/build/settings +++ b/level_0/f_types/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library build_sources_program build_sources_headers types.h types_array.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_colors/data/build/settings b/level_1/fl_colors/data/build/settings index 7da62c0..49bdddd 100644 --- a/level_1/fl_colors/data/build/settings +++ b/level_1/fl_colors/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_memory -lf_file build_sources_library colors.c build_sources_program build_sources_headers colors.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_console/data/build/settings b/level_1/fl_console/data/build/settings index fe983ee..1af3ead 100644 --- a/level_1/fl_console/data/build/settings +++ b/level_1/fl_console/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_memory -lf_console build_sources_library console.c build_sources_program build_sources_headers console.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_directory/data/build/settings b/level_1/fl_directory/data/build/settings index 4d6dc70..687cb9f 100644 --- a/level_1/fl_directory/data/build/settings +++ b/level_1/fl_directory/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_memory build_sources_library directory.c build_sources_program build_sources_headers directory.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_errors/data/build/settings b/level_1/fl_errors/data/build/settings index 2603b2d..af38ab8 100644 --- a/level_1/fl_errors/data/build/settings +++ b/level_1/fl_errors/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll build_sources_library errors.c build_sources_program build_sources_headers errors.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_file/data/build/settings b/level_1/fl_file/data/build/settings index c2276cc..da76f58 100644 --- a/level_1/fl_file/data/build/settings +++ b/level_1/fl_file/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_memory -lf_file build_sources_library file.c build_sources_program build_sources_headers file.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_fss/data/build/settings b/level_1/fl_fss/data/build/settings index fda1b01..fce372e 100644 --- a/level_1/fl_fss/data/build/settings +++ b/level_1/fl_fss/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_conversion -lf_file -lf_memory build_sources_library fss.c fss_basic.c fss_basic_list.c fss_extended.c build_sources_program build_sources_headers fss.h fss_basic.h fss_basic_list.h fss_errors.h fss_extended.h fss_macro.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_serialized/data/build/settings b/level_1/fl_serialized/data/build/settings index 15f84f5..191789d 100644 --- a/level_1/fl_serialized/data/build/settings +++ b/level_1/fl_serialized/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_memory build_sources_library serialized.c build_sources_program build_sources_headers serialized.h +build_sources_bash build_shared yes build_static yes diff --git a/level_1/fl_strings/data/build/settings b/level_1/fl_strings/data/build/settings index fe1eeec..e7c0d73 100644 --- a/level_1/fl_strings/data/build/settings +++ b/level_1/fl_strings/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_memory build_sources_library strings.c build_sources_program build_sources_headers strings.h +build_sources_bash build_shared yes build_static yes diff --git a/level_2/fll_colors/data/build/settings b/level_2/fll_colors/data/build/settings index f3152ce..592c09b 100644 --- a/level_2/fll_colors/data/build/settings +++ b/level_2/fll_colors/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lfl_colors -lf_memory build_sources_library colors.c build_sources_program build_sources_headers colors.h +build_sources_bash build_shared yes build_static yes diff --git a/level_2/fll_execute/data/build/settings b/level_2/fll_execute/data/build/settings index 53b8193..044da81 100644 --- a/level_2/fll_execute/data/build/settings +++ b/level_2/fll_execute/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lf_memory build_sources_library execute.c build_sources_program build_sources_headers execute.h +build_sources_bash build_shared yes build_static yes diff --git a/level_2/fll_fss/data/build/settings b/level_2/fll_fss/data/build/settings index 98874c8..2155f49 100644 --- a/level_2/fll_fss/data/build/settings +++ b/level_2/fll_fss/data/build/settings @@ -14,6 +14,7 @@ build_libraries_fll -lfl_errors -lfl_fss -lf_conversion -lf_file -lf_memory build_sources_library fss_basic.c fss_basic_list.c fss_extended.c fss_errors.c build_sources_program build_sources_headers fss_basic.h fss_basic_list.h fss_extended.h fss_errors.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/firewall/data/build/settings b/level_3/firewall/data/build/settings index daef26d..2aa8c5c 100644 --- a/level_3/firewall/data/build/settings +++ b/level_3/firewall/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfll_execute -lfl_directory -lfl_col build_sources_library firewall.c private-firewall.c build_sources_program main.c build_sources_headers firewall.h +build_sources_bash build_sources_settings default-blacklist default-whitelist example-device-firewall firewall-first firewall-last firewall-other build_shared yes build_static yes diff --git a/level_3/fss_basic_list_read/data/build/settings b/level_3/fss_basic_list_read/data/build/settings index a1b2ada..6723438 100644 --- a/level_3/fss_basic_list_read/data/build/settings +++ b/level_3/fss_basic_list_read/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfll_execute -lfl_directory -lfl_col build_sources_library fss_basic_list_read.c build_sources_program main.c build_sources_headers fss_basic_list_read.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/fss_basic_list_write/data/build/settings b/level_3/fss_basic_list_write/data/build/settings index defe035..5ecc495 100644 --- a/level_3/fss_basic_list_write/data/build/settings +++ b/level_3/fss_basic_list_write/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfl_fss -lfl_file -lfl_errors -lfl_c build_sources_library fss_basic_list_write.c build_sources_program main.c build_sources_headers fss_basic_list_write.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/fss_basic_read/data/build/settings b/level_3/fss_basic_read/data/build/settings index be40484..aa875b7 100644 --- a/level_3/fss_basic_read/data/build/settings +++ b/level_3/fss_basic_read/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfll_execute -lfl_directory -lfl_col build_sources_library fss_basic_read.c build_sources_program main.c build_sources_headers fss_basic_read.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/fss_basic_write/data/build/settings b/level_3/fss_basic_write/data/build/settings index 8733b3c..981f1ee 100644 --- a/level_3/fss_basic_write/data/build/settings +++ b/level_3/fss_basic_write/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfl_fss -lfl_file -lfl_errors -lfl_c build_sources_library fss_basic_write.c build_sources_program main.c build_sources_headers fss_basic_write.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/fss_extended_read/data/build/settings b/level_3/fss_extended_read/data/build/settings index dcb9034..b9dc516 100644 --- a/level_3/fss_extended_read/data/build/settings +++ b/level_3/fss_extended_read/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfll_execute -lfl_directory -lfl_col build_sources_library fss_extended_read.c build_sources_program main.c build_sources_headers fss_extended_read.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/fss_extended_write/data/build/settings b/level_3/fss_extended_write/data/build/settings index c1f6cf2..2b9060c 100644 --- a/level_3/fss_extended_write/data/build/settings +++ b/level_3/fss_extended_write/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfl_fss -lfl_file -lfl_errors -lfl_c build_sources_library fss_extended_write.c build_sources_program main.c build_sources_headers fss_extended_write.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/fss_return_code/data/build/settings b/level_3/fss_return_code/data/build/settings index c65ede0..c8c8b94 100644 --- a/level_3/fss_return_code/data/build/settings +++ b/level_3/fss_return_code/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfl_fss -lfl_errors -lfl_colors -lfl build_sources_library fss_return_code.c build_sources_program main.c build_sources_headers fss_return_code.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/init/data/build/settings b/level_3/init/data/build/settings index e280e45..be55b4e 100644 --- a/level_3/init/data/build/settings +++ b/level_3/init/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfll_fss -lfll_execute -lfl_directory -lfl_col build_sources_library init.c private-init.c build_sources_program main.c build_sources_headers init.h +build_sources_bash build_shared yes build_static yes diff --git a/level_3/return_code/data/build/settings b/level_3/return_code/data/build/settings index e48a4af..f54f0a8 100644 --- a/level_3/return_code/data/build/settings +++ b/level_3/return_code/data/build/settings @@ -16,6 +16,7 @@ build_libraries_fll -lfll_colors -lfl_errors -lfl_colors -lfl_console -lf_print build_sources_library return_code.c build_sources_program main.c build_sources_headers return_code.h +build_sources_bash build_shared yes build_static yes -- 1.8.3.1