mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-01 04:10:05 +00:00
new explicit build script diagnostic system; overrides system; move old build script content onto new system; reconfigure project.4coder
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
###### Get Paths ##############################################################
|
||||
og_path=$PWD
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
root_path=$PWD
|
||||
bin_path=$root_path/bin
|
||||
|
||||
###### Bin Scripts ############################################################
|
||||
$bin_path/build_tests.sh
|
||||
$bin_path/build_samples.sh
|
||||
$bin_path/run_tests.sh
|
||||
$bin_path/run_samples.sh
|
||||
|
||||
###### Restore Path ###########################################################
|
||||
cd $og_path
|
||||
+178
-72
@@ -34,57 +34,29 @@
|
||||
# Object files can be specified as '<name>.o' or '<name>.obj', and will be
|
||||
# automatically adjusted according to the selected compiler.
|
||||
|
||||
###### Get Paths ##############################################################
|
||||
og_path=$PWD
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
root_path=$PWD
|
||||
bin_path="$root_path/bin"
|
||||
local_path="$root_path/local"
|
||||
build_path="$root_path/build"
|
||||
src_path="$root_path/source"
|
||||
|
||||
###### Has Opt Function #######################################################
|
||||
|
||||
###### Crack Operating System From Environment ################################
|
||||
os="undefined"
|
||||
if [ "$OSTYPE" == "win32" ] ||
|
||||
[ "$OSTYPE" == "msys" ]; then
|
||||
os="windows"
|
||||
elif [ "$OSTYPE" == "linux-gnu" ]; then
|
||||
os="linux"
|
||||
elif [ "$OSTYPE" == "darwin" ]; then
|
||||
os="osx"
|
||||
fi
|
||||
|
||||
|
||||
###### Implicit Options #######################################################
|
||||
compiler=$($local_path/compiler.sh)
|
||||
linker=$($local_path/linker.sh)
|
||||
compile_mode=$($local_path/compile_mode.sh)
|
||||
ctx=$($local_path/ctx.sh)
|
||||
|
||||
implicit_opts=($out_name $compiler $linker $compile_mode $ctx $os)
|
||||
|
||||
|
||||
###### Object File Extension ##################################################
|
||||
dot_ext_obj=".obj"
|
||||
if [[ "$linker" == "clang" || "$linker" == "gcc" ]]; then
|
||||
dot_ext_obj=".o"
|
||||
fi
|
||||
|
||||
|
||||
###### Binary File Extension ##################################################
|
||||
dot_ext_exe=""
|
||||
dot_ext_dll=""
|
||||
if [ "$os" == "windows" ]; then
|
||||
dot_ext_exe=".exe"
|
||||
dot_ext_dll=".dll"
|
||||
elif [ "$os" == "linux" ] || [ "$os" == "mac" ]; then
|
||||
dot_ext_exe=""
|
||||
dot_ext_dll=".so"
|
||||
else
|
||||
echo "ERROR: binary extension not defined for OS: $os"
|
||||
fi
|
||||
function bld_has_opt {
|
||||
###### parse arguments ####################################################
|
||||
local key_opt=$1
|
||||
local opts=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
opts+=(${!i})
|
||||
done
|
||||
|
||||
###### scan ###############################################################
|
||||
local has_key=0
|
||||
for ((i=0;i<${#opts[@]};i+=1)); do
|
||||
local opt=${opts[i]}
|
||||
if [[ "$opt" == "$key_opt" ]]; then
|
||||
has_key=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo $has_key
|
||||
}
|
||||
|
||||
###### Flags From Opts Function ###############################################
|
||||
|
||||
@@ -208,7 +180,7 @@ function bld_compile {
|
||||
done
|
||||
|
||||
if [ "$in_file" == "" ]; then
|
||||
echo "lib: missing input file"
|
||||
echo "compile: missing input file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -219,14 +191,23 @@ function bld_compile {
|
||||
local src_opts=($(bld_opts_from_src $final_in_file))
|
||||
local all_opts=($(bld_dedup ${opts[@]} ${src_opts[@]}))
|
||||
|
||||
###### out file name ######################################################
|
||||
local out_file_base=${final_in_file##*/}
|
||||
local out_file_base_no_ext=${out_file_base%.*}
|
||||
local out_file="$out_file_base_no_ext$dot_ext_obj"
|
||||
###### diagnostics ########################################################
|
||||
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
|
||||
|
||||
###### feedback output ####################################################
|
||||
echo "cmp $final_in_file -- ${all_opts[@]}"
|
||||
echo ">>> $out_file"
|
||||
###### 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"
|
||||
|
||||
###### diagnostic output ##################################################
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "cmp $final_in_file -- ${all_opts[@]}"
|
||||
fi
|
||||
|
||||
###### print source file (if the compiler doesn't do it automatically) ####
|
||||
if [ "$manually_print_target" == "1" ]; then
|
||||
echo "$file_base"
|
||||
fi
|
||||
|
||||
###### get real flags #####################################################
|
||||
local flags_file=$bin_path/compiler_flags.txt
|
||||
@@ -264,17 +245,20 @@ function bld_link {
|
||||
done
|
||||
|
||||
if [ "$out_name" == "" ]; then
|
||||
echo "lib: missing output name"
|
||||
echo "link: missing output name"
|
||||
return 1
|
||||
fi
|
||||
if [ "${#in_files}" == "0" ]; then
|
||||
echo "lib: missing input file(s)"
|
||||
echo "link: missing input file(s)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
###### finish options #####################################################
|
||||
local all_opts=($(bld_dedup ${opts[@]}))
|
||||
|
||||
###### diagnostics ########################################################
|
||||
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
|
||||
|
||||
###### sort in files ######################################################
|
||||
local in_src=()
|
||||
local in_obj=()
|
||||
@@ -343,10 +327,14 @@ function bld_link {
|
||||
fi
|
||||
out_file="$out_name$dot_ext_out"
|
||||
|
||||
###### feedback output ####################################################
|
||||
###### diagnostic output ##################################################
|
||||
local final_in_files="${interm_obj[@]} ${in_obj[@]} ${in_lib[@]}"
|
||||
echo "lnk $final_in_files -- ${all_opts[@]}"
|
||||
echo ">>> $out_file"
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "lnk $final_in_files -- ${all_opts[@]}"
|
||||
fi
|
||||
|
||||
###### print output file ##################################################
|
||||
echo "$out_file"
|
||||
|
||||
###### move to output folder ##############################################
|
||||
mkdir -p "$build_path"
|
||||
@@ -356,9 +344,6 @@ function bld_link {
|
||||
if [ "$linker_kind" == "link" ]; then
|
||||
$linker -OUT:"$out_file" $flags $final_in_files
|
||||
elif [ "$linker_kind" == "clang" ]; then
|
||||
# TODO(allen): setup to use clang as the linker driver - much easier way
|
||||
# thank trying to use the actual linker on unix
|
||||
# NOTE(mal): You mean like this? (taking into account that $linker evaluates to clang)
|
||||
$linker -o "$out_file" $flags $final_in_files
|
||||
else
|
||||
echo "ERROR: invokation not defined for this linker"
|
||||
@@ -399,6 +384,9 @@ function bld_lib {
|
||||
###### finish options #####################################################
|
||||
local all_opts=($(bld_dedup ${opts[@]}))
|
||||
|
||||
###### diagnostics ########################################################
|
||||
local diagnostics=$(bld_has_opt diagnostics ${all_opts[@]})
|
||||
|
||||
###### sort in files ######################################################
|
||||
local in_src=()
|
||||
local in_obj=()
|
||||
@@ -449,10 +437,14 @@ function bld_lib {
|
||||
echo "ERROR: static library output not defined for OS: $os"
|
||||
fi
|
||||
|
||||
###### feedback output ####################################################
|
||||
###### diagnostic output ##################################################
|
||||
local final_in_files="${interm_obj[@]} ${in_obj[@]}"
|
||||
echo "lib $final_in_files -- ${all_opts[@]}"
|
||||
echo ">>> $out_file"
|
||||
if [ "$diagnostics" == "1" ]; then
|
||||
echo "lib $final_in_files -- ${all_opts[@]}"
|
||||
fi
|
||||
|
||||
###### print output file ##################################################
|
||||
echo "$out_file"
|
||||
|
||||
###### move to output folder ##############################################
|
||||
mkdir -p "$build_path"
|
||||
@@ -464,7 +456,7 @@ function bld_lib {
|
||||
elif [ "$os" == "linux" || "$os" == "mac" ]; then
|
||||
# TODO(allen): invoke ar here - make sure to delete the original .a first
|
||||
# because ar does not (seem) to replace the output file, just append
|
||||
echo "TODO: implement ar path in bld_core.sh:library"
|
||||
echo "TODO: implement ar path in bld_core.sh:bld_lib"
|
||||
false
|
||||
else
|
||||
echo "ERROR: static library invokation not defined for OS: $os"
|
||||
@@ -510,11 +502,117 @@ function bld_unit {
|
||||
}
|
||||
|
||||
|
||||
###### Show Ctx Function ######################################################
|
||||
|
||||
function bld_show_ctx {
|
||||
local mod_opts=()
|
||||
for ((i=0;i<${#implicit_opts[@]};i+=1)); do
|
||||
local mod_opt="[${implicit_opts[i]}]"
|
||||
mod_opts+=($mod_opt)
|
||||
done
|
||||
echo "${mod_opts[@]}"
|
||||
}
|
||||
|
||||
|
||||
###### Get Paths ##############################################################
|
||||
og_path=$PWD
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
|
||||
root_path=$PWD
|
||||
bin_path="$root_path/bin"
|
||||
local_path="$root_path/local"
|
||||
build_path="$root_path/build"
|
||||
src_path="$root_path/source"
|
||||
|
||||
|
||||
###### Crack Operating System From Environment ################################
|
||||
os="undefined"
|
||||
if [ "$OSTYPE" == "win32" ] ||
|
||||
[ "$OSTYPE" == "msys" ]; then
|
||||
os="windows"
|
||||
elif [ "$OSTYPE" == "linux-gnu" ]; then
|
||||
os="linux"
|
||||
elif [ "$OSTYPE" == "darwin" ]; then
|
||||
os="osx"
|
||||
fi
|
||||
|
||||
|
||||
###### Implicit Options #######################################################
|
||||
compiler=$($local_path/compiler.sh)
|
||||
linker=$($local_path/linker.sh)
|
||||
compile_mode=$($local_path/compile_mode.sh)
|
||||
arch=$($local_path/arch.sh)
|
||||
ctx=$($local_path/ctx.sh)
|
||||
|
||||
|
||||
###### Apply Override #########################################################
|
||||
parse_i="1"
|
||||
override_list=()
|
||||
if [ "${!parse_i}" == "override" ]; then
|
||||
for ((parse_i+=1; parse_i<=$#; parse_i+=1)); do
|
||||
arg="${!parse_i}"
|
||||
if [ "$arg" == "--" ]; then
|
||||
((parse_i+=1))
|
||||
break
|
||||
fi
|
||||
if [[ "$arg" == *":"* ]]; then
|
||||
arg_key="${arg%%:*}"
|
||||
arg_val="${arg#*:}"
|
||||
declare "${arg_key}=$arg_val"
|
||||
override_list+=("[$arg]")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
###### Finish Implicit Options ################################################
|
||||
implicit_opts=($out_name $compiler $linker $compile_mode $os $arch $ctx)
|
||||
|
||||
|
||||
###### Object File Extension ##################################################
|
||||
dot_ext_obj=".obj"
|
||||
if [[ "$linker" == "clang" || "$linker" == "gcc" ]]; then
|
||||
dot_ext_obj=".o"
|
||||
fi
|
||||
|
||||
|
||||
###### Binary File Extension ##################################################
|
||||
dot_ext_exe=""
|
||||
dot_ext_dll=""
|
||||
if [ "$os" == "windows" ]; then
|
||||
dot_ext_exe=".exe"
|
||||
dot_ext_dll=".dll"
|
||||
elif [ "$os" == "linux" ] || [ "$os" == "mac" ]; then
|
||||
dot_ext_exe=""
|
||||
dot_ext_dll=".so"
|
||||
else
|
||||
echo "ERROR: binary extension not defined for OS: $os"
|
||||
fi
|
||||
|
||||
|
||||
###### Binary File Extension ##################################################
|
||||
manually_print_target="0"
|
||||
if [ "$compiler" == "clang" ]; then
|
||||
manually_print_target="1"
|
||||
fi
|
||||
|
||||
|
||||
###### Diagnostics ############################################################
|
||||
top_diagnostics=$(bld_has_opt diagnostics ${implicit_opts[@]})
|
||||
|
||||
|
||||
###### Overrides Diagnostics ##################################################
|
||||
if [[ "$top_diagnostics" == "1" && "${#override_list}" != "0" ]]; then
|
||||
echo "${override_list[@]} {"
|
||||
fi
|
||||
|
||||
|
||||
###### Control ################################################################
|
||||
command=$1
|
||||
command=${!parse_i}
|
||||
args=()
|
||||
for ((i=2; i<=$#; i+=1)); do
|
||||
args+=(${!i})
|
||||
for ((parse_i+=1; parse_i<=$#; parse_i+=1)); do
|
||||
args+=(${!parse_i})
|
||||
done
|
||||
|
||||
if [ "$command" == "compile" ]; then
|
||||
@@ -525,10 +623,18 @@ elif [ "$command" == "lib" ]; then
|
||||
bld_lib ${args[@]}
|
||||
elif [ "$command" == "unit" ]; then
|
||||
bld_unit ${args[@]}
|
||||
elif [ "$command" == "show_ctx" ]; then
|
||||
bld_show_ctx
|
||||
else
|
||||
echo "'$command' not a recognized command"
|
||||
fi
|
||||
|
||||
|
||||
###### Overrides Diagnostics ##################################################
|
||||
if [[ "$top_diagnostics" == "1" && "${#override_list}" != "0" ]]; then
|
||||
echo "}"
|
||||
fi
|
||||
|
||||
|
||||
###### Restore Path ###########################################################
|
||||
cd $og_path
|
||||
|
||||
@@ -10,6 +10,7 @@ local_file_names=(
|
||||
compile_mode.sh
|
||||
ctx.sh
|
||||
linker.sh
|
||||
arch.sh
|
||||
)
|
||||
|
||||
###### Get Paths ##############################################################
|
||||
|
||||
@@ -7,14 +7,17 @@ cd ..
|
||||
|
||||
###### Script #################################################################
|
||||
echo "~~~ Build All Samples ~~~"
|
||||
bin/bld_core.sh show_ctx
|
||||
|
||||
bin/bld_core.sh unit old_style_custom_layer samples/old_style_custom_layer.c
|
||||
bin/bld_core.sh unit toy_language samples/toy_language/toy_language.c
|
||||
bin/bld_core.sh unit toy_language samples/toy_language/toy_language.c
|
||||
bin/bld_core.sh unit static_site_generator samples/static_site_generator/static_site_generator.c
|
||||
bin/bld_core.sh unit output_parse samples/output_parse/output_parse.c
|
||||
bin/bld_core.sh unit output_parse samples/output_parse/output_parse.c
|
||||
bin/bld_core.sh unit c_code_generation samples/c_code_generation.c
|
||||
bin/bld_core.sh unit node_errors samples/node_errors/node_errors.c
|
||||
bin/bld_core.sh unit parse_check samples/parse_check.c
|
||||
bin/bld_core.sh unit node_errors samples/node_errors/node_errors.c
|
||||
bin/bld_core.sh unit parse_check samples/parse_check.c
|
||||
|
||||
echo
|
||||
|
||||
###### Restore Path ###########################################################
|
||||
cd $og_path
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
###### Get Paths ##############################################################
|
||||
og_path=$PWD
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
|
||||
###### Script #################################################################
|
||||
echo "~~~ Build All Tests ~~~"
|
||||
bin/bld_core.sh show_ctx
|
||||
|
||||
bin/bld_core.sh unit sanity_test tests/sanity_tests.c
|
||||
bin/bld_core.sh unit unicode_test tests/unicode_test.c
|
||||
bin/bld_core.sh unit cpp_build_test tests/cpp_build_test.cpp
|
||||
|
||||
echo
|
||||
|
||||
###### Restore Path ###########################################################
|
||||
cd $og_path
|
||||
+11
-1
@@ -1,6 +1,16 @@
|
||||
###### Visual Studio Compiler #################################################
|
||||
cl>-nologo
|
||||
cl>-Zi
|
||||
cl>-FC
|
||||
cl>-MP
|
||||
|
||||
|
||||
###### Clang Compiler #########################################################
|
||||
clang>-Wno-deprecated-declarations
|
||||
clang>-Wno-pointer-sign
|
||||
clang>-Wno-writable-strings
|
||||
clang>-Wno-unknown-warning-option
|
||||
|
||||
|
||||
###### Debug ##################################################################
|
||||
debug>cl>-Zi
|
||||
debug>clang>-g
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo "x64"
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo "x64"
|
||||
echo ""
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
###### Get Paths ##############################################################
|
||||
og_path=$PWD
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
root_path=$PWD
|
||||
build_path=$root_path/build
|
||||
samples_path=$root_path/samples
|
||||
|
||||
echo ~~~ Running Static Site Generator Sample ~~~
|
||||
cd $samples_path
|
||||
if [ -d "static_site_generator/example_site" ]; then
|
||||
cd static_site_generator/example_site
|
||||
mkdir -p generated
|
||||
cd generated
|
||||
$build_path/static_site_generator.exe --siteinfo:../site_info.mdesk --pagedir:../
|
||||
fi
|
||||
echo
|
||||
|
||||
echo ~~~ Running Output Parse Sample ~~~
|
||||
cd $samples_path
|
||||
if [ -d "output_parse/examples" ]; then
|
||||
cd output_parse/examples
|
||||
mkdir -p output
|
||||
cd output
|
||||
$build_path/output_parse.exe ../example.mdesk ../example2.mdesk
|
||||
fi
|
||||
echo
|
||||
|
||||
echo ~~~ Running C Code Generation Sample ~~~
|
||||
cd $build_path
|
||||
./c_code_generation.exe
|
||||
echo
|
||||
|
||||
echo ~~~ Running Error Generation Sample ~~~
|
||||
cd $build_path
|
||||
./node_errors.exe $samples_path/node_errors/node_errors.mdesk
|
||||
echo
|
||||
|
||||
echo ~~~ Running C++ Sample ~~~
|
||||
cd $build_path
|
||||
./cpp_build_test.exe
|
||||
echo
|
||||
|
||||
###### Restore Path ###########################################################
|
||||
cd $og_path
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
###### Get Paths ##############################################################
|
||||
og_path=$PWD
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
|
||||
echo ~~~ Running Sanity Tests ~~~
|
||||
mkdir -p build
|
||||
cd build
|
||||
./sanity_tests.exe
|
||||
./unicode_test.exe
|
||||
|
||||
###### Restore Path ###########################################################
|
||||
cd $og_path
|
||||
@@ -21,9 +21,6 @@ cl %compile_flags% ..\tests\unicode_test.c
|
||||
cl %compile_flags% ..\tests\cpp_build_test.cpp
|
||||
popd
|
||||
|
||||
rem Stop wasting time getting hung on broken parser
|
||||
rem exit
|
||||
|
||||
echo.
|
||||
echo ~~~ Running Sanity Tests ~~~
|
||||
pushd build
|
||||
|
||||
+7
-5
@@ -51,19 +51,21 @@ command_list =
|
||||
},
|
||||
},
|
||||
{
|
||||
.name = "bld_core test",
|
||||
.name = "all_dev_checks",
|
||||
.out = "*compilation*",
|
||||
.footer_panel = true,
|
||||
.save_dirty_files = true,
|
||||
.cursor_at_end = false,
|
||||
.cmd =
|
||||
{
|
||||
{ "git_bash bin\\bld_core.sh", .os = "win" },
|
||||
{ "git_bash bin\\all_dev_checks.sh", .os = "win" },
|
||||
{ "bin/all_dev_checks.sh", .os = "linux" },
|
||||
{ "bin/all_dev_checks.sh", .os = "mac" },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
fkey_command[1] = "build";
|
||||
fkey_command[2] = "build_with_clang";
|
||||
fkey_command[1] = "all_dev_checks";
|
||||
|
||||
fkey_command[5] = "bld_core test";
|
||||
fkey_command[8] = "build";
|
||||
fkey_command[9] = "build_with_clang";
|
||||
|
||||
Reference in New Issue
Block a user