Skip to content
26 changes: 22 additions & 4 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}" .

# ---------------------------------------------------------
Expand Down
28 changes: 23 additions & 5 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}" .

# ---------------------------------------------------------
Expand Down
33 changes: 26 additions & 7 deletions .github/workflows/win-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
9 changes: 7 additions & 2 deletions include/jres_solver/jres_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading