From 59e3721a522656315896a28fb5914e8ff8c0b386 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sat, 14 Mar 2020 01:32:59 -0500 Subject: [PATCH 1/3] [R-package] added command to remove build/ dir in install.libs.R --- R-package/src/install.libs.R | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/R-package/src/install.libs.R b/R-package/src/install.libs.R index 59742860d973..df92d6fb6226 100644 --- a/R-package/src/install.libs.R +++ b/R-package/src/install.libs.R @@ -142,8 +142,18 @@ if (!use_precompile) { dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH), fsep = "/") dir.create(dest, recursive = TRUE, showWarnings = FALSE) if (file.exists(src)) { - cat("Found library file: ", src, " to move to ", dest, sep = "") + print(paste0("Found library file: ", src, " to move to ", dest)) file.copy(src, dest, overwrite = TRUE) } else { stop(paste0("Cannot find lib_lightgbm", SHLIB_EXT)) } + +# clean up the "build" directory +if (dir.exists(build_dir)){ + print("Removing 'build/' directory") + unlink( + x = file.path(R_PACKAGE_SOURCE, "src", "build") + , recursive = TRUE + , force = TRUE + ) +} From 7673da58670454be870e4e19817d294c243204f1 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sat, 14 Mar 2020 10:30:03 -0500 Subject: [PATCH 2/3] linting fix --- R-package/src/install.libs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R-package/src/install.libs.R b/R-package/src/install.libs.R index df92d6fb6226..9f4cd144f31d 100644 --- a/R-package/src/install.libs.R +++ b/R-package/src/install.libs.R @@ -149,7 +149,7 @@ if (file.exists(src)) { } # clean up the "build" directory -if (dir.exists(build_dir)){ +if (dir.exists(build_dir)) { print("Removing 'build/' directory") unlink( x = file.path(R_PACKAGE_SOURCE, "src", "build") From 56635a7cf10b53f543db3b96cd1831dd159ff6b8 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 15 Mar 2020 17:39:13 -0500 Subject: [PATCH 3/3] moved directory definitions up in install.libs.R --- R-package/src/install.libs.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R-package/src/install.libs.R b/R-package/src/install.libs.R index 9f4cd144f31d..14a49cc11ae8 100644 --- a/R-package/src/install.libs.R +++ b/R-package/src/install.libs.R @@ -20,16 +20,19 @@ if (!file.copy("../inst/bin/CMakeLists.txt", "CMakeLists.txt", overwrite = TRUE) stop("Copying CMakeLists failed") } +# Get some paths +source_dir <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/") +build_dir <- file.path(source_dir, "build", fsep = "/") + # Check for precompilation if (!use_precompile) { - # Check repository content - source_dir <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/") - setwd(source_dir) - # Prepare building package - 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) # Prepare installation steps