-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/vcpkg #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ericwait
wants to merge
23
commits into
develop
Choose a base branch
from
feature/vcpkg
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b86830a
Throwing the std::runtime_error instead of just making one
ericwait c11e2c7
Updated cmake lists
ericwait 2442a01
Adding some versioning tools
ericwait ebce0f8
Added a local check to matlab
ericwait 957676d
Updated cmake lists to install components for others to use
ericwait 7cc5313
Adding files for making a vcpkg port
ericwait eec7cc2
Removed old ci file
ericwait a5ea2d3
Removed inline comment in json
ericwait 8efeb90
fixed build to not use env in matrix def
ericwait a206ab0
Trying without linux build
ericwait b4274c4
Update CMakeLists.txt for python
ericwait 084f582
Update src/c/Cuda/_TemplateKernel.cuh removed extra throw
ericwait 41a14e9
Using a github runner
ericwait ce3d83a
Refactor vcpkg file update script to use version source SHA and impro…
ericwait 985c6ef
Merge branch 'feature/vcpkg' of https://github.com/ericwait/hydra-ima…
ericwait dd2bd8e
Fix file paths in vcpkg update script to correctly reference vcpkg.json
ericwait 6cdc6c8
Update CI configuration to debug linux build
ericwait 62ab4e7
Update CUDA Toolkit version to 12.9.1 in CI configuration
ericwait 19b155d
Use default cuda
ericwait 8c9aebb
Fix artifact upload name format in CI workflow
ericwait 31aae57
Update CI configuration to use self-hosted runner for Windows
ericwait becd2df
Refactor artifact collection step to handle OS-specific file types fo…
ericwait 88818d2
Refactor artifact collection step to separate Windows and Linux handling
ericwait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| name: Hydra CUDA CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ '**' ] | ||
| tags: [ 'v*.*.*' ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.runner }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: Windows | ||
| runner: self-hosted | ||
| cuda_arch: "89;90" | ||
| config: Release | ||
| # - os: Linux | ||
| # runner: ubuntu-latest | ||
| # cuda_arch: "89;90" | ||
| # config: Release | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Needed for GitVersion | ||
|
|
||
| - name: Install GitVersion | ||
| uses: gittools/actions/gitversion/setup@v0.10.2 | ||
| with: | ||
| versionSpec: '5.x' | ||
|
|
||
| - name: Determine version | ||
| id: gitversion | ||
| uses: gittools/actions/gitversion/execute@v0.10.2 | ||
|
|
||
| - name: Print GitVersion Info | ||
| run: echo "Calculated version is ${{ steps.gitversion.outputs.semVer }}" | ||
|
|
||
| - name: Patch vcpkg files | ||
| run: > | ||
| python scripts/update-vcpkg-files.py | ||
| ${{ steps.gitversion.outputs.VersionSourceSha }} | ||
| ${{ steps.gitversion.outputs.semVer }} | ||
|
|
||
| - name: Install CUDA Toolkit (Linux only) | ||
| if: matrix.os == 'Linux' | ||
| uses: Jimver/cuda-toolkit@v0.2.11 | ||
| # with: | ||
| # cuda: '12.3.2' | ||
|
|
||
| - name: Configure CMake | ||
| run: > | ||
| cmake -S . -B build | ||
| -DGITVERSION_SEMVER="${{ steps.gitversion.outputs.semVer }}" | ||
| -DGITVERSION_MAJOR="${{ steps.gitversion.outputs.major }}" | ||
| -DGITVERSION_MINOR="${{ steps.gitversion.outputs.minor }}" | ||
| -DGITVERSION_PATCH="${{ steps.gitversion.outputs.patch }}" | ||
| -DCMAKE_CUDA_ARCHITECTURES="${{ matrix.cuda_arch }}" | ||
| -DCMAKE_BUILD_TYPE=${{ matrix.config }} | ||
|
|
||
| - name: Build HydraCudaStatic | ||
| run: cmake --build build --target HydraCudaStatic --config ${{ matrix.config }} --parallel | ||
|
|
||
| - name: Build MEX bindings (optional) | ||
| run: cmake --build build --target Mex --config ${{ matrix.config }} --parallel | ||
| continue-on-error: true | ||
|
|
||
| - name: Build Python bindings (optional) | ||
| run: cmake --build build --target Python --config ${{ matrix.config }} --parallel | ||
| continue-on-error: true | ||
|
|
||
| - name: Collect artifacts (Windows) | ||
| if: matrix.os == 'Windows' | ||
| run: | | ||
| mkdir -p staging/${{ matrix.os }} | ||
| cp -r build/src/c/Cuda/*.{dll,lib,pdb} staging/${{ matrix.os }} 2> $null || true | ||
| cp -r build/src/c/Python/*.pyd staging/${{ matrix.os }} 2> $null || true | ||
| cp -r build/src/c/Mex/*.mex* staging/${{ matrix.os }} 2> $null || true | ||
|
|
||
| - name: Collect artifacts (Linux) | ||
| if: matrix.os != 'Windows' | ||
| run: | | ||
| mkdir -p staging/${{ matrix.os }} | ||
| cp -r build/src/c/Cuda/*.{so,a} staging/${{ matrix.os }} 2>/dev/null || true | ||
| cp -r build/src/c/Python/*.so staging/${{ matrix.os }} 2>/dev/null || true | ||
| cp -r build/src/c/Mex/*.mexa64 staging/${{ matrix.os }} 2>/dev/null || true | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: hydra-${{ matrix.os }}-${{ steps.gitversion.outputs.semVer }} | ||
| path: staging/${{ matrix.os }} | ||
|
|
||
| - name: Install to staging dir | ||
| run: cmake --install build --prefix install-root | ||
|
|
||
| - name: Upload installable artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: hydra_install_${{ matrix.os }} | ||
| path: install-root | ||
|
|
||
| release: | ||
| name: Create GitHub Release | ||
| needs: build | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Download all build artifacts | ||
| uses: actions/download-artifact@v4 | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| name: Hydra Release ${{ github.ref_name }} | ||
| tag_name: ${{ github.ref_name }} | ||
| files: | | ||
| hydra-*/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| mode: Mainline | ||
| branches: | ||
| main: | ||
| regex: ^main$ | ||
| increment: Minor | ||
| prevent-increment-of-merged-branch-version: true | ||
| is-release-branch: true | ||
| tag: '' | ||
| develop: | ||
| regex: ^develop$ | ||
| increment: Patch | ||
| tag: '' | ||
| feature: | ||
| regex: ^features?[/-] | ||
| increment: Inherit | ||
| tag: useBranchName | ||
| hotfix: | ||
| regex: ^hotfix(es)?[/-] | ||
| increment: Patch | ||
| tag: useBranchName | ||
| release: | ||
| regex: ^releases?[/-] | ||
| increment: None | ||
| tag: 'rc' | ||
| pull-request: | ||
| tag: 'pr' | ||
| increment: Inherit | ||
| ignore: | ||
| sha: [] | ||
| commit-message-incrementing: Enabled | ||
| merge-message-strategy: MergeMessage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,126 @@ | ||
| cmake_minimum_required(VERSION 3.22) | ||
|
|
||
| project(HydraImageProcessor LANGUAGES C CXX CUDA) | ||
| # Project metadata | ||
| project(HydraImageProcessor VERSION 0.0.0 LANGUAGES C CXX CUDA) | ||
|
|
||
| set(HYDRA_MODULE_NAME "HIP") | ||
| # =========================== | ||
| # GitVersioning (optional defaults for local builds) | ||
| # =========================== | ||
| if(NOT DEFINED GITVERSION_SEMVER) | ||
| set(GITVERSION_SEMVER "0.0.0-dev") | ||
| endif() | ||
| if(NOT DEFINED GITVERSION_MAJOR) | ||
| set(GITVERSION_MAJOR 0) | ||
| endif() | ||
| if(NOT DEFINED GITVERSION_MINOR) | ||
| set(GITVERSION_MINOR 0) | ||
| endif() | ||
| if(NOT DEFINED GITVERSION_PATCH) | ||
| set(GITVERSION_PATCH 0) | ||
| endif() | ||
|
|
||
| # =========================== | ||
| # Version Header Generation | ||
| # =========================== | ||
| configure_file( | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/c/Version.h.in | ||
| ${CMAKE_BINARY_DIR}/generated/Version.h | ||
| @ONLY | ||
| ) | ||
| include_directories(${CMAKE_BINARY_DIR}/generated) | ||
|
|
||
| # Use CMake's modern FindCUDAToolkit module | ||
| # =========================== | ||
| # CUDA Architecture Defaults | ||
| # =========================== | ||
| if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) | ||
| set(CMAKE_CUDA_ARCHITECTURES "89;90;103;121" | ||
| CACHE STRING "CUDA architectures to build for" | ||
| FORCE) | ||
| endif() | ||
|
|
||
| # =========================== | ||
| # Default Install Locations | ||
| # =========================== | ||
| include(GNUInstallDirs) | ||
|
|
||
| # =========================== | ||
| # Dependencies | ||
| # =========================== | ||
| find_package(CUDAToolkit REQUIRED) | ||
| find_package(OpenMP) | ||
| find_package(OpenMP REQUIRED COMPONENTS CXX) | ||
|
|
||
| # Find optional dependencies | ||
| find_package(Matlab COMPONENTS MAIN_PROGRAM OPTIONAL_COMPONENTS MEX_COMPILER) | ||
| find_package(Python COMPONENTS Development NumPy OPTIONAL) | ||
|
|
||
| # find_package(Python COMPONENTS Development NumPy OPTIONAL) | ||
|
|
||
| # Setup backend Hydra CUDA library (static) for CUDA building | ||
| # =========================== | ||
| # Subdirectories | ||
| # =========================== | ||
| add_subdirectory(src/c/Cuda) | ||
| add_subdirectory(src/c/test_back) | ||
|
|
||
| # Setup MEX interface if Matlab was found | ||
| if (Matlab_FOUND) | ||
| add_subdirectory(src/c/Mex) | ||
| add_subdirectory(src/c/Mex) | ||
| endif() | ||
|
|
||
| # Setup Python interface if Python is found | ||
| # Try to help FindPython by injecting the environment path (for local mamba or CI conda) | ||
| message(STATUS "CONDA_PREFIX: $ENV{CONDA_PREFIX}") | ||
| if(DEFINED ENV{CONDA_PREFIX}) | ||
| if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") | ||
| set(Python_EXECUTABLE "$ENV{CONDA_PREFIX}/python.exe" CACHE FILEPATH "Python interpreter") | ||
| else() | ||
| set(Python_EXECUTABLE "$ENV{CONDA_PREFIX}/python" CACHE FILEPATH "Python interpreter") | ||
| endif() | ||
| list(PREPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}") | ||
| message(STATUS "Python: ${Python_EXECUTABLE}") | ||
| message(STATUS "Python Include Dir: ${Python_INCLUDE_DIRS}") | ||
| else() | ||
| message(STATUS "Using system Python interpreter") | ||
| endif() | ||
|
|
||
| find_package(Python COMPONENTS Interpreter Development NumPy OPTIONAL) | ||
| # Manually set the Python library location if using conda/mamba on Windows | ||
| # if(WIN32 AND NOT Python_LIBRARIES) | ||
| # set(Python_LIBRARIES "$ENV{CONDA_PREFIX}/libs/python311.lib") | ||
| # endif() | ||
|
|
||
| message(STATUS "Python: ${Python_EXECUTABLE}") | ||
| message(STATUS "Python Include Dir: ${Python_INCLUDE_DIRS}") | ||
| message(STATUS "Python Library: ${Python_LIBRARIES}") | ||
| message(STATUS "NumPy Include Dir: ${Python_NumPy_INCLUDE_DIRS}") | ||
|
|
||
| if (Python_FOUND) | ||
| add_subdirectory(src/c/Python) | ||
| add_subdirectory(src/c/Python) | ||
| endif() | ||
|
|
||
| # =========================== | ||
| # CMake Package Config | ||
| # =========================== | ||
| include(CMakePackageConfigHelpers) | ||
|
|
||
| # Generate hydra-config.cmake | ||
| configure_package_config_file( | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/cmake/hydra-config.cmake.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/hydra-config.cmake | ||
| INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Hydra | ||
| ) | ||
|
|
||
| # Generate hydra-config-version.cmake | ||
| write_basic_package_version_file( | ||
| ${CMAKE_CURRENT_BINARY_DIR}/hydra-config-version.cmake | ||
| VERSION ${GITVERSION_SEMVER} | ||
| COMPATIBILITY AnyNewerVersion | ||
| ) | ||
|
|
||
| # Install config files | ||
| install(FILES | ||
| ${CMAKE_CURRENT_BINARY_DIR}/hydra-config.cmake | ||
| ${CMAKE_CURRENT_BINARY_DIR}/hydra-config-version.cmake | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Hydra | ||
| ) | ||
|
|
||
| # Export all targets (defined in subdirs like Cuda) | ||
| install(EXPORT HydraTargets | ||
| FILE HydraTargets.cmake | ||
| NAMESPACE Hydra:: | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Hydra | ||
| ) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # hydra-config.cmake.in | ||
| @PACKAGE_INIT@ | ||
|
|
||
| include("${CMAKE_CURRENT_LIST_DIR}/HydraTargets.cmake") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| name: hydra-build | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - python=3.11 | ||
| - numpy | ||
| - cmake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| 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` | ||||||
| SHA512 0 # This must be updated | ||||||
|
||||||
| SHA512 0 # This must be updated | |
| SHA512 <calculated_sha512_hash> # Replace with the actual hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "hydra", | ||
| "version": "0.1.0", | ||
| "description": "Hydra Image Processor: CUDA-accelerated image analysis backend.", | ||
| "homepage": "https://github.com/ericwait/hydra-image-processor", | ||
| "license": "BSD-3-Clause", | ||
| "dependencies": [ | ||
| "cuda", | ||
| "vcpkg-cmake", | ||
| "vcpkg-cmake-config" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import json, hashlib, urllib.request, sys | ||
|
|
||
| ref = sys.argv[1] # e.g., a tag, branch, or commit SHA | ||
| version = sys.argv[2] # e.g., "3.15.1-vcpkg.1" | ||
|
|
||
| # Construct GitHub tarball URL for the given ref | ||
| tarball_url = f"https://github.com/ericwait/hydra-image-processor/archive/{ref}.tar.gz" | ||
|
|
||
| # Download the tarball | ||
| print(f"Downloading tarball from: {tarball_url}") | ||
| tarball_data = urllib.request.urlopen(tarball_url).read() | ||
|
|
||
| # Compute SHA512 | ||
| sha512 = hashlib.sha512(tarball_data).hexdigest() | ||
| print(f"Computed SHA512: {sha512}") | ||
|
|
||
| # Patch vcpkg.json | ||
| with open("ports/hydra/vcpkg.json", "r") as f: | ||
| vcpkg = json.load(f) | ||
|
|
||
| vcpkg["version"] = version | ||
|
|
||
| with open("ports/hydra/vcpkg.json", "w") as f: | ||
| json.dump(vcpkg, f, indent=2) | ||
| f.write("\n") | ||
|
|
||
| # Patch portfile.cmake | ||
| portfile_path = "ports/hydra/portfile.cmake" | ||
| with open(portfile_path, "r") as f: | ||
| lines = f.readlines() | ||
|
|
||
| with open(portfile_path, "w") as f: | ||
| for line in lines: | ||
| if line.strip().startswith("REF "): | ||
| f.write(f' REF {ref}\n') | ||
| elif line.strip().startswith("SHA512 "): | ||
| f.write(f' SHA512 {sha512}\n') | ||
| else: | ||
| f.write(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.