mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Use project.json instead of .c3p. List project properties. Check project property usage. Change names: lib-dir -> dependency-search-paths, libs -> dependencies, linker-libs -> linked-libraries, linkerlib-dir -> linker-search-paths, csources -> c-sources. Several settings have an xxxx-add, xxxx-override pair for the target, gaining fine grained control over the override.
This commit is contained in:
committed by
Christoffer Lerno
parent
26e4662c3b
commit
f73b507ccb
@@ -12,26 +12,27 @@
|
||||
"./**"
|
||||
],
|
||||
// libraries to use
|
||||
"libs": [],
|
||||
"dependencies": [],
|
||||
|
||||
// c compiler
|
||||
"cc": "cc",
|
||||
// c sources
|
||||
"targets": {
|
||||
"hello_world": {
|
||||
"type": "executable",
|
||||
"csources-override": [
|
||||
"c-sources-override": [
|
||||
"./csource/**"
|
||||
]
|
||||
},
|
||||
"hello_world_win32": {
|
||||
"type": "executable",
|
||||
"csources-override": [
|
||||
"c-sources-override": [
|
||||
"./csource/**"
|
||||
]
|
||||
},
|
||||
"hello_world_lib": {
|
||||
"type": "static-lib",
|
||||
"csources-override": [
|
||||
"c-sources-override": [
|
||||
"./csource/**"
|
||||
]
|
||||
},
|
||||
@@ -76,84 +76,85 @@ static void usage(void)
|
||||
OUTPUT(" headers <file1> [<file2> ...] Analyse files and generate C headers for public methods.");
|
||||
OUTPUT("");
|
||||
OUTPUT("Options:");
|
||||
OUTPUT(" --tinybackend - Use the TinyBackend for compilation.");
|
||||
OUTPUT(" --stdlib <dir> - Use this directory as the C3 standard library path.");
|
||||
OUTPUT(" --nostdlib - Do not include the standard library.");
|
||||
OUTPUT(" --nolibc - Do not implicitly link libc nor any associated files.");
|
||||
OUTPUT(" --libdir <dir> - Add this directory to the C3 library search paths.");
|
||||
OUTPUT(" --lib <name> - Add this library to the compilation.");
|
||||
OUTPUT(" --path <dir> - Use this as the base directory for the current command.");
|
||||
OUTPUT(" --template <template> - Select template for 'init': \"exe\", \"static-lib\", \"dynamic-lib\" or a path.");
|
||||
OUTPUT(" --about - Prints a short description of C3.");
|
||||
OUTPUT(" --symtab <value> - Sets the preferred symtab size.");
|
||||
OUTPUT(" -V --version - Print version information.");
|
||||
OUTPUT(" -E - Lex only.");
|
||||
OUTPUT(" -P - Only parse and output the AST as S-expressions.");
|
||||
OUTPUT(" -C - Only lex, parse and check.");
|
||||
OUTPUT(" - - Read code from standard in.");
|
||||
OUTPUT(" -o <file> - Write output to <file>.");
|
||||
OUTPUT(" -O0 - Optimizations off.");
|
||||
OUTPUT(" -O1 - Simple optimizations only.");
|
||||
OUTPUT(" -O2 - Default optimization level.");
|
||||
OUTPUT(" -O3 - Aggressive optimization.");
|
||||
OUTPUT(" -Os - Optimize for size.");
|
||||
OUTPUT(" -Oz - Optimize for tiny size.");
|
||||
OUTPUT(" -O0+ - No optimization, single module");
|
||||
OUTPUT(" -O1+ - Simple optimizations, single module.");
|
||||
OUTPUT(" -O2+ - Default optimization level, single module");
|
||||
OUTPUT(" -O3+ - Aggressive optimization, single module.");
|
||||
OUTPUT(" -Os+ - Optimize for size, single module.");
|
||||
OUTPUT(" -Oz+ - Optimize for tiny size, single module.");
|
||||
OUTPUT(" --build-dir <dir> - Override build output directory.");
|
||||
OUTPUT(" --obj-out <dir> - Override object file output directory.");
|
||||
OUTPUT(" --llvm-out <dir> - Override llvm output directory for '--emit-llvm'.");
|
||||
OUTPUT(" --emit-llvm - Emit LLVM IR as a .ll file per module.");
|
||||
OUTPUT(" --asm-out <dir> - Override asm output directory for '--emit-asm'.");
|
||||
OUTPUT(" --emit-asm - Emit asm as a .s file per module.");
|
||||
OUTPUT(" --target <target> - Compile for a particular architecture + OS target.");
|
||||
OUTPUT(" --threads <number> - Set the number of threads to use for compilation.");
|
||||
OUTPUT(" --safe - Set mode to 'safe', generating runtime traps on overflows and contract violations.");
|
||||
OUTPUT(" --fast - Set mode to 'fast', removes runtime traps.");
|
||||
OUTPUT(" --tinybackend - Use the TinyBackend for compilation.");
|
||||
OUTPUT(" --stdlib <dir> - Use this directory as the C3 standard library path.");
|
||||
OUTPUT(" --nostdlib - Do not include the standard library.");
|
||||
OUTPUT(" --nolibc - Do not implicitly link libc nor any associated files.");
|
||||
OUTPUT(" --libdir <dir> - Add this directory to the C3 library search paths.");
|
||||
OUTPUT(" --lib <name> - Add this library to the compilation.");
|
||||
OUTPUT(" --path <dir> - Use this as the base directory for the current command.");
|
||||
OUTPUT(" --template <template> - Select template for 'init': \"exe\", \"static-lib\", \"dynamic-lib\" or a path.");
|
||||
OUTPUT(" --about - Prints a short description of C3.");
|
||||
OUTPUT(" --symtab <value> - Sets the preferred symtab size.");
|
||||
OUTPUT(" -V --version - Print version information.");
|
||||
OUTPUT(" -E - Lex only.");
|
||||
OUTPUT(" -P - Only parse and output the AST as S-expressions.");
|
||||
OUTPUT(" -C - Only lex, parse and check.");
|
||||
OUTPUT(" - - Read code from standard in.");
|
||||
OUTPUT(" -o <file> - Write output to <file>.");
|
||||
OUTPUT(" -O0 - Optimizations off.");
|
||||
OUTPUT(" -O1 - Simple optimizations only.");
|
||||
OUTPUT(" -O2 - Default optimization level.");
|
||||
OUTPUT(" -O3 - Aggressive optimization.");
|
||||
OUTPUT(" -Os - Optimize for size.");
|
||||
OUTPUT(" -Oz - Optimize for tiny size.");
|
||||
OUTPUT(" -O0+ - No optimization, single module");
|
||||
OUTPUT(" -O1+ - Simple optimizations, single module.");
|
||||
OUTPUT(" -O2+ - Default optimization level, single module");
|
||||
OUTPUT(" -O3+ - Aggressive optimization, single module.");
|
||||
OUTPUT(" -Os+ - Optimize for size, single module.");
|
||||
OUTPUT(" -Oz+ - Optimize for tiny size, single module.");
|
||||
OUTPUT(" --build-dir <dir> - Override build output directory.");
|
||||
OUTPUT(" --obj-out <dir> - Override object file output directory.");
|
||||
OUTPUT(" --llvm-out <dir> - Override llvm output directory for '--emit-llvm'.");
|
||||
OUTPUT(" --emit-llvm - Emit LLVM IR as a .ll file per module.");
|
||||
OUTPUT(" --asm-out <dir> - Override asm output directory for '--emit-asm'.");
|
||||
OUTPUT(" --emit-asm - Emit asm as a .s file per module.");
|
||||
OUTPUT(" --target <target> - Compile for a particular architecture + OS target.");
|
||||
OUTPUT(" --threads <number> - Set the number of threads to use for compilation.");
|
||||
OUTPUT(" --safe - Set mode to 'safe', generating runtime traps on overflows and contract violations.");
|
||||
OUTPUT(" --fast - Set mode to 'fast', removes runtime traps.");
|
||||
OUTPUT("");
|
||||
OUTPUT(" -g - Emit full debug info.");
|
||||
OUTPUT(" -g0 - Emit no debug info.");
|
||||
OUTPUT(" -gline-tables-only - Only emit line tables for debugging.");
|
||||
OUTPUT(" -g - Emit full debug info.");
|
||||
OUTPUT(" -g0 - Emit no debug info.");
|
||||
OUTPUT(" -gline-tables-only - Only emit line tables for debugging.");
|
||||
OUTPUT("");
|
||||
OUTPUT("");
|
||||
OUTPUT(" -l <library> - Link with the library provided.");
|
||||
OUTPUT(" -L <library dir> - Append the directory to the linker search paths.");
|
||||
OUTPUT(" -z <argument> - Send the <argument> as a parameter to the linker.");
|
||||
OUTPUT(" --forcelinker - Force built in linker usage when doing non-cross linking.");
|
||||
OUTPUT(" -l <library> - Link with the library provided.");
|
||||
OUTPUT(" -L <library dir> - Append the directory to the linker search paths.");
|
||||
OUTPUT(" -z <argument> - Send the <argument> as a parameter to the linker.");
|
||||
OUTPUT(" --forcelinker - Force built in linker usage when doing non-cross linking.");
|
||||
OUTPUT("");
|
||||
OUTPUT(" --reloc=<option> - Relocation model: none, pic, PIC, pie, PIE");
|
||||
OUTPUT(" --x86vec=<option> - Set max level of vector instructions: none, mmx, sse, avx, avx512.");
|
||||
OUTPUT(" --reloc=<option> - Relocation model: none, pic, PIC, pie, PIE");
|
||||
OUTPUT(" --x86vec=<option> - Set max level of vector instructions: none, mmx, sse, avx, avx512.");
|
||||
OUTPUT("");
|
||||
OUTPUT(" --debug-stats - Print debug statistics.");
|
||||
OUTPUT(" --debug-stats - Print debug statistics.");
|
||||
#ifndef NDEBUG
|
||||
OUTPUT(" --debug-log - Print debug logging to stdout.");
|
||||
OUTPUT(" --debug-log - Print debug logging to stdout.");
|
||||
#endif
|
||||
OUTPUT("");
|
||||
OUTPUT(" --benchmarking - Run builtin benchmarks.");
|
||||
OUTPUT(" --testing - Run built-in tests.");
|
||||
OUTPUT(" --benchmarking - Run builtin benchmarks.");
|
||||
OUTPUT(" --testing - Run built-in tests.");
|
||||
OUTPUT("");
|
||||
OUTPUT(" --list-attributes - List all attributes.");
|
||||
OUTPUT(" --list-builtins - List all builtins.");
|
||||
OUTPUT(" --list-keywords - List all keywords.");
|
||||
OUTPUT(" --list-operators - List all operators.");
|
||||
OUTPUT(" --list-precedence - List operator precedence order.");
|
||||
OUTPUT(" --list-targets - List all architectures the compiler supports.");
|
||||
OUTPUT(" --list-attributes - List all attributes.");
|
||||
OUTPUT(" --list-builtins - List all builtins.");
|
||||
OUTPUT(" --list-keywords - List all keywords.");
|
||||
OUTPUT(" --list-operators - List all operators.");
|
||||
OUTPUT(" --list-precedence - List operator precedence order.");
|
||||
OUTPUT(" --list-type-properties - List all type properties.");
|
||||
OUTPUT(" --list-targets - List all architectures the compiler supports.");
|
||||
OUTPUT(" --list-attributes - List all attributes.");
|
||||
OUTPUT(" --list-builtins - List all builtins.");
|
||||
OUTPUT(" --list-keywords - List all keywords.");
|
||||
OUTPUT(" --list-operators - List all operators.");
|
||||
OUTPUT(" --list-precedence - List operator precedence order.");
|
||||
OUTPUT(" --list-targets - List all architectures the compiler supports.");
|
||||
OUTPUT(" --list-attributes - List all attributes.");
|
||||
OUTPUT(" --list-builtins - List all builtins.");
|
||||
OUTPUT(" --list-keywords - List all keywords.");
|
||||
OUTPUT(" --list-operators - List all operators.");
|
||||
OUTPUT(" --list-precedence - List operator precedence order.");
|
||||
OUTPUT(" --list-project-properties - List all available keys used in project.json files.");
|
||||
OUTPUT(" --list-type-properties - List all type properties.");
|
||||
OUTPUT(" --list-targets - List all architectures the compiler supports.");
|
||||
OUTPUT("");
|
||||
OUTPUT(" --winsdk <dir> - Set the directory for Windows system library files for cross compilation.");
|
||||
OUTPUT(" --wincrt=<option> - Windows CRT linking: none, static, dynamic (default).");
|
||||
OUTPUT(" --winsdk <dir> - Set the directory for Windows system library files for cross compilation.");
|
||||
OUTPUT(" --wincrt=<option> - Windows CRT linking: none, static, dynamic (default).");
|
||||
OUTPUT("");
|
||||
OUTPUT(" --macossdk <dir> - Set the directory for the MacOS SDK for cross compilation.");
|
||||
OUTPUT(" --macossdk <dir> - Set the directory for the MacOS SDK for cross compilation.");
|
||||
|
||||
}
|
||||
|
||||
@@ -572,6 +573,12 @@ static void parse_option(BuildOptions *options)
|
||||
options->command = COMMAND_PRINT_SYNTAX;
|
||||
return;
|
||||
}
|
||||
if (match_longopt("list-project-properties"))
|
||||
{
|
||||
options->print_project_properties = true;
|
||||
options->command = COMMAND_PRINT_SYNTAX;
|
||||
return;
|
||||
}
|
||||
if (match_longopt("list-operators"))
|
||||
{
|
||||
options->print_operators = true;
|
||||
|
||||
@@ -279,6 +279,7 @@ typedef struct BuildOptions_
|
||||
bool print_builtins;
|
||||
bool print_operators;
|
||||
bool print_type_properties;
|
||||
bool print_project_properties;
|
||||
bool print_precedence;
|
||||
bool print_build_settings;
|
||||
bool benchmarking;
|
||||
|
||||
@@ -303,7 +303,7 @@ void init_default_build_target(BuildTarget *target, BuildOptions *options)
|
||||
void init_build_target(BuildTarget *target, BuildOptions *options)
|
||||
{
|
||||
*target = (BuildTarget) { 0 };
|
||||
// Locate the project.c3p
|
||||
// Locate the project.json
|
||||
file_find_top_dir();
|
||||
// Parse it
|
||||
Project *project = project_load();
|
||||
|
||||
@@ -7,6 +7,75 @@
|
||||
#define MAX_SYMTAB_SIZE (1024 * 1024)
|
||||
|
||||
|
||||
const char *project_default_keys[] = {
|
||||
"authors",
|
||||
"cc",
|
||||
"cflags",
|
||||
"cpu",
|
||||
"c-sources",
|
||||
"debug-info",
|
||||
"langrev",
|
||||
"dependency-search-paths",
|
||||
"dependencies",
|
||||
"linked-libraries",
|
||||
"macossdk",
|
||||
"nolibc",
|
||||
"nostdlib",
|
||||
"panicfn",
|
||||
"reloc",
|
||||
"soft-float",
|
||||
"sources",
|
||||
"symtab",
|
||||
"target",
|
||||
"targets",
|
||||
"trap-on-wrap",
|
||||
"version",
|
||||
"warnings",
|
||||
"wincrt",
|
||||
"winsdk",
|
||||
"x86-stack-struct-return",
|
||||
"x86vec",
|
||||
"output",
|
||||
};
|
||||
|
||||
const int project_default_keys_count = sizeof(project_default_keys) / sizeof(char*);
|
||||
|
||||
const char* project_target_keys[] = {
|
||||
"output"
|
||||
"cc",
|
||||
"cflags-add",
|
||||
"cflags-override",
|
||||
"cpu",
|
||||
"c-sources-add",
|
||||
"c-sources-override",
|
||||
"debug-info",
|
||||
"langrev",
|
||||
"dependency-search-paths-add",
|
||||
"dependency-search-paths-override",
|
||||
"dependencies-add",
|
||||
"dependencies-override",
|
||||
"linked-libraries",
|
||||
"macossdk",
|
||||
"nolibc",
|
||||
"nostdlib",
|
||||
"panicfn",
|
||||
"reloc",
|
||||
"soft-float",
|
||||
"sources-add",
|
||||
"sources-override",
|
||||
"symtab",
|
||||
"target",
|
||||
"trap-on-wrap",
|
||||
"type",
|
||||
"version",
|
||||
"warnings",
|
||||
"wincrt",
|
||||
"winsdk",
|
||||
"x86-stack-struct-return",
|
||||
"x86vec",
|
||||
};
|
||||
|
||||
const int project_target_keys_count = sizeof(project_target_keys) / sizeof(char*);
|
||||
|
||||
const char *get_valid_string(JSONObject *table, const char *key, const char *category, bool mandatory)
|
||||
{
|
||||
@@ -102,6 +171,8 @@ static const char **get_valid_array(JSONObject *table, const char *key, const ch
|
||||
|
||||
static void check_json_keys(const char** valid_keys, size_t key_count, JSONObject *json, const char *type)
|
||||
{
|
||||
static bool failed_shown = false;
|
||||
bool failed = false;
|
||||
for (size_t i = 0; i < json->member_len; i++)
|
||||
{
|
||||
const char *key = json->keys[i];
|
||||
@@ -110,8 +181,14 @@ static void check_json_keys(const char** valid_keys, size_t key_count, JSONObjec
|
||||
if (strcmp(key, valid_keys[j]) == 0) goto OK;
|
||||
}
|
||||
eprintf("WARNING: Unknown parameter '%s' in '%s'.\n", key, type);
|
||||
failed = true;
|
||||
OK:;
|
||||
}
|
||||
if (failed && !failed_shown)
|
||||
{
|
||||
eprintf("You can use '--list-project-properties' to list all valid properties.\n");
|
||||
failed_shown = true;
|
||||
}
|
||||
}
|
||||
|
||||
INLINE void append_strings_to_strings(const char*** list_of_strings_ptr, const char **strings_to_append)
|
||||
@@ -121,79 +198,30 @@ INLINE void append_strings_to_strings(const char*** list_of_strings_ptr, const c
|
||||
FOREACH_END();
|
||||
}
|
||||
|
||||
static void target_append_strings(JSONObject *json, const char *type, const char ***list_ptr, const char *base, const char *override, const char *add, bool is_default)
|
||||
{
|
||||
const char **value = get_valid_array(json, is_default ? base : override, type, false);
|
||||
const char **add_value = is_default ? NULL : get_valid_array(json, add, type, false);
|
||||
if (value && add_value)
|
||||
{
|
||||
error_exit("'%s' is combining both '%s' and '%s', only one may be used.", type, override, add);
|
||||
}
|
||||
if (value) *list_ptr = value;
|
||||
if (add_value)
|
||||
{
|
||||
append_strings_to_strings(&add_value, *list_ptr);
|
||||
*list_ptr = add_value;
|
||||
}
|
||||
}
|
||||
static void load_into_build_target(JSONObject *json, const char *type, BuildTarget *target, bool is_default)
|
||||
{
|
||||
static const char *default_keys[] = {
|
||||
"authors",
|
||||
"cc",
|
||||
"cflags",
|
||||
"cpu",
|
||||
"csources",
|
||||
"debug-info",
|
||||
"langrev",
|
||||
"lib-dir",
|
||||
"libs",
|
||||
"linker-libs"
|
||||
"macossdk",
|
||||
"nolibc",
|
||||
"nostdlib",
|
||||
"panicfn",
|
||||
"reloc",
|
||||
"soft-float",
|
||||
"sources",
|
||||
"symtab",
|
||||
"target",
|
||||
"targets",
|
||||
"trap-on-wrap",
|
||||
"version",
|
||||
"warnings",
|
||||
"wincrt",
|
||||
"winsdk",
|
||||
"x86-stack-struct-return",
|
||||
"x86vec",
|
||||
"output",
|
||||
};
|
||||
static const char* target_keys[] = {
|
||||
"output"
|
||||
"cc",
|
||||
"cflags-add",
|
||||
"cflags-override",
|
||||
"cpu",
|
||||
"csources-add",
|
||||
"csources-override",
|
||||
"debug-info",
|
||||
"langrev",
|
||||
"lib-dir-add",
|
||||
"lib-dir-override",
|
||||
"libs-add",
|
||||
"libs-override",
|
||||
"linker-libs",
|
||||
"macossdk",
|
||||
"nolibc",
|
||||
"nostdlib",
|
||||
"panicfn",
|
||||
"reloc",
|
||||
"soft-float",
|
||||
"sources-add",
|
||||
"sources-override",
|
||||
"symtab",
|
||||
"target",
|
||||
"trap-on-wrap",
|
||||
"type",
|
||||
"version",
|
||||
"warnings",
|
||||
"wincrt",
|
||||
"winsdk",
|
||||
"x86-stack-struct-return",
|
||||
"x86vec",
|
||||
};
|
||||
if (is_default)
|
||||
{
|
||||
check_json_keys(default_keys, sizeof(default_keys) / sizeof(char*), json, type);
|
||||
check_json_keys(project_default_keys, sizeof(project_default_keys) / sizeof(char*), json, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
check_json_keys(target_keys, sizeof(target_keys) / sizeof(char*), json, type);
|
||||
check_json_keys(project_target_keys, sizeof(project_target_keys) / sizeof(char*), json, type);
|
||||
}
|
||||
const char *cc = get_valid_string(json, "cc", type, false);
|
||||
if (cc) target->cc = cc;
|
||||
@@ -219,47 +247,22 @@ static void load_into_build_target(JSONObject *json, const char *type, BuildTarg
|
||||
}
|
||||
|
||||
// C source dirs.
|
||||
const char **csource_dirs = get_valid_array(json, is_default ? "csources" : "csources-override", type, false);
|
||||
const char **csource_add = is_default ? NULL : get_valid_array(json, "csources-add", type, false);
|
||||
if (csource_dirs && csource_add)
|
||||
{
|
||||
error_exit("'%s' is combining both 'csource-add' and 'csource-override', only one may be used.", type);
|
||||
}
|
||||
if (csource_dirs) target->csource_dirs = csource_dirs;
|
||||
if (csource_add)
|
||||
{
|
||||
append_strings_to_strings(&csource_add, target->csource_dirs);
|
||||
target->csource_dirs = csource_add;
|
||||
}
|
||||
target_append_strings(json, type, &target->csource_dirs, "c-sources", "c-sources-override", "c-sources-add", is_default);
|
||||
|
||||
// Sources
|
||||
target_append_strings(json, type, &target->source_dirs, "sources", "sources-override", "sources-add", is_default);
|
||||
|
||||
const char **add_source_dirs = is_default ? NULL : get_valid_array(json, "sources-add", type, false);
|
||||
bool require_sources = !is_default && !target->source_dirs && !add_source_dirs;
|
||||
const char **source_dirs = get_valid_array(json, is_default ? "sources" : "sources-override", type, require_sources);
|
||||
if (add_source_dirs && source_dirs)
|
||||
{
|
||||
error_exit("'%s' is combining both 'sources-add' and 'sources-override', only one may be used.", type);
|
||||
}
|
||||
if (source_dirs) target->source_dirs = source_dirs;
|
||||
if (add_source_dirs)
|
||||
{
|
||||
append_strings_to_strings(&add_source_dirs, target->source_dirs);
|
||||
target->source_dirs = add_source_dirs;
|
||||
}
|
||||
// Linked-libraries - libraries to add at link time
|
||||
target_append_strings(json, type, &target->linker_libs, "linked-libraries", "linked-libraries-override", "linked-libraries-add", is_default);
|
||||
|
||||
// Libs
|
||||
const char **libraries = get_valid_array(json, is_default ? "libs" : "libs-overrid", type, false);
|
||||
const char **libraries_add = get_valid_array(json, "libs-add", type, false);
|
||||
if (libraries && libraries_add)
|
||||
{
|
||||
error_exit("'%s' is combining both 'libs-add' and 'libs-override', only one may be used.", type);
|
||||
}
|
||||
if (libraries) target->libs = libraries;
|
||||
if (libraries_add)
|
||||
{
|
||||
append_strings_to_strings(&libraries_add, target->libs);
|
||||
target->libs = libraries_add;
|
||||
}
|
||||
// linker-search-paths libs dir - libraries to add at link time
|
||||
target_append_strings(json, type, &target->linker_libdirs, "linker-search-paths", "linker-search-paths-override", "linker-search-paths-add", is_default);
|
||||
|
||||
// dependency-search-paths - path to search for libraries
|
||||
target_append_strings(json, type, &target->libdirs, "dependency-search-paths", "dependency-search-paths-override", "dependency-search-paths-add", is_default);
|
||||
|
||||
// Dependencies
|
||||
target_append_strings(json, type, &target->libs, "dependencies", "dependencies-override", "dependencies-add", is_default);
|
||||
FOREACH_BEGIN(const char *name, target->libs)
|
||||
if (!str_is_valid_lowercase_name(name))
|
||||
{
|
||||
@@ -269,48 +272,6 @@ static void load_into_build_target(JSONObject *json, const char *type, BuildTarg
|
||||
}
|
||||
FOREACH_END();
|
||||
|
||||
// Lib-dir - path to search for libraries
|
||||
const char **lib_dir = get_valid_array(json, is_default ? "lib-dir" : "lib-dir-override", type, false);
|
||||
const char **lib_dir_add = is_default ? NULL : get_valid_array(json, "lib-dir-add", type, false);
|
||||
if (lib_dir && lib_dir_add)
|
||||
{
|
||||
error_exit("'%s' is combining both 'lib-dir-add' and 'lib-dir-override', only one may be used.", type);
|
||||
}
|
||||
if (lib_dir) target->libdirs = lib_dir;
|
||||
if (lib_dir_add)
|
||||
{
|
||||
append_strings_to_strings(&lib_dir_add, target->libdirs);
|
||||
target->libdirs = lib_dir_add;
|
||||
}
|
||||
|
||||
// Linker libs - libraries to add at link time
|
||||
const char **linker_libs = get_valid_array(json, is_default ? "linker-libs" : "linker-libs-override", type, false);
|
||||
const char **linker_libs_add = is_default ? NULL : get_valid_array(json, "linker-libs-add", type, false);
|
||||
if (linker_libs && linker_libs_add)
|
||||
{
|
||||
error_exit("'%s' is combining both 'linker-libs-add' and 'linker-libs-override', only one may be used.", type);
|
||||
}
|
||||
if (linker_libs) target->linker_libs = linker_libs;
|
||||
if (linker_libs_add)
|
||||
{
|
||||
append_strings_to_strings(&linker_libs_add, target->linker_libs);
|
||||
target->linker_libs = linker_libs_add;
|
||||
}
|
||||
|
||||
// Linker libs dir - libraries to add at link time
|
||||
const char **linker_libdir = get_valid_array(json, is_default ? "linker-libdir" : "linker-libdir-override", type, false);
|
||||
const char **linker_libdir_add = is_default ? NULL : get_valid_array(json, "linker-libdir-add", type, false);
|
||||
if (linker_libdir && linker_libdir_add)
|
||||
{
|
||||
error_exit("'%s' is combining both 'linker-libdir-add' and 'linker-libdir-override', only one may be used.", type);
|
||||
}
|
||||
if (linker_libdir) target->linker_libs = linker_libdir;
|
||||
if (linker_libdir_add)
|
||||
{
|
||||
append_strings_to_strings(&linker_libdir_add, target->linker_libs);
|
||||
target->linker_libdirs = linker_libdir_add;
|
||||
}
|
||||
|
||||
// debug-info
|
||||
static const char *debug_infos[3] = {
|
||||
[DEBUG_INFO_FULL] = "full",
|
||||
|
||||
@@ -18,9 +18,9 @@ const char* JSON_EXE =
|
||||
" // warnings used for all targets\n"
|
||||
" \"warnings\": [ \"no-unused\" ],\n"
|
||||
" // directories where C3 library files may be found\n"
|
||||
" \"lib-dir\": [ \"lib\" ],\n"
|
||||
" \"dependency-search-paths\": [ \"lib\" ],\n"
|
||||
" // libraries to use for all targets\n"
|
||||
" \"libs\": [ ],\n"
|
||||
" \"dependencies\": [ ],\n"
|
||||
" // authors, optionally with email\n"
|
||||
" \"authors\": [ \"John Doe <john.doe@example.com>\" ],\n"
|
||||
" // Version using semantic versioning\n"
|
||||
@@ -76,9 +76,9 @@ const char* JSON_STATIC =
|
||||
" // warnings used for all targets\n"
|
||||
" \"warnings\": [ \"no-unused\" ],\n"
|
||||
" // directories where C3 library files may be found\n"
|
||||
" \"lib-dir\": [ \"lib\" ],\n"
|
||||
" \"dependency-search-paths\": [ \"lib\" ],\n"
|
||||
" // libraries to use for all targets\n"
|
||||
" \"libs\": [ ],\n"
|
||||
" \"dependencies\": [ ],\n"
|
||||
" // authors, optionally with email\n"
|
||||
" \"authors\": [ \"John Doe <john.doe@example.com>\" ],\n"
|
||||
" // Version using semantic versioning\n"
|
||||
@@ -134,9 +134,9 @@ const char* JSON_DYNAMIC =
|
||||
" // warnings used for all targets\n"
|
||||
" \"warnings\": [ \"no-unused\" ],\n"
|
||||
" // directories where C3 library files may be found\n"
|
||||
" \"lib-dir\": [ \"lib\" ],\n"
|
||||
" \"dependency-search-paths\": [ \"lib\" ],\n"
|
||||
" // libraries to use for all targets\n"
|
||||
" \"libs\": [ ],\n"
|
||||
" \"dependencies\": [ ],\n"
|
||||
" // authors, optionally with email\n"
|
||||
" \"authors\": [ \"John Doe <john.doe@example.com>\" ],\n"
|
||||
" // Version using semantic versioning\n"
|
||||
@@ -235,7 +235,7 @@ void create_project(BuildOptions *build_options)
|
||||
if (!file_touch("README.md")) goto ERROR;
|
||||
|
||||
|
||||
FILE *file = fopen("project.c3p", "a");
|
||||
FILE *file = fopen("project.json", "a");
|
||||
if (!file) goto ERROR;
|
||||
(void) fprintf(file, template, build_options->project_name);
|
||||
if (fclose(file)) goto ERROR;
|
||||
|
||||
@@ -609,6 +609,23 @@ void print_syntax(BuildOptions *options)
|
||||
printf("%2d .%s\n", i + 1, type_property_list[i]);
|
||||
}
|
||||
}
|
||||
if (options->print_project_properties)
|
||||
{
|
||||
puts("Project properties");
|
||||
puts("------------------");
|
||||
for (int i = 0; i < project_default_keys_count; i++)
|
||||
{
|
||||
printf("%2d %s\n", i + 1, project_default_keys[i]);
|
||||
}
|
||||
puts("");
|
||||
puts("Target properties");
|
||||
puts("-----------------");
|
||||
for (int i = 0; i < project_target_keys_count; i++)
|
||||
{
|
||||
printf("%2d %s\n", i + 1, project_target_keys[i]);
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
if (options->print_precedence)
|
||||
{
|
||||
puts("precedence | operators");
|
||||
|
||||
@@ -44,6 +44,11 @@ typedef uint64_t BitSize;
|
||||
#define CLOBBER_FLAG_ELEMENTS 4
|
||||
#define MAX_CLOBBER_FLAGS (64 * CLOBBER_FLAG_ELEMENTS)
|
||||
|
||||
extern const char *project_default_keys[];
|
||||
extern const int project_default_keys_count;
|
||||
extern const char* project_target_keys[];
|
||||
extern const int project_target_keys_count;
|
||||
|
||||
typedef struct Ast_ Ast;
|
||||
typedef struct Decl_ Decl;
|
||||
typedef struct TypeInfo_ TypeInfo;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define MAX_ARRAY_SIZE INT64_MAX
|
||||
#define MAX_IDENTIFIER_LENGTH 31
|
||||
#define MAX_SOURCE_LOCATION_LEN 255
|
||||
#define PROJECT_JSON "project.c3p"
|
||||
#define PROJECT_JSON "project.json"
|
||||
|
||||
|
||||
#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( _WIN64 )
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMPILER_VERSION "0.3.94"
|
||||
#define COMPILER_VERSION "0.3.95"
|
||||
Reference in New Issue
Block a user