From 2b9276b495c75d9804576521e76201525ac43d19 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 30 Sep 2023 23:15:33 +0200 Subject: [PATCH] Add 'exec' --- releasenotes.md | 2 + resources/testfragments/pwd2.c3 | 3 + .../{run/run.md => scripts/scripts.md} | 0 src/build/build.h | 3 + src/build/build_internal.h | 6 + src/build/build_options.c | 17 +- src/build/builder.c | 3 + src/build/project.c | 327 +++++++----------- src/build/project_creation.c | 4 +- src/compiler/compiler.c | 64 +++- src/compiler/compiler_internal.h | 6 +- src/compiler/sema_passes.c | 26 +- src/version.h | 2 +- 13 files changed, 243 insertions(+), 220 deletions(-) create mode 100644 resources/testfragments/pwd2.c3 rename resources/testproject/{run/run.md => scripts/scripts.md} (100%) diff --git a/releasenotes.md b/releasenotes.md index 9b5ef3c6b..6a7c04ddb 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -3,6 +3,8 @@ ## 0.5.0 Change List ### Changes / improvements +- 'exec' directive to run scripts at compile time. +- Project key descriptions in --list command. - Added `init-lib` to simplify library creation. - Local `const` work like namespaced global `const`. - Added `$$atomic_fetch_*` builtins. diff --git a/resources/testfragments/pwd2.c3 b/resources/testfragments/pwd2.c3 new file mode 100644 index 000000000..2e86a9102 --- /dev/null +++ b/resources/testfragments/pwd2.c3 @@ -0,0 +1,3 @@ +module pwd; + +fn int getnum() => 3; \ No newline at end of file diff --git a/resources/testproject/run/run.md b/resources/testproject/scripts/scripts.md similarity index 100% rename from resources/testproject/run/run.md rename to resources/testproject/scripts/scripts.md diff --git a/src/build/build.h b/src/build/build.h index 35bb081b7..7aad1e1a2 100644 --- a/src/build/build.h +++ b/src/build/build.h @@ -355,6 +355,7 @@ typedef struct BuildOptions_ const char *llvm_out; const char *asm_out; const char *obj_out; + const char *script_dir; RelocModel reloc_model; X86VectorCapability x86_vector_capability; X86CpuSet x86_cpu_set; @@ -429,6 +430,7 @@ typedef struct const char *object_file_dir; const char *ir_file_dir; const char *asm_file_dir; + const char *script_dir; bool run_after_compile; bool generate_benchmark_runner; bool generate_test_runner; @@ -470,6 +472,7 @@ typedef struct const char *testfn; const char *cc; const char *cflags; + const char **exec; const char **csource_dirs; const char **csources; const char **feature_list; diff --git a/src/build/build_internal.h b/src/build/build_internal.h index 72918c209..cf5b5523e 100644 --- a/src/build/build_internal.h +++ b/src/build/build_internal.h @@ -25,6 +25,12 @@ static const char *wincrt_linking[3] = { [WIN_CRT_STATIC] = "static", }; +static const char *trust_level[3] = { + [TRUST_NONE] = "none", + [TRUST_INCLUDE] = "include", + [TRUST_FULL] = "full", +}; + static const char *optsizes[3] = { [SIZE_OPTIMIZATION_NONE] = "none", [SIZE_OPTIMIZATION_SMALL] = "small", diff --git a/src/build/build_options.c b/src/build/build_options.c index 294a2362d..7b41539b7 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -96,13 +96,12 @@ static void usage(void) OUTPUT(" -O5 - Unsafe, highest optimization, fast maths, single module, emit debug info."); OUTPUT(" -Os - Unsafe, high optimization, small code, single module, no debug info."); OUTPUT(" -Oz - Unsafe, high optimization, tiny code, single module, no debug info."); - OUTPUT(" -t1 - Trust level 1 - don't allow $include nor $exec (default)."); - OUTPUT(" -t2 - Trust level 2 - allow $include but not $exec / exec directives."); - OUTPUT(" -t3 - Trust level 3 - full trust, allow both include and exec."); OUTPUT(" -D - Add feature flag ."); OUTPUT(" -U - Remove feature flag ."); + OUTPUT(" --trust=