blob: fc7422c5d7a196270d54268cff6c6ceae850fe2a [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# We want native packages to be relocatable
2inherit relocatable
3
4# Native packages are built indirectly via dependency,
5# no need for them to be a direct target of 'world'
6EXCLUDE_FROM_WORLD = "1"
7
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008PACKAGE_ARCH = "${BUILD_ARCH}"
9
10# used by cmake class
11OECMAKE_RPATH = "${libdir}"
Patrick Williams213cb262021-08-07 19:21:33 -050012OECMAKE_RPATH:class-native = "${libdir}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014TARGET_ARCH = "${BUILD_ARCH}"
15TARGET_OS = "${BUILD_OS}"
16TARGET_VENDOR = "${BUILD_VENDOR}"
17TARGET_PREFIX = "${BUILD_PREFIX}"
18TARGET_CC_ARCH = "${BUILD_CC_ARCH}"
19TARGET_LD_ARCH = "${BUILD_LD_ARCH}"
20TARGET_AS_ARCH = "${BUILD_AS_ARCH}"
21TARGET_CPPFLAGS = "${BUILD_CPPFLAGS}"
22TARGET_CFLAGS = "${BUILD_CFLAGS}"
23TARGET_CXXFLAGS = "${BUILD_CXXFLAGS}"
24TARGET_LDFLAGS = "${BUILD_LDFLAGS}"
25TARGET_FPU = ""
26
27HOST_ARCH = "${BUILD_ARCH}"
28HOST_OS = "${BUILD_OS}"
29HOST_VENDOR = "${BUILD_VENDOR}"
30HOST_PREFIX = "${BUILD_PREFIX}"
31HOST_CC_ARCH = "${BUILD_CC_ARCH}"
32HOST_LD_ARCH = "${BUILD_LD_ARCH}"
33HOST_AS_ARCH = "${BUILD_AS_ARCH}"
34
35CPPFLAGS = "${BUILD_CPPFLAGS}"
36CFLAGS = "${BUILD_CFLAGS}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050037CXXFLAGS = "${BUILD_CXXFLAGS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038LDFLAGS = "${BUILD_LDFLAGS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
40STAGING_BINDIR = "${STAGING_BINDIR_NATIVE}"
41STAGING_BINDIR_CROSS = "${STAGING_BINDIR_NATIVE}"
42
43# native pkg doesn't need the TOOLCHAIN_OPTIONS.
44TOOLCHAIN_OPTIONS = ""
45
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046# Don't build ptest natively
47PTEST_ENABLED = "0"
48
49# Don't use site files for native builds
50export CONFIG_SITE = "${COREBASE}/meta/site/native"
51
52# set the compiler as well. It could have been set to something else
53export CC = "${BUILD_CC}"
54export CXX = "${BUILD_CXX}"
55export FC = "${BUILD_FC}"
56export CPP = "${BUILD_CPP}"
57export LD = "${BUILD_LD}"
58export CCLD = "${BUILD_CCLD}"
59export AR = "${BUILD_AR}"
60export AS = "${BUILD_AS}"
61export RANLIB = "${BUILD_RANLIB}"
62export STRIP = "${BUILD_STRIP}"
63export NM = "${BUILD_NM}"
64
65# Path prefixes
66base_prefix = "${STAGING_DIR_NATIVE}"
67prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
68exec_prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
69
70bindir = "${STAGING_BINDIR_NATIVE}"
71sbindir = "${STAGING_SBINDIR_NATIVE}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080072base_libdir = "${STAGING_LIBDIR_NATIVE}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073libdir = "${STAGING_LIBDIR_NATIVE}"
74includedir = "${STAGING_INCDIR_NATIVE}"
75sysconfdir = "${STAGING_ETCDIR_NATIVE}"
76datadir = "${STAGING_DATADIR_NATIVE}"
77
78baselib = "lib"
79
Patrick Williamsc0f7c042017-02-23 20:41:17 -060080export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir} /lib /lib64 /usr/lib /usr/lib64"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081
82NATIVE_PACKAGE_PATH_SUFFIX ?= ""
83bindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Brad Bishopc342db32019-05-15 21:57:59 -040084sbindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080085base_libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
87libexecdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
88
89do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_NATIVE}/"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050090do_populate_sysroot[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091
92# Since we actually install these into situ there is no staging prefix
93STAGING_DIR_HOST = ""
94STAGING_DIR_TARGET = ""
95PKG_CONFIG_DIR = "${libdir}/pkgconfig"
96
97EXTRA_NATIVE_PKGCONFIG_PATH ?= ""
98PKG_CONFIG_PATH .= "${EXTRA_NATIVE_PKGCONFIG_PATH}"
99PKG_CONFIG_SYSROOT_DIR = ""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500100PKG_CONFIG_SYSTEM_LIBRARY_PATH[unexport] = "1"
101PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500103# we dont want libc-*libc to kick in for native recipes
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104LIBCOVERRIDE = ""
105CLASSOVERRIDE = "class-native"
106MACHINEOVERRIDES = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107MACHINE_FEATURES = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108
Patrick Williams213cb262021-08-07 19:21:33 -0500109PATH:prepend = "${COREBASE}/scripts/native-intercept:"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500111# This class encodes staging paths into its scripts data so can only be
112# reused if we manipulate the paths.
113SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}"
114
Brad Bishop19323692019-04-05 15:28:33 -0400115# No strip sysroot when DEBUG_BUILD is enabled
116INHIBIT_SYSROOT_STRIP ?= "${@oe.utils.vartrue('DEBUG_BUILD', '1', '', d)}"
117
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118python native_virtclass_handler () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500119 pn = e.data.getVar("PN")
120 if not pn.endswith("-native"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121 return
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700122 bpn = e.data.getVar("BPN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124 # Set features here to prevent appends and distro features backfill
125 # from modifying native distro features
126 features = set(d.getVar("DISTRO_FEATURES_NATIVE").split())
127 filtered = set(bb.utils.filter("DISTRO_FEATURES", d.getVar("DISTRO_FEATURES_FILTER_NATIVE"), d).split())
128 d.setVar("DISTRO_FEATURES", " ".join(sorted(features | filtered)))
129
130 classextend = e.data.getVar('BBCLASSEXTEND') or ""
131 if "native" not in classextend:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132 return
133
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600134 def map_dependencies(varname, d, suffix = "", selfref=True):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135 if suffix:
Patrick Williams213cb262021-08-07 19:21:33 -0500136 varname = varname + ":" + suffix
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137 deps = d.getVar(varname)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138 if not deps:
139 return
140 deps = bb.utils.explode_deps(deps)
141 newdeps = []
142 for dep in deps:
143 if dep == pn:
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600144 if not selfref:
145 continue
146 newdeps.append(dep)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147 elif "-cross-" in dep:
148 newdeps.append(dep.replace("-cross", "-native"))
149 elif not dep.endswith("-native"):
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700150 # Replace ${PN} with ${BPN} in the dependency to make sure
151 # dependencies on, e.g., ${PN}-foo become ${BPN}-foo-native
152 # rather than ${BPN}-native-foo-native.
153 newdeps.append(dep.replace(pn, bpn) + "-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154 else:
155 newdeps.append(dep)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600156 d.setVar(varname, " ".join(newdeps), parsing=True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600158 map_dependencies("DEPENDS", e.data, selfref=False)
159 for pkg in e.data.getVar("PACKAGES", False).split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160 map_dependencies("RDEPENDS", e.data, pkg)
161 map_dependencies("RRECOMMENDS", e.data, pkg)
162 map_dependencies("RSUGGESTS", e.data, pkg)
163 map_dependencies("RPROVIDES", e.data, pkg)
164 map_dependencies("RREPLACES", e.data, pkg)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600165 map_dependencies("PACKAGES", e.data)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167 provides = e.data.getVar("PROVIDES")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 nprovides = []
169 for prov in provides.split():
170 if prov.find(pn) != -1:
171 nprovides.append(prov)
172 elif not prov.endswith("-native"):
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700173 nprovides.append(prov + "-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174 else:
175 nprovides.append(prov)
176 e.data.setVar("PROVIDES", ' '.join(nprovides))
177
178
179}
180
181addhandler native_virtclass_handler
182native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
183
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500184python do_addto_recipe_sysroot () {
185 bb.build.exec_func("extend_recipe_sysroot", d)
186}
187addtask addto_recipe_sysroot after do_populate_sysroot
Andrew Geissler82c905d2020-04-13 13:39:40 -0500188do_addto_recipe_sysroot[deptask] = "do_populate_sysroot"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500189
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500190inherit nopackages
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191
192do_packagedata[stamp-extra-info] = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193
194USE_NLS = "no"
Brad Bishop19323692019-04-05 15:28:33 -0400195
196RECIPERDEPTASK = "do_populate_sysroot"
197do_populate_sysroot[rdeptask] = "${RECIPERDEPTASK}"
Andrew Geissler595f6302022-01-24 19:11:47 +0000198
199#
200# Native task outputs are directly run on the target (host) system after being
201# built. Even if the output of this recipe doesn't change, a change in one of
202# its dependencies may cause a change in the output it generates (e.g. rpm
203# output depends on the output of its dependent zstd library).
204#
205# This can cause poor interactions with hash equivalence, since this recipes
206# output-changing dependency is "hidden" and downstream task only see that this
207# recipe has the same outhash and therefore is equivalent. This can result in
208# different output in different cases.
209#
210# To resolve this, unhide the output-changing dependency by adding its unihash
211# to this tasks outhash calculation. Unfortunately, don't know specifically
212# know which dependencies are output-changing, so we have to add all of them.
213#
214python native_add_do_populate_sysroot_deps () {
215 current_task = "do_" + d.getVar("BB_CURRENTTASK")
216 if current_task != "do_populate_sysroot":
217 return
218
219 taskdepdata = d.getVar("BB_TASKDEPDATA", False)
220 pn = d.getVar("PN")
221 deps = {
222 dep[0]:dep[6] for dep in taskdepdata.values() if
223 dep[1] == current_task and dep[0] != pn
224 }
225
226 d.setVar("HASHEQUIV_EXTRA_SIGDATA", "\n".join("%s: %s" % (k, deps[k]) for k in sorted(deps.keys())))
227}
228SSTATECREATEFUNCS += "native_add_do_populate_sysroot_deps"