Skip to content

Commit

Permalink
more robust invocation of dll2lib.R
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Nov 26, 2018
1 parent c407111 commit 592dee7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
26 changes: 23 additions & 3 deletions cmake/modules/FindLibR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,29 @@ else()

# call dll2lib.R to ensure export files are generated
execute_process(
COMMAND "${LIBR_HOME}/bin/${LIBR_ARCH}/Rscript.exe" "dll2lib.R"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools"
RESULT_VARIABLE LIBR_DLL2LIB_RESULT)

COMMAND
"${LIBR_HOME}/bin/${LIBR_ARCH}/Rscript.exe"
"dll2lib.R"
"${CMAKE_C_COMPILER}"

WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/tools"

OUTPUT_VARIABLE
LIBR_DLL2LIB_STDOUT

ERROR_VARIABLE
LIBR_DLL2LIB_STDERR

RESULT_VARIABLE
LIBR_DLL2LIB_RESULT)

if(NOT LIBR_DLL2LIB_RESULT EQUAL 0)
message(STATUS "${LIBR_DLL2LIB_STDOUT}")
message(STATUS "${LIBR_DLL2LIB_STDERR}")
message(FATAL_ERROR "Failed to generate .lib files for R DLLs!")
endif()

endif()

Expand Down
28 changes: 3 additions & 25 deletions src/cpp/tools/dll2lib.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
args <- commandArgs(TRUE)

# Put MSVC tools on the PATH.
# TODO: let CMake set this path for us
dirs <- c(

# for Jenkins
"C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.14.26428/bin/HostX64/x64",
"C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.15.26726/bin/HostX64/x64",

# for local installs
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/HostX64/x64",
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/HostX64/x64"

)

found <- FALSE
for (dir in dirs) {
if (file.exists(dir)) {
Sys.setenv(PATH = paste(dir, Sys.getenv("PATH"), sep = ";"))
found <- TRUE
break
}
}

if (!found)
stop("Failed to discover path to MSVC 2017 tools")
# Put the path containing the C compiler on the PATH.
Sys.setenv(PATH = paste(dirname(args[1]), Sys.getenv("PATH"), sep = ";"))

# Find R DLLs.
dlls <- list.files(R.home("bin"), pattern = "dll$", full.names = TRUE)
Expand Down

0 comments on commit 592dee7

Please sign in to comment.