Commit fc59fce0 authored by Guolin Ke's avatar Guolin Ke
Browse files

[R] update build commands.

parent 3421bc6c
Package: lightgbm
Type: Package
Title: Light Gradient Boosting Machine
Version: 2.0.2
Date: 2017-06-22
Version: 2.0.4
Date: 2017-07-14
Author: Guolin Ke <guolin.ke@microsoft.com>
Maintainer: Guolin Ke <guolin.ke@microsoft.com>
Description: LightGBM is a gradient boosting framework that uses tree based learning algorithms.
......
......@@ -14,8 +14,6 @@ Note: 32-bit R/Rtools is not supported.
Installing [Rtools](https://cran.r-project.org/bin/windows/Rtools/) is mandatory, and only support the 64-bit version.
[cmake](https://cmake.org/) must be version 3.8 or higher.
The default compiler is Visual Studio (or [MS Build](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017)) in Windows, with an automatic fallback to Rtools or any [MinGW64](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/) (x86_64-posix-seh) available (this means if you have only Rtools and cmake, it will compile fine).
To force the usage of Rtools / MinGW, you can set `use_mingw` to `TRUE` in `R-package/src/install.libs.R`.
......@@ -44,7 +42,7 @@ Or build a self-contained R package which can be installed afterwards:
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM/R-package
Rscript build_package.R
R CMD INSTALL lightgbm_2.0.2.tar.gz --no-multiarch
R CMD INSTALL lightgbm_2.0.4.tar.gz --no-multiarch
```
Note: for the build with Visual Studio/MSBuild in Windows, you should use the Windows CMD or Powershell.
......
......@@ -25,12 +25,10 @@ if (!use_precompile) {
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")
}
......@@ -42,35 +40,46 @@ if (!use_precompile) {
setwd(build_dir)
# Prepare installation steps
cmake_base <- "cmake "
cmake_cmd <- "cmake "
build_cmd <- "make _lightgbm -j"
lib_folder <- file.path(R_PACKAGE_SOURCE, "src", fsep = "/")
if (use_gpu) {
cmake_cmd <- paste0(cmake_cmd, " -DUSE_GPU=ON ")
}
# Check if Windows installation (for gcc vs Visual Studio)
if (WINDOWS) {
if (use_mingw) {
cmake_cmd <- paste0(cmake_base, " -G \"MinGW Makefiles\" ")
cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ")
build_cmd <- "mingw32-make.exe _lightgbm -j"
system(paste0(cmake_cmd, " ..")) # Must build twice for Windows due sh.exe in Rtools
} else {
cmake_cmd <- paste0(cmake_base, " -DCMAKE_GENERATOR_PLATFORM=x64 ")
tryVS <- system(paste0(cmake_cmd, " .."))
if (tryVS == 1) {
try_vs <- 0
local_vs_def <- ""
vs_versions <- c("Visual Studio 15 2017 Win64", "Visual Studio 14 2015 Win64", "Visual Studio 12 2013 Win64")
for(vs in vs_versions){
vs_def <- paste0(" -G \"", vs, "\"")
tmp_cmake_cmd <- paste0(cmake_cmd, vs_def)
try_vs <- system(paste0(tmp_cmake_cmd, " .."))
unlink("./*", recursive = TRUE) # Clean up build directory
cmake_cmd <- paste0(cmake_base, " -G \"MinGW Makefiles\" ") # Switch to MinGW on failure, try build once
if (try_vs == 0) {
local_vs_def = vs_def
break
}
}
if (try_vs == 1) {
cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ") # Switch to MinGW on failure, try build once
system(paste0(cmake_cmd, " ..")) # Must build twice for Windows due sh.exe in Rtools
build_cmd <- "mingw32-make.exe _lightgbm -j"
} else {
cmake_cmd <- paste0(cmake_cmd, local_vs_def)
build_cmd <- "cmake --build . --target _lightgbm --config Release"
lib_folder <- file.path(R_PACKAGE_SOURCE, "src/Release", fsep = "/")
}
}
}
if (use_gpu) {
cmake_cmd <- paste0(cmake_cmd, " -DUSE_GPU=ON ")
}
# Install
system(paste0(cmake_cmd, " .."))
system(build_cmd)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment