From 50feab2a43b15c0c15e4219633cecb0475c20e20 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Tue, 17 Dec 2024 21:28:22 -0800 Subject: [PATCH] Build a release for mac, windows and linux. --- .github/workflows/build.yaml | 141 +++++++++++++++++++++++++++++++++++ CMake/FindFBX.cmake | 33 +++++--- 2 files changed, 162 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..33fb44a --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,141 @@ +name: "Build fbx-udim-unpack" +on: + pull_request: + branches: + - master + push: + branches: + - master + tags: + - "v*" + +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-build + cancel-in-progress: true + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-2022, ubuntu-20.04, macos-14] + include: + - os: windows-2022 + sdk_url: "https://github.com/V-Sekai/FBXSDK-Windows/archive/refs/tags/2020.2.zip" + sdk_license: "sdk/Windows/2020.2/License.rtf" + build_command: | + find sdk -type f -name '*.zst' -exec sh -c 'zstd -d "{}" -o "${0%.zst}"' {} \; + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DFBXSDK_ROOT=sdk + cmake --build build + run_command: ./build/Release/fbx-udim-unpack.exe --help + artifact_name: fbx-udim-unpack-windows-x86_64 + artifact_path: build/Release/fbx-udim-unpack.exe + - os: ubuntu-20.04 + sdk_url: "https://github.com/V-Sekai/FBXSDK-Linux/archive/refs/tags/2020.2.zip" + sdk_license: "sdk/Linux/2020.2/License.txt" + build_command: | + find sdk -type f -name '*.zst' -exec sh -c 'zstd -d "{}" -o "${0%.zst}"' {} \; + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DFBXSDK_ROOT=sdk + cmake --build build + run_command: ./build/fbx-udim-unpack --help + artifact_name: fbx-udim-unpack-linux-x86_64 + artifact_path: build/fbx-udim-unpack + - os: macos-14 + sdk_url: "https://github.com/V-Sekai/FBXSDK-Darwin/archive/refs/tags/2020.2.zip" + sdk_license: "sdk/Darwin/2020.2/License.rtf" + build_command: | + find sdk -type f -name '*.zst' -exec sh -c 'zstd -d "{}" -o "${0%.zst}"' {} \; + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DFBXSDK_ROOT=sdk + cmake --build build + run_command: ./build/fbx-udim-unpack --help + artifact_name: fbx-udim-unpack-macos-x86_64 + artifact_path: build/fbx-udim-unpack + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Ninja + run: | + if [[ $RUNNER_OS == "Windows" ]]; then + choco install ninja + elif [[ $RUNNER_OS == "Linux" ]]; then + sudo apt-get install ninja-build + else + brew install ninja + fi + shell: bash + + - name: Install 7z + run: | + if [[ $RUNNER_OS == "Windows" ]]; then + choco install 7zip + elif [[ $RUNNER_OS == "Linux" ]]; then + sudo apt-get install p7zip-full + else + brew install p7zip + fi + shell: bash + + - name: Setup filter.lfs.required + run: | + git config --global filter.lfs.required false + shell: bash + + - name: Setup filter.lfs.smudge + run: | + git config --global filter.lfs.smudge "git-lfs smudge --skip %f" + shell: bash + + - name: Setup filter.lfs.process + run: | + git config --global filter.lfs.process "git-lfs filter-process --skip" + shell: bash + + - name: Fetch sdk + run: | + curl -O -L "${{ matrix.sdk_url }}" + shell: bash + + - name: Install 7z extract + run: | + 7z x 2020.2.zip + shell: bash + + - name: Extract and move SDK + run: | + mkdir -p sdk + 7z x 2020.2.zip -osdk + mv sdk/*/* sdk/ + shell: bash + + - name: CMake configure and build + run: ${{ matrix.build_command }} + shell: bash + + - name: Run fbx-udim-unpack help + run: ${{ matrix.run_command }} + shell: bash + + - name: Prepare artifacts + run: | + export TARGET=${{ matrix.artifact_name }} + mkdir $TARGET + cp ${{ matrix.sdk_license }} $TARGET/FBX-SDK-License.txt + cp LICENSE $TARGET/fbx-udim-unpack-License.txt + cp ${{ matrix.artifact_path }} $TARGET/${{ matrix.artifact_name }} + 7z a -r $TARGET.zip $TARGET + shell: bash + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ${{ matrix.artifact_name }}.zip + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact_name }} + path: ${{ matrix.artifact_name }}/* diff --git a/CMake/FindFBX.cmake b/CMake/FindFBX.cmake index 474c584..911120f 100644 --- a/CMake/FindFBX.cmake +++ b/CMake/FindFBX.cmake @@ -10,13 +10,13 @@ # FBXSDK_LIBS # FBXSDK_LIBS_DEBUG # -set(_fbxsdk_version "2020.1.1") +set(_fbxsdk_version "2020.2") set(_fbxsdk_vstudio_version "vs2017") message("Looking for FBX SDK version: ${_fbxsdk_version}") if (APPLE) - set(_fbxsdk_approot "/Applications/Autodesk/FBX SDK") + set(_fbxsdk_approot "${CMAKE_SOURCE_DIR}/sdk") set(_fbxsdk_libdir_debug "lib/clang/debug") set(_fbxsdk_libdir_release "lib/clang/release") set(_fbxsdk_libname_debug "libfbxsdk.a") @@ -28,7 +28,7 @@ if (APPLE) elseif (WIN32) # the $ENV{PROGRAMFILES} variable doesn't really work since there's no # 64-bit cmake version - set(_fbxsdk_approot "C:/Program Files/Autodesk/FBX/FBX SDK") + set(_fbxsdk_approot "${CMAKE_SOURCE_DIR}/sdk") set(_fbxsdk_libdir_debug "lib/${_fbxsdk_vstudio_version}/x64/debug") set(_fbxsdk_libdir_release "lib/${_fbxsdk_vstudio_version}/x64/release") set(_fbxsdk_libname_debug "libfbxsdk-md.lib") @@ -37,8 +37,18 @@ elseif (WIN32) set(_xml2_libname_release "libxml2-md.lib") set(_zlib_libname_debug "zlib-md.lib") set(_zlib_libname_release "zlib-md.lib") +elseif (UNIX) + set(_fbxsdk_approot "${CMAKE_SOURCE_DIR}/sdk") + set(_fbxsdk_libdir_debug "lib/gcc/debug") + set(_fbxsdk_libdir_release "lib/gcc/release") + set(_fbxsdk_libname_debug "libfbxsdk.so") + set(_fbxsdk_libname_release "libfbxsdk.so") + set(_xml2_libname_debug "libxml2.so") + set(_xml2_libname_release "libxml2.so") + set(_zlib_libname_debug "libz.so") + set(_zlib_libname_release "libz.so") else () - message(FATAL_ERROR" FIXME: find FBX SDK on Linux") + message(FATAL_ERROR "FIXME: find FBX SDK on unknown platform") endif() # should point the the FBX SDK installation dir @@ -47,34 +57,33 @@ message("_fbxsdk_root: ${_fbxsdk_root}") # find header dir and libs find_path(FBXSDK_INCLUDE_DIR "fbxsdk.h" - PATHS ${_fbxsdk_root} + PATHS ${_fbxsdk_root} "${CMAKE_SOURCE_DIR}/sdk/include" PATH_SUFFIXES "include") message("FBXSDK_INCLUDE_DIR: ${FBXSDK_INCLUDE_DIR}") find_library(FBXSDK_LIBRARY ${_fbxsdk_libname_release} - PATHS ${_fbxsdk_root} + PATHS ${_fbxsdk_root} "${CMAKE_SOURCE_DIR}/sdk/lib" PATH_SUFFIXES ${_fbxsdk_libdir_release}) message("FBXSDK_LIBRARY: ${FBXSDK_LIBRARY}") find_library(FBXSDK_LIBRARY_DEBUG ${_fbxsdk_libname_debug} - PATHS ${_fbxsdk_root} + PATHS ${_fbxsdk_root} "${CMAKE_SOURCE_DIR}/sdk/lib" PATH_SUFFIXES ${_fbxsdk_libdir_debug}) message("FBXSDK_LIBRARY_DEBUG: ${FBXSDK_LIBRARY_DEBUG}") - find_library(XML2_LIBRARY ${_xml2_libname_release} - PATHS ${_fbxsdk_root} + PATHS ${_fbxsdk_root} "${CMAKE_SOURCE_DIR}/sdk/lib" PATH_SUFFIXES ${_fbxsdk_libdir_release}) message("XML2_LIBRARY: ${XML2_LIBRARY}") find_library(XML2_LIBRARY_DEBUG ${_xml2_libname_debug} - PATHS ${_fbxsdk_root} + PATHS ${_fbxsdk_root} "${CMAKE_SOURCE_DIR}/sdk/lib" PATH_SUFFIXES ${_fbxsdk_libdir_debug}) message("XML2_LIBRARY_DEBUG: ${XML2_LIBRARY_DEBUG}") find_library(ZLIB_LIBRARY ${_zlib_libname_release} - PATHS ${_fbxsdk_root} + PATHS ${_fbxsdk_root} "${CMAKE_SOURCE_DIR}/sdk/lib" PATH_SUFFIXES ${_fbxsdk_libdir_release}) message("ZIB_LIBRARY: ${ZLIB_LIBRARY}") find_library(ZLIB_LIBRARY_DEBUG ${_zlib_libname_debug} - PATHS ${_fbxsdk_root} + PATHS ${_fbxsdk_root} "${CMAKE_SOURCE_DIR}/sdk/lib" PATH_SUFFIXES ${_fbxsdk_libdir_debug}) message("ZLIB_LIBRARY_DEBUG: ${ZLIB_LIBRARY_DEBUG}")