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] Introduce R-specific control of lib_lightgbm #2837

Merged
merged 4 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_TIMETAG "Set to ON to output time costs" 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)
OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF)
Expand Down Expand Up @@ -70,6 +71,10 @@ if(USE_R35)
ADD_DEFINITIONS(-DR_VER_ABOVE_35)
endif(USE_R35)

if(BUILD_FOR_R)
ADD_DEFINITIONS(-DLGB_R_BUILD)
endif(BUILD_FOR_R)

if(USE_TIMETAG)
ADD_DEFINITIONS(-DTIMETAG)
endif(USE_TIMETAG)
Expand Down
3 changes: 2 additions & 1 deletion R-package/src/install.libs.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ if (!use_precompile) {
if (R_ver >= 3.5) {
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)
if (WINDOWS) {
Expand Down Expand Up @@ -71,7 +72,7 @@ if (!use_precompile) {
build_cmd <- "mingw32-make.exe _lightgbm"
} else {
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 = "/")
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/io/json11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include <LightGBM/utils/json11.h>

#include <limits>
#include <cassert>
#ifndef LGB_R_BUILD
#include <cassert>
#endif
#include <cmath>
#include <cstdio>
#include <cstdlib>
Expand Down Expand Up @@ -624,7 +626,9 @@ struct JsonParser final {
* the input and return res. If not, flag an error.
*/
Json expect(const string &expected, Json res) {
assert(i != 0);
#ifndef LGB_R_BUILD
assert(i != 0);
#endif
i--;
if (str.compare(i, expected.length(), expected) == 0) {
i += expected.length();
Expand Down