From 1d33037c848334d3cc7ea40b0bdbb571d6bcabcd Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Wed, 2 Oct 2024 17:11:02 -0400 Subject: [PATCH 1/9] Fix publisDirs functionality It looks like this was not actually working as intended when I merged in the previous PR. I am renaming this feature and making some updates so that this will actually honor this setting. --- build-package.ps1 | 2 +- invoke-build.ps1 | 6 +++--- preconfigured-packages.json | 4 ++-- scripts/ps-modules/Build/Build.psm1 | 7 +++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build-package.ps1 b/build-package.ps1 index c6c60591..ff6ad3a5 100644 --- a/build-package.ps1 +++ b/build-package.ps1 @@ -10,4 +10,4 @@ Write-Banner -Level 1 -Title "Installing preconfigured package: `"$PackageName`" $pkg = Get-PackageInfo -PackageName $PackageName Write-Message "$(NL)Running invoke-build.ps1...$(NL)" -./invoke-build.ps1 -PackageName $PackageName -PackageAndFeatures $pkg.package -LinkType $pkg.linkType -BuildType $pkg.buildType -StagedArtifactsPath $StagedArtifactsPath -VcpkgHash $pkg.vcpkgHash -Publish $pkg.publish -ShowDebug:$ShowDebug +./invoke-build.ps1 -PackageName $PackageName -PackageAndFeatures $pkg.package -LinkType $pkg.linkType -BuildType $pkg.buildType -StagedArtifactsPath $StagedArtifactsPath -VcpkgHash $pkg.vcpkgHash -PublishDirs $pkg.publishDirs -ShowDebug:$ShowDebug diff --git a/invoke-build.ps1 b/invoke-build.ps1 index 8727c9e7..aac85cbc 100644 --- a/invoke-build.ps1 +++ b/invoke-build.ps1 @@ -5,7 +5,7 @@ param( [string]$BuildType = "release", # Build type: release or debug [string]$StagedArtifactsPath = "StagedArtifacts", # Output path to stage these artifacts to [string]$VcpkgHash = "", # The hash of vcpkg to checkout (if applicable) - [PSObject]$PublishInfo = $false, # Optional info on what to publish or not publish to the final artifact + [PSObject]$PublishDirs = $false, # Optional info on what to publish or not publish to the final artifact [switch]$ShowDebug = $false # Show additional debugging information ) @@ -16,9 +16,9 @@ Run-CleanupStep Run-SetupVcPkgStep $VcPkgHash Run-PreBuildStep $PackageAndFeatures Run-InstallPackageStep -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -Run-PrestageAndFinalizeBuildArtifactsStep -linkType $LinkType -buildType $BuildType -publishInfo $PublishInfo +Run-PrestageAndFinalizeBuildArtifactsStep -linkType $LinkType -buildType $BuildType -publishDirs $PublishDirs Run-PostBuildStep -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -Run-StageBuildArtifactsStep -packageName $PackageName -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -stagedArtifactsPath $StagedArtifactsPath -publishInfo $PublishInfo +Run-StageBuildArtifactsStep -packageName $PackageName -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -stagedArtifactsPath $StagedArtifactsPath Run-StageSourceArtifactsStep -packageName $PackageName -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -stagedArtifactsPath $StagedArtifactsPath Write-Message "$(NL)$(NL)Done.$(NL)" diff --git a/preconfigured-packages.json b/preconfigured-packages.json index c3a74673..6eac672f 100644 --- a/preconfigured-packages.json +++ b/preconfigured-packages.json @@ -22,7 +22,7 @@ "linkType": "static", "buildType": "release", "vcpkgHash": "6db51d86a9c2796581d74c9a7eb46e52ee8cb7eb", - "publish": { + "publishDirs": { "include": false, "lib": false, "bin": false, @@ -35,7 +35,7 @@ "linkType": "static", "buildType": "release", "vcpkgHash": "6db51d86a9c2796581d74c9a7eb46e52ee8cb7eb", - "publish": { + "publishDirs": { "include": false, "lib": false, "bin": false, diff --git a/scripts/ps-modules/Build/Build.psm1 b/scripts/ps-modules/Build/Build.psm1 index 90783e9f..c5fca705 100644 --- a/scripts/ps-modules/Build/Build.psm1 +++ b/scripts/ps-modules/Build/Build.psm1 @@ -245,7 +245,7 @@ function Run-PrestageAndFinalizeBuildArtifactsStep { param( [string]$linkType, [string]$buildType, - [PSObject]$publishInfo + [PSObject]$publishDirs ) $preStagePath = (Get-PreStagePath) Create-EmptyDir $preStagePath @@ -293,7 +293,7 @@ function Run-PrestageAndFinalizeBuildArtifactsStep { foreach ($srcDir in $srcToDestDirs.Keys) { $destDir = $srcToDestDirs[$srcDir] $dirName = [System.IO.Path]::GetFileName($srcDir) - if ($publishInfo.$dirName -eq $false) { + if ($publishDirs.$dirName -eq $false) { $keysToRemove += $srcDir } } @@ -346,8 +346,7 @@ function Run-StageBuildArtifactsStep { [string]$packageAndFeatures, [string]$linkType, [string]$buildType, - [string]$stagedArtifactsPath, - [PSObject]$publishInfo + [string]$stagedArtifactsPath ) Write-Banner -Level 3 -Title "Stage build artifacts" From da4916cdf33125f6fab9144d8c33822f439e72be Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Wed, 2 Oct 2024 15:44:59 -0400 Subject: [PATCH 2/9] Add onnx support Adding onnx support, though we may not want to fully build onnx in the end. If you want to fully build onnx on Mac, you'll need these tools: - autoconf - automake - autoconf-archive --- .pipelines/build-package-preconfigured.yml | 1 + custom-steps/onnx/pre-build.ps1 | 5 +++++ preconfigured-packages.json | 13 +++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 custom-steps/onnx/pre-build.ps1 diff --git a/.pipelines/build-package-preconfigured.yml b/.pipelines/build-package-preconfigured.yml index 7dc25959..4ddd36ca 100644 --- a/.pipelines/build-package-preconfigured.yml +++ b/.pipelines/build-package-preconfigured.yml @@ -18,6 +18,7 @@ parameters: - libzip-static - libzip-dynamic - minizip + - onnx - openssl-static - opencv4 - pango diff --git a/custom-steps/onnx/pre-build.ps1 b/custom-steps/onnx/pre-build.ps1 new file mode 100644 index 00000000..2a0d5aad --- /dev/null +++ b/custom-steps/onnx/pre-build.ps1 @@ -0,0 +1,5 @@ +Import-Module "$PSScriptRoot/../../scripts/ps-modules/Build" -DisableNameChecking + +if ((Get-IsOnMacOS)) { + brew install autoconf automake autoconf-archive +} diff --git a/preconfigured-packages.json b/preconfigured-packages.json index 6eac672f..da447640 100644 --- a/preconfigured-packages.json +++ b/preconfigured-packages.json @@ -244,6 +244,19 @@ "linkType": "dynamic", "buildType": "release" } + }, + { + "name": "onnx", + "mac": { + "package": "onnx", + "linkType": "dynamic", + "buildType": "release" + }, + "win": { + "package": "onnx", + "linkType": "dynamic", + "buildType": "release" + } } ] } From 300f006d07abf83d48f04461801c27a060f812c8 Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Mon, 30 Sep 2024 13:18:52 -0400 Subject: [PATCH 3/9] Copy onnxruntime-gpu port https://github.com/microsoft/vcpkg/tree/master/ports/onnxruntime-gpu --- custom-ports/onnxruntime-gpu/portfile.cmake | 102 ++++++++++++++++++++ custom-ports/onnxruntime-gpu/vcpkg.json | 8 ++ 2 files changed, 110 insertions(+) create mode 100644 custom-ports/onnxruntime-gpu/portfile.cmake create mode 100644 custom-ports/onnxruntime-gpu/vcpkg.json diff --git a/custom-ports/onnxruntime-gpu/portfile.cmake b/custom-ports/onnxruntime-gpu/portfile.cmake new file mode 100644 index 00000000..87dcfa29 --- /dev/null +++ b/custom-ports/onnxruntime-gpu/portfile.cmake @@ -0,0 +1,102 @@ +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) + +vcpkg_download_distfile(ARCHIVE + URLS "https://github.com/microsoft/onnxruntime/releases/download/v${VERSION}/onnxruntime-win-x64-gpu-${VERSION}.zip" + FILENAME "onnxruntime-win-x64-gpu-${VERSION}.zip" + SHA512 9576eafca59fc7f2af9f62d7ee8aa31208ef965d17f3ad71747d5a9a46cdffd6b3958dc945109d82937555df8bb35319ce92925e66ab707f1ca8e7564ecb3ced +) + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${ARCHIVE}" + NO_REMOVE_ONE_LEVEL +) + +# Download repo for experimental features +vcpkg_from_github( + OUT_SOURCE_PATH REPO_PATH + REPO microsoft/onnxruntime + REF v${VERSION} + SHA512 3bf25e431d175c61953d28b1bf8f6871376684263992451a5b2a66e670768fc66e7027f141c6e3f4d1eddeebeda51f31ea0adf4749e50d99ee89d0a26bec77ce +) + +file(COPY + ${REPO_PATH}/include/onnxruntime/core/session/experimental_onnxruntime_cxx_api.h + ${REPO_PATH}/include/onnxruntime/core/session/experimental_onnxruntime_cxx_inline.h + DESTINATION ${CURRENT_PACKAGES_DIR}/include + ) + +file(MAKE_DIRECTORY + ${CURRENT_PACKAGES_DIR}/include + ${CURRENT_PACKAGES_DIR}/lib + ${CURRENT_PACKAGES_DIR}/bin + ${CURRENT_PACKAGES_DIR}/debug/lib + ${CURRENT_PACKAGES_DIR}/debug/bin + ) + +file(COPY + ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/include + DESTINATION ${CURRENT_PACKAGES_DIR} + ) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) +# # Handle copyright +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/LICENSE") diff --git a/custom-ports/onnxruntime-gpu/vcpkg.json b/custom-ports/onnxruntime-gpu/vcpkg.json new file mode 100644 index 00000000..ac545ae0 --- /dev/null +++ b/custom-ports/onnxruntime-gpu/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "onnxruntime-gpu", + "version": "1.19.2", + "description": "onnxruntime (GPU)", + "homepage": "https://github.com/microsoft/onnxruntime", + "license": "MIT", + "supports": "windows & !x86 & !uwp & !static & !arm" +} From a8987447ad034a20fc7675bdc0e593e81602663a Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Wed, 2 Oct 2024 15:46:52 -0400 Subject: [PATCH 4/9] Add Mac support to onnxruntime-gpu --- custom-ports/onnxruntime-gpu/portfile.cmake | 118 ++++++++------------ custom-ports/onnxruntime-gpu/vcpkg.json | 2 +- 2 files changed, 45 insertions(+), 75 deletions(-) diff --git a/custom-ports/onnxruntime-gpu/portfile.cmake b/custom-ports/onnxruntime-gpu/portfile.cmake index 87dcfa29..a0afd1d5 100644 --- a/custom-ports/onnxruntime-gpu/portfile.cmake +++ b/custom-ports/onnxruntime-gpu/portfile.cmake @@ -1,10 +1,21 @@ vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) -vcpkg_download_distfile(ARCHIVE - URLS "https://github.com/microsoft/onnxruntime/releases/download/v${VERSION}/onnxruntime-win-x64-gpu-${VERSION}.zip" - FILENAME "onnxruntime-win-x64-gpu-${VERSION}.zip" - SHA512 9576eafca59fc7f2af9f62d7ee8aa31208ef965d17f3ad71747d5a9a46cdffd6b3958dc945109d82937555df8bb35319ce92925e66ab707f1ca8e7564ecb3ced -) +set(PKG_NAME "") +if(VCPKG_HOST_IS_WINDOWS) + set(PKG_NAME "onnxruntime-win-x64-gpu-${VERSION}") + vcpkg_download_distfile(ARCHIVE + URLS "https://github.com/microsoft/onnxruntime/releases/download/v${VERSION}/${PKG_NAME}.zip" + FILENAME "${PKG_NAME}.zip" + SHA512 9576eafca59fc7f2af9f62d7ee8aa31208ef965d17f3ad71747d5a9a46cdffd6b3958dc945109d82937555df8bb35319ce92925e66ab707f1ca8e7564ecb3ced + ) +elseif(VCPKG_HOST_IS_OSX) + set(PKG_NAME "onnxruntime-osx-universal2-${VERSION}") + vcpkg_download_distfile(ARCHIVE + URLS "https://github.com/microsoft/onnxruntime/releases/download/v${VERSION}/${PKG_NAME}.tgz" + FILENAME "${PKG_NAME}.tgz" + SHA512 a4b233f5cb258624af4fa57c10c93010c01730d067809054846a7e9eec3f8d5025a52cc07f920258b0db5073a787d8fcffa5f627c0dd34c690900c836d797d49 + ) +endif() vcpkg_extract_source_archive( SOURCE_PATH @@ -21,82 +32,41 @@ vcpkg_from_github( ) file(COPY - ${REPO_PATH}/include/onnxruntime/core/session/experimental_onnxruntime_cxx_api.h - ${REPO_PATH}/include/onnxruntime/core/session/experimental_onnxruntime_cxx_inline.h - DESTINATION ${CURRENT_PACKAGES_DIR}/include - ) + ${REPO_PATH}/include/onnxruntime/core/session/experimental_onnxruntime_cxx_api.h + ${REPO_PATH}/include/onnxruntime/core/session/experimental_onnxruntime_cxx_inline.h + DESTINATION ${CURRENT_PACKAGES_DIR}/include +) file(MAKE_DIRECTORY - ${CURRENT_PACKAGES_DIR}/include - ${CURRENT_PACKAGES_DIR}/lib + ${CURRENT_PACKAGES_DIR}/include + ${CURRENT_PACKAGES_DIR}/lib +) + +if(VCPKG_HOST_IS_WINDOWS) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin - ${CURRENT_PACKAGES_DIR}/debug/lib - ${CURRENT_PACKAGES_DIR}/debug/bin ) +endif() file(COPY - ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/include - DESTINATION ${CURRENT_PACKAGES_DIR} - ) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/lib) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/lib) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.pdb - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/lib) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) - -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/lib) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.lib - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + ${SOURCE_PATH}/${PKG_NAME}/include + DESTINATION ${CURRENT_PACKAGES_DIR} +) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_shared.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) +if(VCPKG_HOST_IS_WINDOWS) + file(GLOB LIB_FILES "${SOURCE_PATH}/${PKG_NAME}/lib/*.lib") + file(GLOB BIN_FILES "${SOURCE_PATH}/${PKG_NAME}/lib/*.dll" "${SOURCE_PATH}/${PKG_NAME}/lib/*.pdb") +elseif(VCPKG_HOST_IS_OSX) + file(GLOB LIB_FILES "${SOURCE_PATH}/${PKG_NAME}/lib/*.dylib" "${SOURCE_PATH}/${PKG_NAME}/lib/*.dSYM") +endif() -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) +foreach(file ${LIB_FILES}) + file(COPY ${file} DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +endforeach() -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_tensorrt.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) +foreach(file ${BIN_FILES}) + file(COPY ${file} DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +endforeach() -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/bin) -file(COPY ${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/lib/onnxruntime_providers_cuda.dll - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) -# # Handle copyright -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/LICENSE") +# Handle copyright +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/${PKG_NAME}/LICENSE") diff --git a/custom-ports/onnxruntime-gpu/vcpkg.json b/custom-ports/onnxruntime-gpu/vcpkg.json index ac545ae0..0e738a4f 100644 --- a/custom-ports/onnxruntime-gpu/vcpkg.json +++ b/custom-ports/onnxruntime-gpu/vcpkg.json @@ -4,5 +4,5 @@ "description": "onnxruntime (GPU)", "homepage": "https://github.com/microsoft/onnxruntime", "license": "MIT", - "supports": "windows & !x86 & !uwp & !static & !arm" + "supports": "!x86 & !uwp & !static" } From 50dd96f626658a0a6f7d7fa3397afe09d39c978f Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Wed, 2 Oct 2024 16:00:53 -0400 Subject: [PATCH 5/9] Add onnxruntime-gpu to preconfigured-packages --- preconfigured-packages.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/preconfigured-packages.json b/preconfigured-packages.json index da447640..baaea78a 100644 --- a/preconfigured-packages.json +++ b/preconfigured-packages.json @@ -257,6 +257,23 @@ "linkType": "dynamic", "buildType": "release" } + }, + { + "name": "onnxruntime-gpu", + "mac": { + "package": "onnxruntime-gpu", + "linkType": "dynamic", + "buildType": "release", + "buildOptions": { + "createUniversalBinaries": false, + "createDsyms": false + } + }, + "win": { + "package": "onnxruntime-gpu", + "linkType": "dynamic", + "buildType": "release" + } } ] } From e740ac5a610a8d95e81b0e080d32e48fc980a6ae Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Wed, 2 Oct 2024 16:01:03 -0400 Subject: [PATCH 6/9] Add special buildOptions overrides to support onnxruntime-gpu --- build-package.ps1 | 2 +- invoke-build.ps1 | 5 +-- scripts/ps-modules/Build/Build.psm1 | 3 +- scripts/ps-modules/MacBuild/MacBuild.psm1 | 44 +++++++++++++++++++++-- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/build-package.ps1 b/build-package.ps1 index ff6ad3a5..5b8e54f9 100644 --- a/build-package.ps1 +++ b/build-package.ps1 @@ -10,4 +10,4 @@ Write-Banner -Level 1 -Title "Installing preconfigured package: `"$PackageName`" $pkg = Get-PackageInfo -PackageName $PackageName Write-Message "$(NL)Running invoke-build.ps1...$(NL)" -./invoke-build.ps1 -PackageName $PackageName -PackageAndFeatures $pkg.package -LinkType $pkg.linkType -BuildType $pkg.buildType -StagedArtifactsPath $StagedArtifactsPath -VcpkgHash $pkg.vcpkgHash -PublishDirs $pkg.publishDirs -ShowDebug:$ShowDebug +./invoke-build.ps1 -PackageName $PackageName -PackageAndFeatures $pkg.package -LinkType $pkg.linkType -BuildType $pkg.buildType -StagedArtifactsPath $StagedArtifactsPath -VcpkgHash $pkg.vcpkgHash -BuildOptions $pkg.buildOptions -PublishDirs $pkg.publishDirs -ShowDebug:$ShowDebug diff --git a/invoke-build.ps1 b/invoke-build.ps1 index aac85cbc..2f8ae069 100644 --- a/invoke-build.ps1 +++ b/invoke-build.ps1 @@ -5,7 +5,8 @@ param( [string]$BuildType = "release", # Build type: release or debug [string]$StagedArtifactsPath = "StagedArtifacts", # Output path to stage these artifacts to [string]$VcpkgHash = "", # The hash of vcpkg to checkout (if applicable) - [PSObject]$PublishDirs = $false, # Optional info on what to publish or not publish to the final artifact + [PSObject]$BuildOptions = $null, # Additional options to control how this package is built + [PSObject]$PublishDirs = $null, # Optional info on what to publish or not publish to the final artifact [switch]$ShowDebug = $false # Show additional debugging information ) @@ -16,7 +17,7 @@ Run-CleanupStep Run-SetupVcPkgStep $VcPkgHash Run-PreBuildStep $PackageAndFeatures Run-InstallPackageStep -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -Run-PrestageAndFinalizeBuildArtifactsStep -linkType $LinkType -buildType $BuildType -publishDirs $PublishDirs +Run-PrestageAndFinalizeBuildArtifactsStep -linkType $LinkType -buildType $BuildType -buildOptions $BuildOptions -publishDirs $PublishDirs Run-PostBuildStep -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType Run-StageBuildArtifactsStep -packageName $PackageName -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -stagedArtifactsPath $StagedArtifactsPath Run-StageSourceArtifactsStep -packageName $PackageName -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType -stagedArtifactsPath $StagedArtifactsPath diff --git a/scripts/ps-modules/Build/Build.psm1 b/scripts/ps-modules/Build/Build.psm1 index c5fca705..98bc5460 100644 --- a/scripts/ps-modules/Build/Build.psm1 +++ b/scripts/ps-modules/Build/Build.psm1 @@ -245,6 +245,7 @@ function Run-PrestageAndFinalizeBuildArtifactsStep { param( [string]$linkType, [string]$buildType, + [PSObject]$buildOptions, [PSObject]$publishDirs ) $preStagePath = (Get-PreStagePath) @@ -318,7 +319,7 @@ function Run-PrestageAndFinalizeBuildArtifactsStep { # Finalize artifacts (Mac-only) if((Get-IsOnMacOS) -and (Test-Path $destArm64LibDir)) { $destUniversalLibDir = "$preStagePath/lib" - Create-FinalizedMacBuildArtifacts -arm64LibDir "$destArm64LibDir" -x64LibDir "$destX64LibDir" -universalLibDir "$destUniversalLibDir" + Create-FinalizedMacBuildArtifacts -arm64LibDir "$destArm64LibDir" -x64LibDir "$destX64LibDir" -universalLibDir "$destUniversalLibDir" -createUniversalBinaries $buildOptions.createUniversalBinaries -createDsyms $buildOptions.createDsyms } } diff --git a/scripts/ps-modules/MacBuild/MacBuild.psm1 b/scripts/ps-modules/MacBuild/MacBuild.psm1 index 0549f3f7..730c3029 100644 --- a/scripts/ps-modules/MacBuild/MacBuild.psm1 +++ b/scripts/ps-modules/MacBuild/MacBuild.psm1 @@ -34,6 +34,26 @@ function Create-UniversalBinaries { } } +function Copy-SrcLibToDestLib { + param( + [string]$srcLibDir, + [string]$destLibDir + ) + New-Item -Path "$destLibDir" -ItemType Directory -Force | Out-Null + Write-Message "Copying files from: $srcLibDir ==> $destLibDir..." + $items = Get-ChildItem -Path "$srcLibDir/*" -Include "*.dylib","*.a","*.dSYM" + foreach($item in $items) { + $fileName = $item.Name + Write-Message "> $fileName" + $srcPath = $item.FullName + $destPath = (Join-Path $destLibDir $fileName) + + if (-not $item.PSIsContainer) { + Invoke-Expression -Command "cp -R `"$srcPath`" `"$destPath`"" + } + } + } + function Copy-NonLibraryFiles { param( [string]$srcDir, @@ -53,17 +73,28 @@ function Create-FinalizedMacBuildArtifacts { param ( [string]$arm64LibDir, [string]$x64LibDir, - [string]$universalLibDir + [string]$universalLibDir, + [bool]$createUniversalBinaries, + [bool]$createDsyms ) Write-Banner -Level 3 -Title "Finalizing Mac artifacts" Write-Message "arm64LibDir: $arm64LibDir" Update-LibsToRelativePaths -arm64LibDir $arm64LibDir -x64LibDir $x64LibDir - Create-UniversalBinaries -arm64LibDir $arm64LibDir -x64LibDir $x64LibDir -universalLibDir $universalLibDir + if($createUniversalBinaries) { + Write-Host ">> Create-UniversalBinaries" + Create-UniversalBinaries -arm64LibDir $arm64LibDir -x64LibDir $x64LibDir -universalLibDir $universalLibDir + } + else { + Write-Host ">> Copy-SrcLibToDestLib" + Copy-SrcLibToDestLib -srcLibDir $arm64LibDir -destLibDir $universalLibDir + } Copy-NonLibraryFiles -srcDir $arm64LibDir -destDir $universalLibDir Remove-Item -Force -Recurse -Path $arm64LibDir Remove-Item -Force -Recurse -Path $x64LibDir Remove-DylibSymlinks -libDir $universalLibDir - Run-CreateDysmAndStripDebugSymbols -libDir $universalLibDir + if($createDsyms) { + Run-CreateDysmAndStripDebugSymbols -libDir $universalLibDir + } } function Update-LibraryPath { @@ -260,6 +291,13 @@ function Remove-DylibSymlinks { foreach ($item in $filesAndSymlinks) { Write-Message "> Renaming: $($item.Filename) ==> $($item.NewFilename)" Move-Item -Path "$($item.Filename)" -Destination "$($item.NewFilename)" + $dsymDir = "$($item.Filename).dSYM" + if (Test-Path -Path $dsymDir -PathType Container) { + $newDsymDir = "$($item.NewFilename).dSYM" + Write-Message "> Renaming: $dsymDir ==> $newDsymDir" + Move-Item -Path "$dsymDir" -Destination "$newDsymDir" + # TODO: Rename the inner .dylib in the dwarf dir + } } Pop-Location From 6145d070f9686255212ab506dc6d01ac8e97cabe Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Wed, 2 Oct 2024 16:01:31 -0400 Subject: [PATCH 7/9] Add pipeline support for onnxruntime-gpu --- .pipelines/build-package-preconfigured.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pipelines/build-package-preconfigured.yml b/.pipelines/build-package-preconfigured.yml index 4ddd36ca..67033652 100644 --- a/.pipelines/build-package-preconfigured.yml +++ b/.pipelines/build-package-preconfigured.yml @@ -19,6 +19,7 @@ parameters: - libzip-dynamic - minizip - onnx + - onnxruntime-gpu - openssl-static - opencv4 - pango From 080e37d09d6bdb042315aeb219eb621cdb0947f3 Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Fri, 4 Oct 2024 12:08:31 -0400 Subject: [PATCH 8/9] Downgrade to 1.18.24, to match what we use in AIResources See: https://github.com/TechSmith/AIResources/commit/84dadcf36b570f45ef2f99bded3cc93bf6024ef0 vs https://github.com/microsoft/onnxruntime/releases/download/v1.18.1/onnxruntime-win-x64-1.18.1.zip --- custom-ports/onnxruntime-gpu/vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-ports/onnxruntime-gpu/vcpkg.json b/custom-ports/onnxruntime-gpu/vcpkg.json index 0e738a4f..f907bc15 100644 --- a/custom-ports/onnxruntime-gpu/vcpkg.json +++ b/custom-ports/onnxruntime-gpu/vcpkg.json @@ -1,6 +1,6 @@ { "name": "onnxruntime-gpu", - "version": "1.19.2", + "version": "1.18.1", "description": "onnxruntime (GPU)", "homepage": "https://github.com/microsoft/onnxruntime", "license": "MIT", From c0c9d9332593de4d8f4d17237f95a7e1ef6616da Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Fri, 4 Oct 2024 12:22:18 -0400 Subject: [PATCH 9/9] fixup! Downgrade to 1.18.24, to match what we use in AIResources --- custom-ports/onnxruntime-gpu/portfile.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom-ports/onnxruntime-gpu/portfile.cmake b/custom-ports/onnxruntime-gpu/portfile.cmake index a0afd1d5..a7ff023f 100644 --- a/custom-ports/onnxruntime-gpu/portfile.cmake +++ b/custom-ports/onnxruntime-gpu/portfile.cmake @@ -6,14 +6,14 @@ if(VCPKG_HOST_IS_WINDOWS) vcpkg_download_distfile(ARCHIVE URLS "https://github.com/microsoft/onnxruntime/releases/download/v${VERSION}/${PKG_NAME}.zip" FILENAME "${PKG_NAME}.zip" - SHA512 9576eafca59fc7f2af9f62d7ee8aa31208ef965d17f3ad71747d5a9a46cdffd6b3958dc945109d82937555df8bb35319ce92925e66ab707f1ca8e7564ecb3ced + SHA512 1a7f5c1ca0cecb50505e0f33fd5b485b557c8930c79869b25acab036683c376d8e5e429f46cd30cbb592456203eca791948a7bcf1b730685c45196e85300c95e ) elseif(VCPKG_HOST_IS_OSX) set(PKG_NAME "onnxruntime-osx-universal2-${VERSION}") vcpkg_download_distfile(ARCHIVE URLS "https://github.com/microsoft/onnxruntime/releases/download/v${VERSION}/${PKG_NAME}.tgz" FILENAME "${PKG_NAME}.tgz" - SHA512 a4b233f5cb258624af4fa57c10c93010c01730d067809054846a7e9eec3f8d5025a52cc07f920258b0db5073a787d8fcffa5f627c0dd34c690900c836d797d49 + SHA512 5a59c36a683aed3c984e2eb97d91a50923f906ff5969edeeb941659a395411dd6f0f36d87f51e170f2fda70b2381a1afe3b40ef0c4395f393e50981e227cdbc5 ) endif() @@ -28,7 +28,7 @@ vcpkg_from_github( OUT_SOURCE_PATH REPO_PATH REPO microsoft/onnxruntime REF v${VERSION} - SHA512 3bf25e431d175c61953d28b1bf8f6871376684263992451a5b2a66e670768fc66e7027f141c6e3f4d1eddeebeda51f31ea0adf4749e50d99ee89d0a26bec77ce + SHA512 192cb95e131d7a7796f29556355d0c9055c05723e1120e21155ed21e05301d862f2ba3fd613d8f9289b61577f64cc4b406db7bb25d1bd666b75c29a0f29cc9d8 ) file(COPY