"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "e906a82c4386e4363720971f6cff4fbc86b33f93"
Unverified Commit 17b8ce16 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] Introduce R-specific control of lib_lightgbm (#2837)

* [R-package] Introduced define LGB_BUILD_R to control compilation of lib_lightgbm for the R package

* fixed comment

* switched to cmake options

* fixed typo
parent 6b6709b9
...@@ -14,6 +14,7 @@ OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) ...@@ -14,6 +14,7 @@ OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF)
OPTION(USE_R35 "Set to ON if your R version is not earlier than 3.5" OFF) OPTION(USE_R35 "Set to ON if your R version is not earlier than 3.5" OFF)
OPTION(USE_TIMETAG "Set to ON to output time costs" OFF) OPTION(USE_TIMETAG "Set to ON to output time costs" OFF)
OPTION(USE_DEBUG "Set to ON for Debug mode" OFF) OPTION(USE_DEBUG "Set to ON for Debug mode" OFF)
OPTION(BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF)
if(APPLE) if(APPLE)
OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF) OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF)
...@@ -70,6 +71,10 @@ if(USE_R35) ...@@ -70,6 +71,10 @@ if(USE_R35)
ADD_DEFINITIONS(-DR_VER_ABOVE_35) ADD_DEFINITIONS(-DR_VER_ABOVE_35)
endif(USE_R35) endif(USE_R35)
if(BUILD_FOR_R)
ADD_DEFINITIONS(-DLGB_R_BUILD)
endif(BUILD_FOR_R)
if(USE_TIMETAG) if(USE_TIMETAG)
ADD_DEFINITIONS(-DTIMETAG) ADD_DEFINITIONS(-DTIMETAG)
endif(USE_TIMETAG) endif(USE_TIMETAG)
......
...@@ -43,6 +43,7 @@ if (!use_precompile) { ...@@ -43,6 +43,7 @@ if (!use_precompile) {
if (R_ver >= 3.5) { if (R_ver >= 3.5) {
cmake_cmd <- paste0(cmake_cmd, " -DUSE_R35=ON ") cmake_cmd <- paste0(cmake_cmd, " -DUSE_R35=ON ")
} }
cmake_cmd <- paste0(cmake_cmd, " -DBUILD_FOR_R=ON ")
# Check if Windows installation (for gcc vs Visual Studio) # Check if Windows installation (for gcc vs Visual Studio)
if (WINDOWS) { if (WINDOWS) {
...@@ -71,7 +72,7 @@ if (!use_precompile) { ...@@ -71,7 +72,7 @@ if (!use_precompile) {
build_cmd <- "mingw32-make.exe _lightgbm" build_cmd <- "mingw32-make.exe _lightgbm"
} else { } else {
cmake_cmd <- paste0(cmake_cmd, local_vs_def) cmake_cmd <- paste0(cmake_cmd, local_vs_def)
build_cmd <- "cmake --build . --target _lightgbm --config Release" build_cmd <- "cmake --build . --target _lightgbm --config Release"
lib_folder <- file.path(R_PACKAGE_SOURCE, "src/Release", fsep = "/") lib_folder <- file.path(R_PACKAGE_SOURCE, "src/Release", fsep = "/")
} }
} }
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
#include <LightGBM/utils/json11.h> #include <LightGBM/utils/json11.h>
#include <limits> #include <limits>
#include <cassert> #ifndef LGB_R_BUILD
#include <cassert>
#endif
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
...@@ -624,7 +626,9 @@ struct JsonParser final { ...@@ -624,7 +626,9 @@ struct JsonParser final {
* the input and return res. If not, flag an error. * the input and return res. If not, flag an error.
*/ */
Json expect(const string &expected, Json res) { Json expect(const string &expected, Json res) {
assert(i != 0); #ifndef LGB_R_BUILD
assert(i != 0);
#endif
i--; i--;
if (str.compare(i, expected.length(), expected) == 0) { if (str.compare(i, expected.length(), expected) == 0) {
i += expected.length(); i += expected.length();
......
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