Skip to content

Commit 0bfcd2c

Browse files
conan: add initial prebuilt package support with conan
1 parent fffc4b7 commit 0bfcd2c

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

conanfile.py

+34-37
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
1+
import os
2+
import json
3+
import subprocess
14
from conan import ConanFile
2-
from conan.tools.meson import MesonToolchain, Meson
3-
from conan.tools.gnu import PkgConfigDeps
5+
from conan.tools.files import copy
46

57

6-
class sentry_kernelConan(ConanFile):
8+
class Sentryecipe(ConanFile):
79
name = "sentry-kernel"
8-
version = "0.3"
9-
channel = "testing"
10-
package_type = "application"
11-
description = """This is the package of the Sentry kernel.
12-
A fully featured micro-kernel for small embedded systems, designed
13-
for the Outpost Operating System"""
14-
License = "Apache-2.0"
15-
topics = ("kernel", "embedded", "Outpost", "security")
16-
url = "https://github.com/outpost-os/sentry-kernel.git"
17-
tools_requires = ""
18-
build_requires = "ninja/>1.11", "dtc/[>1.6]", "cargo/[>1.75]"
19-
test_requires = "gcovr", "frama-c"
20-
python_requires = "meson/[>1.3 <1.5]", "dts-utils/[>0.2.2]", "svd2json/[>0.1.6]", "kconfiglib/[>14.1]"
10+
relpath = "builddir/staging"
11+
settings = "arch", "os"
2112

22-
# Binary configuration
23-
settings = "os", "baremetal", "arch", "armv7", "compiler", "gcc"
24-
25-
exports = "dts/*", "configs/*", "schemas/*", "subprojects/*"
26-
# Sources are located in the same place as this recipe, copy them to the recipe
27-
exports_sources = "meson.build", "meson.options", "kernel/*", "uapi/*", "autotest/*", "idle/*", "doc/*", "tools/*"
28-
package_type = "unknown"
13+
def init(self):
14+
proc = subprocess.run(["meson", "introspect", "--machines", "builddir"], check=True, capture_output=True, text=True)
15+
result = json.loads(proc.stdout)
16+
self.arch = result["host"]["cpu_family"]
17+
self.os = result["host"]["system"]
2918

19+
def set_version(self):
20+
proc = subprocess.run(["meson", "introspect", "--projectinfo", "builddir"], check=True, capture_output=True, text=True)
21+
result = json.loads(proc.stdout)
22+
self.version = result["version"]
3023

3124
def layout(self):
32-
self.folders.build = "build"
33-
34-
def generate(self):
35-
deps = PkgConfigDeps(self)
36-
deps.generate()
37-
tc = MesonToolchain(self)
38-
tc.generate()
39-
40-
def build(self):
41-
meson = Meson(self)
42-
meson.configure(c)
43-
meson.build()
25+
self.folders.build = os.path.join(self.relpath)
26+
self.folders.source = self.folders.build
27+
self.cpp.source.includedirs = ["usr/local/include"]
28+
self.cpp.build.libdirs = ["usr/local/lib"]
29+
self.cpp_info.bindirs = ['usr/local/bin']
30+
self.cpp_info.resdirs = ['usr/local/share']
4431

4532
def package(self):
46-
meson = Meson(self)
47-
meson.install()
33+
local_include_folder = os.path.join(self.source_folder, self.cpp.source.includedirs[0])
34+
local_lib_folder = os.path.join(self.build_folder, self.cpp.build.libdirs[0])
35+
copy(self, "*.h", local_include_folder, os.path.join(self.package_folder, "include"), keep_path=False)
36+
copy(self, "*.lib", local_lib_folder, os.path.join(self.package_folder, "lib"), keep_path=False)
37+
copy(self, "*.elf", local_lib_folder, os.path.join(self.package_folder, "bin"), keep_path=False)
38+
copy(self, "*.hex", local_lib_folder, os.path.join(self.package_folder, "hex"), keep_path=False)
39+
40+
def package_info(self):
41+
self.cpp_info.libs = ["uapi"]
42+
self.cpp_info.components["uapi"].libs = "libuapi"
43+
self.cpp_info.components["firmware"].filenames = "*.hex"
44+
self.cpp_info.components["binaries"].filenames = "*.elf"

0 commit comments

Comments
 (0)