Skip to content

Commit

Permalink
Refactor build scripts and package paths
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Sep 24, 2024
1 parent 8173445 commit 7c6fe52
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,37 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Run Build Script Windows
if: matrix.os == 'windows-latest'
working-directory: ${{runner.workspace}}
run: ./scripts/build-windows.ps1
working-directory: ${{runner.workspace}}/locaal-sdk
run: ./scripts/build-windows.ps1 -Clean
shell: pwsh

- name: Run Build Script Linux and MacOS
if: matrix.os != 'windows-latest'
working-directory: ${{runner.workspace}}
run: ./scripts/build-nix.sh
working-directory: ${{runner.workspace}}/locaal-sdk
run: ./scripts/build-nix.sh --clean
shell: bash

- name: Package
working-directory: ${{runner.workspace}}/build
- name: Package Windows
if: matrix.os == 'windows-latest'
working-directory: ${{runner.workspace}}/locaal-sdk
run: |
cmake --install ./build_x64 --prefix installed
7z a ${{ matrix.os }}-package.zip ./installed/*
- name: Package Linux and MacOS
if: matrix.os == 'windows-latest'
working-directory: ${{runner.workspace}}/locaal-sdk
run: |
cmake --install . --prefix installed
cmake --install ./build --prefix installed
7z a ${{ matrix.os }}-package.zip ./installed/*
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-package
path: ${{runner.workspace}}/build/${{ matrix.os }}-package.zip
path: ${{runner.workspace}}/locaal-sdk/${{ matrix.os }}-package.zip

release:
needs: build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# CMake build directory
build/
build_x64/
installed/

# CMake generated files
CMakeCache.txt
Expand Down
2 changes: 1 addition & 1 deletion cmake/BuildICU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if(WIN32)
PATHS ${ICU_BINARY_DIR}
NO_DEFAULT_PATH)
# Copy the DLLs to the output directory
install(FILES ${ICU_DLL_${lib}} DESTINATION "obs-plugins/64bit")
install(FILES ${ICU_DLL_${lib}} DESTINATION "bin")
# add the library
add_library(ICU::${lib} SHARED IMPORTED GLOBAL)
set_target_properties(ICU::${lib} PROPERTIES IMPORTED_LOCATION "${ICU_LIB_${lib}}" IMPORTED_IMPLIB
Expand Down
7 changes: 4 additions & 3 deletions cmake/BuildSentencepiece.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# build sentencepiece from "https://github.com/google/sentencepiece.git"

set(SENTENCEPIECE_INSTALL_LIB_LOCATION lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})

if(APPLE)

include(FetchContent)
Expand Down Expand Up @@ -28,15 +30,14 @@ elseif(WIN32)
$<BUILD_INTERFACE:${sentencepiece_fetch_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

else()

set(SP_URL
"https://github.com/google/sentencepiece.git"
CACHE STRING "URL of sentencepiece repository")

set(SP_CMAKE_OPTIONS -DSPM_ENABLE_SHARED=OFF)
set(SENTENCEPIECE_INSTALL_LIB_LOCATION lib/${CMAKE_STATIC_LIBRARY_PREFIX}sentencepiece${CMAKE_STATIC_LIBRARY_SUFFIX})

include(ExternalProject)

Expand Down Expand Up @@ -67,4 +68,4 @@ endif()
# add exported target install
install(TARGETS sentencepiece EXPORT sentencepiece-targets)
install(EXPORT sentencepiece-targets NAMESPACE sentencepiece:: DESTINATION lib/cmake/sentencepiece)
install(FILES ${sentencepiece_fetch_SOURCE_DIR}/lib/libsentencepiece.a DESTINATION "bin")
install(FILES ${sentencepiece_fetch_SOURCE_DIR}/${SENTENCEPIECE_INSTALL_LIB_LOCATION} DESTINATION "bin")
8 changes: 5 additions & 3 deletions cmake/BuildWhispercpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ elseif(WIN32)

# glob all dlls in the bin directory and install them
file(GLOB WHISPER_DLLS ${whispercpp_fetch_SOURCE_DIR}/bin/*.dll)
install(FILES ${WHISPER_DLLS} DESTINATION "obs-plugins/64bit")
install(FILES ${WHISPER_DLLS} DESTINATION "bin")
else()
if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
set(Whispercpp_BUILD_TYPE Release)
Expand Down Expand Up @@ -156,5 +156,7 @@ install(FILES ${whispercpp_fetch_SOURCE_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}w
DESTINATION "bin")
install(FILES ${whispercpp_fetch_SOURCE_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}ggml${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION "bin")
install(FILES ${whispercpp_fetch_SOURCE_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}whisper.coreml${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION "bin")
if(APPLE)
install(FILES ${whispercpp_fetch_SOURCE_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}whisper.coreml${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION "bin")
endif(APPLE)
6 changes: 3 additions & 3 deletions cmake/FetchOnnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ if(APPLE)
${CMAKE_INSTALL_NAME_TOOL} -change "@rpath/libonnxruntime.${Onnxruntime_VERSION}.dylib"
"@loader_path/../Frameworks/libonnxruntime.${Onnxruntime_VERSION}.dylib" $<TARGET_FILE:${CMAKE_PROJECT_NAME}>)
elseif(MSVC)

set(Onnxruntime_LIB_NAMES onnxruntime;onnxruntime_providers_shared)
foreach(lib_name IN LISTS Onnxruntime_LIB_NAMES)
add_library(Ort::${lib_name} SHARED IMPORTED)
set_target_properties(Ort::${lib_name} PROPERTIES IMPORTED_IMPLIB ${onnxruntime_SOURCE_DIR}/lib/${lib_name}.lib)
set_target_properties(Ort::${lib_name} PROPERTIES IMPORTED_LOCATION ${onnxruntime_SOURCE_DIR}/lib/${lib_name}.dll)
set_target_properties(Ort::${lib_name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${onnxruntime_SOURCE_DIR}/include)
target_link_libraries(Ort INTERFACE Ort::${lib_name})
install(FILES ${onnxruntime_SOURCE_DIR}/lib/${lib_name}.dll DESTINATION "obs-plugins/64bit")
install(FILES ${onnxruntime_SOURCE_DIR}/lib/${lib_name}.dll DESTINATION "bin")
endforeach()

# add exported target install
Expand All @@ -98,7 +98,7 @@ else()
set(Onnxruntime_INSTALL_LIBS ${Onnxruntime_LINK_LIBS}
"${onnxruntime_SOURCE_DIR}/lib/libonnxruntime_providers_shared.so")
endif()
install(FILES ${Onnxruntime_INSTALL_LIBS} DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins/${CMAKE_PROJECT_NAME}")
install(FILES ${Onnxruntime_INSTALL_LIBS} DESTINATION "bin")

target_link_libraries(Ort INTERFACE ${Onnxruntime_LINK_LIBS})
target_include_directories(Ort INTERFACE "${onnxruntime_SOURCE_DIR}/include")
Expand Down

0 comments on commit 7c6fe52

Please sign in to comment.