Commit f2ea4433 authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier Committed by Alexander Semke
Browse files

Allow building R backend with MSVC

parent 250ee36a
Pipeline #243036 passed with stage
in 6 minutes and 8 seconds
......@@ -31,6 +31,13 @@ add_backend(rbackend ${RBackend_SRCS})
set_target_properties( cantor_rbackend PROPERTIES INSTALL_RPATH_USE_LINK_PATH false)
target_link_libraries( cantor_rbackend cantor_help ${R_USED_LIBS} KF5::SyntaxHighlighting)
# When compiling with MSVC, we have to create a .lib file for R.dll, first
find_package(Python3 COMPONENTS Interpreter REQUIRED)
COMMENT "Generate .lib file for R.dll")
add_dependencies(cantor_rbackend R_lib)
add_executable( testr testr.cpp)
import subprocess
import os
import sys
# Generate a .lib file for a given .dll
# This assumed dumpbin and lib to be in the path, which they should be, when compiling with MSVC (and that's what this is needed for)
# Usage: python3 XYZ.dll output_directory architecture
dllfile = sys.argv[1]
workdir = sys.argv[2]
arch = sys.argv[3]
base = os.path.basename(dllfile).replace(".dll", "")
deffile = base + ".def"
libfile = base + ".lib"
dump = subprocess.check_output(["dumpbin", "/exports", dllfile]).decode("latin1").splitlines()
exports = []
for line in dump:
fields = line.split()
if len(fields) != 4:
with open(os.path.join(workdir, deffile), "wt+") as outdef:
outdef.write("\n".join(exports))["lib", f"/def:{deffile}", f"/out:{libfile}", f"/machine:{arch}"])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment