Skip to content

Feature/vcpkg - #7

Open
ericwait wants to merge 23 commits into
developfrom
feature/vcpkg
Open

Feature/vcpkg#7
ericwait wants to merge 23 commits into
developfrom
feature/vcpkg

Conversation

@ericwait

@ericwait ericwait commented Jul 28, 2025

Copy link
Copy Markdown
Owner

✅ Add vcpkg Packaging Support for Hydra

Summary

This PR introduces initial support for building and packaging the Hydra Image Processor library via vcpkg. It includes:

  • vcpkg.json with dependencies and metadata
  • portfile.cmake that fetches the GitHub repo using vcpkg_from_github
  • Python script to dynamically update version in vcpkg.json during CI
  • Updated GitHub Actions (hydra-ci.yml) workflow:
    • Adds workflow_dispatch and push support for feature/vcpkg
    • Injects GitVersion version info into CMake and vcpkg files
    • Uploads CI artifacts (binaries and install folder)

Testing

  • vcpkg install hydra --overlay-ports=ports completes successfully
  • CI builds complete for feature/vcpkg (both Windows and Linux)
  • GitHub Actions inject version correctly into vcpkg.json

Next Steps

Once merged:

  • Open PR to microsoft/vcpkg for official inclusion
  • Tag a release so SHA + version pinning works in portfile.cmake
  • Optional: Add additional CI jobs for x64-windows (non-static), x64-linux, etc.

Summary by Sourcery

Enable vcpkg support and improve build/packaging infrastructure by enhancing CMake scripts, integrating GitVersion, standardizing CUDA error handling, and adding a comprehensive GitHub Actions CI workflow for building, packaging, and releasing Hydra.

New Features:

  • Add vcpkg packaging support for Hydra including vcpkg.json, portfile.cmake, and dynamic version/SHA updates via a Python script

Enhancements:

  • Overhaul CMake build system to integrate GitVersion, generate version headers, configure and install package targets for C, CUDA, Python, and MATLAB interfaces
  • Standardize error handling in CUDA kernels to throw exceptions consistently

CI:

  • Introduce GitHub Actions workflow for multi-platform builds, version injection, vcpkg file patching, artifact staging, and automated release creation

Chores:

  • Add .gitversion.yml for mainline versioning strategy and environment.yml for conda build dependencies

@ericwait
ericwait requested a review from Copilot July 28, 2025 18:43
@ericwait ericwait self-assigned this Jul 28, 2025
@sourcery-ai

sourcery-ai Bot commented Jul 28, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR introduces vcpkg packaging support alongside CI enhancements, integrates GitVersion-based version and install/export in CMake, restructures CUDA, MEX and Python CMake modules for consistency, and standardizes exception handling in CUDA kernels.

Class diagram for updated CMake build targets and interfaces

classDiagram
    class HydraCudaStatic {
        +STATIC library
        +CUDA kernels
        +OpenMP support
        +Install rules
    }
    class HydraMex {
        +MODULE library
        +Matlab MEX interface
        +Depends on HydraCudaStatic
        +Custom output name
        +Platform-specific suffix
    }
    class HydraPy {
        +MODULE library
        +Python interface
        +Depends on HydraCudaStatic
        +Custom output name
        +Platform-specific suffix
    }
    HydraMex --|> HydraCudaStatic : links to
    HydraPy --|> HydraCudaStatic : links to
Loading

Class diagram for standardized exception handling in CUDA kernels

classDiagram
    class ImageChunk {
        +sendROI(...)
        +throws std::runtime_error
    }
    class Kernel {
        +getOffsetCopy(...)
        +throws std::runtime_error
    }
    class CudaKernels {
        +cAddTwoImages(...)
        +cElementWiseDifference(...)
        +cClosure(...)
        +cEntropyFilter(...)
        +cGaussian(...)
        +cHighPassFilter(...)
        +cIdentityFilter(...)
        +cMaxFilter(...)
        +cMeanAndVariance(...)
        +cMeanFilter(...)
        +cMedianFilter(...)
        +cMinFilter(...)
        +cMinMax(...)
        +cMultiplySum(...)
        +cNLMeans(...)
        +cOpener(...)
        +cStdFilter(...)
        +cSum(...)
        +cVarFilter(...)
        +cWienerFilter(...)
        +All: throw std::runtime_error on ROI failure
    }
