aboutsummaryrefslogtreecommitdiff
path: root/src/build_settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/build_settings.cpp')
-rw-r--r--src/build_settings.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp
index 8364bbfbe..00594c1b4 100644
--- a/src/build_settings.cpp
+++ b/src/build_settings.cpp
@@ -441,6 +441,7 @@ struct BuildContext {
String extra_assembler_flags;
String microarch;
BuildModeKind build_mode;
+ bool keep_executable;
bool generate_docs;
bool custom_optimization_level;
i32 optimization_level;
@@ -2209,11 +2210,34 @@ gb_internal bool init_build_paths(String init_filename) {
while (output_name.len > 0 && (output_name[output_name.len-1] == '/' || output_name[output_name.len-1] == '\\')) {
output_name.len -= 1;
}
+ // Only trim the extension if it's an Odin source file.
+ // This lets people build folders with extensions or files beginning with dots.
+ if (path_extension(output_name) == ".odin" && !path_is_directory(output_name)) {
+ output_name = remove_extension_from_path(output_name);
+ }
output_name = remove_directory_from_path(output_name);
- output_name = remove_extension_from_path(output_name);
output_name = copy_string(ha, string_trim_whitespace(output_name));
- output_path = path_from_string(ha, output_name);
-
+ // This is `path_from_string` without the extension trimming.
+ Path res = {};
+ if (output_name.len > 0) {
+ String fullpath = path_to_full_path(ha, output_name);
+ defer (gb_free(ha, fullpath.text));
+
+ res.basename = directory_from_path(fullpath);
+ res.basename = copy_string(ha, res.basename);
+
+ if (path_is_directory(fullpath)) {
+ if (res.basename.len > 0 && res.basename.text[res.basename.len - 1] == '/') {
+ res.basename.len--;
+ }
+ } else {
+ isize name_start = (res.basename.len > 0) ? res.basename.len + 1 : res.basename.len;
+ res.name = substring(fullpath, name_start, fullpath.len);
+ res.name = copy_string(ha, res.name);
+ }
+ }
+ output_path = res;
+
// Note(Dragos): This is a fix for empty filenames
// Turn the trailing folder into the file name
if (output_path.name.len == 0) {
@@ -2278,9 +2302,10 @@ gb_internal bool init_build_paths(String init_filename) {
case TargetOs_windows:
case TargetOs_linux:
case TargetOs_darwin:
+ case TargetOs_freebsd:
break;
default:
- gb_printf_err("-sanitize:address is only supported on windows, linux, and darwin\n");
+ gb_printf_err("-sanitize:address is only supported on Windows, Linux, Darwin, and FreeBSD\n");
return false;
}
}
@@ -2288,12 +2313,10 @@ gb_internal bool init_build_paths(String init_filename) {
if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
switch (build_context.metrics.os) {
case TargetOs_linux:
+ case TargetOs_freebsd:
break;
default:
- gb_printf_err("-sanitize:memory is only supported on linux\n");
- return false;
- }
- if (build_context.metrics.os != TargetOs_linux) {
+ gb_printf_err("-sanitize:memory is only supported on Linux and FreeBSD\n");
return false;
}
}
@@ -2302,9 +2325,10 @@ gb_internal bool init_build_paths(String init_filename) {
switch (build_context.metrics.os) {
case TargetOs_linux:
case TargetOs_darwin:
+ case TargetOs_freebsd:
break;
default:
- gb_printf_err("-sanitize:thread is only supported on linux and darwin\n");
+ gb_printf_err("-sanitize:thread is only supported on Linux, Darwin, and FreeBSD\n");
return false;
}
}