diff --git a/meta/4ed_build.cpp b/meta/4ed_build.cpp index b114acb8..53fbc0b2 100644 --- a/meta/4ed_build.cpp +++ b/meta/4ed_build.cpp @@ -491,18 +491,26 @@ do_buildsuper(char *cdir, char *file, u32 arch){ END_TIME_SECTION("build custom"); } +// TODO(allen): Remove this internal i32 get_freetype_include(char *out, u32 max){ i32 size = 0; +#if 0 #if defined(IS_LINUX) char freetype_include[512]; FILE *file = popen("pkg-config --cflags freetype2", "r"); if (file != 0){ fgets(freetype_include, sizeof(freetype_include), file); size = strlen(freetype_include); - freetype_include[size-1] = 0; + memcpy(out, freetype_include, size); pclose(file); } +#elif defined(IS_MAC) + char *freetype_include = "/usr/local/include/freetype2"; + size = strlen(freetype_include); + memcpy(out, freetype_include, size + ); +#endif #endif return(size); } @@ -521,6 +529,7 @@ build_main(char *cdir, b32 update_local_theme, u32 flags, u32 arch){ i32 ft_size = get_freetype_include(ft_include, sizeof(ft_include) - 1); if (ft_size > 0){ ft_include[ft_size] = 0; + fprintf(stdout, "FREETYPE: %s\n", ft_include); build_includes = fm_list(build_includes, fm_list_one_item(ft_include)); } diff --git a/meta/4ed_file_moving.h b/meta/4ed_file_moving.h index a2222a60..c02c6ec7 100644 --- a/meta/4ed_file_moving.h +++ b/meta/4ed_file_moving.h @@ -35,7 +35,7 @@ static i32 prev_error = 0; #endif #define systemf(...) do{ \ - i32 n = snprintf(SF_CMD, sizeof(SF_CMD), __VA_ARGS__); \ + i32 n = snprintf(SF_CMD, sizeof(SF_CMD), __VA_ARGS__); \ AllowLocal(n); \ Assert(n < sizeof(SF_CMD)); \ SYSTEMF_PRINTF("%s\n", SF_CMD); \ @@ -136,13 +136,13 @@ internal void fm__swap_ptr(char **A, char **B); // Slashes #if defined(IS_WINDOWS) -#define SLASH "\\" +# define SLASH "\\" static char platform_correct_slash = '\\'; #elif defined(IS_LINUX) || defined(IS_MAC) -#define SLASH "/" +# define SLASH "/" static char platform_correct_slash = '/'; #else -#error Slash not set for this platform. +# error Slash not set for this platform. #endif // File Extensions diff --git a/platform_linux/linux_4ed.cpp b/platform_linux/linux_4ed.cpp index 46aeaa37..8b7ded10 100644 --- a/platform_linux/linux_4ed.cpp +++ b/platform_linux/linux_4ed.cpp @@ -50,7 +50,6 @@ #include #include -#include #include #include @@ -76,7 +75,7 @@ #include #include "4ed_shared_thread_constants.h" -#include "linux_threading_wrapper.h" +#include "unix_threading_wrapper.h" // // Linux macros @@ -118,7 +117,7 @@ internal void LinuxStringDup(String*, void*, size_t); global System_Functions sysfunc; #include "4ed_shared_library_constants.h" -#include "linux_library_wrapper.h" +#include "unix_library_wrapper.h" #include "4ed_standard_libraries.cpp" #include "4ed_coroutine.cpp" @@ -484,10 +483,6 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){ return(close_me); } -// -// Linux rendering/font system functions -// - #include "4ed_font_data.h" #include "4ed_system_shared.cpp" diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index b49fada1..276c5703 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -45,6 +45,14 @@ #include "unix_4ed_headers.h" #include +#include +#include + +//////////////////////////////// + +#include "4ed_shared_thread_constants.h" +#include "unix_threading_wrapper.h" + //////////////////////////////// #define SLASH '/' @@ -52,7 +60,7 @@ global System_Functions sysfunc; #include "4ed_shared_library_constants.h" -#include "mac_library_wrapper.h" +#include "unix_library_wrapper.h" #include "4ed_standard_libraries.cpp" #include "4ed_coroutine.cpp" @@ -76,6 +84,14 @@ global Coroutine_System_Auto_Alloc coroutines; #include "osx_objective_c_to_cpp_links.h" OSX_Vars osx; +#include + +#include "4ed_font_data.h" +#include "4ed_system_shared.cpp" + +#include "4ed_link_system_functions.cpp" +#include "4ed_shared_init_logic.cpp" + external void* osx_allocate(umem size){ void *result = system_memory_allocate(size); @@ -111,6 +127,64 @@ osx_step(){ external void osx_init(){ + // + // System Linkage + // + + link_system_code(); + + // + // Memory init + // + + memset(&linuxvars, 0, sizeof(linuxvars)); + memset(&target, 0, sizeof(target)); + memset(&memory_vars, 0, sizeof(memory_vars)); + memset(&plat_settings, 0, sizeof(plat_settings)); + + memset(&libraries, 0, sizeof(libraries)); + memset(&app, 0, sizeof(app)); + memset(&custom_api, 0, sizeof(custom_api)); + + memory_init(); + + // + // HACK(allen): + // Previously zipped stuff is here, it should be zipped in the new pattern now. + // + + init_shared_vars(); + + // + // Dynamic Linkage + // + + load_app_code(); + link_rendering(); +#if defined(FRED_SUPER) + load_custom_code(); +#else + custom_api.get_bindings = get_bindings; +#endif + + // + // Read command line + // + + read_command_line(argc, argv); + + // + // Threads + // + + work_system_init(); + + // + // Coroutines + // + + coroutines_init(); + // TODO } diff --git a/platform_unix/unix_4ed_headers.h b/platform_unix/unix_4ed_headers.h index 4b4d44b3..7548359b 100644 --- a/platform_unix/unix_4ed_headers.h +++ b/platform_unix/unix_4ed_headers.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/platform_linux/linux_library_wrapper.h b/platform_unix/unix_library_wrapper.h similarity index 100% rename from platform_linux/linux_library_wrapper.h rename to platform_unix/unix_library_wrapper.h diff --git a/platform_linux/linux_threading_wrapper.h b/platform_unix/unix_threading_wrapper.h similarity index 95% rename from platform_linux/linux_threading_wrapper.h rename to platform_unix/unix_threading_wrapper.h index 5409fe72..9ea8562b 100644 --- a/platform_linux/linux_threading_wrapper.h +++ b/platform_unix/unix_threading_wrapper.h @@ -9,8 +9,8 @@ // TOP -#if !defined(LINUX_THREADING_WRAPPER) -#define LINUX_THREADING_WRAPPER +#if !defined(MAC_THREADING_WRAPPER) +#define MAC_THREADING_WRAPPER #define PLAT_THREAD_SIG(n) void* n(void *ptr) typedef PLAT_THREAD_SIG(Thread_Function); @@ -35,7 +35,6 @@ union Semaphore{ FixSize(SEMAPHORE_TYPE_SIZE); }; - internal void system_init_and_launch_thread(Thread *t, Thread_Function *proc, void *ptr){ pthread_create(&t->t, 0, proc, ptr);