blob: 08106e345ca0181f637a8c8fc842a6e61fa67280 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# 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
8PACKAGES = ""
9PACKAGES_class-native = ""
10PACKAGES_DYNAMIC = ""
11PACKAGES_DYNAMIC_class-native = ""
12PACKAGE_ARCH = "${BUILD_ARCH}"
13
14# used by cmake class
15OECMAKE_RPATH = "${libdir}"
16OECMAKE_RPATH_class-native = "${libdir}"
17
18# When this class has packaging enabled, setting
19# RPROVIDES becomes unnecessary.
20RPROVIDES = "${PN}"
21
22TARGET_ARCH = "${BUILD_ARCH}"
23TARGET_OS = "${BUILD_OS}"
24TARGET_VENDOR = "${BUILD_VENDOR}"
25TARGET_PREFIX = "${BUILD_PREFIX}"
26TARGET_CC_ARCH = "${BUILD_CC_ARCH}"
27TARGET_LD_ARCH = "${BUILD_LD_ARCH}"
28TARGET_AS_ARCH = "${BUILD_AS_ARCH}"
29TARGET_CPPFLAGS = "${BUILD_CPPFLAGS}"
30TARGET_CFLAGS = "${BUILD_CFLAGS}"
31TARGET_CXXFLAGS = "${BUILD_CXXFLAGS}"
32TARGET_LDFLAGS = "${BUILD_LDFLAGS}"
33TARGET_FPU = ""
34
35HOST_ARCH = "${BUILD_ARCH}"
36HOST_OS = "${BUILD_OS}"
37HOST_VENDOR = "${BUILD_VENDOR}"
38HOST_PREFIX = "${BUILD_PREFIX}"
39HOST_CC_ARCH = "${BUILD_CC_ARCH}"
40HOST_LD_ARCH = "${BUILD_LD_ARCH}"
41HOST_AS_ARCH = "${BUILD_AS_ARCH}"
42
43CPPFLAGS = "${BUILD_CPPFLAGS}"
44CFLAGS = "${BUILD_CFLAGS}"
45CXXFLAGS = "${BUILD_CXXFLAGS}"
46LDFLAGS = "${BUILD_LDFLAGS}"
47
48STAGING_BINDIR = "${STAGING_BINDIR_NATIVE}"
49STAGING_BINDIR_CROSS = "${STAGING_BINDIR_NATIVE}"
50
51# native pkg doesn't need the TOOLCHAIN_OPTIONS.
52TOOLCHAIN_OPTIONS = ""
53
54# Don't build ptest natively
55PTEST_ENABLED = "0"
56
57# Don't use site files for native builds
58export CONFIG_SITE = "${COREBASE}/meta/site/native"
59
60# set the compiler as well. It could have been set to something else
61export CC = "${BUILD_CC}"
62export CXX = "${BUILD_CXX}"
63export FC = "${BUILD_FC}"
64export CPP = "${BUILD_CPP}"
65export LD = "${BUILD_LD}"
66export CCLD = "${BUILD_CCLD}"
67export AR = "${BUILD_AR}"
68export AS = "${BUILD_AS}"
69export RANLIB = "${BUILD_RANLIB}"
70export STRIP = "${BUILD_STRIP}"
71export NM = "${BUILD_NM}"
72
73# Path prefixes
74base_prefix = "${STAGING_DIR_NATIVE}"
75prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
76exec_prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
77
78bindir = "${STAGING_BINDIR_NATIVE}"
79sbindir = "${STAGING_SBINDIR_NATIVE}"
80base_libdir = "${STAGING_LIBDIR_NATIVE}"
81libdir = "${STAGING_LIBDIR_NATIVE}"
82includedir = "${STAGING_INCDIR_NATIVE}"
83sysconfdir = "${STAGING_ETCDIR_NATIVE}"
84datadir = "${STAGING_DATADIR_NATIVE}"
85
86baselib = "lib"
87
88export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir} /lib /lib64 /usr/lib /usr/lib64"
89
90NATIVE_PACKAGE_PATH_SUFFIX ?= ""
91bindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
92sbindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
93base_libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
94libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
95libexecdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
96
97do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_NATIVE}/"
98do_populate_sysroot[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/${PN}"
99
100# Since we actually install these into situ there is no staging prefix
101STAGING_DIR_HOST = ""
102STAGING_DIR_TARGET = ""
103PKG_CONFIG_DIR = "${libdir}/pkgconfig"
104
105EXTRA_NATIVE_PKGCONFIG_PATH ?= ""
106PKG_CONFIG_PATH .= "${EXTRA_NATIVE_PKGCONFIG_PATH}"
107PKG_CONFIG_SYSROOT_DIR = ""
108PKG_CONFIG_SYSTEM_LIBRARY_PATH[unexport] = "1"
109PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1"
110
111# we dont want libc-*libc to kick in for native recipes
112LIBCOVERRIDE = ""
113CLASSOVERRIDE = "class-native"
114MACHINEOVERRIDES = ""
115MACHINE_FEATURES = ""
116
117PATH_prepend = "${COREBASE}/scripts/native-intercept:"
118
119# This class encodes staging paths into its scripts data so can only be
120# reused if we manipulate the paths.
121SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}"
122
123# No strip sysroot when DEBUG_BUILD is enabled
124INHIBIT_SYSROOT_STRIP ?= "${@oe.utils.vartrue('DEBUG_BUILD', '1', '', d)}"
125
126python native_virtclass_handler () {
127 pn = e.data.getVar("PN")
128 if not pn.endswith("-native"):
129 return
130
131 # Set features here to prevent appends and distro features backfill
132 # from modifying native distro features
133 features = set(d.getVar("DISTRO_FEATURES_NATIVE").split())
134 filtered = set(bb.utils.filter("DISTRO_FEATURES", d.getVar("DISTRO_FEATURES_FILTER_NATIVE"), d).split())
135 d.setVar("DISTRO_FEATURES", " ".join(sorted(features | filtered)))
136
137 classextend = e.data.getVar('BBCLASSEXTEND') or ""
138 if "native" not in classextend:
139 return
140
141 def map_dependencies(varname, d, suffix = ""):
142 if 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 dep == pn:
151 continue
152 elif "-cross-" in dep:
153 newdeps.append(dep.replace("-cross", "-native"))
154 elif not dep.endswith("-native"):
155 newdeps.append(dep + "-native")
156 else:
157 newdeps.append(dep)
158 d.setVar(varname, " ".join(newdeps))
159
160 map_dependencies("DEPENDS", e.data)
161 for pkg in [e.data.getVar("PN"), "", "${PN}"]:
162 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)
167
168 provides = e.data.getVar("PROVIDES")
169 nprovides = []
170 for prov in provides.split():
171 if prov.find(pn) != -1:
172 nprovides.append(prov)
173 elif not prov.endswith("-native"):
174 nprovides.append(prov.replace(prov, prov + "-native"))
175 else:
176 nprovides.append(prov)
177 e.data.setVar("PROVIDES", ' '.join(nprovides))
178
179
180}
181
182addhandler native_virtclass_handler
183native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
184
185python do_addto_recipe_sysroot () {
186 bb.build.exec_func("extend_recipe_sysroot", d)
187}
188addtask addto_recipe_sysroot after do_populate_sysroot
189do_addto_recipe_sysroot[deptask] = "do_populate_sysroot"
190
191inherit nopackages
192
193do_packagedata[stamp-extra-info] = ""
194
195USE_NLS = "no"
196
197RECIPERDEPTASK = "do_populate_sysroot"
198do_populate_sysroot[rdeptask] = "${RECIPERDEPTASK}"