From ea8cc49181148cce8752881b1e25b942f99d6794 Mon Sep 17 00:00:00 2001 From: koolkdev Date: Mon, 10 Jan 2022 21:08:24 +0200 Subject: [PATCH] workflow: Static build and upload artifact (#1) --- .github/workflows/build.yml | 47 +++++++++++++++++++++++--------- CMakePresets.json | 26 ++++++++++++++---- README.md | 2 +- wfs-extract/CMakeLists.txt | 2 +- wfs-file-injector/CMakeLists.txt | 2 +- wfs-fuse/CMakeLists.txt | 3 ++ wfslib | 2 +- 7 files changed, 62 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6936017..2e3843b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,19 @@ jobs: strategy: matrix: platform: [ubuntu-latest, windows-latest] # macos-latest + include: + - platform: ubuntu-latest + configure_preset: 'static' + build_preset: 'static-release' + release_name: 'linux-x86-64' + cc: 'gcc-11' + cxx: 'g++-11' + + - platform: windows-latest + configure_preset: 'windows-static' + build_preset: 'windows-static-release' + release_name: 'windows-x64' + runs-on: ${{matrix.platform}} steps: @@ -18,27 +31,35 @@ jobs: - name: Run vcpkg uses: lukka/run-vcpkg@v10 + with: + vcpkgJsonGlob: 'vcpkg.json' - - name: Update gcc - run: | - sudo apt update - sudo apt install gcc-11 g++-11 - echo "CC=gcc-11" >> $GITHUB_ENV - echo "CXX=g++-11" >> $GITHUB_ENV - shell: bash + - name: Install requirements + run: sudo apt install gcc-11 g++-11 if: matrix.platform == 'ubuntu-latest' - - name: Set clang + - name: Set compiler run: | - echo "CC=/usr/local/opt/llvm/bin/clang" >> $GITHUB_ENV - echo "CXX=/usr/local/opt/llvm/bin/clang++" >> $GITHUB_ENV + echo "CC=${{matrix.cc}}" >> $GITHUB_ENV + echo "CXX=${{matrix.cxx}}" >> $GITHUB_ENV shell: bash - if: matrix.platform == 'macos-latest' + if: matrix.cc != '' - name: Run cmake uses: lukka/run-cmake@v10 with: - configurePreset: 'default' - buildPreset: 'release' + configurePreset: ${{matrix.configure_preset}} + buildPreset: ${{matrix.build_preset}} + - name: Upload wfs-extract + uses: actions/upload-artifact@v2 + with: + name: wfs-extract-${{matrix.release_name}} + path: build/${{matrix.configure_preset}}/wfs-extract/Release + + - name: Upload wfs-file-injector + uses: actions/upload-artifact@v2 + with: + name: wfs-file-injector-${{matrix.release_name}} + path: build/${{matrix.configure_preset}}/wfs-file-injector/Release diff --git a/CMakePresets.json b/CMakePresets.json index db91025..6afd2ee 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -18,15 +18,21 @@ } }, { - "name": "windows-static", + "name": "static", "inherits": [ "default" ], - "generator": "Ninja", "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "$env{VSCMD_ARG_TGT_ARCH}-windows-static", - "CMAKE_BUILD_TYPE": "Release", - "BUILD_STATIC_MSVC": "ON" + "BUILD_STATIC": "ON" + } + }, + { + "name": "windows-static", + "inherits": [ + "static" + ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "$env{Platform}-windows-static" } } ], @@ -40,6 +46,16 @@ "name": "release", "configurePreset": "default", "configuration": "Release" + }, + { + "name": "static-release", + "configurePreset": "static", + "configuration": "Release" + }, + { + "name": "windows-static-release", + "configurePreset": "windows-static", + "configuration": "Release" } ] } diff --git a/README.md b/README.md index 24f6a6f..c5432ef 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ sudo wfs-fuse /dev/sdb /mnt --otp otp.bin --seeprom seeprom.bin -o default_permi ## Build Requirements: -* Visual Studio 2022 / GCC 12+ / LLVM 13+ +* Visual Studio 2022 / GCC 12+ / ~~LLVM 13+~~ * CMake 3.20+ * Ninja diff --git a/wfs-extract/CMakeLists.txt b/wfs-extract/CMakeLists.txt index 5c06ed3..c8de0c7 100644 --- a/wfs-extract/CMakeLists.txt +++ b/wfs-extract/CMakeLists.txt @@ -8,7 +8,7 @@ target_compile_options(${PROJECT_NAME} PRIVATE $<$>:-Wall -Wextra -Wpedantic -Werror> ) -if (BUILD_STATIC_MSVC) +if(BUILD_STATIC AND MSVC) set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() diff --git a/wfs-file-injector/CMakeLists.txt b/wfs-file-injector/CMakeLists.txt index 1db589b..5cabfb8 100644 --- a/wfs-file-injector/CMakeLists.txt +++ b/wfs-file-injector/CMakeLists.txt @@ -8,7 +8,7 @@ target_compile_options(${PROJECT_NAME} PRIVATE $<$>:-Wall -Wextra -Wpedantic -Werror> ) -if (BUILD_STATIC_MSVC) +if(BUILD_STATIC AND MSVC) set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() diff --git a/wfs-fuse/CMakeLists.txt b/wfs-fuse/CMakeLists.txt index f38c367..b6ddd1b 100644 --- a/wfs-fuse/CMakeLists.txt +++ b/wfs-fuse/CMakeLists.txt @@ -16,3 +16,6 @@ target_link_libraries(wfs-fuse PRIVATE wfslib ) + +if +target_link_libraries(myLib -static-libgcc -static-libstdc++) diff --git a/wfslib b/wfslib index 56ad5a2..4b9c413 160000 --- a/wfslib +++ b/wfslib @@ -1 +1 @@ -Subproject commit 56ad5a2af65b1df108236abf4280584fef8a14f2 +Subproject commit 4b9c413a5a4083e24bb6b3955fa9ac989c4a3dd2