diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-06-10 15:53:27 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-08-12 10:05:11 +0100 |
| commit | bdb5e99854c76f31d5463f55a657d40098a0743a (patch) | |
| tree | 1b77d9e688cc1ab0002695b84a50e80ceda37494 /meta/classes-recipe | |
| parent | 7c9a1f20f1f07d8a946f300878e680103d70ac84 (diff) | |
| download | poky-bdb5e99854c76f31d5463f55a657d40098a0743a.tar.gz | |
classes/lib: Switch classextend to use new filter API
Currently, class extensions are implmented using shadow variables and
access indirection which is horribly ineffient and ugly.
Switch to using the new bitbake filter API, which allows a translation
of the variable before the expanded value is returned. This allows us
to drop the shadow variable accesses. It also avoids the need to iterate
PACKAGES and make many variable changes since a filter against RDEPENDS
applies to RDEPENDS:${PN} and all of it's other overridden values.
Since data expansion happens at access, it also avoids many of the race
conditions this code has tranditionally been plagued with.
(From OE-Core rev: 24a9858a8927e91d499ee342ed93a0dbb44d83bc)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
| -rw-r--r-- | meta/classes-recipe/native.bbclass | 39 | ||||
| -rw-r--r-- | meta/classes-recipe/nativesdk.bbclass | 11 | ||||
| -rw-r--r-- | meta/classes-recipe/toolchain-scripts.bbclass | 4 |
3 files changed, 17 insertions, 37 deletions
diff --git a/meta/classes-recipe/native.bbclass b/meta/classes-recipe/native.bbclass index 625975a694..7d1fe343fa 100644 --- a/meta/classes-recipe/native.bbclass +++ b/meta/classes-recipe/native.bbclass | |||
| @@ -138,38 +138,18 @@ python native_virtclass_handler () { | |||
| 138 | if "native" not in classextend: | 138 | if "native" not in classextend: |
| 139 | return | 139 | return |
| 140 | 140 | ||
| 141 | def map_dependencies(varname, d, suffix = "", selfref=True, regex=False): | 141 | def map_dependencies(varname, d, suffix, selfref=True, regex=False): |
| 142 | if suffix: | 142 | varname = varname + ":" + suffix |
| 143 | varname = varname + ":" + suffix | ||
| 144 | deps = d.getVar(varname) | ||
| 145 | if not deps: | ||
| 146 | return | ||
| 147 | deps = bb.utils.explode_deps(deps) | ||
| 148 | newdeps = [] | ||
| 149 | for dep in deps: | ||
| 150 | if regex and dep.startswith("^") and dep.endswith("$"): | ||
| 151 | newdeps.append(dep[:-1].replace(pn, bpn) + "-native$") | ||
| 152 | elif dep == pn: | ||
| 153 | if not selfref: | ||
| 154 | continue | ||
| 155 | newdeps.append(dep) | ||
| 156 | elif "-cross-" in dep: | ||
| 157 | newdeps.append(dep.replace("-cross", "-native")) | ||
| 158 | elif not dep.endswith("-native"): | ||
| 159 | # Replace ${PN} with ${BPN} in the dependency to make sure | ||
| 160 | # dependencies on, e.g., ${PN}-foo become ${BPN}-foo-native | ||
| 161 | # rather than ${BPN}-native-foo-native. | ||
| 162 | newdeps.append(dep.replace(pn, bpn) + "-native") | ||
| 163 | else: | ||
| 164 | newdeps.append(dep) | ||
| 165 | output_varname = varname | ||
| 166 | # Handle ${PN}-xxx -> ${BPN}-xxx-native | 143 | # Handle ${PN}-xxx -> ${BPN}-xxx-native |
| 167 | if suffix != "${PN}" and "${PN}" in suffix: | 144 | if suffix != "${PN}" and "${PN}" in suffix: |
| 168 | output_varname = varname.replace("${PN}", "${BPN}") + "-native" | 145 | output_varname = varname.replace("${PN}", "${BPN}") + "-native" |
| 169 | d.renameVar(varname, output_varname) | 146 | d.renameVar(varname, output_varname) |
| 170 | d.setVar(output_varname, " ".join(newdeps)) | ||
| 171 | 147 | ||
| 172 | map_dependencies("DEPENDS", e.data, selfref=False) | 148 | d.setVarFilter("DEPENDS", "native_filter(val, '" + pn + "', '" + bpn + "', selfref=False)") |
| 149 | |||
| 150 | for varname in ["RDEPENDS", "RRECOMMENDS", "RSUGGESTS", "RPROVIDES", "RREPLACES"]: | ||
| 151 | d.setVarFilter(varname, "native_filter(val, '" + pn + "', '" + bpn + "')") | ||
| 152 | |||
| 173 | # We need to handle things like ${@bb.utils.contains('PTEST_ENABLED', '1', '${PN}-ptest', '', d)} | 153 | # We need to handle things like ${@bb.utils.contains('PTEST_ENABLED', '1', '${PN}-ptest', '', d)} |
| 174 | # and not pass ${PN}-test since in the native case it would be ignored. This does mean we ignore | 154 | # and not pass ${PN}-test since in the native case it would be ignored. This does mean we ignore |
| 175 | # anonymous python derived PACKAGES entries. | 155 | # anonymous python derived PACKAGES entries. |
| @@ -181,8 +161,9 @@ python native_virtclass_handler () { | |||
| 181 | map_dependencies("RSUGGESTS", e.data, pkg) | 161 | map_dependencies("RSUGGESTS", e.data, pkg) |
| 182 | map_dependencies("RPROVIDES", e.data, pkg) | 162 | map_dependencies("RPROVIDES", e.data, pkg) |
| 183 | map_dependencies("RREPLACES", e.data, pkg) | 163 | map_dependencies("RREPLACES", e.data, pkg) |
| 184 | map_dependencies("PACKAGES", e.data) | 164 | |
| 185 | map_dependencies("PACKAGES_DYNAMIC", e.data, regex=True) | 165 | d.setVarFilter("PACKAGES", "native_filter(val, '" + pn + "', '" + bpn + "')") |
| 166 | d.setVarFilter("PACKAGES_DYNAMIC", "native_filter(val, '" + pn + "', '" + bpn + "', regex=True)") | ||
| 186 | 167 | ||
| 187 | provides = e.data.getVar("PROVIDES") | 168 | provides = e.data.getVar("PROVIDES") |
| 188 | nprovides = [] | 169 | nprovides = [] |
diff --git a/meta/classes-recipe/nativesdk.bbclass b/meta/classes-recipe/nativesdk.bbclass index 7ecb4c12c1..9838d5a54b 100644 --- a/meta/classes-recipe/nativesdk.bbclass +++ b/meta/classes-recipe/nativesdk.bbclass | |||
| @@ -99,15 +99,14 @@ python () { | |||
| 99 | 99 | ||
| 100 | import oe.classextend | 100 | import oe.classextend |
| 101 | 101 | ||
| 102 | clsextend = oe.classextend.NativesdkClassExtender("nativesdk", d) | 102 | clsextend = oe.classextend.ClassExtender("nativesdk", [], d) |
| 103 | clsextend.rename_packages() | ||
| 104 | clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split()) | 103 | clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split()) |
| 105 | 104 | ||
| 106 | clsextend.map_depends_variable("DEPENDS") | 105 | clsextend.set_filter("DEPENDS", deps=True) |
| 107 | clsextend.map_depends_variable("PACKAGE_WRITE_DEPS") | 106 | clsextend.set_filter("PACKAGE_WRITE_DEPS", deps=False) |
| 108 | clsextend.map_packagevars() | 107 | clsextend.map_packagevars() |
| 109 | clsextend.map_variable("PROVIDES") | 108 | clsextend.set_filter("PROVIDES", deps=False) |
| 110 | clsextend.map_regexp_variable("PACKAGES_DYNAMIC") | 109 | |
| 111 | d.setVar("LIBCEXTENSION", "") | 110 | d.setVar("LIBCEXTENSION", "") |
| 112 | d.setVar("ABIEXTENSION", "") | 111 | d.setVar("ABIEXTENSION", "") |
| 113 | } | 112 | } |
diff --git a/meta/classes-recipe/toolchain-scripts.bbclass b/meta/classes-recipe/toolchain-scripts.bbclass index 5874a48af8..5d28df845b 100644 --- a/meta/classes-recipe/toolchain-scripts.bbclass +++ b/meta/classes-recipe/toolchain-scripts.bbclass | |||
| @@ -238,11 +238,11 @@ toolchain_create_sdk_siteconfig () { | |||
| 238 | python __anonymous () { | 238 | python __anonymous () { |
| 239 | import oe.classextend | 239 | import oe.classextend |
| 240 | deps = "" | 240 | deps = "" |
| 241 | prefixes = (d.getVar("MULTILIB_VARIANTS") or "").split() | ||
| 241 | for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split(): | 242 | for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split(): |
| 242 | deps += " %s:do_populate_sysroot" % dep | 243 | deps += " %s:do_populate_sysroot" % dep |
| 243 | for variant in (d.getVar('MULTILIB_VARIANTS') or "").split(): | 244 | for variant in (d.getVar('MULTILIB_VARIANTS') or "").split(): |
| 244 | clsextend = oe.classextend.ClassExtender(variant, d) | 245 | newdep = oe.classextend.add_suffix(dep, variant, prefixes) |
| 245 | newdep = clsextend.extend_name(dep) | ||
| 246 | deps += " %s:do_populate_sysroot" % newdep | 246 | deps += " %s:do_populate_sysroot" % newdep |
| 247 | d.appendVarFlag('do_configure', 'depends', deps) | 247 | d.appendVarFlag('do_configure', 'depends', deps) |
| 248 | } | 248 | } |
