diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index a426132..01dc7f4 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -116,7 +116,8 @@ jobs: cmake -B build \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH="${{ env.HIGHS_DIR }}" \ - -DBUILD_SHARED_LIBS=OFF + -DBUILD_SHARED_LIBS=OFF \ + -DJRES_VERSION="${{ inputs.version }}" - name: Build Project run: cmake --build build --config Release @@ -151,10 +152,27 @@ jobs: - name: Set Asset Name run: echo "ASSET_NAME=jres-solver-${{ env.SAFE_VERSION }}-${{ env.SAFE_PLATFORM }}-${{ env.SAFE_ARCH }}.${{ inputs.asset_ext }}" >> $GITHUB_ENV - - name: Package (tar.gz) + - name: Package (Curated Selection) run: | - # Archive the entire 'dist' folder content (bin, include, lib) - cd dist + mkdir -p package/bin + mkdir -p package/lib + mkdir -p package/include/jres_solver + + echo "Packaging Binary Artifacts..." + + # Executables + cp dist/bin/jres_solver package/bin/ + cp dist/bin/jres_formatter package/bin/ + + # Library (Grab .a or .so depending on build, likely .a) + # Using find/cp with wildcard to be robust against lib vs lib64 differences + find dist -name "libjres_solver.*" -exec cp {} package/lib/ \; + + # Specific Header + cp dist/include/jres_solver/jres_solver.hpp package/include/jres_solver/ + + # Archive the 'package' folder content + cd package tar -czvf "../${{ env.ASSET_NAME }}" . # --------------------------------------------------------- diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index 3f8c83c..80cf5e0 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -92,7 +92,8 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH="${{ env.HIGHS_DIR }}" \ -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/dist" \ - -DBUILD_SHARED_LIBS=OFF + -DBUILD_SHARED_LIBS=OFF \ + -DJRES_VERSION="${{ inputs.version }}" - name: Build Project run: cmake --build build --config Release @@ -130,15 +131,32 @@ jobs: - name: Ad-hoc Sign Binary (macOS) if: startsWith(inputs.os, 'macos') run: | - # Sign staged binaries in the /dist folder + # Sign staged binaries in the /dist folder before packaging codesign --force --deep -s - dist/bin/jres_solver codesign --force --deep -s - dist/bin/jres_formatter # No need to sign .a static libs - - name: Package (tar.gz) + - name: Package (Curated Selection) run: | - # Archive the entire 'dist' folder content (bin, include, lib) - cd dist + mkdir -p package/bin + mkdir -p package/lib + mkdir -p package/include/jres_solver + + echo "Packaging Binary Artifacts..." + + # Executables + cp dist/bin/jres_solver package/bin/ + cp dist/bin/jres_formatter package/bin/ + + # Library (Grab .dylib or .a) + # Using find/cp with wildcard to be robust + find dist -name "libjres_solver.*" -exec cp {} package/lib/ \; + + # Specific Header + cp dist/include/jres_solver/jres_solver.hpp package/include/jres_solver/ + + # Archive the 'package' folder content + cd package tar -czvf "../${{ env.ASSET_NAME }}" . # --------------------------------------------------------- diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index e8d9b17..de46d4d 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -62,7 +62,9 @@ jobs: -G "Visual Studio 17 2022" ` -DCMAKE_BUILD_TYPE=Release ` -DCMAKE_PREFIX_PATH="$env:HIGHS_DIR" ` - -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}\dist" + -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}\dist" ` + -DBUILD_SHARED_LIBS=OFF ` + -DJRES_VERSION="${{ inputs.version }}" - name: Add Build Dir to PATH shell: pwsh @@ -106,15 +108,32 @@ jobs: $assetName = "jres-solver-${{ env.SAFE_VERSION }}-windows-${{ env.SAFE_ARCH }}.zip" echo "ASSET_NAME=$assetName" >> $env:GITHUB_ENV - - name: Create Release Zip + - name: Package (Curated Selection) shell: pwsh run: | - $assetPath = "$env:ASSET_NAME" - $source = "${{ github.workspace }}\dist" - Write-Host "Zipping staged artifacts from $source..." + $pkg = "package" + New-Item -ItemType Directory -Path "$pkg\bin" -Force | Out-Null + New-Item -ItemType Directory -Path "$pkg\lib" -Force | Out-Null + New-Item -ItemType Directory -Path "$pkg\include\jres_solver" -Force | Out-Null + + Write-Host "Packaging Binary Artifacts..." + + # Executables + Copy-Item "dist\bin\jres_solver.exe" -Destination "$pkg\bin\" + Copy-Item "dist\bin\jres_formatter.exe" -Destination "$pkg\bin\" - # Compress the whole 'dist' folder structure (bin, lib, include) - Get-ChildItem $source -Recurse | Compress-Archive -DestinationPath $assetPath + # Library (static) + if (Test-Path "dist\lib\jres_solver.lib") { + Copy-Item "dist\lib\jres_solver.lib" -Destination "$pkg\lib\" + } + + # Specific Header + Copy-Item "dist\include\jres_solver\jres_solver.hpp" -Destination "$pkg\include\jres_solver\" + + # Zip the package folder + $assetPath = "$env:ASSET_NAME" + Write-Host "Zipping curated package to $assetPath..." + Get-ChildItem -Path $pkg | Compress-Archive -DestinationPath $assetPath # --------------------------------------------------------- # Generate Signature (Checksum) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab5f591..bd0fdf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,9 +166,11 @@ set_target_properties(jres_solver_lib PROPERTIES OUTPUT_NAME "jres_solver") if(WIN32) target_sources(jres_solver_lib PRIVATE ${VERSION_RC}) - # Only export symbols if we are actually building shared + if(BUILD_SHARED_LIBS) target_compile_definitions(jres_solver_lib PRIVATE JRES_SOLVER_EXPORTS) + else() + target_compile_definitions(jres_solver_lib PUBLIC JRES_STATIC) endif() endif() diff --git a/include/jres_solver/jres_solver.hpp b/include/jres_solver/jres_solver.hpp index b3bd946..8b329e0 100644 --- a/include/jres_solver/jres_solver.hpp +++ b/include/jres_solver/jres_solver.hpp @@ -13,10 +13,15 @@ #define JRES_SOLVER_HPP #if defined(_WIN32) - // Windows/MSVC: Use __declspec(dllexport/dllimport) - #ifdef JRES_SOLVER_EXPORTS + // Windows/MSVC: Handle DLL exports, imports, AND static builds + #if defined(JRES_STATIC) + // Static build: No special attributes needed + #define JRES_SOLVER_API + #elif defined(JRES_SOLVER_EXPORTS) + // Building the DLL: Export symbols #define JRES_SOLVER_API __declspec(dllexport) #else + // Using the DLL: Import symbols #define JRES_SOLVER_API __declspec(dllimport) #endif #else