Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Cantor
Commits
f2ea4433
Commit
f2ea4433
authored
May 13, 2022
by
Thomas Friedrichsmeier
Committed by
Alexander Semke
Oct 06, 2022
Browse files
Allow building R backend with MSVC
parent
250ee36a
Pipeline
#243036
passed with stage
in 6 minutes and 8 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/backends/R/CMakeLists.txt
View file @
f2ea4433
...
...
@@ -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
)
if
(
MSVC
)
# When compiling with MSVC, we have to create a .lib file for R.dll, first
find_package
(
Python3 COMPONENTS Interpreter REQUIRED
)
add_custom_target
(
R_lib COMMAND
${
Python3_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/GenLibFile.py
${
R_R_LIBRARY
}
${
CMAKE_BINARY_DIR
}
${
CMAKE_SYSTEM_PROCESSOR
}
COMMENT
"Generate .lib file for R.dll"
)
add_dependencies
(
cantor_rbackend R_lib
)
endif
(
MSVC
)
if
(
BUILD_TESTING
)
add_executable
(
testr testr.cpp
)
...
...
src/backends/R/GenLibFile.py
0 → 100644
View file @
f2ea4433
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 GenLibFile.py 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
:
continue
exports
.
append
(
fields
[
3
])
os
.
chdir
(
workdir
)
with
open
(
os
.
path
.
join
(
workdir
,
deffile
),
"wt+"
)
as
outdef
:
outdef
.
write
(
"EXPORTS
\n
"
)
outdef
.
write
(
"
\n
"
.
join
(
exports
))
subprocess
.
call
([
"lib"
,
f
"/def:
{
deffile
}
"
,
f
"/out:
{
libfile
}
"
,
f
"/machine:
{
arch
}
"
])
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment