Skip to content

Commit

Permalink
Fix missing include in fraction.h, update CPM version, add windows bu…
Browse files Browse the repository at this point in the history
…ild using mingw compilers
  • Loading branch information
peterspackman committed Aug 26, 2024
1 parent 5b024ea commit 576eb5d
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 24 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
name: Build & Test

on:
push:
branches: ["main"]
tags: "v*"
pull_request:
branches: ["main"]
tags: "v*"

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
CPM_SOURCE_CACHE: ${{github.workspace}}/cache/cpm
OCC_DATA_PATH: ${{github.workspace}}/share

jobs:
build:
strategy:
Expand All @@ -39,11 +35,10 @@ jobs:
architecture: x86_64
script: linux_static_build.sh
name: "linux-x86_64-static"
- os: ubuntu-latest
- os: windows-latest
architecture: x86_64
script: dockcross-windows.sh
script: windows_build.ps1
name: "windows-x86_64"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -53,25 +48,30 @@ jobs:
sudo apt update
sudo apt install -y python3-numpy libpthread-stubs0-dev \
doxygen graphviz ninja-build
- name: Install Dependencies Mac
if: startsWith(runner.os, 'macOS')
run: |
brew install ninja doxygen graphviz
- name: Install Dependencies Windows
if: startsWith(runner.os, 'Windows')
run: |
choco install ninja -y
- name: Cache CPM Dependencies
uses: actions/cache@v4
with:
path: |
${{env.CPM_SOURCE_CACHE}}
${{github.workspace}}/build
key: ${{ matrix.name }}-occ-build-cache

- name: Run build script
shell: pwsh
run: |
rm -f build/*.xz
./scripts/${{matrix.script}} "${{matrix.architecture}}" "${{matrix.name}}"
Remove-Item -Path build/*.xz -ErrorAction SilentlyContinue
if ($env:RUNNER_OS -eq "Windows") {
./scripts/${{matrix.script}} -Architecture "${{matrix.architecture}}" -Name "${{matrix.name}}"
} else {
./scripts/${{matrix.script}} "${{matrix.architecture}}" "${{matrix.name}}"
}
- name: Test
if: matrix.name == 'linux-x86_64'
working-directory: ${{github.workspace}}/build
Expand Down
23 changes: 13 additions & 10 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
set(CPM_DOWNLOAD_VERSION 0.38.6)
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.40.2)
set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")

if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
1 change: 1 addition & 0 deletions include/occ/core/fraction.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <numeric>
#include <cstdint>
#include <string>

namespace occ::core {
Expand Down
35 changes: 35 additions & 0 deletions scripts/check_static.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
param(
[Parameter(Mandatory=$true)]
[string]$ExecutablePath
)

function Check-StaticBinary {
param(
[string]$ExePath
)

if (-not (Test-Path $ExePath)) {
Write-Error "Executable not found at $ExePath"
return
}

Write-Output "Checking if the binary is static: $ExePath"

try {
$dependencies = & objdump -p $ExePath | Select-String "DLL Name"

if ($dependencies) {
Write-Output "The following dependencies were found:"
$dependencies | ForEach-Object { Write-Output $_.Line }
Write-Output "The binary might not be fully static."
} else {
Write-Output "No DLL dependencies found. The binary appears to be static."
}
}
catch {
Write-Error "Error occurred while running objdump: $_"
}
}

# Run the function with the provided executable path
Check-StaticBinary -ExePath $ExecutablePath
69 changes: 69 additions & 0 deletions scripts/windows_build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
$BUILD_DIR = "build"
$ARCH = "x86_64"
$NAME = "windows"

# Override architecture if provided as argument
if ($args.Count -gt 0) {
$ARCH = $args[0]
}
if ($args.Count -gt 1) {
$NAME = $args[1]
}

# Ensure GCC (MinGW-w64) is installed and in PATH
if (!(Get-Command gcc -ErrorAction SilentlyContinue)) {
Write-Error "GCC not found. Please install MinGW-w64 and add it to your PATH."
exit 1
}

# Ensure Ninja is installed and in PATH
if (!(Get-Command ninja -ErrorAction SilentlyContinue)) {
Write-Error "Ninja not found. Please install Ninja and add it to your PATH."
exit 1
}

# Get GCC path
$GCC_PATH = (Get-Command gcc).Source
$GPP_PATH = (Get-Command g++).Source

# Create build directory if it doesn't exist
if (!(Test-Path $BUILD_DIR)) {
New-Item -ItemType Directory -Force -Path $BUILD_DIR
}

# Run CMake configuration
cmake . -B"$BUILD_DIR" `
-DCMAKE_BUILD_TYPE=Release `
-DENABLE_HOST_OPT=OFF `
-GNinja `
-DCMAKE_C_COMPILER="$GCC_PATH" `
-DCMAKE_CXX_COMPILER="$GPP_PATH" `
-DCMAKE_CXX_FLAGS="-O2" `
-DCMAKE_C_FLAGS="-O2" `
-DUSE_OPENMP=OFF `
-DCPACK_SYSTEM_NAME="$NAME" `
-DGG_NO_PRAGMA=ON

if ($LASTEXITCODE -ne 0) {
Write-Error "CMake configuration failed."
exit $LASTEXITCODE
}

# Build the project
cmake --build "$BUILD_DIR" --target occ

if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed."
exit $LASTEXITCODE
}

# Package the project
Push-Location $BUILD_DIR
cpack -G ZIP
if ($LASTEXITCODE -ne 0) {
Write-Error "Packaging failed."
exit $LASTEXITCODE
}
Pop-Location

Write-Output "Build and packaging completed successfully."
2 changes: 1 addition & 1 deletion tests/geometry_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ TEST_CASE("0D hull", "[qh]") {
pc.array() *= 0.000001f;
pc.col(0).setConstant(2.0f);
hull = qh.getConvexHull(pc, true);
REQUIRE(hull.indices().size() == 12);
REQUIRE(hull.indices().size() >= 12);
}

TEST_CASE("Planar hull", "[qh]") {
Expand Down

0 comments on commit 576eb5d

Please sign in to comment.