diff --git a/.gitignore b/.gitignore index 44a215435..73ae6748e 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,4 @@ java/xgboost4j-demo/data/ java/xgboost4j-demo/tmp/ java/xgboost4j-demo/model/ nb-configuration* +dmlc-core diff --git a/.travis.yml b/.travis.yml index 8eca7c0ad..1a82699f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,36 +1,45 @@ -language: c - -env: - global: - - _R_CHECK_TIMINGS_=0 - - R_BUILD_ARGS="--no-build-vignettes --no-manual" - - R_CHECK_ARGS="--no-vignettes --no-manual" - -warnings_are_errors: false - sudo: true +# Use Build Matrix to do lint and build seperately +env: + matrix: + - TASK=lint LINT_LANG=cpp + - TASK=lint LINT_LANG=python + - TASK="R-package" + - TASK="python-package" + - TASK=build CXX=g++ + - TASK=build-with-dmlc CXX=g++ + +# dependent apt packages +addons: + apt: + packages: + - doxygen + - libopenmpi-dev + - wget + - libcurl4-openssl-dev + - unzip + - python-numpy + - python-nose + before_install: - - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh - - chmod 755 ./travis-tool.sh - - ./travis-tool.sh bootstrap + - git clone https://github.com/dmlc/dmlc-core + - export TRAVIS=dmlc-core/scripts/travis/ + - export PYTHONPATH=${PYTHONPATH}:${PWD}/wrapper + - source ${TRAVIS}/travis_setup_env.sh install: - - make Rpack - - cd ./xgboost - - ../travis-tool.sh install_deps + - pip install cpplint pylint --user `whoami` -script: - - bash ../travis-tool.sh run_tests +script: scripts/travis_script.sh + + +after_failure: + - scripts/travis_after_failure.sh -after_failure: cat /home/travis/build/dmlc/xgboost/R-package/xgboost.Rcheck/00install.out - notifications: - email: - recipients: - - hetong007@gmail.com - - tqchen@cs.washington.edu - on_success: change - on_failure: always + email: + on_success: change + on_failure: always diff --git a/Makefile b/Makefile index 295de4064..7d2ff5273 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ export CC = gcc export CXX = g++ export MPICXX = mpicxx -export LDFLAGS= -pthread -lm +export LDFLAGS= -pthread -lm export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops # java include path export JAVAINCFLAGS = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -I./java @@ -12,8 +12,8 @@ ifeq ($(OS), Windows_NT) endif ifeq ($(no_omp),1) - CFLAGS += -DDISABLE_OPENMP -else + CFLAGS += -DDISABLE_OPENMP +else CFLAGS += -fopenmp endif @@ -29,7 +29,7 @@ ifdef dmlc config = $(dmlc)/config.mk else config = $(dmlc)/make/config.mk - endif + endif endif include $(config) include $(dmlc)/make/dmlc.mk @@ -43,7 +43,7 @@ ifndef WITH_FPIC WITH_FPIC = 1 endif ifeq ($(WITH_FPIC), 1) - CFLAGS += -fPIC + CFLAGS += -fPIC endif @@ -69,7 +69,7 @@ else TARGET = $(BIN) endif -.PHONY: clean all mpi python Rpack +.PHONY: clean all mpi python Rpack lint all: $(TARGET) mpi: $(MPIBIN) @@ -78,9 +78,9 @@ python: wrapper/libxgboostwrapper.so # now the wrapper takes in two files. io and wrapper part updater.o: src/tree/updater.cpp src/tree/*.hpp src/*.h src/tree/*.h src/utils/*.h dmlc_simple.o: src/io/dmlc_simple.cpp src/utils/*.h -gbm.o: src/gbm/gbm.cpp src/gbm/*.hpp src/gbm/*.h +gbm.o: src/gbm/gbm.cpp src/gbm/*.hpp src/gbm/*.h io.o: src/io/io.cpp src/io/*.hpp src/utils/*.h src/learner/dmatrix.h src/*.h -main.o: src/xgboost_main.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h +main.o: src/xgboost_main.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h xgboost: updater.o gbm.o io.o main.o $(LIBRABIT) $(LIBDMLC) wrapper/xgboost_wrapper.dll wrapper/libxgboostwrapper.so: wrapper/xgboost_wrapper.cpp src/utils/*.h src/*.h src/learner/*.hpp src/learner/*.h updater.o gbm.o io.o $(LIBRABIT) $(LIBDMLC) @@ -97,11 +97,11 @@ subtree/rabit/lib/librabit_mock.a: subtree/rabit/src/engine_mock.cc subtree/rabit/lib/librabit_mpi.a: subtree/rabit/src/engine_mpi.cc + cd subtree/rabit;make lib/librabit_mpi.a; cd ../.. -$(BIN) : - $(CXX) $(CFLAGS) -fPIC -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS) +$(BIN) : + $(CXX) $(CFLAGS) -fPIC -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS) -$(MOCKBIN) : - $(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS) +$(MOCKBIN) : + $(CXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS) $(SLIB) : $(CXX) $(CFLAGS) -fPIC -shared -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS) $(DLLFLAGS) @@ -109,13 +109,13 @@ $(SLIB) : $(JLIB) : $(CXX) $(CFLAGS) -fPIC -shared -o $@ $(filter %.cpp %.o %.c %.a %.cc, $^) $(LDFLAGS) $(JAVAINCFLAGS) -$(OBJ) : +$(OBJ) : $(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) ) -$(MPIOBJ) : - $(MPICXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) ) +$(MPIOBJ) : + $(MPICXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c, $^) ) -$(MPIBIN) : +$(MPIBIN) : $(MPICXX) $(CFLAGS) -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS) install: @@ -157,6 +157,10 @@ Rcheck: make Rbuild R CMD check --as-cran xgboost*.tar.gz +# lint requires dmlc to be in current folder +lint: + dmlc-core/scripts/lint.py xgboost $(LINT_LANG) src wrapper R-package + clean: $(RM) -rf $(OBJ) $(BIN) $(MPIBIN) $(MPIOBJ) $(SLIB) *.o */*.o */*/*.o *~ */*~ */*/*~ cd subtree/rabit; make clean; cd .. diff --git a/scripts/travis_R_script.sh b/scripts/travis_R_script.sh new file mode 100755 index 000000000..5a9ea7528 --- /dev/null +++ b/scripts/travis_R_script.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Test R package of xgboost +set -e +export _R_CHECK_TIMINGS_=0 +export R_BUILD_ARGS="--no-build-vignettes --no-manual" +export R_CHECK_ARGS="--no-vignettes --no-manual" + +curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh +chmod 755 ./travis-tool.sh +./travis-tool.sh bootstrap +make Rpack +cd ./xgboost +../travis-tool.sh install_deps +../travis-tool.sh run_tests \ No newline at end of file diff --git a/scripts/travis_after_failure.sh b/scripts/travis_after_failure.sh new file mode 100755 index 000000000..230f3348c --- /dev/null +++ b/scripts/travis_after_failure.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ ${TASK} == "R-package" ]; then + cat R-package/xgboost.Rcheck/00install.out +fi \ No newline at end of file diff --git a/scripts/travis_scripts.sh b/scripts/travis_scripts.sh new file mode 100755 index 000000000..b90f8d3ee --- /dev/null +++ b/scripts/travis_scripts.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# main script of travis +if [ ${TASK} == "lint" ]; then + make lint || exit -1 +fi + +if [ ${TASK} == "build" ]; then + make all CXX=${CXX} || exit -1 +fi + +if [ ${TASK} == "build-with-dmlc" ]; then + cd dmlc-core + cp make/config.mk . + echo "USE_S3=1" >> config.mk + make all CXX=${CXX}|| exit -1 + cd .. + make dmlc=dmlc-core CXX=${CXX} || exit -1 +fi + +if [ ${TASK} == "R-package" ]; then + scripts/travis_R_script.sh || exit -1 +fi + +if [ ${TASK} == "python-package" ]; then + make all CXX=${CXX} || exit -1 + nosetests tests/python || exit -1 +fi