-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admit defeat, pursue wrapper .exe generation tack
- Loading branch information
1 parent
2250b86
commit 02b36be
Showing
4 changed files
with
84 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <windows.h> | ||
#include <tchar.h> | ||
#define ENVVAR_MAXLEN 32760 | ||
|
||
/* PATH_ENTRIES is our simulated RPATH, usually of the form "../path1;../path2;../path3" */ | ||
#ifndef PATH_ENTRIES | ||
#define PATH_ENTRIES TEXT("") | ||
#endif | ||
|
||
/* JULIA_EXE_PATH is the relative path to julia.exe */ | ||
#ifndef JULIA_EXE_PATH | ||
#define JULIA_EXE_PATH "../libexec/julia.exe" | ||
#endif | ||
|
||
int wmain(int argc, char **argv) { | ||
// On windows, we simulate RPATH by pushing onto PATH | ||
LPSTR pathVal = (LPSTR) malloc(ENVVAR_MAXLEN*sizeof(TCHAR)); | ||
DWORD dwRet = GetEnvironmentVariable("PATH", pathVal, ENVVAR_MAXLEN); | ||
if (dwRet == 0) { | ||
// If we cannot get PATH, then our job is easy! | ||
pathVal[0] = '\0'; | ||
lstrcat(pathVal, TEXT(PATH_ENTRIES)); | ||
} else { | ||
// Otherwise, we append, if we have enough space to: | ||
if (ENVVAR_MAXLEN - dwRet < _tcslen(PATH_ENTRIES) ) { | ||
printf("ERROR: Cannot append entries to PATH: not enough space in environment block. Reduce size of PATH!"); | ||
exit(1); | ||
} | ||
lstrcat(pathVal, TEXT(";")); | ||
lstrcat(pathVal, TEXT(PATH_ENTRIES)); | ||
} | ||
SetEnvironmentVariable("PATH", pathVal); | ||
free(pathVal); | ||
|
||
STARTUPINFO info; | ||
PROCESS_INFORMATION processInfo; | ||
DWORD exit_code = 1; | ||
GetStartupInfo(&info); | ||
if (CreateProcess(TEXT(JULIA_EXE_PATH), GetCommandLine(), NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo)) { | ||
WaitForSingleObject(processInfo.hProcess, INFINITE); | ||
GetExitCodeProcess(pi.hProcess, &exit_code); | ||
CloseHandle(processInfo.hProcess); | ||
CloseHandle(processInfo.hThread); | ||
} | ||
return exit_code; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters