blob: 5a273cdebba75fe0f30c40f1f011f9356cb43e95 [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 = ""
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050026TUNE_FEATURES = ""
27ABIEXTENSION = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028
29HOST_ARCH = "${BUILD_ARCH}"
30HOST_OS = "${BUILD_OS}"
31HOST_VENDOR = "${BUILD_VENDOR}"
32HOST_PREFIX = "${BUILD_PREFIX}"
33HOST_CC_ARCH = "${BUILD_CC_ARCH}"
34HOST_LD_ARCH = "${BUILD_LD_ARCH}"
35HOST_AS_ARCH = "${BUILD_AS_ARCH}"
36
37CPPFLAGS = "${BUILD_CPPFLAGS}"
38CFLAGS = "${BUILD_CFLAGS}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039CXXFLAGS = "${BUILD_CXXFLAGS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040LDFLAGS = "${BUILD_LDFLAGS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
42STAGING_BINDIR = "${STAGING_BINDIR_NATIVE}"
43STAGING_BINDIR_CROSS = "${STAGING_BINDIR_NATIVE}"
44
45# native pkg doesn't need the TOOLCHAIN_OPTIONS.
46TOOLCHAIN_OPTIONS = ""
47
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048# Don't build ptest natively
49PTEST_ENABLED = "0"
50
51# Don't use site files for native builds
52export CONFIG_SITE = "${COREBASE}/meta/site/native"
53
54# set the compiler as well. It could have been set to something else
55export CC = "${BUILD_CC}"
56export CXX = "${BUILD_CXX}"
57export FC = "${BUILD_FC}"
58export CPP = "${BUILD_CPP}"
59export LD = "${BUILD_LD}"
60export CCLD = "${BUILD_CCLD}"
61export AR = "${BUILD_AR}"
62export AS = "${BUILD_AS}"
63export RANLIB = "${BUILD_RANLIB}"
64export STRIP = "${BUILD_STRIP}"
65export NM = "${BUILD_NM}"
66
67# Path prefixes
68base_prefix = "${STAGING_DIR_NATIVE}"
69prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
70exec_prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
71
72bindir = "${STAGING_BINDIR_NATIVE}"
73sbindir = "${STAGING_SBINDIR_NATIVE}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080074base_libdir = "${STAGING_LIBDIR_NATIVE}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075libdir = "${STAGING_LIBDIR_NATIVE}"
76includedir = "${STAGING_INCDIR_NATIVE}"
77sysconfdir = "${STAGING_ETCDIR_NATIVE}"
78datadir = "${STAGING_DATADIR_NATIVE}"
79
80baselib = "lib"
81
Patrick Williamsc0f7c042017-02-23 20:41:17 -060082export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir} /lib /lib64 /usr/lib /usr/lib64"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083
84NATIVE_PACKAGE_PATH_SUFFIX ?= ""
85bindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Brad Bishopc342db32019-05-15 21:57:59 -040086sbindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080087base_libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
89libexecdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
90
91do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_NATIVE}/"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050092do_populate_sysroot[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093
94# Since we actually install these into situ there is no staging prefix
95STAGING_DIR_HOST = ""
96STAGING_DIR_TARGET = ""
97PKG_CONFIG_DIR = "${libdir}/pkgconfig"
98
99EXTRA_NATIVE_PKGCONFIG_PATH ?= ""
100PKG_CONFIG_PATH .= "${EXTRA_NATIVE_PKGCONFIG_PATH}"
101PKG_CONFIG_SYSROOT_DIR = ""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500102PKG_CONFIG_SYSTEM_LIBRARY_PATH[unexport] = "1"
103PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500105# we dont want libc-*libc to kick in for native recipes
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500106LIBCOVERRIDE = ""
107CLASSOVERRIDE = "class-native"
108MACHINEOVERRIDES = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500109MACHINE_FEATURES = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110
Patrick Williams213cb262021-08-07 19:21:33 -0500111PATH:prepend = "${COREBASE}/scripts/native-intercept:"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113# This class encodes staging paths into its scripts data so can only be
114# reused if we manipulate the paths.
115SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}"
116
Brad Bishop19323692019-04-05 15:28:33 -0400117# No strip sysroot when DEBUG_BUILD is enabled
118INHIBIT_SYSROOT_STRIP ?= "${@oe.utils.vartrue('DEBUG_BUILD', '1', '', d)}"
119
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120python native_virtclass_handler () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500121 pn = e.data.getVar("PN")
122 if not pn.endswith("-native"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123 return
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700124 bpn = e.data.getVar("BPN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500126 # Set features here to prevent appends and distro features backfill
127 # from modifying native distro features
128 features = set(d.getVar("DISTRO_FEATURES_NATIVE").split())
129 filtered = set(bb.utils.filter("DISTRO_FEATURES", d.getVar("DISTRO_FEATURES_FILTER_NATIVE"), d).split())
130 d.setVar("DISTRO_FEATURES", " ".join(sorted(features | filtered)))
131
132 classextend = e.data.getVar('BBCLASSEXTEND') or ""
133 if "native" not in classextend:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134 return
135
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600136 def map_dependencies(varname, d, suffix = "", selfref=True):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500137 if suffix:
Patrick Williams213cb262021-08-07 19:21:33 -0500138 varname = varname + ":" + suffix
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500139 deps = d.getVar(varname)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140 if not deps:
141 return
142 deps = bb.utils.explode_deps(deps)
143 newdeps = []
144 for dep in deps:
145 if dep == pn:
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600146 if not selfref:
147 continue
148 newdeps.append(dep)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149 elif "-cross-" in dep:
150 newdeps.append(dep.replace("-cross", "-native"))
151 elif not dep.endswith("-native"):
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700152 # Replace ${PN} with ${BPN} in the dependency to make sure
153 # dependencies on, e.g., ${PN}-foo become ${BPN}-foo-native
154 # rather than ${BPN}-native-foo-native.
155 newdeps.append(dep.replace(pn, bpn) + "-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156 else:
157 newdeps.append(dep)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600158 d.setVar(varname, " ".join(newdeps), parsing=True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600160 map_dependencies("DEPENDS", e.data, selfref=False)
161 for pkg in e.data.getVar("PACKAGES", False).split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162 map_dependencies("RDEPENDS", e.data, pkg)
163 map_dependencies("RRECOMMENDS", e.data, pkg)
164 map_dependencies("RSUGGESTS", e.data, pkg)
165 map_dependencies("RPROVIDES", e.data, pkg)
166 map_dependencies("RREPLACES", e.data, pkg)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600167 map_dependencies("PACKAGES", e.data)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500169 provides = e.data.getVar("PROVIDES")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170 nprovides = []
171 for prov in provides.split():
172 if prov.find(pn) != -1:
173 nprovides.append(prov)
174 elif not prov.endswith("-native"):
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700175 nprovides.append(prov + "-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176 else:
177 nprovides.append(prov)
178 e.data.setVar("PROVIDES", ' '.join(nprovides))
179
180
181}
182
183addhandler native_virtclass_handler
184native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
185
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500186python do_addto_recipe_sysroot () {
187 bb.build.exec_func("extend_recipe_sysroot", d)
188}
189addtask addto_recipe_sysroot after do_populate_sysroot
Andrew Geissler82c905d2020-04-13 13:39:40 -0500190do_addto_recipe_sysroot[deptask] = "do_populate_sysroot"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500191
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500192inherit nopackages
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193
194do_packagedata[stamp-extra-info] = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500195
196USE_NLS = "no"
Brad Bishop19323692019-04-05 15:28:33 -0400197
198RECIPERDEPTASK = "do_populate_sysroot"
199do_populate_sysroot[rdeptask] = "${RECIPERDEPTASK}"
Andrew Geissler595f6302022-01-24 19:11:47 +0000200
201#
202# Native task outputs are directly run on the target (host) system after being
203# built. Even if the output of this recipe doesn't change, a change in one of
204# its dependencies may cause a change in the output it generates (e.g. rpm
205# output depends on the output of its dependent zstd library).
206#
207# This can cause poor interactions with hash equivalence, since this recipes
208# output-changing dependency is "hidden" and downstream task only see that this
209# recipe has the same outhash and therefore is equivalent. This can result in
210# different output in different cases.
211#
212# To resolve this, unhide the output-changing dependency by adding its unihash
213# to this tasks outhash calculation. Unfortunately, don't know specifically
214# know which dependencies are output-changing, so we have to add all of them.
215#
216python native_add_do_populate_sysroot_deps () {
217 current_task = "do_" + d.getVar("BB_CURRENTTASK")
218 if current_task != "do_populate_sysroot":
219 return
220
221 taskdepdata = d.getVar("BB_TASKDEPDATA", False)
222 pn = d.getVar("PN")
223 deps = {
224 dep[0]:dep[6] for dep in taskdepdata.values() if
225 dep[1] == current_task and dep[0] != pn
226 }
227
228 d.setVar("HASHEQUIV_EXTRA_SIGDATA", "\n".join("%s: %s" % (k, deps[k]) for k in sorted(deps.keys())))
229}
230SSTATECREATEFUNCS += "native_add_do_populate_sysroot_deps"