Loading

Flow diagram for dynamic vcpkg version update in CI

flowchart TD
    A[Start CI Job]
    B[Run GitVersion to get version info]
    C[Run update-vcpkg-files.py]
    D[Update vcpkg.json version]
    E[Update portfile.cmake REF and SHA512]
    F[Continue build]
    A --> B --> C --> D --> E --> F
Loading

File-Level Changes

Change Details Files
vcpkg packaging support and CI workflow enhancements
  • Add vcpkg.json with project metadata and dependencies
  • Create minimal portfile.cmake fetching from GitHub
  • Implement Python script to update vcpkg files with current tag and SHA
  • Extend GitHub Actions to patch vcpkg, build targets, stage and upload artifacts
vcpkg.json
ports/hydra/portfile.cmake
scripts/update-vcpkg-files.py
.github/workflows/hydra-ci.yml
.gitversion.yml
environment.yml
Integrate GitVersion and package export in main CMakeLists
  • Set project VERSION and default GitVersion variables
  • Generate Version.h from template and include generated directory
  • Configure and install hydra-config.cmake and version file via CMakePackageConfigHelpers
  • Define default CUDA architectures, GNUInstallDirs and required dependencies
CMakeLists.txt
cmake/hydra-config.cmake.in
src/c/Version.h.in
Restructure CUDA subproject build and installation
  • Introduce setup_cuda_library function to unify target creation
  • Collect and validate common includes, headers and sources lists
  • Enable OpenMP via find_package and link flags
  • Add install rules and export HydraTargets for package config
src/c/Cuda/CMakeLists.txt
Modernize MEX and Python interface CMake modules
  • Enforce C++17 standard and conditional USE_PROCESS_MUTEX define
  • Unify add_library setup with proper include directories and link libraries
  • Specify platform-specific output properties and suffixes
  • Integrate post-build auto-generation scripts
src/c/Mex/CMakeLists.txt
src/c/Python/CMakeLists.txt
Standardize exception throwing in CUDA kernels
  • Replace bare std::runtime_error(...) calls with throw std::runtime_error(...)
  • Ensure correct exception semantics across device-copy operations
src/c/Cuda/CudaAddTwoImages.cuh
src/c/Cuda/CudaClosure.cuh
src/c/Cuda/CudaElementWiseDifference.cuh
src/c/Cuda/CudaLoG.cuh
src/c/Cuda/Kernel.cu
src/c/Cuda/ImageChunk.h
src/c/Cuda/_TemplateKernel.cuh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces comprehensive vcpkg packaging support for the Hydra Image Processor library. It sets up a complete build and packaging infrastructure with modern CMake practices, automated CI workflows, and vcpkg integration for distribution.

  • Adds vcpkg packaging files with dependency metadata and CMake configuration
  • Modernizes the CMake build system with improved structure and proper installation targets
  • Implements GitHub Actions CI workflow with GitVersion integration for automated builds

Reviewed Changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vcpkg.json / portfile.cmake vcpkg package definition and build configuration
CMakeLists.txt Modernized root CMake with versioning, dependencies, and package config
src/c/Cuda/CMakeLists.txt Restructured CUDA library build with proper OpenMP and installation setup
.github/workflows/hydra-ci.yml Complete CI pipeline with GitVersion, multi-platform builds, and artifact uploads
scripts/update-vcpkg-files.py Python utility for dynamic version updates during CI
Multiple .cuh files Bug fixes for missing throw statements in error handling
Comments suppressed due to low confidence (1)

