-
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.
Compile R package by custom tool chain. (#584)
* add R's library file to vs project and cmake. * support using dll built by vs. * better search for the library file. * remove mingw related doc . * update document. * Let R handle the library compile. * try fix build from github. * Update README.md * cleaner build. * fix the install problem in linux. * Update README.md
- Loading branch information
Showing
20 changed files
with
118 additions
and
453 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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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("./../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.exists("src/_IS_FULL_PACKAGE")){ | ||
file.create("src/_IS_FULL_PACKAGE") | ||
} | ||
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,12 +0,0 @@ | ||
# package root | ||
PKGROOT=../../ | ||
|
||
ENABLE_STD_THREAD=1 | ||
CXX_STD = CXX11 | ||
|
||
LGBM_RFLAGS = -DUSE_SOCKET | ||
|
||
PKG_CPPFLAGS= -I$(PKGROOT)/include $(LGBM_RFLAGS) -Wno-deprecated-declarations -Wno-unknown-pragmas | ||
PKG_CXXFLAGS= $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS) -std=c++11 | ||
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS) | ||
OBJECTS = ./lightgbm-all.o ./lightgbm_R.o | ||
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,12 +0,0 @@ | ||
# package root | ||
PKGROOT=../../ | ||
|
||
ENABLE_STD_THREAD=1 | ||
CXX_STD = CXX11 | ||
|
||
LGBM_RFLAGS = -DUSE_SOCKET | ||
|
||
PKG_CPPFLAGS= -I$(PKGROOT)/include $(LGBM_RFLAGS) -Wno-unknown-pragmas | ||
PKG_CXXFLAGS= $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS) -std=c++11 | ||
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) $(SHLIB_PTHREAD_FLAGS) -lws2_32 -liphlpapi | ||
OBJECTS = ./lightgbm-all.o ./lightgbm_R.o | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
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") | ||
} | ||
if(use_gpu){ | ||
if(!file.copy("./../../compute", "./", overwrite=TRUE, recursive = TRUE)){ | ||
print("cannot find folder LightGBM/compute, will disable GPU build") | ||
use_gpu <- FALSE | ||
} | ||
} | ||
if(!file.copy("./../../CMakeLists.txt", "./", overwrite=TRUE, recursive=TRUE)){ | ||
stop("cannot find file LightGBM/CMakeLists.txt") | ||
} | ||
} | ||
|
||
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') | ||
} | ||
} | ||
|
||
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)) | ||
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)) | ||
file.copy(src, dest, overwrite = TRUE) | ||
} else { | ||
stop("cannot find lib_lightgbm.dll") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.