Skip to content

Commit

Permalink
Merge pull request #120 from rime/test
Browse files Browse the repository at this point in the history
修改構建腳本:make test 運行測試
  • Loading branch information
lotem authored Jan 12, 2017
2 parents 63f2efb + c8b1e67 commit 9c4fa8a
Show file tree
Hide file tree
Showing 189 changed files with 37 additions and 41 deletions.
15 changes: 5 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -110,7 +110,7 @@ else(X11Keysym)
message(WARNING "X11/keysym.h not found.")
endif(X11Keysym)

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/include)
link_directories(${PROJECT_SOURCE_DIR}/thirdparty/lib)
if(MSVC)
Expand Down Expand Up @@ -157,17 +157,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
${PROJECT_SOURCE_DIR}/rime.pc.in
${PROJECT_BINARY_DIR}/rime.pc
@ONLY)
install(FILES include/rime_api.h DESTINATION include)
install(FILES src/rime_api.h DESTINATION include)
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")

Expand Down
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,26 +16,34 @@ 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:
cmake --build debug-build --target install

uninstall-debug:
cmake --build debug-build --target uninstall

test: release
(cd build/test; ./rime_test)

7 changes: 5 additions & 2 deletions Makefile.xcode
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:
Expand All @@ -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

Expand Down
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ build_script:
- .\build.bat test

after_build:
- 7z a rime.zip build\bin build\lib include thirdparty\data\opencc
- md build\include
- copy /y src\*.h build\include
- 7z a rime.zip build\bin build\lib build\include thirdparty\data\opencc
- dir build /s

before_test:
Expand Down
15 changes: 8 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

aux_source_directory(. LIBRIME_SRC_BASE)
aux_source_directory(algo LIBRIME_SRC_ALGO)
aux_source_directory(dict LIBRIME_SRC_DICT)
aux_source_directory(gear LIBRIME_SRC_GEAR)
aux_source_directory(lever LIBRIME_SRC_LEVER)
aux_source_directory(. LIBRIME_SRC_API)
aux_source_directory(rime LIBRIME_SRC_BASE)
aux_source_directory(rime/algo LIBRIME_SRC_ALGO)
aux_source_directory(rime/dict LIBRIME_SRC_DICT)
aux_source_directory(rime/gear LIBRIME_SRC_GEAR)
aux_source_directory(rime/lever LIBRIME_SRC_LEVER)

if(BUILD_SEPARATE_LIBS)
set(LIBRIME_SRC ${LIBRIME_SRC_BASE})
set(LIBRIME_SRC ${LIBRIME_SRC_API} ${LIBRIME_SRC_BASE})
set(LIBRIME_GEARS_SRC ${LIBRIME_SRC_ALGO} ${LIBRIME_SRC_DICT} ${LIBRIME_SRC_GEAR} ${LIBRIME_SRC_LEVER})
else(BUILD_SEPARATE_LIBS)
set(LIBRIME_SRC ${LIBRIME_SRC_BASE} ${LIBRIME_SRC_ALGO} ${LIBRIME_SRC_DICT} ${LIBRIME_SRC_GEAR} ${LIBRIME_SRC_LEVER})
set(LIBRIME_SRC ${LIBRIME_SRC_API} ${LIBRIME_SRC_BASE} ${LIBRIME_SRC_ALGO} ${LIBRIME_SRC_DICT} ${LIBRIME_SRC_GEAR} ${LIBRIME_SRC_LEVER})
endif(BUILD_SEPARATE_LIBS)

set(RIME_OPTIONAL_DEPS "")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 2 additions & 8 deletions travis-script.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9c4fa8a

Please sign in to comment.