Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions python/cppjit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ def __new__(mcs, name, this_bases, d):

# - workaround (TODO: may not be needed with Clang9) --------------------------
if "win32" in sys.platform:
cppdef("""template<>
std::basic_ostream<char, std::char_traits<char>>& __cdecl std::endl<char, std::char_traits<char>>(
std::basic_ostream<char, std::char_traits<char>>&);""")
# Ill-formed if std::endl<char> was already instantiated; then the
# instantiation exists and the workaround is unnecessary.
try:
cppdef("""template<>
std::basic_ostream<char, std::char_traits<char>>& __cdecl std::endl<char, std::char_traits<char>>(
std::basic_ostream<char, std::char_traits<char>>&);""")
except SyntaxError:
pass
15 changes: 10 additions & 5 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# the C++ sides of the tests live under cpp/ and build into shared
# libraries next to their sources (load_reflection_info resolves the
# header as a sibling of the loaded Dict.so)
# header as a sibling of the loaded Dict library)
soext = .so
ifeq ($(OS),Windows_NT)
soext = .dll
endif

dictnames = advancedcpp \
advancedcpp2 \
conversions \
Expand All @@ -17,7 +22,7 @@ dictnames = advancedcpp \
stltypes \
templates

dicts = $(addprefix cpp/,$(addsuffix Dict.so,$(dictnames)))
dicts = $(addprefix cpp/,$(addsuffix Dict$(soext),$(dictnames)))

all : $(dicts)

Expand All @@ -30,11 +35,11 @@ ifeq ($(PLATFORM),Darwin)
endif

# a worker can load the library while another rebuilds it, so publish it whole
cpp/%Dict.so: cpp/%.cxx cpp/%.h
cpp/%Dict$(soext): cpp/%.cxx cpp/%.h
$(CXX) $(cppflags) -shared -o $@.$$$$.tmp $< && mv -f $@.$$$$.tmp $@

# convenience: `make datatypesDict.so` builds cpp/datatypesDict.so
%Dict.so: cpp/%Dict.so ;
# convenience: `make datatypesDict$(soext)` builds cpp/datatypesDict$(soext)
%Dict$(soext): cpp/%Dict$(soext) ;

.PHONY: test clean

Expand Down
4 changes: 3 additions & 1 deletion test/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setup_make(targetname, optional=False):
if fcntl is not None:
fcntl.flock(lockf, fcntl.LOCK_EX)
popen = subprocess.Popen(
["make", targetname + "Dict.so"],
["make", targetname + "Dict" + soext],
cwd=str(currpath),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand Down Expand Up @@ -76,6 +76,8 @@ def setup_make(targetname, optional=False):
else:
IS_WINDOWS = 32

soext = ".dll" if IS_WINDOWS else ".so"
Comment thread
aaronj0 marked this conversation as resolved.

IS_MAC_ARM = 0
IS_MAC_X86 = 0
if "darwin" in sys.platform:
Expand Down
12 changes: 7 additions & 5 deletions test/test_basic_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import py
from pytest import raises
from support import needs_dictionary, setup_make
from support import needs_dictionary, setup_make, soext

# reuse the example01
currpath = py.path.local(__file__).dirpath()
Expand Down Expand Up @@ -48,17 +48,19 @@ def test03_add_library_path(self):
with raises(OSError, match="No such directory"):
cppjit.add_library_path("not/a/real/path")

with tempfile.TemporaryDirectory() as tpath:
# once loaded, the copied library is mapped into the process; Windows
# then refuses to delete it, which would fail the cleanup
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tpath:
cppjit.add_library_path(tpath)

# now we should actually see if load library can follow this...
# first, try to load without moving to directory...
with raises(RuntimeError, match="Could not load library"):
cppjit.load_library("test.so")
cppjit.load_library("test" + soext)

# then copy to our rpath, and make sure it can be loaded now
shutil.copyfile(test_dct + ".so", tpath + "/test.so")
cppjit.load_library("test.so")
shutil.copyfile(test_dct + soext, tpath + "/test" + soext)
cppjit.load_library("test" + soext)

def test03a_load_library_failure_reason(self):
"""load_library reports the loader's failure reason"""
Expand Down
Loading