CMakeLists.txt:36

  • CUDA architecture '103' and '121' do not exist. Valid CUDA compute capabilities include values like 52, 61, 70, 75, 80, 86, 89, 90. These invalid architectures will cause compilation failures.
  set(CMAKE_CUDA_ARCHITECTURES "89;90;103;121"

Comment thread src/c/Cuda/_TemplateKernel.cuh Outdated
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ericwait/hydra-image-processor
REF v${GITVERSION_SEMVER} # you can pass this in via `cmake -D`

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The REF should use a fixed version tag or commit SHA for vcpkg stability. Using a variable like ${GITVERSION_SEMVER} will cause build failures as this variable is not available in the vcpkg context.

Suggested change
REF v${GITVERSION_SEMVER} # you can pass this in via `cmake -D`
REF v1.2.3 # Replace with the actual fixed version tag or commit SHA

Copilot uses AI. Check for mistakes.
OUT_SOURCE_PATH SOURCE_PATH
REPO ericwait/hydra-image-processor
REF v${GITVERSION_SEMVER} # you can pass this in via `cmake -D`
SHA512 0 # This must be updated

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SHA512 value is set to 0, which is invalid. This must be updated with the actual SHA512 hash of the source archive for vcpkg to verify the download integrity.

Suggested change
SHA512 0 # This must be updated
SHA512 <calculated_sha512_hash> # Replace with the actual hash

Copilot uses AI. Check for mistakes.
Comment thread CMakeLists.txt Outdated

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ericwait - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Redundant 'throw' keyword in exception statement. (link)

General comments:

  • Consider consolidating the repetitive binding build patterns in the MATLAB and Python CMakeLists into a shared function or macro to reduce duplication and maintenance overhead.
  • The update-vcpkg-files.py script downloads the entire source tarball to compute the SHA512; you could improve CI performance and reliability by leveraging vcpkg’s built-in hash fetching or the GitHub API instead of re-downloading the full archive.
  • The new portfile.cmake pins HEAD_REF to main and uses a fixed REF pattern—consider parameterizing or documenting the expected tag format so future version bumps won’t break the vcpkg port build.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider consolidating the repetitive binding build patterns in the MATLAB and Python CMakeLists into a shared function or macro to reduce duplication and maintenance overhead.
- The update-vcpkg-files.py script downloads the entire source tarball to compute the SHA512; you could improve CI performance and reliability by leveraging vcpkg’s built-in hash fetching or the GitHub API instead of re-downloading the full archive.
- The new portfile.cmake pins HEAD_REF to main and uses a fixed REF pattern—consider parameterizing or documenting the expected tag format so future version bumps won’t break the vcpkg port build.

## Individual Comments

### Comment 1
<location> `src/c/Cuda/_TemplateKernel.cuh:75` </location>
<code_context>
 		{
 			if (!chunks[i].sendROI(imageIn, deviceImages.getCurBuffer()))
-				std::runtime_error("Error sending ROI to device!");
+				throw throw std::runtime_error("Error sending ROI to device!");

 			deviceImages.setAllDims(chunks[i].getFullChunkSize());
</code_context>

<issue_to_address>
Redundant 'throw' keyword in exception statement.

'throw throw std::runtime_error(...)' will cause a compilation error. Use only 'throw std::runtime_error(...)'.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/c/Cuda/_TemplateKernel.cuh Outdated
@coderabbitai

coderabbitai Bot commented Jan 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Comment @coderabbitai help to get the list of available commands and usage tips.

@ericwait
ericwait changed the base branch from main to develop July 9, 2026 01:31
@ericwait

ericwait commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

Retargeted to develop per the new branching model (feature branches → develop → PR → main; see CONTRIBUTING.md).

Heads-up: since this branch was cut, v4.0.0 moved the build to scikit-build-core (single pip install ., CUDA source made self-sufficient, in-repo conda recipe removed, distribution via conda-forge). This PR will need a substantial rebase against develop, and it is worth re-evaluating which parts of the vcpkg approach are still needed under the new build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants