diff options
| author | gingerBill <bill@gingerbill.org> | 2022-12-18 21:17:07 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-12-18 21:17:07 +0000 |
| commit | ac5f5a33e94054396de66a37043e226349b6c91c (patch) | |
| tree | 3b561345c4542112da67b9139c3ff6cf54cf7219 /src/build_settings.cpp | |
| parent | ff6b76986a0647ffc7d99c7e7df78ec8e5fb91b2 (diff) | |
`gb_internal` a lot
Diffstat (limited to 'src/build_settings.cpp')
| -rw-r--r-- | src/build_settings.cpp | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp index ba68e388b..d66db8099 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -57,7 +57,7 @@ enum TargetABIKind : u16 { }; -String target_os_names[TargetOs_COUNT] = { +gb_global String target_os_names[TargetOs_COUNT] = { str_lit(""), str_lit("windows"), str_lit("darwin"), @@ -72,7 +72,7 @@ String target_os_names[TargetOs_COUNT] = { str_lit("freestanding"), }; -String target_arch_names[TargetArch_COUNT] = { +gb_global String target_arch_names[TargetArch_COUNT] = { str_lit(""), str_lit("amd64"), str_lit("i386"), @@ -82,19 +82,19 @@ String target_arch_names[TargetArch_COUNT] = { str_lit("wasm64"), }; -String target_endian_names[TargetEndian_COUNT] = { +gb_global String target_endian_names[TargetEndian_COUNT] = { str_lit(""), str_lit("little"), str_lit("big"), }; -String target_abi_names[TargetABI_COUNT] = { +gb_global String target_abi_names[TargetABI_COUNT] = { str_lit(""), str_lit("win64"), str_lit("sysv"), }; -TargetEndianKind target_endians[TargetArch_COUNT] = { +gb_global TargetEndianKind target_endians[TargetArch_COUNT] = { TargetEndian_Invalid, TargetEndian_Little, TargetEndian_Little, @@ -107,7 +107,7 @@ TargetEndianKind target_endians[TargetArch_COUNT] = { #define ODIN_VERSION_RAW "dev-unknown-unknown" #endif -String const ODIN_VERSION = str_lit(ODIN_VERSION_RAW); +gb_global String const ODIN_VERSION = str_lit(ODIN_VERSION_RAW); @@ -162,7 +162,7 @@ enum CommandKind : u32 { Command_all = ~(u32)0, }; -char const *odin_command_strings[32] = { +gb_global char const *odin_command_strings[32] = { "run", "build", "check", @@ -333,10 +333,10 @@ struct BuildContext { gb_global BuildContext build_context = {0}; -bool global_warnings_as_errors(void) { +gb_internal bool global_warnings_as_errors(void) { return build_context.warnings_as_errors; } -bool global_ignore_warnings(void) { +gb_internal bool global_ignore_warnings(void) { return build_context.ignore_warnings; } @@ -502,9 +502,9 @@ gb_global NamedTargetMetrics named_targets[] = { { str_lit("freestanding_amd64_sysv"), &target_freestanding_amd64_sysv }, }; -NamedTargetMetrics *selected_target_metrics; +gb_global NamedTargetMetrics *selected_target_metrics; -TargetOsKind get_target_os_from_string(String str) { +gb_internal TargetOsKind get_target_os_from_string(String str) { for (isize i = 0; i < TargetOs_COUNT; i++) { if (str_eq_ignore_case(target_os_names[i], str)) { return cast(TargetOsKind)i; @@ -513,7 +513,7 @@ TargetOsKind get_target_os_from_string(String str) { return TargetOs_Invalid; } -TargetArchKind get_target_arch_from_string(String str) { +gb_internal TargetArchKind get_target_arch_from_string(String str) { for (isize i = 0; i < TargetArch_COUNT; i++) { if (str_eq_ignore_case(target_arch_names[i], str)) { return cast(TargetArchKind)i; @@ -523,7 +523,7 @@ TargetArchKind get_target_arch_from_string(String str) { } -bool is_excluded_target_filename(String name) { +gb_internal bool is_excluded_target_filename(String name) { String original_name = name; name = remove_extension_from_path(name); @@ -588,13 +588,13 @@ struct LibraryCollections { gb_global Array<LibraryCollections> library_collections = {0}; -void add_library_collection(String name, String path) { +gb_internal void add_library_collection(String name, String path) { // TODO(bill): Check the path is valid and a directory LibraryCollections lc = {name, string_trim_whitespace(path)}; array_add(&library_collections, lc); } -bool find_library_collection_path(String name, String *path) { +gb_internal bool find_library_collection_path(String name, String *path) { for_array(i, library_collections) { if (library_collections[i].name == name) { if (path) *path = library_collections[i].path; @@ -604,7 +604,7 @@ bool find_library_collection_path(String name, String *path) { return false; } -bool is_arch_wasm(void) { +gb_internal bool is_arch_wasm(void) { switch (build_context.metrics.arch) { case TargetArch_wasm32: case TargetArch_wasm64: @@ -613,7 +613,7 @@ bool is_arch_wasm(void) { return false; } -bool is_arch_x86(void) { +gb_internal bool is_arch_x86(void) { switch (build_context.metrics.arch) { case TargetArch_i386: case TargetArch_amd64: @@ -622,7 +622,7 @@ bool is_arch_x86(void) { return false; } -bool allow_check_foreign_filepath(void) { +gb_internal bool allow_check_foreign_filepath(void) { switch (build_context.metrics.arch) { case TargetArch_wasm32: case TargetArch_wasm64: @@ -638,13 +638,14 @@ bool allow_check_foreign_filepath(void) { // is_abs_path // has_subdir -String const WIN32_SEPARATOR_STRING = {cast(u8 *)"\\", 1}; -String const NIX_SEPARATOR_STRING = {cast(u8 *)"/", 1}; +gb_global String const WIN32_SEPARATOR_STRING = {cast(u8 *)"\\", 1}; +gb_global String const NIX_SEPARATOR_STRING = {cast(u8 *)"/", 1}; -String const WASM_MODULE_NAME_SEPARATOR = str_lit(".."); +gb_global String const WASM_MODULE_NAME_SEPARATOR = str_lit(".."); -String internal_odin_root_dir(void); -String odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void); + +gb_internal String odin_root_dir(void) { if (global_module_path_set) { return global_module_path; } @@ -670,7 +671,7 @@ String odin_root_dir(void) { #if defined(GB_SYSTEM_WINDOWS) -String internal_odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; wchar_t *text; @@ -725,7 +726,7 @@ String internal_odin_root_dir(void) { String path_to_fullpath(gbAllocator a, String s); -String internal_odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; u8 *text; @@ -777,9 +778,9 @@ String internal_odin_root_dir(void) { // NOTE: Linux / Unix is unfinished and not tested very well. #include <sys/stat.h> -String path_to_fullpath(gbAllocator a, String s); +gb_internal String path_to_fullpath(gbAllocator a, String s); -String internal_odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; u8 *text; @@ -938,7 +939,7 @@ String internal_odin_root_dir(void) { gb_global BlockingMutex fullpath_mutex; #if defined(GB_SYSTEM_WINDOWS) -String path_to_fullpath(gbAllocator a, String s) { +gb_internal String path_to_fullpath(gbAllocator a, String s) { String result = {}; mutex_lock(&fullpath_mutex); defer (mutex_unlock(&fullpath_mutex)); @@ -965,7 +966,7 @@ String path_to_fullpath(gbAllocator a, String s) { return result; } #elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX) -String path_to_fullpath(gbAllocator a, String s) { +gb_internal String path_to_fullpath(gbAllocator a, String s) { char *p; mutex_lock(&fullpath_mutex); p = realpath(cast(char *)s.text, 0); @@ -978,7 +979,7 @@ String path_to_fullpath(gbAllocator a, String s) { #endif -String get_fullpath_relative(gbAllocator a, String base_dir, String path) { +gb_internal String get_fullpath_relative(gbAllocator a, String base_dir, String path) { u8 *str = gb_alloc_array(heap_allocator(), u8, base_dir.len+1+path.len+1); defer (gb_free(heap_allocator(), str)); @@ -1004,7 +1005,7 @@ String get_fullpath_relative(gbAllocator a, String base_dir, String path) { } -String get_fullpath_core(gbAllocator a, String path) { +gb_internal String get_fullpath_core(gbAllocator a, String path) { String module_dir = odin_root_dir(); String core = str_lit("core/"); @@ -1024,11 +1025,11 @@ String get_fullpath_core(gbAllocator a, String path) { return path_to_fullpath(a, res); } -bool show_error_line(void) { +gb_internal bool show_error_line(void) { return build_context.show_error_line; } -bool has_asm_extension(String const &path) { +gb_internal bool has_asm_extension(String const &path) { String ext = path_extension(path); if (ext == ".asm") { return true; @@ -1041,7 +1042,7 @@ bool has_asm_extension(String const &path) { } // temporary -char *token_pos_to_string(TokenPos const &pos) { +gb_internal char *token_pos_to_string(TokenPos const &pos) { gbString s = gb_string_make_reserve(temporary_allocator(), 128); String file = get_file_path_string(pos.file_id); switch (build_context.ODIN_ERROR_POS_STYLE) { @@ -1056,7 +1057,7 @@ char *token_pos_to_string(TokenPos const &pos) { return s; } -void init_build_context(TargetMetrics *cross_target) { +gb_internal void init_build_context(TargetMetrics *cross_target) { BuildContext *bc = &build_context; gb_affinity_init(&bc->affinity); @@ -1258,7 +1259,7 @@ void init_build_context(TargetMetrics *cross_target) { #endif -Array<String> split_by_comma(String const &list) { +gb_internal Array<String> split_by_comma(String const &list) { isize n = 1; for (isize i = 0; i < list.len; i++) { if (list.text[i] == ',') { @@ -1280,12 +1281,12 @@ Array<String> split_by_comma(String const &list) { return res; } -bool check_target_feature_is_valid(TokenPos pos, String const &feature) { +gb_internal bool check_target_feature_is_valid(TokenPos pos, String const &feature) { // TODO(bill): check_target_feature_is_valid return true; } -bool check_target_feature_is_enabled(TokenPos pos, String const &target_feature_list) { +gb_internal bool check_target_feature_is_enabled(TokenPos pos, String const &target_feature_list) { BuildContext *bc = &build_context; mutex_lock(&bc->target_features_mutex); defer (mutex_unlock(&bc->target_features_mutex)); @@ -1307,7 +1308,7 @@ bool check_target_feature_is_enabled(TokenPos pos, String const &target_feature_ return true; } -void enable_target_feature(TokenPos pos, String const &target_feature_list) { +gb_internal void enable_target_feature(TokenPos pos, String const &target_feature_list) { BuildContext *bc = &build_context; mutex_lock(&bc->target_features_mutex); defer (mutex_unlock(&bc->target_features_mutex)); @@ -1326,7 +1327,7 @@ void enable_target_feature(TokenPos pos, String const &target_feature_list) { } -char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quotes) { +gb_internal char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quotes) { isize len = 0; isize i = 0; for (auto const &entry : build_context.target_features_set) { @@ -1359,7 +1360,7 @@ char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quot // NOTE(Jeroen): Set/create the output and other paths and report an error as appropriate. // We've previously called `parse_build_flags`, so `out_filepath` should be set. -bool init_build_paths(String init_filename) { +gb_internal bool init_build_paths(String init_filename) { gbAllocator ha = heap_allocator(); BuildContext *bc = &build_context; |