From 9f3f906ea98a567775561e6eb68ee00e7d1cd23d Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 9 Sep 2023 21:09:06 -0500 Subject: [PATCH] Test passing --- .gitignore | 1 + CMakeLists.txt | 67 ++++++++++++++++++++++++++------------------------ Makefile | 20 ++++++--------- 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index d50d151..e382c7e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ htmlcov /dist/ /lib/ /install/ +/download/ *.so .venv/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 181ad50..f96ec44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,9 @@ elseif(NOT APPLE) endif() add_executable(piper src/cpp/main.cpp src/cpp/piper.cpp) +add_executable(test_piper src/cpp/test.cpp src/cpp/piper.cpp) +# NOTE: external project prefix are shortened because of path length restrictions on Windows # NOTE: onnxruntime is pulled from piper-phonemize # ---- fmt --- @@ -36,6 +38,7 @@ if(NOT DEFINED FMT_DIR) CMAKE_ARGS -DFMT_TEST:BOOL=OFF # Don't build all the tests ) add_dependencies(piper fmt_external) + add_dependencies(test_piper fmt_external) endif() # ---- spdlog --- @@ -50,6 +53,7 @@ if(NOT DEFINED SPDLOG_DIR) CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SPDLOG_DIR} ) add_dependencies(piper spdlog_external) + add_dependencies(test_piper spdlog_external) endif() # ---- piper-phonemize --- @@ -59,10 +63,11 @@ if(NOT DEFINED PIPER_PHONEMIZE_DIR) ExternalProject_Add( piper_phonemize_external PREFIX "${CMAKE_CURRENT_BINARY_DIR}/p" - URL "https://github.com/rhasspy/piper-phonemize/archive/refs/heads/workflow.zip" + URL "https://github.com/rhasspy/piper-phonemize/archive/refs/heads/master.zip" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PIPER_PHONEMIZE_DIR} ) add_dependencies(piper piper_phonemize_external) + add_dependencies(test_piper piper_phonemize_external) endif() # ---- Declare executable ---- @@ -100,38 +105,36 @@ target_include_directories(piper PUBLIC target_compile_definitions(piper PUBLIC _PIPER_VERSION=${piper_version}) # ---- Declare test ---- +include(CTest) +enable_testing() +add_test( + NAME test_piper + COMMAND test_piper "${CMAKE_SOURCE_DIR}/etc/test_voice.onnx" "${PIPER_PHONEMIZE_DIR}/share/espeak-ng-data" "${CMAKE_CURRENT_BINARY_DIR}/test.wav" +) + +target_compile_features(test_piper PUBLIC cxx_std_17) + +target_include_directories( + test_piper PUBLIC + ${FMT_DIR}/include + ${SPDLOG_DIR}/include + ${PIPER_PHONEMIZE_DIR}/include +) + +target_link_directories( + test_piper PUBLIC + ${FMT_DIR}/lib + ${SPDLOG_DIR}/lib + ${PIPER_PHONEMIZE_DIR}/lib +) -# include(CTest) -# enable_testing() -# add_executable(test_piper src/cpp/test.cpp src/cpp/piper.cpp) -# add_test( -# NAME test_piper -# COMMAND test_piper "${CMAKE_SOURCE_DIR}/etc/test_voice.onnx" "${PIPER_PHONEMIZE_DIR}/share/espeak-ng-data" "${CMAKE_CURRENT_BINARY_DIR}/test.wav" - -# ) -# target_compile_features(test_piper PUBLIC cxx_std_17) - -# target_include_directories( -# test_piper PUBLIC -# ${FMT_DIR}/include -# ${SPDLOG_DIR}/include -# ${PIPER_PHONEMIZE_DIR}/include -# ) - -# target_link_directories( -# test_piper PUBLIC -# ${FMT_DIR}/lib -# ${SPDLOG_DIR}/lib -# ${PIPER_PHONEMIZE_DIR}/lib -# ) - -# target_link_libraries(test_piper PUBLIC -# fmt -# spdlog -# espeak-ng -# piper_phonemize -# onnxruntime -# ) +target_link_libraries(test_piper PUBLIC + fmt + spdlog + espeak-ng + piper_phonemize + onnxruntime +) # ---- Declare install targets ---- diff --git a/Makefile b/Makefile index ddde320..2ee7ced 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,10 @@ -.PHONY: piper clean +.PHONY: clean -LIB_DIR := lib/Linux-$(shell uname -m) -VERSION := $(cat VERSION) -DOCKER_PLATFORM ?= linux/amd64,linux/arm64,linux/arm/v7 - -piper: - mkdir -p build - cd build && cmake ../src/cpp -DCMAKE_BUILD_TYPE=Release && make - cp -aR $(LIB_DIR)/piper_phonemize/lib/espeak-ng-data $(LIB_DIR)/piper_phonemize/lib/*.so* $(LIB_DIR)/piper_phonemize/etc/* build/ +all: + cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install + cmake --build build --config Release + cd build && ctest --config Release + cmake --install build clean: - rm -rf build/ dist/ - -docker: - docker buildx build . --platform '$(DOCKER_PLATFORM)' --output 'type=local,dest=dist' + rm -rf build install