Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/actions/build-config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: 'Build Configuration'
description: 'Build PopSift for a specific configuration (Release/Debug)'

inputs:
build-type:
description: 'Build type (Release or Debug)'
required: true
platform:
description: 'Platform (linux or windows)'
required: true
deps-install-dir:
description: 'Dependencies install directory (Linux only)'
required: false
default: '/opt/'
vcpkg-root:
description: 'vcpkg root directory (Windows only)'
required: false
workspace-dir:
description: 'Workspace directory (Windows only)'
required: false

runs:
using: 'composite'
steps:
# Linux steps
- name: Setup directories (Linux)
if: inputs.platform == 'linux'
shell: bash
run: |
source ./.github/scripts/build-linux.sh
BUILD_TYPE=${{ inputs.build-type }} setup_directories

- name: Configure CMake (Linux)
if: inputs.platform == 'linux'
shell: bash
run: |
source ./.github/scripts/build-linux.sh
configure_cmake "${{ inputs.build-type }}" "${{ inputs.deps-install-dir }}"

- name: Build and Install (Linux)
if: inputs.platform == 'linux'
shell: bash
run: |
source ./.github/scripts/build-linux.sh
build_and_install "${{ inputs.build-type }}"

- name: Build As Third Party (Linux)
if: inputs.platform == 'linux'
shell: bash
run: |
source ./.github/scripts/build-linux.sh
build_as_third_party "${{ inputs.build-type }}" "${{ inputs.deps-install-dir }}"

# Windows steps
- name: Setup directories (Windows)
if: inputs.platform == 'windows'
shell: powershell
run: |
. .\.github\scripts\build-windows.ps1
Setup-Directories -BuildType "${{ inputs.build-type }}"

- name: Configure CMake (Windows)
if: inputs.platform == 'windows'
shell: powershell
run: |
. .\.github\scripts\build-windows.ps1
Configure-CMake -BuildType "${{ inputs.build-type }}" -VcpkgRoot "${{ inputs.vcpkg-root }}" -WorkspaceDir "${{ inputs.workspace-dir }}"

- name: Build and Install (Windows)
if: inputs.platform == 'windows'
shell: powershell
run: |
. .\.github\scripts\build-windows.ps1
Build-AndInstall -BuildType "${{ inputs.build-type }}"

- name: Build As Third Party (Windows)
if: inputs.platform == 'windows'
shell: powershell
run: |
. .\.github\scripts\build-windows.ps1
Build-AsThirdParty -BuildType "${{ inputs.build-type }}" -VcpkgRoot "${{ inputs.vcpkg-root }}" -WorkspaceDir "${{ inputs.workspace-dir }}"
71 changes: 71 additions & 0 deletions .github/scripts/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
# Linux build functions for PopSift
# Usage: source this file and call the individual functions

# Creates the necessary build directories for different build types
# Uses BUILD_TYPE environment variable to create build and install directories
setup_directories() {
echo "Setting up build directories..."
mkdir -p ./build_"${BUILD_TYPE,,}"
mkdir -p ./build_as_3rdparty_"${BUILD_TYPE,,}"
mkdir -p ../popsift_install_"${BUILD_TYPE,,}"
}

# Configures CMake for PopSift build with specified options
# Parameters:
# $1 - build_type: Release or Debug
# $2 - deps_dir: Directory containing pre-installed dependencies (e.g., /opt/)
# Creates a build directory named <build_$build_type> and runs CMake configuration with PopSift-specific options
configure_cmake() {
local build_type="$1"
local deps_dir="$2"
local build_dir="build_${build_type,,}"
local install_dir="../popsift_install_${build_type,,}"

echo "Configuring CMake for $build_type..."
cd "./$build_dir" || exit
cmake .. \
-DCMAKE_BUILD_TYPE="$build_type" \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_PREFIX_PATH="$deps_dir" \
-DPopSift_BUILD_DOCS:BOOL=OFF \
-DCMAKE_INSTALL_PREFIX:PATH="$PWD/$install_dir"
cd ..
}

# Builds and installs PopSift for the specified build type
# Parameters:
# $1 - build_type: Release or Debug
# Uses parallel build with all available CPU cores
build_and_install() {
local build_type="$1"
local build_dir="build_${build_type,,}"

echo "Building and installing $build_type..."
cd "./$build_dir" || exit
cmake --build . --config "$build_type" --parallel
cmake --install . --config "$build_type"
cd ..
}

# Tests building PopSift applications as a third-party consumer
# This verifies that the installed PopSift can be found and used by external projects
# Parameters:
# $1 - build_type: Release or Debug
# $2 - deps_dir: Directory containing pre-installed dependencies
# Builds only the application from src/application using the installed PopSift library
build_as_third_party() {
local build_type="$1"
local deps_dir="$2"
local build_dir="build_as_3rdparty_${build_type,,}"
local install_dir="../popsift_install_${build_type,,}"

echo "Testing third-party build for $build_type..."
cd "./$build_dir" || exit
cmake ../src/application \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_BUILD_TYPE="$build_type" \
-DCMAKE_PREFIX_PATH:PATH="$PWD/$install_dir;$deps_dir"
cmake --build . --config "$build_type" --parallel
cd ..
}
160 changes: 160 additions & 0 deletions .github/scripts/build-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Windows build functions for PopSift
# Usage: source this file and call the individual functions

<#
.SYNOPSIS
Creates the necessary build directories for different build types on Windows.

.DESCRIPTION
Sets up build directories for the main PopSift build and third-party build testing.
Creates directories with lowercase build type names (e.g. build_release) following Windows conventions.

