Commit 3e94f25f authored by Laurae's avatar Laurae Committed by Guolin Ke
Browse files

[R-package] Remove paste0 ambiguity for paths (#612)

* Remove paste0 ambiguity for paths

* Fix equal missing typo

* Get rid of all trailing slashes
parent 4e751a45
...@@ -7,7 +7,7 @@ use_mingw <- FALSE ...@@ -7,7 +7,7 @@ use_mingw <- FALSE
if (!use_precompile) { if (!use_precompile) {
# Check repository content # Check repository content
source_dir <- paste0(R_PACKAGE_SOURCE, "/src/") source_dir <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/")
setwd(source_dir) setwd(source_dir)
if (!file.exists("_IS_FULL_PACKAGE")) { if (!file.exists("_IS_FULL_PACKAGE")) {
...@@ -29,14 +29,14 @@ if (!use_precompile) { ...@@ -29,14 +29,14 @@ if (!use_precompile) {
} }
# Prepare building package # Prepare building package
build_dir <- paste0(source_dir, "build/") build_dir <- file.path(source_dir, "build", fsep = "/")
dir.create(build_dir, recursive = TRUE, showWarnings = FALSE) dir.create(build_dir, recursive = TRUE, showWarnings = FALSE)
setwd(build_dir) setwd(build_dir)
# Prepare installation steps # Prepare installation steps
cmake_cmd <- "cmake" cmake_cmd <- "cmake"
build_cmd <- "make -j" build_cmd <- "make -j"
lib_folder <- paste0(R_PACKAGE_SOURCE, "/src/") lib_folder <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/")
# Check if Windows installation (for gcc vs Visual Studio) # Check if Windows installation (for gcc vs Visual Studio)
if (WINDOWS) { if (WINDOWS) {
...@@ -46,7 +46,7 @@ if (!use_precompile) { ...@@ -46,7 +46,7 @@ if (!use_precompile) {
} else { } else {
cmake_cmd <- paste0(cmake_cmd, " -DCMAKE_GENERATOR_PLATFORM=x64 ") cmake_cmd <- paste0(cmake_cmd, " -DCMAKE_GENERATOR_PLATFORM=x64 ")
build_cmd <- "cmake --build . --target _lightgbm --config Release" build_cmd <- "cmake --build . --target _lightgbm --config Release"
lib_folder <- paste0(R_PACKAGE_SOURCE, "/src/Release/") lib_folder <- file.path(R_PACKAGE_SOURCE, "src/Release", fsep = "/")
} }
} }
...@@ -57,24 +57,24 @@ if (!use_precompile) { ...@@ -57,24 +57,24 @@ if (!use_precompile) {
# Install # Install
system(paste0(cmake_cmd, " ..")) system(paste0(cmake_cmd, " .."))
system(build_cmd) system(build_cmd)
src <- paste0(lib_folder, "lib_lightgbm", SHLIB_EXT) src <- file.path(lib_folder, paste0("lib_lightgbm", SHLIB_EXT), fsep = "/")
} else { } else {
# Has precompiled package # Has precompiled package
lib_folder <- paste0(R_PACKAGE_SOURCE, "/../") lib_folder <- file.path(R_PACKAGE_SOURCE, "../", fsep = "/")
if (file.exists(paste0(lib_folder, "lib_lightgbm", SHLIB_EXT))) { if (file.exists(file.path(lib_folder, paste0("lib_lightgbm", SHLIB_EXT), fsep = "/"))) {
src <- paste0(lib_folder, "lib_lightgbm", SHLIB_EXT) src <- file.path(lib_folder, paste0("lib_lightgbm", SHLIB_EXT), fsep = "/")
} else if (file.exists(paste0(lib_folder, "Release/lib_lightgbm", SHLIB_EXT))){ } else if (file.exists(file.path(lib_folder, paste0("Release/lib_lightgbm", SHLIB_EXT), fsep = "/"))) {
src <- paste0(lib_folder, "Release/lib_lightgbm", SHLIB_EXT) src <- file.path(lib_folder, paste0("Release/lib_lightgbm", SHLIB_EXT), fsep = "/")
} else { } else {
src <- paste0(lib_folder, "windows/x64/DLL/lib_lightgbm", SHLIB_EXT) # Expected result: installation will fail if it is not here or any other src <- file.path(lib_folder, paste0("/windows/x64/DLL/lib_lightgbm", SHLIB_EXT), fsep = "/") # Expected result: installation will fail if it is not here or any other
} }
} }
# Check installation correctness # Check installation correctness
dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH)) dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH), fsep = "/")
dir.create(dest, recursive = TRUE, showWarnings = FALSE) dir.create(dest, recursive = TRUE, showWarnings = FALSE)
if (file.exists(src)) { if (file.exists(src)) {
cat("Found library file: ", src, " to move to ", dest, sep = "") cat("Found library file: ", src, " to move to ", dest, sep = "")
......
Markdown is supported
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