[jvm-packages] Another pack of build/CI improvements (#2422)
* [jvm-packages] Fixed compilation on Windows * [jvm-packages] Build the JNI bindings on Appveyor * [jvm-packages] Build & test on OS X * [jvm-packages] Re-applied the CMake build changes reverted by #2395 * Fixed Appveyor JVM build * Muted Maven on Travis * Don't link with libawt * "linux2"->"linux" Python2.x and 3.X use slightly different values for ``sys.platform``.
This commit is contained in:
parent
46b9889cc5
commit
2cb51f7097
@ -33,8 +33,6 @@ matrix:
|
|||||||
env: TASK=cmake_test
|
env: TASK=cmake_test
|
||||||
- os: linux
|
- os: linux
|
||||||
env: TASK=r_test
|
env: TASK=r_test
|
||||||
- os: osx
|
|
||||||
env: TASK=java_test
|
|
||||||
- os: osx
|
- os: osx
|
||||||
env: TASK=python_lightweight_test
|
env: TASK=python_lightweight_test
|
||||||
- os: osx
|
- os: osx
|
||||||
|
|||||||
@ -96,8 +96,6 @@ if(MSVC)
|
|||||||
else()
|
else()
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||||
#Prevent shared library being called liblibxgboost.so on Linux
|
|
||||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LINK_LIBRARIES dmlccore rabit)
|
set(LINK_LIBRARIES dmlccore rabit)
|
||||||
@ -137,11 +135,12 @@ endif()
|
|||||||
add_library(objxgboost OBJECT ${SOURCES})
|
add_library(objxgboost OBJECT ${SOURCES})
|
||||||
set_target_properties(${objxgboost} PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
set_target_properties(${objxgboost} PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||||
|
|
||||||
add_library(libxgboost SHARED $<TARGET_OBJECTS:objxgboost> ${CUDA_OBJS})
|
add_executable(runxgboost $<TARGET_OBJECTS:objxgboost> ${CUDA_OBJS})
|
||||||
add_executable(xgboost $<TARGET_OBJECTS:objxgboost> ${CUDA_OBJS})
|
set_target_properties(runxgboost PROPERTIES OUTPUT_NAME xgboost)
|
||||||
|
target_link_libraries(runxgboost ${LINK_LIBRARIES})
|
||||||
|
|
||||||
|
add_library(xgboost SHARED $<TARGET_OBJECTS:objxgboost> ${CUDA_OBJS})
|
||||||
target_link_libraries(xgboost ${LINK_LIBRARIES})
|
target_link_libraries(xgboost ${LINK_LIBRARIES})
|
||||||
target_link_libraries(libxgboost ${LINK_LIBRARIES})
|
|
||||||
|
|
||||||
option(JVM_BINDINGS "Build JVM bindings" OFF)
|
option(JVM_BINDINGS "Build JVM bindings" OFF)
|
||||||
|
|
||||||
@ -150,11 +149,11 @@ if(JVM_BINDINGS)
|
|||||||
|
|
||||||
include_directories(${JNI_INCLUDE_DIRS} jvm-packages/xgboost4j/src/native)
|
include_directories(${JNI_INCLUDE_DIRS} jvm-packages/xgboost4j/src/native)
|
||||||
|
|
||||||
add_library(libxgboost4j SHARED
|
add_library(xgboost4j SHARED
|
||||||
$<TARGET_OBJECTS:objxgboost>
|
$<TARGET_OBJECTS:objxgboost>
|
||||||
${CUDA_OBJS}
|
${CUDA_OBJS}
|
||||||
jvm-packages/xgboost4j/src/native/xgboost4j.cpp)
|
jvm-packages/xgboost4j/src/native/xgboost4j.cpp)
|
||||||
target_link_libraries(libxgboost4j
|
target_link_libraries(xgboost4j
|
||||||
${LINK_LIBRARIES}
|
${LINK_LIBRARIES}
|
||||||
${JNI_LIBRARIES})
|
${JAVA_JVM_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
13
appveyor.yml
13
appveyor.yml
@ -1,7 +1,10 @@
|
|||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- solution_name: C:/projects/xgboost/build2013/xgboost.sln
|
- target: native
|
||||||
- solution_name: C:/projects/xgboost/build2015/xgboost.sln
|
solution_name: C:/projects/xgboost/build2013/xgboost.sln
|
||||||
|
- target: native
|
||||||
|
solution_name: C:/projects/xgboost/build2015/xgboost.sln
|
||||||
|
- target: jvm
|
||||||
platform:
|
platform:
|
||||||
- x64
|
- x64
|
||||||
|
|
||||||
@ -10,6 +13,7 @@ configuration:
|
|||||||
- Release
|
- Release
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- SET PATH=;%PATH%
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
|
|
||||||
before_build:
|
before_build:
|
||||||
@ -19,5 +23,8 @@ before_build:
|
|||||||
- cmake .. -G"Visual Studio 12 2013 Win64"
|
- cmake .. -G"Visual Studio 12 2013 Win64"
|
||||||
- cd ../build2015
|
- cd ../build2015
|
||||||
- cmake .. -G"Visual Studio 14 2015 Win64"
|
- cmake .. -G"Visual Studio 14 2015 Win64"
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- msbuild %solution_name%
|
- cd %APPVEYOR_BUILD_FOLDER%
|
||||||
|
- if "%target%" == "native" msbuild %solution_name%
|
||||||
|
- if "%target%" == "jvm" cd jvm-packages && C:\Python36-x64\python create_jni.py
|
||||||
|
|||||||
@ -6,7 +6,11 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from subprocess import check_output
|
|
||||||
|
|
||||||
|
# Monkey-patch the API inconsistency between Python2.X and 3.X.
|
||||||
|
if sys.platform.startswith("linux"):
|
||||||
|
sys.platform = "linux"
|
||||||
|
|
||||||
|
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
@ -56,14 +60,18 @@ def cp(source, target):
|
|||||||
|
|
||||||
def normpath(path):
|
def normpath(path):
|
||||||
"""Normalize UNIX path to a native path."""
|
"""Normalize UNIX path to a native path."""
|
||||||
return os.path.join(*path.split("/"))
|
normalized = os.path.join(*path.split("/"))
|
||||||
|
if os.path.isabs(path):
|
||||||
|
return os.path.abspath("/") + normalized
|
||||||
|
else:
|
||||||
|
return normalized
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
# Enable of your compiler supports OpenMP.
|
# Enable of your compiler supports OpenMP.
|
||||||
CONFIG["USE_OPENMP"] = "OFF"
|
CONFIG["USE_OPENMP"] = "OFF"
|
||||||
os.environ["JAVA_HOME"] = check_output(
|
os.environ["JAVA_HOME"] = subprocess.check_output(
|
||||||
"/usr/libexec/java_home").strip().decode()
|
"/usr/libexec/java_home").strip().decode()
|
||||||
|
|
||||||
print("building Java wrapper")
|
print("building Java wrapper")
|
||||||
@ -88,7 +96,7 @@ if __name__ == "__main__":
|
|||||||
library_name = {
|
library_name = {
|
||||||
"win32": "xgboost4j.dll",
|
"win32": "xgboost4j.dll",
|
||||||
"darwin": "libxgboost4j.dylib",
|
"darwin": "libxgboost4j.dylib",
|
||||||
"linux2": "libxgboost4j.so"
|
"linux": "libxgboost4j.so"
|
||||||
}[sys.platform]
|
}[sys.platform]
|
||||||
maybe_makedirs("xgboost4j/src/main/resources/lib")
|
maybe_makedirs("xgboost4j/src/main/resources/lib")
|
||||||
cp("../lib/" + library_name, "xgboost4j/src/main/resources/lib")
|
cp("../lib/" + library_name, "xgboost4j/src/main/resources/lib")
|
||||||
|
|||||||
@ -76,7 +76,7 @@ XGB_EXTERN_C int XGBoost4jCallbackDataIterNext(
|
|||||||
batch, jenv->GetFieldID(batchClass, "featureValue", "[F"));
|
batch, jenv->GetFieldID(batchClass, "featureValue", "[F"));
|
||||||
XGBoostBatchCSR cbatch;
|
XGBoostBatchCSR cbatch;
|
||||||
cbatch.size = jenv->GetArrayLength(joffset) - 1;
|
cbatch.size = jenv->GetArrayLength(joffset) - 1;
|
||||||
cbatch.offset = reinterpret_cast<long *>(
|
cbatch.offset = reinterpret_cast<jlong *>(
|
||||||
jenv->GetLongArrayElements(joffset, 0));
|
jenv->GetLongArrayElements(joffset, 0));
|
||||||
if (jlabel != nullptr) {
|
if (jlabel != nullptr) {
|
||||||
cbatch.label = jenv->GetFloatArrayElements(jlabel, 0);
|
cbatch.label = jenv->GetFloatArrayElements(jlabel, 0);
|
||||||
|
|||||||
@ -81,10 +81,9 @@ fi
|
|||||||
|
|
||||||
if [ ${TASK} == "java_test" ]; then
|
if [ ${TASK} == "java_test" ]; then
|
||||||
set -e
|
set -e
|
||||||
make jvm-packages
|
|
||||||
cd jvm-packages
|
cd jvm-packages
|
||||||
mvn clean install -DskipTests=true
|
mvn -q clean install -DskipTests -Dmaven.test.skip
|
||||||
mvn test
|
mvn -q test
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${TASK} == "cmake_test" ]; then
|
if [ ${TASK} == "cmake_test" ]; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user