Skip to content

Commit

Permalink
Support additional keys in projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
data-man committed Sep 15, 2023
1 parent d129cd4 commit 9a066b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
4 changes: 3 additions & 1 deletion resources/examples/nolibc/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"type": "executable",
"opt": "O3",
"nolibc": true,
"nostdlib": true
"nostdlib": true,
"fast": true,
"forcelinker": true
},
},
"debug-info": "none",
Expand Down
11 changes: 11 additions & 0 deletions src/build/project.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const char *project_default_keys[] = {
"debug-info",
"dependencies",
"dependency-search-paths",
"fast",
"forcelinker",
"langrev",
"link-args",
"linked-libraries",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 15 additions & 3 deletions src/build/project_creation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 9a066b0

Please sign in to comment.