Browse Source

Added static linking for macOS. Also fixed the build.sh. Thanks, vass :/

Zachary Pierson 7 years ago
parent
commit
6d880bc3bb
2 changed files with 8 additions and 4 deletions
  1. 4 2
      build.sh
  2. 4 2
      src/main.cpp

+ 4 - 2
build.sh

@@ -7,11 +7,13 @@ libraries="-pthread -ldl -lm -lstdc++"
 other_args=""
 other_args=""
 compiler="clang"
 compiler="clang"
 
 
+if [ -z "$release_mode" ]; then release_mode="0"; fi
+
 if [ "$release_mode" -eq "0" ]; then
 if [ "$release_mode" -eq "0" ]; then
-	other_args="${other_args} -g
+	other_args="${other_args} -g"
 fi
 fi
 if [ "$release_mode" -eq "1" ]; then
 if [ "$release_mode" -eq "1" ]; then
-	other_args="${other_args} -O3 -march=native
+	other_args="${other_args} -O3 -march=native"
 fi
 fi
 
 
 if [[ "$(uname)" == "Darwin" ]]; then
 if [[ "$(uname)" == "Darwin" ]]; then

+ 4 - 2
src/main.cpp

@@ -833,7 +833,10 @@ int main(int arg_count, char **arg_ptr) {
 				if(lib.len > 2 && lib[0] == '-' && lib[1] == 'f') {
 				if(lib.len > 2 && lib[0] == '-' && lib[1] == 'f') {
 					// framework thingie
 					// framework thingie
 					len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " -framework %.*s ", (int)(lib.len) - 2, lib.text + 2);
 					len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " -framework %.*s ", (int)(lib.len) - 2, lib.text + 2);
-				} else if (string_has_extension(lib, str_lit("dylib"))) {
+				} else if (string_has_extension(lib, str_lit("a"))) {
+					// static libs, absolute full path relative to the file in which the lib was imported from
+					len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " %.*s ", LIT(lib));
+				} else if (string_has_extension(lib, str_lit("dylib"))) {
 					// dynamic lib, relative path to executable
 					// dynamic lib, relative path to executable
 					len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " -l:%s/%.*s ", cwd, LIT(lib));
 					len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf), " -l:%s/%.*s ", cwd, LIT(lib));
 				} else {
 				} else {
@@ -869,7 +872,6 @@ int main(int arg_count, char **arg_ptr) {
 		char *linker;
 		char *linker;
 		if (build_context.is_dll) {
 		if (build_context.is_dll) {
 			// Shared libraries are .dylib on MacOS and .so on Linux.
 			// Shared libraries are .dylib on MacOS and .so on Linux.
-			// TODO(zangent): Is that statement entirely truthful?
 			#if defined(GB_SYSTEM_OSX)
 			#if defined(GB_SYSTEM_OSX)
 				output_ext = ".dylib";
 				output_ext = ".dylib";
 			#else
 			#else