Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions R-package/src/install.libs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -142,8 +145,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)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_dir variable is not defined when use_precompile == TRUE, isn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 yep you're right! Let me fix that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it up in 56635a7. This also exposed that that setwd(source_dir) was unnecessary.

thanks!

print("Removing 'build/' directory")
unlink(
x = file.path(R_PACKAGE_SOURCE, "src", "build")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be clearer:

x = file.path(R_PACKAGE_SOURCE, "src", "build") -> x = file.path(build_dir)

(Suggestions are disabled after merging a PR.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blegh sorry, yeah you're right. That would eliminate a source of duplication. Let me add that right now.

, recursive = TRUE
, force = TRUE
)
}