mirror of
https://github.com/Ed94/metadesk.git
synced 2026-06-12 23:51:37 -07:00
[bld] setup new feature for include path management
This commit is contained in:
+17
-9
@@ -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
|
||||
|
||||
@@ -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 ###########################################################
|
||||
|
||||
@@ -14,3 +14,4 @@ clang>-Wno-unknown-warning-option
|
||||
###### Debug ##################################################################
|
||||
debug>cl>-Zi
|
||||
debug>clang>-g
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
###### Examples ###############################################################
|
||||
type_info_final_program.c>examples/type_metadata
|
||||
+1
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -6,8 +6,8 @@
|
||||
**
|
||||
*/
|
||||
|
||||
#include "generated/type_info_meta.h"
|
||||
#include "generated/type_info_meta.c"
|
||||
#include "generated/meta_types.h"
|
||||
#include "generated/meta_types.c"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ main(int argc, char **argv)
|
||||
if (!MD_S8Match(arrow->string, MD_S8Lit("->"), 0) ||
|
||||
MD_NodeIsNil(out))
|
||||
{
|
||||
// TODO(allen): error map type
|
||||
// TODO: error map type
|
||||
}
|
||||
|
||||
int is_complete = MD_NodeHasChild(map_tag, MD_S8Lit("complete"), 0);
|
||||
@@ -352,7 +352,10 @@ main(int argc, char **argv)
|
||||
if (!MD_NodeIsNil(array_tag))
|
||||
{
|
||||
array_count = array_tag->first_child;
|
||||
// TODO(allen): error if array_count is nil
|
||||
if (MD_NodeIsNil(array_count))
|
||||
{
|
||||
// TODO: error array count
|
||||
}
|
||||
}
|
||||
|
||||
TypeMember *member = MD_PushArray(arena, TypeMember, 1);
|
||||
|
||||
+18
-4
@@ -76,8 +76,8 @@ command_list =
|
||||
.cmd =
|
||||
{
|
||||
{ "git_bash bin\\build_examples.sh", .os = "win" },
|
||||
{ "bin/build_tests.sh", .os = "linux" },
|
||||
{ "bin/build_tests.sh", .os = "mac" },
|
||||
{ "bin/build_examples.sh", .os = "linux" },
|
||||
{ "bin/build_examples.sh", .os = "mac" },
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -89,8 +89,21 @@ command_list =
|
||||
.cmd =
|
||||
{
|
||||
{ "git_bash bin\\run_examples.sh", .os = "win" },
|
||||
{ "bin/build_tests.sh", .os = "linux" },
|
||||
{ "bin/build_tests.sh", .os = "mac" },
|
||||
{ "bin/run_examples.sh", .os = "linux" },
|
||||
{ "bin/run_examples.sh", .os = "mac" },
|
||||
},
|
||||
},
|
||||
{
|
||||
.name = "type_info_example",
|
||||
.out = "*run*",
|
||||
.footer_panel = false,
|
||||
.save_dirty_files = true,
|
||||
.cursor_at_end = false,
|
||||
.cmd =
|
||||
{
|
||||
{ "git_bash bin\\type_info_example.sh", .os = "win" },
|
||||
{ "bin/type_info_example.sh", .os = "linux" },
|
||||
{ "bin/type_info_example.sh", .os = "mac" },
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -99,3 +112,4 @@ fkey_command[1] = "build_tests";
|
||||
fkey_command[2] = "run_tests";
|
||||
fkey_command[3] = "build_examples";
|
||||
fkey_command[4] = "run_examples";
|
||||
fkey_command[5] = "type_info_example";
|
||||
|
||||
Reference in New Issue
Block a user