Skip to content

Commit

Permalink
dynlib.t now tests windows shared library build
Browse files Browse the repository at this point in the history
  • Loading branch information
zdevito committed Mar 4, 2015
1 parent 3b67f7f commit 42bae31
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion msvc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ $(BUILD)\terra.obj: $(BUILD)\clangpaths.h $(BUILD)\terralib.h $(BUILD)\strict.h

$(TERRA_DIR)\release\terra.dll: $(BUILD)\terra.obj
cd $(TERRA_DIR)\release
$(LINK) /MACHINE:X64 /DLL /out:terra.dll /IMPLIB:terra.lib $(BUILD)/*.obj $(LIBS) $(LIBPATHS) $(EXPORTS)
$(LINK) /nologo /MACHINE:X64 /DLL /out:terra.dll /IMPLIB:terra.lib $(BUILD)/*.obj $(LIBS) $(LIBPATHS) $(EXPORTS)

REDIST=$(VCINSTALLDIR)redist\x64\Microsoft.VC120.CRT

$(TERRA_DIR)\release\terra.exe: $(TERRA_DIR)\release\terra.dll $(SRC)\main.cpp
cd $(TERRA_DIR)
copy $(LUAJIT_DIR)\src\lua51.dll release
copy $(LUAJIT_DIR)\src\lua51.lib release
copy "$(REDIST)\msvcp120.dll" release
copy "$(REDIST)\msvcr120.dll" release
xcopy /E /I /Q /Y $(CLANG_RESOURCE_DIRECTORY) release\include\clang_resource
Expand Down
2 changes: 1 addition & 1 deletion src/tcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2643,7 +2643,7 @@ static bool SaveAndLink(terra_State * T, Module * M, std::vector<const char *> *
cmd.push_back("-o");
cmd.push_back(filename);
#else
cmd.push_back("-defaultlib:libcmt");
cmd.push_back("-defaultlib:msvcrt");
cmd.push_back("-nologo");
llvm::SmallString<256> fileout("-out:");
fileout.append(filename);
Expand Down
26 changes: 16 additions & 10 deletions tests/dynlib.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
if require("ffi").os == "Windows" then
print("dynamic library not built on windows yet")
return
end
local ffi = require 'ffi'
-- test that the dynamic library for terra was built correctly
-- by compiling a new program that links against it and running it
terralib.includepath = terralib.terrahome.."/include"
Expand Down Expand Up @@ -29,12 +26,21 @@ terra main(argc : int, argv : &rawstring)
return 0;
end

if ffi.os ~= "Windows" then

local flags = terralib.newlist {"-L", terralib.terrahome,"-Wl,-rpath,"..terralib.terrahome,"-lterra"}
if require("ffi").os == "OSX" then
flags:insertall {"-pagezero_size","10000", "-image_base", "100000000"}
end
local flags = terralib.newlist {"-L", terralib.terrahome,"-Wl,-rpath,"..terralib.terrahome,"-lterra"}
if require("ffi").os == "OSX" then
flags:insertall {"-pagezero_size","10000", "-image_base", "100000000"}
end

terralib.saveobj("dynlib",{main = main},flags)

terralib.saveobj("dynlib",{main = main},flags)
assert(0 == os.execute("./dynlib"))

assert(0 == os.execute("./dynlib"))
else
local putenv = terralib.externfunction("_putenv", rawstring -> int)
local flags = {terralib.terrahome.."\\terra.lib",terralib.terrahome.."\\lua51.lib"}
terralib.saveobj("dynlib.exe",{main = main},flags)
putenv("Path="..os.getenv("Path")..";"..terralib.terrahome) --make dll search happy
assert(0 == os.execute(".\\dynlib.exe"))
end

0 comments on commit 42bae31

Please sign in to comment.