[packaging/craft-blueprints-kde] libs: Build onnxruntime from source as a shared library instead of shipping binaries. Update to 1.27.

Maciej Bonin <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 8e7d5c111328b337fddbf15755b12b2bd3410013 by Maciej Bonin.
Committed on 18/08/2026 at 12:49.
Pushed by pillowtrucker into branch 'master'.

Build onnxruntime from source as a shared library instead of shipping binaries. Update to 1.27.

D  +0    -46   libs/_windows/onnxruntime/onnxruntime.py
A  +63   -0    libs/onnxruntime/onnxruntime.py

https://invent.kde.org/packaging/craft-blueprints-kde/-/commit/8e7d5c111328b337fddbf15755b12b2bd3410013

diff --git a/libs/_windows/onnxruntime/onnxruntime.py b/libs/_windows/onnxruntime/onnxruntime.py
deleted file mode 100644
index b27e040e1..000000000
--- a/libs/_windows/onnxruntime/onnxruntime.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# SPDX-License-Identifier: BSD-2-Clause
-# SPDX-FileCopyrightText: 2025 Mauritius Clemens <[email protected]>
-
-import info
-import utils
-from Package.BinaryPackageBase import BinaryPackageBase
-from Utils import CraftHash
-
-
-class subinfo(info.infoclass):
-    # This defines the basic information about your software package (both the basic
-    # metainformation like human readable names, where the source comes from, and
-    # what other blueprints it depends on).
-    def setTargets(self):
-        # The human-readable name of the main binary
-        self.displayName = "onnxruntime"
-        # A description of the entire package
-        self.description = " ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator "
-        # The project's webpage (if you're unsure for a KDE project, just use this one)
-        self.webpage = "https://github.com/microsoft/onnxruntime"
-
-        VERSION = "1.22.1"
-        for ver in [VERSION]:
-            self.targets[ver] = f"https://github.com/microsoft/onnxruntime/releases/download/v{ver}/onnxruntime-win-x64-{ver}.zip"
-            self.targetInstSrc[ver] = "onnxruntime-win-x64-" + ver
-            self.targetDigests[ver] = ("855276cd4be3cda14fe636c69eb038d75bf5bcd552bda1193a5d79c51f436dfe", CraftHash.HashAlgorithm.SHA256)
-        self.defaultTarget = VERSION
-
-
-class Package(BinaryPackageBase):
-    # This defines which build system your blueprint should use. In this case, we are
-    # using the CMake package base, but there are a lot of options for specific use cases,
-    # such as Meson, Perl, QMake, and Binary ones. See
-    # https://invent.kde.org/packaging/craft/-/tree/master/bin/Package
-    # for details on which package base options are available. For KDE projects, however
-    # you will almost certainly be using CMake, and the others are commonly more useful
-    # for when you are creating blueprints for new dependencies.
-    def __init__(self, **kwargs):
-        # Always remember to just initialize the package base like so
-        super().__init__(**kwargs)
-
-    def install(self):
-        super().install()
-        utils.mergeTree(self.sourceDir() / "lib", self.installDir() / "lib")
-        utils.mergeTree(self.sourceDir() / "include", self.installDir() / "include")
-        return True
diff --git a/libs/onnxruntime/onnxruntime.py b/libs/onnxruntime/onnxruntime.py
new file mode 100644
index 000000000..058450551
--- /dev/null
+++ b/libs/onnxruntime/onnxruntime.py
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: BSD-2-Clause
+# SPDX-FileCopyrightText: 2025 Mauritius Clemens <[email protected]>
+
+import info
+from Package.CMakePackageBase import CMakePackageBase
+from Utils import CraftHash
+
+
+class subinfo(info.infoclass):
+    def registerOptions(self):
+        self.options.dynamic.setDefault("buildType", "Release")
+        self.options.dynamic.setDefault("buildStatic", True)
+
+    def setTargets(self):
+        self.displayName = "onnxruntime"
+        self.description = " ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator "
+        self.webpage = "https://github.com/microsoft/onnxruntime"
+
+        VERSION = "1.27.0"
+        for ver in [VERSION]:
+            self.targets[ver] = f"https://github.com/microsoft/onnxruntime/archive/refs/tags/v{ver}.zip"
+            self.targetInstSrc[ver] = "onnxruntime-" + ver
+            self.targetDigests[ver] = ("14146bc2a9e0597a6bbbd58be60b37d629666497408ee7de030725f79a08ba3c", CraftHash.HashAlgorithm.SHA256)
+            self.targetConfigurePath[ver] = "cmake"
+        self.defaultTarget = VERSION
+
+    def setDependencies(self):
+        self.buildDependencies["virtual/base"] = None
+        # onnxruntime requires cmake >= 3.28; distro cmake can be older
+        # (almalinux 9 ships 3.26). dev-utils/cmake installs an official
+        # cmake.org build into the craft prefix and shims it onto PATH.
+        self.buildDependencies["dev-utils/cmake"] = None
+
+
+class Package(CMakePackageBase):
+    def __init__(self, **kwargs):
+        super().__init__(**kwargs)
+        self.subinfo.options.configure.args += [
+            # Single shared onnxruntime lib with its dependencies baked in
+            # (onnxruntime's own switch; buildStatic covers BUILD_SHARED_LIBS).
+            "-Donnxruntime_BUILD_SHARED_LIB=ON",
+            "-Donnxruntime_USE_TELEMETRY=OFF",
+            f"-Donnxruntime_BUILD_UNIT_TESTS={self.subinfo.options.dynamic.buildTests.asOnOff}",
+            f"-Donnxruntime_RUN_ONNX_TESTS={self.subinfo.options.dynamic.buildTests.asOnOff}",
+            "-DBUILD_ONNX_PYTHON=OFF",
+            f"-DONNX_BUILD_TESTS={self.subinfo.options.dynamic.buildTests.asOnOff}",
+            "-DONNX_BUILD_BENCHMARKS=OFF",
+            "-Donnxruntime_USE_CUDA=OFF",
+            "-Donnxruntime_USE_DNNL=OFF",
+            "-Donnxruntime_USE_TENSORRT=OFF",
+            "-Donnxruntime_USE_MIGRAPHX=OFF",
+            "-Donnxruntime_USE_AVX=OFF",
+            "-Donnxruntime_USE_AVX2=OFF",
+            "-Donnxruntime_USE_AVX512=OFF",
+            "-DCMAKE_CXX_STANDARD=20",
+            "-DCMAKE_CXX_STANDARD_REQUIRED=ON",
+            "-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=NEVER",
+            # Align the FetchContent deps' MSVC CRT with onnxruntime's own /MD
+            # (they default to static /MT when built as static libs -> LNK4098/LNK1169).
+            "-Dprotobuf_MSVC_STATIC_RUNTIME=OFF",
+            "-DABSL_MSVC_STATIC_RUNTIME=OFF",
+            "-DONNX_USE_MSVC_STATIC_RUNTIME=OFF",
+        ]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.