From d873ee19c11b7e010400d6fd7fcd0bfdb805a90b Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Thu, 2 May 2024 07:37:26 +0500 Subject: [PATCH] example project file --- .vscode/launch.json | 1 + build.sh | 2 +- example.proj.dtsod | 48 +++++++++++++++++++++++++++++++++++++++ src/CompilationScenario.c | 6 ++--- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 example.proj.dtsod diff --git a/.vscode/launch.json b/.vscode/launch.json index 2b3d5b5..6b7d442 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,6 +12,7 @@ "linux": { "program": "${workspaceFolder}/bin/cbuild", }, + "args": [ "-p", "../example.proj.dtsod", "exe"], "preLaunchTask": "build", "stopAtEntry": false, "externalConsole": false, diff --git a/build.sh b/build.sh index 7e855dd..aeff8e3 100644 --- a/build.sh +++ b/build.sh @@ -7,7 +7,7 @@ WARN="-Wall -Wextra -Wno-discarded-qualifiers -Wno-unused-parameter" ARGS_DEBUG="-O0 -g" ARGS_RELEASE="-O2 -flto=auto -fdata-sections -ffunction-sections -Wl,--gc-sections" -if [ "$1" -eq "debug" ]; then +if [[ "$1" = "debug" ]]; then ARGS=$ARGS_DEBUG else ARGS=$ARGS_RELEASE diff --git a/example.proj.dtsod b/example.proj.dtsod new file mode 100644 index 0000000..f93c159 --- /dev/null +++ b/example.proj.dtsod @@ -0,0 +1,48 @@ +cbuild_version: 0; +import: [ "c", "c++", "gcc", "./some_local_file.dtsod" ]; + +gcc: { + src_languages: [ "c" ], + src_dirs: [ "src" ], +}; + +configurations: { + release: { + preprocess_sources: { + src_languages: [ "c", "c++" ], + src_dirs: [ "src" ], + }, + gcc: { + pre_args: [ "-O2" ], + post_args: [ "-Wl,--gc-sections" ], + }; + }; +}; + +tasks: { + exe: { + pre_tasks: [ ], + tool_order: [ "preprocess_sources", "gcc", "g++", "g++-link" ], + #g++: [ ... ], + }; +}; + +languages: [ + { + aliases: [ "c" ], + file_extensions: [ "c" ], + }, + { + aliases: [ "c-header" ], + file_extensions: [ "h" ], + } +]; + +tools: [ + { + aliases: [ "gcc" ], + exe_file: "gcc", + supported_languages: [ "c" ]; # set to "any" to use with any lang + parallel: false, + } +]; \ No newline at end of file diff --git a/src/CompilationScenario.c b/src/CompilationScenario.c index 1beba28..5c34a43 100644 --- a/src/CompilationScenario.c +++ b/src/CompilationScenario.c @@ -138,7 +138,6 @@ Maybe CompilationScenario_applyConfigurationOptions(CompilationScenario* sc, Has try(CompilationScenario_tryApplyConditionalOptions(sc, dtsod, configuration), _m0, ;); if(!_m0.value.Bool) safethrow(cptr_concat("configuration '", configuration, "' not found"), ;); - return MaybeNull; } @@ -146,7 +145,6 @@ Maybe CompilationScenario_applyTaskOptions(CompilationScenario* sc, Hashtable* d try(CompilationScenario_tryApplyConditionalOptions(sc, dtsod, task), _m0, ;); if(!_m0.value.Bool) safethrow(cptr_concat("task '", task, "' not found"), ;); - return MaybeNull; } @@ -155,7 +153,7 @@ Maybe CompilationScenario_tryRegisterLanguages(CompilationScenario* sc, Hashtabl if(!Hashtable_tryGet(dtsod, "languages", &val)) return SUCCESS(UniFalse); - if(!UniCheckTypePtr(val, Hashtable)) + if(!UniCheckTypePtr(val, Autoarr(Unitype))) safethrow(ERR_WRONGTYPE, ;); Autoarr(Unitype)* languages_serializad = val.VoidPtr; @@ -206,7 +204,7 @@ Maybe CompilationScenario_tryRegisterTools(CompilationScenario* sc, Hashtable* d if(!Hashtable_tryGet(dtsod, "tools", &val)) return SUCCESS(UniFalse); - if(!UniCheckTypePtr(val, Hashtable)) + if(!UniCheckTypePtr(val, Autoarr(Unitype))) safethrow(ERR_WRONGTYPE, ;); Autoarr(Unitype)* tools_serializad = val.VoidPtr;