From 55f8ff4eb5d02e35286e44025096113b008a6a2f Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Wed, 11 Jan 2017 23:58:33 +0800 Subject: [PATCH] chore(Makefile): make test; build `rime_test` in release configuration --- CMakeLists.txt | 11 +++-------- Makefile | 27 ++++++++++++++------------- Makefile.xcode | 7 +++++-- travis-script.sh | 10 ++-------- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02c795a417..1650426845 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ add_definitions(-DRIME_VERSION="${LIBRIME_VERSION}") option(BUILD_SHARED_LIBS "Build Rime as shared library" ON) option(BUILD_STATIC "Build with dependencies as static libraries" OFF) option(BUILD_DATA "Build data for Rime" OFF) -option(BUILD_TEST "Build and run tests" OFF) +option(BUILD_TEST "Build and run tests" ON) option(BUILD_SEPARATE_LIBS "Build a separate rime-gears library" OFF) option(ENABLE_LOGGING "Enable logging with google-glog library" ON) option(BOOST_USE_CXX11 "Boost has been built with C++11 support" OFF) @@ -161,13 +161,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") install(FILES ${PROJECT_BINARY_DIR}/rime.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) install(FILES cmake/RimeConfig.cmake DESTINATION share/cmake/rime) if(BUILD_DATA) - install(FILES ${PROJECT_SOURCE_DIR}/data/default.yaml DESTINATION ${pkgdatadir}) - install(FILES ${PROJECT_SOURCE_DIR}/data/symbols.yaml DESTINATION ${pkgdatadir}) - install(FILES ${PROJECT_SOURCE_DIR}/data/essay.txt DESTINATION ${pkgdatadir}) - file(GLOB preset_schema ${PROJECT_SOURCE_DIR}/data/preset/*.yaml) - install(FILES ${preset_schema} DESTINATION ${pkgdatadir}) - file(GLOB supplement_schema ${PROJECT_SOURCE_DIR}/data/supplement/*.yaml) - install(FILES ${supplement_schema} DESTINATION ${pkgdatadir}) + file(GLOB preset_data_files ${PROJECT_SOURCE_DIR}/data/preset/*.yaml) + install(FILES ${preset_data_files} DESTINATION ${pkgdatadir}) endif(BUILD_DATA) endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/Makefile b/Makefile index 782254c1f0..407292b931 100644 --- a/Makefile +++ b/Makefile @@ -3,16 +3,9 @@ RIME_ROOT = $(CURDIR) sharedir = $(DESTDIR)/usr/share bindir = $(DESTDIR)/usr/bin -.PHONY: all install uninstall thirdparty clean librime-static librime debug +.PHONY: all thirdparty clean librime librime-static install-librime uninstall-librime release install uninstall debug install-debug uninstall-debug test -all: librime - @echo ':)' - -install: install-librime - @echo ':)' - -uninstall: uninstall-librime - @echo ':)' +all: release thirdparty: make -f Makefile.thirdparty @@ -23,22 +16,26 @@ thirdparty/%: clean: rm -Rf build build-static debug-build +librime: release +install-librime: install +uninstall-librime: uninstall + librime-static: cmake . -Bbuild-static -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC=ON -DBUILD_SHARED_LIBS=OFF cmake --build build-static -librime: +release: cmake . -Bbuild -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release cmake --build build -install-librime: +install: cmake --build build --target install -uninstall-librime: +uninstall: cmake --build build --target uninstall debug: - cmake . -Bdebug-build -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DBUILD_TEST=ON + cmake . -Bdebug-build -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug cmake --build debug-build install-debug: @@ -46,3 +43,7 @@ install-debug: uninstall-debug: cmake --build debug-build --target uninstall + +test: release + (cd build/test; ./rime_test) + diff --git a/Makefile.xcode b/Makefile.xcode index 6905bc97bf..e33f9d52af 100644 --- a/Makefile.xcode +++ b/Makefile.xcode @@ -1,7 +1,7 @@ RIME_ROOT = $(CURDIR) RIME_COMPILER_OPTIONS = CC=clang CXX=clang++ CXXFLAGS="-stdlib=libc++" LDFLAGS="-stdlib=libc++" -.PHONY: all release debug clean thirdparty +.PHONY: all release debug clean test thirdparty all: release @@ -10,7 +10,7 @@ release: cmake --build xbuild --config Release | grep -v setenv | tee build.log debug: - cmake . -Bxdebug -GXcode -DBUILD_STATIC=ON -DBUILD_TEST=ON -DBUILD_SEPARATE_LIBS=ON + cmake . -Bxdebug -GXcode -DBUILD_STATIC=ON -DBUILD_SEPARATE_LIBS=ON cmake --build xdebug --config Debug | grep -v setenv | tee build.log clean: @@ -20,6 +20,9 @@ clean: rm -f thirdparty/lib/* > /dev/null 2>&1 || true make -f Makefile.thirdparty clean-src +test: release + (cd xbuild/test; LD_LIBRARY_PATH=../lib/Release Release/rime_test) + thirdparty: $(RIME_COMPILER_OPTIONS) make -f Makefile.thirdparty diff --git a/travis-script.sh b/travis-script.sh index 7e6f9068e0..25a75441f2 100755 --- a/travis-script.sh +++ b/travis-script.sh @@ -1,13 +1,7 @@ #!/bin/bash if [[ "$TRAVIS_OS_NAME" == linux ]]; then - make debug - pushd debug-build/test - ./rime_test - popd + make test elif [[ "$TRAVIS_OS_NAME" == osx ]]; then - make -f Makefile.xcode debug - pushd xdebug/test - ./Debug/rime_test - popd + make -f Makefile.xcode test fi