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 16, 2023
1 parent d129cd4 commit 0585c24
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion resources/examples/nolibc/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"type": "executable",
"opt": "O3",
"nolibc": true,
"nostdlib": true
"nostdlib": true,
"forcelinker": true,
},
},
"debug-info": "none",
Expand Down
7 changes: 6 additions & 1 deletion src/build/project.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const char *project_default_keys[] = {
"debug-info",
"dependencies",
"dependency-search-paths",
"forcelinker",
"langrev",
"link-args",
"linked-libraries",
Expand Down Expand Up @@ -58,6 +59,7 @@ const char* project_target_keys[] = {
"dependencies-override",
"dependency-search-paths-add",
"dependency-search-paths-override",
"forcelinker",
"langrev",
"link-args-add",
"link-args-override",
Expand Down Expand Up @@ -346,11 +348,13 @@ static void load_into_build_target(JSONObject *json, const char *type, BuildTarg
int reloc = get_valid_string_setting(json, "reloc", type, reloc_models, 0, 5, "'none', 'pic', 'PIC', 'pie' or 'PIE'.");
if (reloc > -1) target->reloc_model = (RelocModel)reloc;


// Cpu
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);

// 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 +474,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 0585c24

Please sign in to comment.