From fffc4b7ad44e872aacbce242138148129a045c83 Mon Sep 17 00:00:00 2001 From: pthierry Date: Fri, 2 Aug 2024 15:40:01 +0200 Subject: [PATCH 1/2] initial conan packging config --- conanfile.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 conanfile.py diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000..067fe3e9 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,47 @@ +from conan import ConanFile +from conan.tools.meson import MesonToolchain, Meson +from conan.tools.gnu import PkgConfigDeps + + +class sentry_kernelConan(ConanFile): + name = "sentry-kernel" + version = "0.3" + channel = "testing" + package_type = "application" + description = """This is the package of the Sentry kernel. + A fully featured micro-kernel for small embedded systems, designed + for the Outpost Operating System""" + License = "Apache-2.0" + topics = ("kernel", "embedded", "Outpost", "security") + url = "https://github.com/outpost-os/sentry-kernel.git" + tools_requires = "" + build_requires = "ninja/>1.11", "dtc/[>1.6]", "cargo/[>1.75]" + test_requires = "gcovr", "frama-c" + python_requires = "meson/[>1.3 <1.5]", "dts-utils/[>0.2.2]", "svd2json/[>0.1.6]", "kconfiglib/[>14.1]" + + # Binary configuration + settings = "os", "baremetal", "arch", "armv7", "compiler", "gcc" + + exports = "dts/*", "configs/*", "schemas/*", "subprojects/*" + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "meson.build", "meson.options", "kernel/*", "uapi/*", "autotest/*", "idle/*", "doc/*", "tools/*" + package_type = "unknown" + + + def layout(self): + self.folders.build = "build" + + def generate(self): + deps = PkgConfigDeps(self) + deps.generate() + tc = MesonToolchain(self) + tc.generate() + + def build(self): + meson = Meson(self) + meson.configure(c) + meson.build() + + def package(self): + meson = Meson(self) + meson.install() From 0bfcd2ca05c3e8bbd2439347e42a6471638f4a7b Mon Sep 17 00:00:00 2001 From: pthierry Date: Thu, 26 Sep 2024 13:16:17 +0200 Subject: [PATCH 2/2] conan: add initial prebuilt package support with conan --- conanfile.py | 71 +++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/conanfile.py b/conanfile.py index 067fe3e9..634c7de5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,47 +1,44 @@ +import os +import json +import subprocess from conan import ConanFile -from conan.tools.meson import MesonToolchain, Meson -from conan.tools.gnu import PkgConfigDeps +from conan.tools.files import copy -class sentry_kernelConan(ConanFile): +class Sentryecipe(ConanFile): name = "sentry-kernel" - version = "0.3" - channel = "testing" - package_type = "application" - description = """This is the package of the Sentry kernel. - A fully featured micro-kernel for small embedded systems, designed - for the Outpost Operating System""" - License = "Apache-2.0" - topics = ("kernel", "embedded", "Outpost", "security") - url = "https://github.com/outpost-os/sentry-kernel.git" - tools_requires = "" - build_requires = "ninja/>1.11", "dtc/[>1.6]", "cargo/[>1.75]" - test_requires = "gcovr", "frama-c" - python_requires = "meson/[>1.3 <1.5]", "dts-utils/[>0.2.2]", "svd2json/[>0.1.6]", "kconfiglib/[>14.1]" + relpath = "builddir/staging" + settings = "arch", "os" - # Binary configuration - settings = "os", "baremetal", "arch", "armv7", "compiler", "gcc" - - exports = "dts/*", "configs/*", "schemas/*", "subprojects/*" - # Sources are located in the same place as this recipe, copy them to the recipe - exports_sources = "meson.build", "meson.options", "kernel/*", "uapi/*", "autotest/*", "idle/*", "doc/*", "tools/*" - package_type = "unknown" + def init(self): + proc = subprocess.run(["meson", "introspect", "--machines", "builddir"], check=True, capture_output=True, text=True) + result = json.loads(proc.stdout) + self.arch = result["host"]["cpu_family"] + self.os = result["host"]["system"] + def set_version(self): + proc = subprocess.run(["meson", "introspect", "--projectinfo", "builddir"], check=True, capture_output=True, text=True) + result = json.loads(proc.stdout) + self.version = result["version"] def layout(self): - self.folders.build = "build" - - def generate(self): - deps = PkgConfigDeps(self) - deps.generate() - tc = MesonToolchain(self) - tc.generate() - - def build(self): - meson = Meson(self) - meson.configure(c) - meson.build() + self.folders.build = os.path.join(self.relpath) + self.folders.source = self.folders.build + self.cpp.source.includedirs = ["usr/local/include"] + self.cpp.build.libdirs = ["usr/local/lib"] + self.cpp_info.bindirs = ['usr/local/bin'] + self.cpp_info.resdirs = ['usr/local/share'] def package(self): - meson = Meson(self) - meson.install() + local_include_folder = os.path.join(self.source_folder, self.cpp.source.includedirs[0]) + local_lib_folder = os.path.join(self.build_folder, self.cpp.build.libdirs[0]) + copy(self, "*.h", local_include_folder, os.path.join(self.package_folder, "include"), keep_path=False) + copy(self, "*.lib", local_lib_folder, os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.elf", local_lib_folder, os.path.join(self.package_folder, "bin"), keep_path=False) + copy(self, "*.hex", local_lib_folder, os.path.join(self.package_folder, "hex"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["uapi"] + self.cpp_info.components["uapi"].libs = "libuapi" + self.cpp_info.components["firmware"].filenames = "*.hex" + self.cpp_info.components["binaries"].filenames = "*.elf"