-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add some stuff for README * Bump R package version and fix license * Attempt to add one additional option and refactor * Add more review fixes for install.libs.R * Undo ./../../ removal (path breaking) * Retry again simple /../ * No print, use cat.
- Loading branch information
Showing
4 changed files
with
103 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
if(!file.copy("./../include", "src/", overwrite=TRUE, recursive = TRUE)){ | ||
stop("cannot find folder LightGBM/include") | ||
if (!file.copy("./../include", "src/", overwrite = TRUE, recursive = TRUE)) { | ||
stop("Cannot find folder LightGBM/include") | ||
} | ||
if(!file.copy("./../src", "src/", overwrite=TRUE, recursive = TRUE)){ | ||
stop("cannot find folder LightGBM/src") | ||
if (!file.copy("./../src", "src/", overwrite = TRUE, recursive = TRUE)) { | ||
stop("Cannot find folder LightGBM/src") | ||
} | ||
if(!file.copy("./../compute", "src/", overwrite=TRUE, recursive = TRUE)){ | ||
print("cannot find folder LightGBM/compute, will disable GPU build") | ||
if (!file.copy("./../compute", "src/", overwrite = TRUE, recursive = TRUE)) { | ||
print("Cannot find folder LightGBM/compute, will disable GPU build") | ||
} | ||
if(!file.copy("./../CMakeLists.txt", "src/", overwrite=TRUE, recursive=TRUE)){ | ||
stop("cannot find file LightGBM/CMakeLists.txt") | ||
if (!file.copy("./../CMakeLists.txt", "src/", overwrite = TRUE, recursive = TRUE)) { | ||
stop("Cannot find file LightGBM/CMakeLists.txt") | ||
} | ||
if(!file.exists("src/_IS_FULL_PACKAGE")){ | ||
if (!file.exists("src/_IS_FULL_PACKAGE")) { | ||
file.create("src/_IS_FULL_PACKAGE") | ||
} | ||
system("R CMD build --no-build-vignettes .") | ||
system("R CMD build --no-build-vignettes .") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,83 @@ | ||
# User options | ||
use_precompile <- FALSE | ||
use_gpu <- FALSE | ||
use_mingw <- FALSE | ||
source_dir <- paste0(R_PACKAGE_SOURCE, '/src') | ||
setwd(source_dir) | ||
if(!file.exists("_IS_FULL_PACKAGE")){ | ||
if(!file.copy("./../../include", "./", overwrite=TRUE, recursive = TRUE)){ | ||
stop("cannot find folder LightGBM/include") | ||
} | ||
if(!file.copy("./../../src", "./", overwrite=TRUE, recursive = TRUE)){ | ||
stop("cannot find folder LightGBM/src") | ||
|
||
# Check for precompilation | ||
if (!use_precompile) { | ||
|
||
# Check repository content | ||
source_dir <- paste0(R_PACKAGE_SOURCE, "/src") | ||
setwd(source_dir) | ||
|
||
if (!file.exists("_IS_FULL_PACKAGE")) { | ||
if (!file.copy("./../../include", "./", overwrite = TRUE, recursive = TRUE)) { | ||
stop("Cannot find folder LightGBM/include") | ||
} | ||
if (!file.copy("./../../src", "./", overwrite = TRUE, recursive = TRUE)) { | ||
stop("Cannot find folder LightGBM/src") | ||
} | ||
if (use_gpu) { | ||
if (!file.copy("./../../compute", "./", overwrite = TRUE, recursive = TRUE)) { | ||
print("Cannot find folder LightGBM/compute, disabling GPU build.") | ||
use_gpu <- FALSE | ||
} | ||
} | ||
if (!file.copy("./../../CMakeLists.txt", "./", overwrite = TRUE, recursive = TRUE)) { | ||
stop("Cannot find file LightGBM/CMakeLists.txt") | ||
} | ||
} | ||
if(use_gpu){ | ||
if(!file.copy("./../../compute", "./", overwrite=TRUE, recursive = TRUE)){ | ||
print("cannot find folder LightGBM/compute, will disable GPU build") | ||
use_gpu <- FALSE | ||
|
||
# Prepare building package | ||
build_dir <- paste0(source_dir, "/build") | ||
dir.create(build_dir, recursive = TRUE, showWarnings = FALSE) | ||
setwd(build_dir) | ||
|
||
# Prepare installatio nsteps | ||
cmake_cmd <- "cmake" | ||
build_cmd <- "make -j" | ||
lib_folder <- paste0(R_PACKAGE_SOURCE, "/src") | ||
|
||
if (WINDOWS) { | ||
if (use_mingw) { | ||
cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ") | ||
build_cmd <- "mingw32-make.exe -j" | ||
} else { | ||
cmake_cmd <- paste0(cmake_cmd, " -DCMAKE_GENERATOR_PLATFORM=x64 ") | ||
build_cmd <- "cmake --build . --target _lightgbm --config Release" | ||
lib_folder <- paste0(R_PACKAGE_SOURCE, "/src/Release") | ||
} | ||
} | ||
if(!file.copy("./../../CMakeLists.txt", "./", overwrite=TRUE, recursive=TRUE)){ | ||
stop("cannot find file LightGBM/CMakeLists.txt") | ||
|
||
if (use_gpu) { | ||
cmake_cmd <- paste0(cmake_cmd, " -DUSE_GPU=1 ") | ||
} | ||
} | ||
|
||
build_dir <- paste0(source_dir, "/build") | ||
dir.create(build_dir, recursive = TRUE, showWarnings = FALSE) | ||
setwd(build_dir) | ||
|
||
cmake_cmd <- "cmake" | ||
build_cmd <- "make -j" | ||
lib_folder <- paste0(R_PACKAGE_SOURCE, '/src') | ||
|
||
if (WINDOWS) { | ||
if(use_mingw){ | ||
cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ") | ||
build_cmd <- "mingw32-make.exe -j" | ||
} else{ | ||
cmake_cmd <- paste0(cmake_cmd, " -DCMAKE_GENERATOR_PLATFORM=x64 ") | ||
build_cmd <- "cmake --build . --target _lightgbm --config Release" | ||
lib_folder <- paste0(R_PACKAGE_SOURCE, '/src/Release') | ||
|
||
# Install | ||
system(paste0(cmake_cmd, " ..")) | ||
system(build_cmd) | ||
src <- paste0(lib_folder, "/lib_lightgbm", SHLIB_EXT) | ||
|
||
} else { | ||
|
||
# Has precompiled package | ||
lib_folder <- paste0(R_PACKAGE_SOURCE, "/../") | ||
if (file.exists(paste0(lib_folder, "lib_lightgbm", SHLIB_EXT))) { | ||
src <- paste0(lib_folder, "lib_lightgbm", SHLIB_EXT) | ||
} else if (file.exists(paste0(lib_folder, "windows/x64/DLL/lib_lightgbm", SHLIB_EXT))) { | ||
src <- paste0(lib_folder, "windows/x64/DLL/lib_lightgbm", SHLIB_EXT) | ||
} else { | ||
src <- paste0(lib_folder, "Release/lib_lightgbm", SHLIB_EXT) # Expected result: installation will fail if it is not here or any other | ||
} | ||
|
||
} | ||
|
||
if(use_gpu) { | ||
cmake_cmd <- paste0(cmake_cmd, " -DUSE_GPU=1 ") | ||
} | ||
|
||
system(paste0(cmake_cmd, " ..")) | ||
system(build_cmd) | ||
dest <- file.path(R_PACKAGE_DIR, paste0('libs', R_ARCH)) | ||
# Check installation correctness | ||
dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH)) | ||
dir.create(dest, recursive = TRUE, showWarnings = FALSE) | ||
src <- paste0(lib_folder, '/lib_lightgbm', SHLIB_EXT) | ||
if(file.exists(src)){ | ||
print(paste0("find library file: ", src)) | ||
if (file.exists(src)) { | ||
cat("Found library file: ", src, " to move to ", dest, sep = "") | ||
file.copy(src, dest, overwrite = TRUE) | ||
} else { | ||
stop("cannot find lib_lightgbm.dll") | ||
stop(paste0("Cannot find lib_lightgbm", SHLIB_EXT)) | ||
} |