[bld] setup new feature for include path management

This commit is contained in:
Allen Webster
2021-09-25 17:37:33 -07:00
parent 70e630cab6
commit 3f5d4a96a9
9 changed files with 88 additions and 20 deletions
+17 -9
View File
@@ -186,21 +186,29 @@ function bld_compile {
###### finith in file #####################################################
local final_in_file=$root_path/$in_file
###### finish options #####################################################
local src_opts=($(bld_opts_from_src $final_in_file))
local all_opts=($(bld_dedup ${opts[@]} ${src_opts[@]}))
###### diagnostics ########################################################
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
###### out file name ######################################################
local file_base=${final_in_file##*/}
local file_base_no_ext=${file_base%.*}
local out_file="$file_base_no_ext$dot_ext_obj"
###### finish options #####################################################
local src_opts=($(bld_opts_from_src $final_in_file))
local all_opts=($(bld_dedup $file_base ${opts[@]} ${src_opts[@]}))
###### diagnostics ########################################################
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
###### get real flags #####################################################
local flags_file=$bin_path/compiler_flags.txt
local flags=$(bld_flags_from_opts $flags_file ${all_opts[@]})
local flags=($(bld_flags_from_opts $flags_file ${all_opts[@]}))
###### get inc paths ######################################################
local paths_file=$bin_path/compiler_inc_paths.txt
local paths=($(bld_flags_from_opts $paths_file ${all_opts[@]}))
local incs=()
for ((i=0; i<${#paths[@]}; i+=1)); do
incs+=("-I$root_path/${paths[i]}")
done
###### move to output folder ##############################################
mkdir -p "$build_path"
@@ -211,7 +219,7 @@ function bld_compile {
rm -f "$out_file_base.obj"
###### get flags ##########################################################
local all_flags="-c -I$src_path ${flags}"
local all_flags="-c -I$src_path ${incs[@]} ${flags[@]}"
###### diagnostic output ##################################################
if [ "$diagnostics" == "1" ]; then
+2 -1
View File
@@ -11,16 +11,17 @@ bin/bld_core.sh show_ctx
examps="examples"
bin/bld_core.sh unit type_metadata $examps/type_metadata/type_metadata.c
bin/bld_core.sh unit hello_world $examps/intro/hello_world.c
bin/bld_core.sh unit parse_check $examps/intro/parse_check.c
bin/bld_core.sh unit datadesk_like $examps/intro/datadesk_like_template.c
bin/bld_core.sh unit user_errors $examps/user_errors/user_errors.c
bin/bld_core.sh unit type_metadata $examps/type_metadata/type_metadata.c
if [ -d $examps/type_metadata/generated/type_info_meta.h ]; then
bin/bld_core.sh unit type_info $examps/type_metadata/type_info_final_program.c
fi
echo
###### Restore Path ###########################################################
+1
View File
@@ -14,3 +14,4 @@ clang>-Wno-unknown-warning-option
###### Debug ##################################################################
debug>cl>-Zi
debug>clang>-g
+2
View File
@@ -0,0 +1,2 @@
###### Examples ###############################################################
type_info_final_program.c>examples/type_metadata
+1 -2
View File
@@ -6,10 +6,9 @@ cd "$(dirname "$0")"
cd ..
root_path=$PWD
build_path=$root_path/build
examps=$root_path/examples
echo ~~~ Running Type Metadata Example ~~~
echo ~~~ Running Type Metadata Generator Example ~~~
cd $examps/type_metadata/generated
$build_path/type_metadata.exe $examps/type_metadata/types.mdesk
echo
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
###### Get Paths ##############################################################
og_path=$PWD
cd "$(dirname "$0")"
cd ..
root_path=$PWD
build_path=$root_path/build
bin_path=$root_path/bin
# TODO(allen): IMPORTANT!! Build scripts here are a bit of a mess. They force
# us to use non-absolute paths for builds, but then we need absolute paths for
# other things. Not good!
examps_path=$root_path/examples
examps=examples
###### Script #################################################################
echo ~~~ Type Info Example ~~~
$bin_path/bld_core.sh show_ctx
echo ~~~ Building Metaprogram ~~~
$bin_path/bld_core.sh unit type_metadata $examps/type_metadata/type_metadata.c
echo ~~~ Running Metaprogram ~~~
cd $examps/type_metadata/generated
$build_path/type_metadata.exe $examps_path/type_metadata/types.mdesk
echo
if [ -f $examps_path/type_metadata/generated/meta_types.h ]; then
echo ~~~ Building Program ~~~
$bin_path/bld_core.sh unit type_info $examps/type_metadata/type_info_final_program.c
else
echo !!! Skipping Program !!!
fi
echo
###### Restore Path ###########################################################
cd $og_path