.PARAMETER BuildType
The build configuration (Release or Debug)
#>
function Setup-Directories {
param([string]$BuildType)

Write-Host "Setting up build directories for $BuildType..."
$buildDir = "build_$($BuildType.ToLower())"
$thirdPartyDir = "build_as_3rdparty_$($BuildType.ToLower())"

New-Item -ItemType Directory -Path $buildDir -Force | Out-Null
New-Item -ItemType Directory -Path $thirdPartyDir -Force | Out-Null
}

<#
.SYNOPSIS
Configures CMake for PopSift build on Windows using vcpkg for dependency management.

.DESCRIPTION
Sets up CMake configuration with Visual Studio 2022 generator, enables shared libraries,
and configures PopSift-specific options. Uses vcpkg manifest mode for dependency management.

.PARAMETER BuildType
The build configuration (Release or Debug)

.PARAMETER VcpkgRoot
Path to the vcpkg installation directory

.PARAMETER WorkspaceDir
Path to the workspace directory for install location
#>
function Configure-CMake {
param(
[string]$BuildType,
[string]$VcpkgRoot,
[string]$WorkspaceDir
)

Write-Host "Configuring CMake for $BuildType..."
$buildDir = "build_$($BuildType.ToLower())"
$installDir = "$WorkspaceDir/install_$($BuildType.ToLower())"
$vcpkgToolchain = "$VcpkgRoot/scripts/buildsystems/vcpkg.cmake"

Set-Location $buildDir
cmake .. -G "Visual Studio 17 2022" -A x64 `
-DBUILD_SHARED_LIBS:BOOL=ON `
-DCMAKE_GENERATOR_TOOLSET="cuda=$env:CUDA_PATH" `
-DPopSift_USE_GRID_FILTER:BOOL=ON `
-DPopSift_BUILD_DOCS:BOOL=OFF `
-DPopSift_USE_POSITION_INDEPENDENT_CODE:BOOL=ON `
-DPopSift_BUILD_EXAMPLES:BOOL=ON `
-DCMAKE_BUILD_TYPE="$BuildType" `
-DCMAKE_INSTALL_PREFIX="$installDir" `
-DVCPKG_INSTALLED_DIR="$env:VCPKG_INSTALLED_DIR" `
-DCMAKE_TOOLCHAIN_FILE="$vcpkgToolchain"

if ($LASTEXITCODE -ne 0) {
throw "CMake configuration failed for $BuildType"
}
Set-Location ..
}

<#
.SYNOPSIS
Builds and installs PopSift for the specified build configuration.

.DESCRIPTION
Performs parallel build using all available CPU cores and installs the built
libraries and executables to the configured install directory.

.PARAMETER BuildType
The build configuration (Release or Debug)
#>
function Build-AndInstall {
param([string]$BuildType)

Write-Host "Building and installing $BuildType..."
$buildDir = "build_$($BuildType.ToLower())"

Set-Location $buildDir
cmake --build . --config $BuildType --parallel
if ($LASTEXITCODE -ne 0) {
throw "Build failed for $BuildType"
}

cmake --build . --config $BuildType --target install
if ($LASTEXITCODE -ne 0) {
throw "Install failed for $BuildType"
}
Set-Location ..
}

<#
.SYNOPSIS
Tests building PopSift applications as a third-party consumer on Windows.

.DESCRIPTION
Verifies that the installed PopSift can be found and used by external projects.
This is important for testing the installation and packaging. Uses vcpkg manifest
mode dependencies from the main project build since src/application doesn't have
its own vcpkg.json file.

.PARAMETER BuildType
The build configuration (Release or Debug)

.PARAMETER VcpkgRoot
Path to the vcpkg installation directory

.PARAMETER WorkspaceDir
Path to the workspace directory containing the main build and install
#>
function Build-AsThirdParty {
param(
[string]$BuildType,
[string]$VcpkgRoot,
[string]$WorkspaceDir
)

Write-Host "Testing third-party build for $BuildType..."
$thirdPartyDir = "build_as_3rdparty_$($BuildType.ToLower())"
$installDir = "$WorkspaceDir/install_$($BuildType.ToLower())"
$vcpkgToolchain = "$VcpkgRoot/scripts/buildsystems/vcpkg.cmake"

# In vcpkg manifest mode, dependencies are installed locally in vcpkg_installed/
# Since src/application doesn't have vcpkg.json, we need to point to the main project's vcpkg_installed directory so the third-party build can find the dependencies
$mainProjectVcpkgInstalled = $env:VCPKG_INSTALLED_DIR
Write-Host "Dependencies installed in $mainProjectVcpkgInstalled..."
# print first level content of the folder mainProjectVcpkgInstalled
Get-ChildItem -Path $mainProjectVcpkgInstalled -Directory | ForEach-Object { Write-Host " - $($_.Name)" }

Set-Location $thirdPartyDir
cmake ../src/application -G "Visual Studio 17 2022" -A x64 `
-DBUILD_SHARED_LIBS:BOOL=ON `
-DCMAKE_BUILD_TYPE=$BuildType `
-DCMAKE_PREFIX_PATH="$installDir;$mainProjectVcpkgInstalled/x64-windows" `
-DCMAKE_TOOLCHAIN_FILE="$vcpkgToolchain" `
-DVCPKG_INSTALLED_DIR="$mainProjectVcpkgInstalled" `
-DVCPKG_TARGET_TRIPLET=x64-windows

if ($LASTEXITCODE -ne 0) {
throw "Third-party CMake configuration failed for $BuildType"
}

cmake --build . --config $BuildType --parallel
if ($LASTEXITCODE -ne 0) {
throw "Third-party build failed for $BuildType"
}
Set-Location ..
}
Loading
Loading