Fix for make on Windows, Fix for -D flag
parent
bf4198d910
commit
53184771ad
|
@ -71,12 +71,14 @@ struct CLI_Handles{
|
||||||
Plat_Handle proc;
|
Plat_Handle proc;
|
||||||
Plat_Handle out_read;
|
Plat_Handle out_read;
|
||||||
Plat_Handle out_write;
|
Plat_Handle out_write;
|
||||||
|
Plat_Handle in_read;
|
||||||
|
Plat_Handle in_write;
|
||||||
u32 scratch_space[4];
|
u32 scratch_space[4];
|
||||||
i32 exit;
|
i32 exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Sys_CLI_Call_Sig(name) b32 name(char *path, char *script_name, CLI_Handles *cli_out)
|
#define Sys_CLI_Call_Sig(n, path, script, cli_out) b32 n(char *path, char *script, CLI_Handles *cli_out)
|
||||||
typedef Sys_CLI_Call_Sig(System_CLI_Call);
|
typedef Sys_CLI_Call_Sig(System_CLI_Call, path, script, cli_out);
|
||||||
|
|
||||||
#define Sys_CLI_Begin_Update_Sig(name) void name(CLI_Handles *cli)
|
#define Sys_CLI_Begin_Update_Sig(name) void name(CLI_Handles *cli)
|
||||||
typedef Sys_CLI_Begin_Update_Sig(System_CLI_Begin_Update);
|
typedef Sys_CLI_Begin_Update_Sig(System_CLI_Begin_Update);
|
||||||
|
|
|
@ -69,7 +69,9 @@ system_load_library(Library *library, char *name, Load_Library_Location location
|
||||||
|
|
||||||
b32 success = false;
|
b32 success = false;
|
||||||
if (path.size > 0){
|
if (path.size > 0){
|
||||||
append(&path, SLASH);
|
if (path.str[path.size - 1] != SLASH){
|
||||||
|
append(&path, SLASH);
|
||||||
|
}
|
||||||
append(&path, name);
|
append(&path, name);
|
||||||
terminate_with_null(&path);
|
terminate_with_null(&path);
|
||||||
success = system_load_library_direct(library, path.str);
|
success = system_load_library_direct(library, path.str);
|
||||||
|
|
|
@ -350,7 +350,7 @@ Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
//
|
//
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_CLI_Call_Sig(system_cli_call){
|
Sys_CLI_Call_Sig(system_cli_call, path, script_name, cli_out){
|
||||||
LINUX_FN_DEBUG("%s %s", path, script_name);
|
LINUX_FN_DEBUG("%s %s", path, script_name);
|
||||||
|
|
||||||
int pipe_fds[2];
|
int pipe_fds[2];
|
||||||
|
@ -1671,22 +1671,24 @@ main(int argc, char **argv){
|
||||||
init_shared_vars();
|
init_shared_vars();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Dynamic Linkage
|
// Load Core Code
|
||||||
//
|
//
|
||||||
|
|
||||||
load_app_code();
|
load_app_code();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read command line
|
||||||
|
//
|
||||||
|
read_command_line(argc, argv);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Load Custom Code
|
||||||
|
//
|
||||||
#if defined(FRED_SUPER)
|
#if defined(FRED_SUPER)
|
||||||
load_custom_code();
|
load_custom_code();
|
||||||
#else
|
#else
|
||||||
custom_api.get_bindings = get_bindings;
|
custom_api.get_bindings = get_bindings;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
|
||||||
// Read command line
|
|
||||||
//
|
|
||||||
|
|
||||||
read_command_line(argc, argv);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Threads
|
// Threads
|
||||||
//
|
//
|
||||||
|
|
|
@ -188,7 +188,7 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){
|
||||||
// HACK(allen): Why does this work differently from the win32 version!?
|
// HACK(allen): Why does this work differently from the win32 version!?
|
||||||
internal
|
internal
|
||||||
Sys_Send_Exit_Signal_Sig(system_send_exit_signal){
|
Sys_Send_Exit_Signal_Sig(system_send_exit_signal){
|
||||||
DBG_POINT();
|
|
||||||
osxvars.keep_running = false;
|
osxvars.keep_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,16 +226,16 @@ Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
global i32 cli_count = 0;
|
global i32 cli_count = 0;
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_CLI_Call_Sig(system_cli_call){
|
Sys_CLI_Call_Sig(system_cli_call, path, script_name, cli_out){
|
||||||
i32 pipe_fds[2];
|
i32 pipe_fds[2];
|
||||||
if (pipe(pipe_fds) == -1){
|
if (pipe(pipe_fds) == -1){
|
||||||
DBG_POINT();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 child_pid = fork();
|
i32 child_pid = fork();
|
||||||
if (child_pid == -1){
|
if (child_pid == -1){
|
||||||
DBG_POINT();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ Sys_CLI_Call_Sig(system_cli_call){
|
||||||
dup2(pipe_fds[PIPE_FD_WRITE], STDERR_FILENO);
|
dup2(pipe_fds[PIPE_FD_WRITE], STDERR_FILENO);
|
||||||
|
|
||||||
if (chdir(path) == -1){
|
if (chdir(path) == -1){
|
||||||
DBG_POINT();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ Sys_CLI_Call_Sig(system_cli_call){
|
||||||
};
|
};
|
||||||
|
|
||||||
if (execv("/bin/sh", argv) == -1){
|
if (execv("/bin/sh", argv) == -1){
|
||||||
DBG_POINT();
|
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ Sys_CLI_Update_Step_Sig(system_cli_update_step){
|
||||||
while (space_left > 0 && select(pipe_read_fd + 1, &fds, NULL, NULL, &tv) == 1){
|
while (space_left > 0 && select(pipe_read_fd + 1, &fds, NULL, NULL, &tv) == 1){
|
||||||
ssize_t num = read(pipe_read_fd, ptr, space_left);
|
ssize_t num = read(pipe_read_fd, ptr, space_left);
|
||||||
if (num == -1){
|
if (num == -1){
|
||||||
DBG_POINT();
|
|
||||||
} else if (num == 0){
|
} else if (num == 0){
|
||||||
// NOTE(inso): EOF
|
// NOTE(inso): EOF
|
||||||
break;
|
break;
|
||||||
|
@ -577,7 +577,7 @@ osx_try_to_close(void){
|
||||||
|
|
||||||
external void
|
external void
|
||||||
osx_step(void){
|
osx_step(void){
|
||||||
DBG_POINT();
|
|
||||||
|
|
||||||
Application_Step_Result result = {};
|
Application_Step_Result result = {};
|
||||||
result.mouse_cursor_type = APP_MOUSE_CURSOR_DEFAULT;
|
result.mouse_cursor_type = APP_MOUSE_CURSOR_DEFAULT;
|
||||||
|
@ -663,14 +663,12 @@ osx_init(){
|
||||||
// System Linkage
|
// System Linkage
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
link_system_code();
|
link_system_code();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Memory init
|
// Memory init
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
memset(&target, 0, sizeof(target));
|
memset(&target, 0, sizeof(target));
|
||||||
memset(&memory_vars, 0, sizeof(memory_vars));
|
memset(&memory_vars, 0, sizeof(memory_vars));
|
||||||
memset(&plat_settings, 0, sizeof(plat_settings));
|
memset(&plat_settings, 0, sizeof(plat_settings));
|
||||||
|
@ -689,48 +687,43 @@ osx_init(){
|
||||||
// Previously zipped stuff is here, it should be zipped in the new pattern now.
|
// Previously zipped stuff is here, it should be zipped in the new pattern now.
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
init_shared_vars();
|
init_shared_vars();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Dynamic Linkage
|
// Load Core Code
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
load_app_code();
|
load_app_code();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read command line
|
||||||
|
//
|
||||||
|
read_command_line(osx_objc.argc, osx_objc.argv);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Load Custom Code
|
||||||
|
//
|
||||||
#if defined(FRED_SUPER)
|
#if defined(FRED_SUPER)
|
||||||
load_custom_code();
|
load_custom_code();
|
||||||
#else
|
#else
|
||||||
custom_api.get_bindings = get_bindings;
|
custom_api.get_bindings = get_bindings;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
|
||||||
// Read command line
|
|
||||||
//
|
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
read_command_line(osx_objc.argc, osx_objc.argv);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Threads
|
// Threads
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
work_system_init();
|
work_system_init();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Coroutines
|
// Coroutines
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
coroutines_init();
|
coroutines_init();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Font System Init
|
// Font System Init
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
|
|
||||||
Partition *scratch = &shared_vars.scratch;
|
Partition *scratch = &shared_vars.scratch;
|
||||||
Temp_Memory temp = begin_temp_memory(scratch);
|
Temp_Memory temp = begin_temp_memory(scratch);
|
||||||
Font_Setup_List font_setup = system_font_get_local_stubs(scratch);
|
Font_Setup_List font_setup = system_font_get_local_stubs(scratch);
|
||||||
|
@ -742,7 +735,6 @@ osx_init(){
|
||||||
// App Init
|
// App Init
|
||||||
//
|
//
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
char cwd[4096];
|
char cwd[4096];
|
||||||
u32 size = sysfunc.get_current_path(cwd, sizeof(cwd));
|
u32 size = sysfunc.get_current_path(cwd, sizeof(cwd));
|
||||||
if (size == 0 || size >= sizeof(cwd)){
|
if (size == 0 || size >= sizeof(cwd)){
|
||||||
|
@ -752,19 +744,15 @@ osx_init(){
|
||||||
terminate_with_null(&curdir);
|
terminate_with_null(&curdir);
|
||||||
replace_char(&curdir, '\\', '/');
|
replace_char(&curdir, '\\', '/');
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
|
|
||||||
String clipboard_string = {0};
|
String clipboard_string = {0};
|
||||||
if (osx_objc.has_clipboard_item){
|
if (osx_objc.has_clipboard_item){
|
||||||
clipboard_string = make_string(osx_objc.clipboard_data, osx_objc.clipboard_size);
|
clipboard_string = make_string(osx_objc.clipboard_data, osx_objc.clipboard_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
|
|
||||||
LOG("Initializing application variables\n");
|
LOG("Initializing application variables\n");
|
||||||
app.init(&sysfunc, &target, &memory_vars, clipboard_string, curdir, custom_api);
|
app.init(&sysfunc, &target, &memory_vars, clipboard_string, curdir, custom_api);
|
||||||
|
|
||||||
DBG_POINT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "mac_4ed_file_track.cpp"
|
#include "mac_4ed_file_track.cpp"
|
||||||
|
|
|
@ -61,6 +61,11 @@
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
|
internal void
|
||||||
|
win32_output_error_string(b32 use_error_box = true);
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
#include "win32_utf8.h"
|
#include "win32_utf8.h"
|
||||||
|
|
||||||
#include "4ed_file_track.h"
|
#include "4ed_file_track.h"
|
||||||
|
@ -177,7 +182,7 @@ global Coroutine_System_Auto_Alloc coroutines;
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
win32_output_error_string(b32 use_error_box = true){
|
win32_output_error_string(b32 use_error_box){
|
||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
|
|
||||||
char *str = 0;
|
char *str = 0;
|
||||||
|
@ -188,6 +193,9 @@ win32_output_error_string(b32 use_error_box = true){
|
||||||
system_error_box(str, false);
|
system_error_box(str, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
LOGF("win32 error raw: %d\n", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
@ -380,7 +388,9 @@ win32_read_clipboard_contents(){
|
||||||
//
|
//
|
||||||
|
|
||||||
internal
|
internal
|
||||||
Sys_CLI_Call_Sig(system_cli_call){
|
Sys_CLI_Call_Sig(system_cli_call, path, script_name, cli_out){
|
||||||
|
Assert(sizeof(Plat_Handle) >= sizeof(HANDLE));
|
||||||
|
|
||||||
char cmd[] = "c:\\windows\\system32\\cmd.exe";
|
char cmd[] = "c:\\windows\\system32\\cmd.exe";
|
||||||
char *env_variables = 0;
|
char *env_variables = 0;
|
||||||
char command_line[2048];
|
char command_line[2048];
|
||||||
|
@ -391,28 +401,34 @@ Sys_CLI_Call_Sig(system_cli_call){
|
||||||
b32 success = terminate_with_null(&s);
|
b32 success = terminate_with_null(&s);
|
||||||
|
|
||||||
if (success){
|
if (success){
|
||||||
success = 0;
|
success = false;
|
||||||
|
|
||||||
SECURITY_ATTRIBUTES sec_attributes = {};
|
*(HANDLE*)&cli_out->proc = INVALID_HANDLE_VALUE;
|
||||||
HANDLE out_read;
|
*(HANDLE*)&cli_out->out_read = INVALID_HANDLE_VALUE;
|
||||||
HANDLE out_write;
|
*(HANDLE*)&cli_out->out_write = INVALID_HANDLE_VALUE;
|
||||||
|
*(HANDLE*)&cli_out->in_read = INVALID_HANDLE_VALUE;
|
||||||
|
*(HANDLE*)&cli_out->in_write = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
sec_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
|
SECURITY_ATTRIBUTES security_atrb = {};
|
||||||
sec_attributes.bInheritHandle = TRUE;
|
security_atrb.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
|
security_atrb.bInheritHandle = TRUE;
|
||||||
|
|
||||||
if (CreatePipe(&out_read, &out_write, &sec_attributes, 0)){
|
HANDLE out_read = INVALID_HANDLE_VALUE;
|
||||||
|
HANDLE out_write = INVALID_HANDLE_VALUE;
|
||||||
|
if (CreatePipe(&out_read, &out_write, &security_atrb, 0)){
|
||||||
if (SetHandleInformation(out_read, HANDLE_FLAG_INHERIT, 0)){
|
if (SetHandleInformation(out_read, HANDLE_FLAG_INHERIT, 0)){
|
||||||
STARTUPINFO startup = {};
|
STARTUPINFO startup = {};
|
||||||
startup.cb = sizeof(STARTUPINFO);
|
startup.cb = sizeof(STARTUPINFO);
|
||||||
startup.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
startup.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
||||||
startup.hStdInput = INVALID_HANDLE_VALUE;
|
|
||||||
|
HANDLE in_read = CreateFileA("nul", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, &security_atrb, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
|
|
||||||
|
startup.hStdInput = in_read;
|
||||||
startup.hStdOutput = out_write;
|
startup.hStdOutput = out_write;
|
||||||
startup.hStdError = out_write;
|
startup.hStdError = out_write;
|
||||||
startup.wShowWindow = SW_HIDE;
|
startup.wShowWindow = SW_HIDE;
|
||||||
|
|
||||||
PROCESS_INFORMATION info = {};
|
PROCESS_INFORMATION info = {};
|
||||||
|
|
||||||
Assert(sizeof(Plat_Handle) >= sizeof(HANDLE));
|
|
||||||
if (CreateProcess_utf8((u8*)cmd, (u8*)command_line, 0, 0, TRUE, 0, env_variables, (u8*)path, &startup, &info)){
|
if (CreateProcess_utf8((u8*)cmd, (u8*)command_line, 0, 0, TRUE, 0, env_variables, (u8*)path, &startup, &info)){
|
||||||
success = 1;
|
success = 1;
|
||||||
CloseHandle(info.hThread);
|
CloseHandle(info.hThread);
|
||||||
|
@ -425,18 +441,13 @@ Sys_CLI_Call_Sig(system_cli_call){
|
||||||
else{
|
else{
|
||||||
CloseHandle(out_read);
|
CloseHandle(out_read);
|
||||||
CloseHandle(out_write);
|
CloseHandle(out_write);
|
||||||
*(HANDLE*)&cli_out->proc = INVALID_HANDLE_VALUE;
|
CloseHandle(in_read);
|
||||||
*(HANDLE*)&cli_out->out_read = INVALID_HANDLE_VALUE;
|
|
||||||
*(HANDLE*)&cli_out->out_write = INVALID_HANDLE_VALUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// TODO(allen): failed SetHandleInformation
|
// TODO(allen): failed SetHandleInformation
|
||||||
CloseHandle(out_read);
|
CloseHandle(out_read);
|
||||||
CloseHandle(out_write);
|
CloseHandle(out_write);
|
||||||
*(HANDLE*)&cli_out->proc = INVALID_HANDLE_VALUE;
|
|
||||||
*(HANDLE*)&cli_out->out_read = INVALID_HANDLE_VALUE;
|
|
||||||
*(HANDLE*)&cli_out->out_write = INVALID_HANDLE_VALUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -512,6 +523,12 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
|
||||||
CloseHandle(*(HANDLE*)&cli->proc);
|
CloseHandle(*(HANDLE*)&cli->proc);
|
||||||
CloseHandle(*(HANDLE*)&cli->out_read);
|
CloseHandle(*(HANDLE*)&cli->out_read);
|
||||||
CloseHandle(*(HANDLE*)&cli->out_write);
|
CloseHandle(*(HANDLE*)&cli->out_write);
|
||||||
|
if (*(HANDLE*)&cli->in_read != INVALID_HANDLE_VALUE){
|
||||||
|
CloseHandle(*(HANDLE*)&cli->in_read);
|
||||||
|
}
|
||||||
|
if (*(HANDLE*)&cli->in_write != INVALID_HANDLE_VALUE){
|
||||||
|
CloseHandle(*(HANDLE*)&cli->in_write);
|
||||||
|
}
|
||||||
|
|
||||||
--win32vars.running_cli;
|
--win32vars.running_cli;
|
||||||
}
|
}
|
||||||
|
@ -1169,22 +1186,25 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
||||||
init_shared_vars();
|
init_shared_vars();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Dynamic Linkage
|
// Load Core Code
|
||||||
|
//
|
||||||
|
load_app_code();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read Command Line
|
||||||
|
//
|
||||||
|
read_command_line(argc, argv);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Load Custom Code
|
||||||
//
|
//
|
||||||
|
|
||||||
load_app_code();
|
|
||||||
#if defined(FRED_SUPER)
|
#if defined(FRED_SUPER)
|
||||||
load_custom_code();
|
load_custom_code();
|
||||||
#else
|
#else
|
||||||
custom_api.get_bindings = get_bindings;
|
custom_api.get_bindings = get_bindings;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
|
||||||
// Read Command Line
|
|
||||||
//
|
|
||||||
|
|
||||||
read_command_line(argc, argv);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Threads
|
// Threads
|
||||||
//
|
//
|
||||||
|
|
|
@ -19,6 +19,9 @@ system_load_library_direct(Library *library, char *name){
|
||||||
AssertLibrarySizes();
|
AssertLibrarySizes();
|
||||||
library->lib = LoadLibraryA(name);
|
library->lib = LoadLibraryA(name);
|
||||||
b32 success = (library->lib != 0);
|
b32 success = (library->lib != 0);
|
||||||
|
if (!success){
|
||||||
|
win32_output_error_string(false);
|
||||||
|
}
|
||||||
return(success);
|
return(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue