From: Adriaan Schmidt <adriaan.schmidt@siemens.com>
To: <isar-users@googlegroups.com>
Cc: <jan.kiszka@siemens.com>, Adriaan Schmidt <adriaan.schmidt@siemens.com>
Subject: [RFC PATCH] native.bbclass
Date: Tue, 17 Jan 2023 19:03:58 +0100 [thread overview]
Message-ID: <20230117180358.1499566-1-adriaan.schmidt@siemens.com> (raw)
Hi all,
as mentioned by Jan, I have another approach of building native/host/compat
arch packages, inspired by OE's native class.
The way it works is:
- A recipe can inherit native.bbclass (or, if we like we could even add it
to all recipes via the dpkg class).
- For recipes that inherit native.bbclass, bitbake generates a new bitbake
target with suffix `-native`. Recipes can DEPEND on those `-native` packages.
My use case that made me develop this is goreleaser, a build tool
for which I have a bitbake recipe. If I want to crosscompile, I need it
for the host architecture. By DEPENDing on `goreleaser-native`, I can
then add `goreleaser:native` to the build dependencies in my control file
(the `:native` makes dpkg-buildpackage choose the right architecture).
- When building the recipe, the only change is that we set PACKAGE_ARCH=HOST_ARCH.
In addition we have the override `class-native`, which is set when building
the native variant of the recipe and lets us make conditional changes to
what is built.
Some caveats/notes:
- Both "normal" target arch and `-native` builds generate ARCH=all packages
and source packages. So there is potential duplication. In theory those
packages should be identical, but we currently don't have any way of knowing.
This is in part due to using shared isar-apt to transfer packages between
jobs, where the last job to push a package always wins.
My earlier RFC on removing (that use of) isar-apt and explicitly
transferring dependent packages might help here. In that case we have full
control of what packages are provided, and can detect such duplicates.
- I'm changing the default overrides to include PACKAGE_ARCH instead of
DISTRO_ARCH. Maybe this is how it always should have been?
- This is currently only for "native", but I think we can simply duplicate
the pattern to also support compat arch packages.
- Using PN in recipes can become tricky. For example, I sometimes see the
pattern of setting SRC_URI="git://github.com/${PN}/${PN}.git".
This would break when building the native variant, as this will then
have a different PN. Personally, I don't think this is a big problem.
Using ${PN} in SRC_URI may not be a good idea anyways, and if we really
need a variable, there is BPN, which does not have the -native suffix.
- We currently don't have a use case for this in meta-isar. But maybe we
can come up with a good example.
I'd like to try if this approach works for the other use cases we have.
Adriaan
PS: If you'd like some more examples of the BBCLASSEXTEND feature, have
a look at the SDK generation, which has been refactored in that way.
---
meta/classes/native.bbclass | 13 +++++++++++++
meta/conf/bitbake.conf | 5 +++--
2 files changed, 16 insertions(+), 2 deletions(-)
create mode 100644 meta/classes/native.bbclass
diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclass
new file mode 100644
index 00000000..896c8a06
--- /dev/null
+++ b/meta/classes/native.bbclass
@@ -0,0 +1,13 @@
+BBCLASSEXTEND = "native"
+BPN = "${PN}"
+
+python native_virtclass_handler() {
+ pn = e.data.getVar('PN')
+ if pn.endswith('-native'):
+ e.data.setVar('BPN', pn[:-len('-native')])
+ e.data.appendVar('OVERRIDES', ':class-native')
+}
+addhandler native_virtclass_handler
+native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
+
+PACKAGE_ARCH_class-native = "${HOST_ARCH}"
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 98412e02..ef962fc7 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -67,8 +67,8 @@ KERNEL_FILE_mipsel ?= "vmlinux"
KERNEL_FILE_riscv64 ?= "vmlinux"
KERNEL_FILE_arm64 ?= "vmlinux"
-OVERRIDES = "${DISTRO_ARCH}:${COMPAT_OVERRIDE}:${MACHINE}:${DISTRO}:${BASE_DISTRO_CODENAME}:forcevariable"
-FILESOVERRIDES = "${DISTRO_ARCH}:${MACHINE}"
+OVERRIDES = "${PACKAGE_ARCH}:${COMPAT_OVERRIDE}:${MACHINE}:${DISTRO}:${BASE_DISTRO_CODENAME}:forcevariable"
+FILESOVERRIDES = "${PACKAGE_ARCH}:${MACHINE}"
COMPAT_OVERRIDE = "${@'compat-arch' if d.getVar('ISAR_ENABLE_COMPAT_ARCH') == '1' else ''}"
# Setting default QEMU_ARCH variables for different DISTRO_ARCH:
@@ -81,6 +81,7 @@ QEMU_ARCH_riscv64 = "riscv64"
# Codename of the repository created by the caching class
DEBDISTRONAME ?= "isar"
+NATIVELSBSTRING ?= "isarnative"
# Strings used in sstate signature files
TARGET_VENDOR = ""
--
2.30.2
next reply other threads:[~2023-01-17 18:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 18:03 Adriaan Schmidt [this message]
2023-01-18 6:09 ` Jan Kiszka
2023-01-28 5:31 ` Moessbauer, Felix
2023-01-28 5:09 ` Moessbauer, Felix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117180358.1499566-1-adriaan.schmidt@siemens.com \
--to=adriaan.schmidt@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=jan.kiszka@siemens.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox