Browse Source

Added some speculative Windows support

ModuleSystem
Macoy Madson 10 months ago
parent
commit
77b72c2f0b
5 changed files with 28 additions and 6 deletions
  1. +13
    -1
      Jamrules
  2. +10
    -1
      src/DynamicLoader.cpp
  3. +1
    -1
      src/Main.cpp
  4. +2
    -2
      src/RunProcess.cpp
  5. +2
    -1
      test/Dependencies.cake

+ 13
- 1
Jamrules View File

@ -14,7 +14,19 @@ LINK = clang++ ;
## Compiler arguments
if $(UNIX)
if $(CROSS_COMPILE_WINDOWS)
{
C++ = x86_64-w64-mingw32-g++ ;
LINK = x86_64-w64-mingw32-g++ ;
AR = x86_64-w64-mingw32-ar ;
SUFSHR = .dll ;
OS_DEPENDENT_C++FLAGS = -DWINDOWS ;
# TODO: Windows support
OS_DEPENDENT_LINKFLAGS = ;
}
else if $(UNIX)
{
OS_DEPENDENT_C++FLAGS = -DUNIX ;
# For dynamic linking


+ 10
- 1
src/DynamicLoader.cpp View File

@ -4,8 +4,10 @@
#ifdef UNIX
#include <dlfcn.h>
#elif WINDOWS
#include <windows.h>
#else
#error "Platform support needed for dynamic loading"
#error Platform support is needed for dynamic loading
#endif
DynamicLibHandle loadDynamicLibrary(const char* libraryPath)
@ -22,6 +24,9 @@ DynamicLibHandle loadDynamicLibrary(const char* libraryPath)
fprintf(stderr, "DynamicLoader Error:\n%s\n", dlerror());
return nullptr;
}
#elif WINDOWS
// TODO: Any way to get errors if this fails?
libHandle = LoadLibrary(libraryPath);
#endif
return libHandle;
@ -54,6 +59,10 @@ void* getSymbolFromDynamicLibrary(DynamicLibHandle library, const char* symbolNa
}
return symbol;
#elif WINDOWS
// TODO: Any way to get errors if this fails?
void* procedure = (void*)GetProcAddress((HINSTANCE)library, symbolName);
return procedure;
#else
return nullptr;
#endif


+ 1
- 1
src/Main.cpp View File

@ -116,7 +116,7 @@ int main(int argc, char* argv[])
EvaluatorEnvironment environment = {};
importFundamentalGenerators(environment);
// Create module definition for top-level references to attach to
Token modulePsuedoInvocationName = {TokenType_Symbol, "<module>", "psuedotarget", 1, 1, 1};
Token modulePsuedoInvocationName = {TokenType_Symbol, "<module>", filename, 1, 0, 1};
{
ObjectDefinition moduleDefinition = {};
moduleDefinition.name = &modulePsuedoInvocationName;


+ 2
- 2
src/RunProcess.cpp View File

@ -9,7 +9,7 @@
#include <sys/wait.h> // waitpid
#include <unistd.h> // exec, fork
#else
#error Platform support needed for running subprocesses
#error Platform support is needed for running subprocesses
#endif
#include "Utilities.hpp"
@ -72,7 +72,7 @@ int runProcess(const RunProcessArguments& arguments, int* statusOut)
pid_t pid = fork();
if (pid == -1)
{
perror("RunProcess fork() error: cannot create child");
perror("RunProcess fork() error: cannot create child: ");
return 1;
}
// Child


+ 2
- 1
test/Dependencies.cake View File

@ -21,7 +21,7 @@
(output.push_back (array TokenType_OpenParen ""
startToken.source startToken.lineNumber
startToken.columnStart startToken.columnEnd))
(output.push_back (array TokenType_Symbol "defun"
(output.push_back (array TokenType_Symbol "defun" ;; "defun-local" to get rid of error
startToken.source startToken.lineNumber
startToken.columnStart startToken.columnEnd))
(output.push_back (array TokenType_Symbol "amazing-print"
@ -48,6 +48,7 @@
(output.push_back (array TokenType_CloseParen ""
startToken.source startToken.lineNumber
startToken.columnStart startToken.columnEnd))
;; (bad-function)
(return true))
(amazing-print-create)

Loading…
Cancel
Save