[R-package] added command to remove build/ dir in install.libs.R (#2909)

This commit is contained in:
James Lamb 2020-03-15 18:00:14 -05:00 коммит произвёл GitHub
Родитель 4aa888c815
Коммит a78e3ed006
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -20,16 +20,19 @@ if (!file.copy("../inst/bin/CMakeLists.txt", "CMakeLists.txt", overwrite = TRUE)
stop("Copying CMakeLists failed") 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 # Check for precompilation
if (!use_precompile) { if (!use_precompile) {
# Check repository content
source_dir <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/")
setwd(source_dir)
# Prepare building package # Prepare building package
build_dir <- file.path(source_dir, "build", fsep = "/") dir.create(
dir.create(build_dir, recursive = TRUE, showWarnings = FALSE) build_dir
, recursive = TRUE
, showWarnings = FALSE
)
setwd(build_dir) setwd(build_dir)
# Prepare installation steps # Prepare installation steps
@ -142,8 +145,18 @@ if (!use_precompile) {
dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH), fsep = "/") 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 = "") print(paste0("Found library file: ", src, " to move to ", dest))
file.copy(src, dest, overwrite = TRUE) file.copy(src, dest, overwrite = TRUE)
} else { } else {
stop(paste0("Cannot find lib_lightgbm", SHLIB_EXT)) 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
)
}