From 9a066b0d3d304a69eaf4e62fff988266ed1d84e8 Mon Sep 17 00:00:00 2001 From: Dmitry Atamanov Date: Fri, 15 Sep 2023 20:41:03 +0500 Subject: [PATCH] Support additional keys in projects. --- resources/examples/nolibc/project.json | 4 +++- src/build/project.c | 11 +++++++++++ src/build/project_creation.c | 18 +++++++++++++++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/resources/examples/nolibc/project.json b/resources/examples/nolibc/project.json index b3d8c461e..4dad639e0 100644 --- a/resources/examples/nolibc/project.json +++ b/resources/examples/nolibc/project.json @@ -7,7 +7,9 @@ "type": "executable", "opt": "O3", "nolibc": true, - "nostdlib": true + "nostdlib": true, + "fast": true, + "forcelinker": true }, }, "debug-info": "none", diff --git a/src/build/project.c b/src/build/project.c index b16f7aa6e..76c4fe06b 100644 --- a/src/build/project.c +++ b/src/build/project.c @@ -16,6 +16,8 @@ const char *project_default_keys[] = { "debug-info", "dependencies", "dependency-search-paths", + "fast", + "forcelinker", "langrev", "link-args", "linked-libraries", @@ -58,6 +60,8 @@ const char* project_target_keys[] = { "dependencies-override", "dependency-search-paths-add", "dependency-search-paths-override", + "fast", + "forcelinker", "langrev", "link-args-add", "link-args-override", @@ -351,6 +355,12 @@ static void load_into_build_target(JSONObject *json, const char *type, BuildTarg const char *cpu = get_valid_string(json, "cpu", type, false); if (cpu) target->cpu = cpu; + // Force linker + target->force_linker = get_valid_bool(json, "forcelinker", type, target->force_linker); + + // Safe mode + target->feature.safe_mode = get_valid_bool(json, "fast", type, target->feature.safe_mode); + // WinCRT int wincrt = get_valid_string_setting(json, "wincrt", type, wincrt_linking, 0, 5, "'none', 'static' or 'dynamic'."); if (wincrt > -1) target->win.crt_linking = (WinCrtLinking)wincrt; @@ -470,6 +480,7 @@ static void project_add_targets(Project *project, JSONObject *project_data) BuildTarget default_target = { .optimization_level = OPTIMIZATION_NONE, + .force_linker = false, .memory_environment = MEMORY_ENV_NORMAL, .size_optimization_level = SIZE_OPTIMIZATION_NONE, .arch_os_target = ARCH_OS_TARGET_DEFAULT, diff --git a/src/build/project_creation.c b/src/build/project_creation.c index e26a19442..6d11a8ae0 100644 --- a/src/build/project_creation.c +++ b/src/build/project_creation.c @@ -31,9 +31,13 @@ const char* JSON_EXE = " \"targets\": {\n" " \"%s\": {\n" " // executable or library\n" - " \"type\": \"executable\"\n" + " \"type\": \"executable\",\n" " // additional libraries, sources\n" " // and overrides of global settings here\n" + " \"opt\": \"O0\",\n" + " \"nolibc\": false,\n" + " \"nostdlib\": false,\n" + " \"forcelinker\": false\n" " },\n" " }\n" " /*\n" @@ -89,9 +93,13 @@ const char* JSON_STATIC = " \"targets\": {\n" " \"%s\": {\n" " // executable or library\n" - " \"type\": \"static-lib\"\n" + " \"type\": \"static-lib\",\n" " // additional libraries, sources\n" " // and overrides of global settings here\n" + " \"opt\": \"O0\",\n" + " \"nolibc\": false,\n" + " \"nostdlib\": false,\n" + " \"forcelinker\": false\n" " },\n" " }\n" " /*\n" @@ -147,9 +155,13 @@ const char* JSON_DYNAMIC = " \"targets\": {\n" " \"%s\": {\n" " // executable or library\n" - " \"type\": \"dynamic-lib\"\n" + " \"type\": \"dynamic-lib\",\n" " // additional libraries, sources\n" " // and overrides of global settings here\n" + " \"opt\": \"O0\",\n" + " \"nolibc\": false,\n" + " \"nostdlib\": false,\n" + " \"forcelinker\": false\n" " },\n" " }\n" " /*\n"