aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorthebirk <pingnor@gmail.com>2019-02-01 15:12:20 +0100
committerthebirk <pingnor@gmail.com>2019-02-01 15:12:20 +0100
commitdc3d62d437ae7667e7817b13b89b8165cb379f22 (patch)
tree66ad0083c1010996d06f2faf92c31745813db30c /src/main.cpp
parentdee28d998ff6583dab49a57ee4b792d9e289a18f (diff)
Fixed -out dropping extension on linux.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index dcea12aa7..9351df3b2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1056,15 +1056,15 @@ int main(int arg_count, char **arg_ptr) {
// Unlike the Win32 linker code, the output_ext includes the dot, because
// typically executable files on *NIX systems don't have extensions.
- char *output_ext = "";
+ String output_ext = {};
char *link_settings = "";
char *linker;
if (build_context.is_dll) {
// Shared libraries are .dylib on MacOS and .so on Linux.
#if defined(GB_SYSTEM_OSX)
- output_ext = ".dylib";
+ output_ext = STR_LIT(".dylib");
#else
- output_ext = ".so";
+ output_ext = STR_LIT(".so");
#endif
link_settings = "-shared";
@@ -1073,6 +1073,14 @@ int main(int arg_count, char **arg_ptr) {
link_settings = "";
}
+ if (build_context.out_filepath.len > 0) {
+ //NOTE(thebirk): We have a custom -out arguments, so we should use the extension from that
+ isize pos = string_extension_position(build_context.out_filepath);
+ if (pos > 0) {
+ output_ext = substring(build_context.out_filepath, pos, build_context.out_filepath.len);
+ }
+ }
+
#if defined(GB_SYSTEM_OSX)
linker = "ld";
#else
@@ -1088,7 +1096,7 @@ int main(int arg_count, char **arg_ptr) {
#endif
exit_code = system_exec_command_line_app("ld-link", true,
- "%s \"%.*s.o\" -o \"%.*s%s\" %s "
+ "%s \"%.*s.o\" -o \"%.*s%.*s\" %s "
" %s "
" %.*s "
" %s "
@@ -1101,7 +1109,7 @@ int main(int arg_count, char **arg_ptr) {
// This points the linker to where the entry point is
" -e _main "
#endif
- , linker, LIT(output_base), LIT(output_base), output_ext,
+ , linker, LIT(output_base), LIT(output_base), LIT(output_ext),
lib_str,
str_eq_ignore_case(cross_compile_target, str_lit("Essence")) ? "-lfreetype -lglue" : "-lc -lm",
LIT(build_context.link_flags),
@@ -1134,8 +1142,10 @@ int main(int arg_count, char **arg_ptr) {
remove_temp_files(output_base);
if (run_output) {
- output_base = path_to_full_path(heap_allocator(), output_base);
- system_exec_command_line_app("odin run", false, "\"%.*s\" %.*s", LIT(output_base), LIT(run_args_string));
+ //NOTE(thebirk): This whole thing is a little leaky
+ String complete_path = concatenate_strings(heap_allocator(), output_base, output_ext);
+ complete_path = path_to_full_path(heap_allocator(), complete_path);
+ system_exec_command_line_app("odin run", false, "\"%.*s\" %.*s", LIT(complete_path), LIT(run_args_string));
}
#endif
#endif