Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # We want native packages to be relocatable |
| 2 | inherit relocatable |
| 3 | |
| 4 | # Native packages are built indirectly via dependency, |
| 5 | # no need for them to be a direct target of 'world' |
| 6 | EXCLUDE_FROM_WORLD = "1" |
| 7 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | PACKAGE_ARCH = "${BUILD_ARCH}" |
| 9 | |
| 10 | # used by cmake class |
| 11 | OECMAKE_RPATH = "${libdir}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 12 | OECMAKE_RPATH:class-native = "${libdir}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14 | TARGET_ARCH = "${BUILD_ARCH}" |
| 15 | TARGET_OS = "${BUILD_OS}" |
| 16 | TARGET_VENDOR = "${BUILD_VENDOR}" |
| 17 | TARGET_PREFIX = "${BUILD_PREFIX}" |
| 18 | TARGET_CC_ARCH = "${BUILD_CC_ARCH}" |
| 19 | TARGET_LD_ARCH = "${BUILD_LD_ARCH}" |
| 20 | TARGET_AS_ARCH = "${BUILD_AS_ARCH}" |
| 21 | TARGET_CPPFLAGS = "${BUILD_CPPFLAGS}" |
| 22 | TARGET_CFLAGS = "${BUILD_CFLAGS}" |
| 23 | TARGET_CXXFLAGS = "${BUILD_CXXFLAGS}" |
| 24 | TARGET_LDFLAGS = "${BUILD_LDFLAGS}" |
| 25 | TARGET_FPU = "" |
Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 26 | TUNE_FEATURES = "" |
| 27 | ABIEXTENSION = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | |
| 29 | HOST_ARCH = "${BUILD_ARCH}" |
| 30 | HOST_OS = "${BUILD_OS}" |
| 31 | HOST_VENDOR = "${BUILD_VENDOR}" |
| 32 | HOST_PREFIX = "${BUILD_PREFIX}" |
| 33 | HOST_CC_ARCH = "${BUILD_CC_ARCH}" |
| 34 | HOST_LD_ARCH = "${BUILD_LD_ARCH}" |
| 35 | HOST_AS_ARCH = "${BUILD_AS_ARCH}" |
| 36 | |
| 37 | CPPFLAGS = "${BUILD_CPPFLAGS}" |
| 38 | CFLAGS = "${BUILD_CFLAGS}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 39 | CXXFLAGS = "${BUILD_CXXFLAGS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | LDFLAGS = "${BUILD_LDFLAGS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | |
| 42 | STAGING_BINDIR = "${STAGING_BINDIR_NATIVE}" |
| 43 | STAGING_BINDIR_CROSS = "${STAGING_BINDIR_NATIVE}" |
| 44 | |
| 45 | # native pkg doesn't need the TOOLCHAIN_OPTIONS. |
| 46 | TOOLCHAIN_OPTIONS = "" |
| 47 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | # Don't build ptest natively |
| 49 | PTEST_ENABLED = "0" |
| 50 | |
| 51 | # Don't use site files for native builds |
| 52 | export CONFIG_SITE = "${COREBASE}/meta/site/native" |
| 53 | |
| 54 | # set the compiler as well. It could have been set to something else |
| 55 | export CC = "${BUILD_CC}" |
| 56 | export CXX = "${BUILD_CXX}" |
| 57 | export FC = "${BUILD_FC}" |
| 58 | export CPP = "${BUILD_CPP}" |
| 59 | export LD = "${BUILD_LD}" |
| 60 | export CCLD = "${BUILD_CCLD}" |
| 61 | export AR = "${BUILD_AR}" |
| 62 | export AS = "${BUILD_AS}" |
| 63 | export RANLIB = "${BUILD_RANLIB}" |
| 64 | export STRIP = "${BUILD_STRIP}" |
| 65 | export NM = "${BUILD_NM}" |
| 66 | |
| 67 | # Path prefixes |
| 68 | base_prefix = "${STAGING_DIR_NATIVE}" |
| 69 | prefix = "${STAGING_DIR_NATIVE}${prefix_native}" |
| 70 | exec_prefix = "${STAGING_DIR_NATIVE}${prefix_native}" |
| 71 | |
| 72 | bindir = "${STAGING_BINDIR_NATIVE}" |
| 73 | sbindir = "${STAGING_SBINDIR_NATIVE}" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 74 | base_libdir = "${STAGING_LIBDIR_NATIVE}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | libdir = "${STAGING_LIBDIR_NATIVE}" |
| 76 | includedir = "${STAGING_INCDIR_NATIVE}" |
| 77 | sysconfdir = "${STAGING_ETCDIR_NATIVE}" |
| 78 | datadir = "${STAGING_DATADIR_NATIVE}" |
| 79 | |
| 80 | baselib = "lib" |
| 81 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 82 | export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir} /lib /lib64 /usr/lib /usr/lib64" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | |
| 84 | NATIVE_PACKAGE_PATH_SUFFIX ?= "" |
| 85 | bindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 86 | sbindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 87 | base_libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}" |
| 89 | libexecdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}" |
| 90 | |
| 91 | do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_NATIVE}/" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 92 | do_populate_sysroot[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/${PN}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | |
| 94 | # Since we actually install these into situ there is no staging prefix |
| 95 | STAGING_DIR_HOST = "" |
| 96 | STAGING_DIR_TARGET = "" |
| 97 | PKG_CONFIG_DIR = "${libdir}/pkgconfig" |
| 98 | |
| 99 | EXTRA_NATIVE_PKGCONFIG_PATH ?= "" |
| 100 | PKG_CONFIG_PATH .= "${EXTRA_NATIVE_PKGCONFIG_PATH}" |
| 101 | PKG_CONFIG_SYSROOT_DIR = "" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 102 | PKG_CONFIG_SYSTEM_LIBRARY_PATH[unexport] = "1" |
| 103 | PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 105 | # we dont want libc-*libc to kick in for native recipes |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 106 | LIBCOVERRIDE = "" |
| 107 | CLASSOVERRIDE = "class-native" |
| 108 | MACHINEOVERRIDES = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 109 | MACHINE_FEATURES = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 111 | PATH:prepend = "${COREBASE}/scripts/native-intercept:" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 112 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 113 | # This class encodes staging paths into its scripts data so can only be |
| 114 | # reused if we manipulate the paths. |
| 115 | SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}" |
| 116 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 117 | # No strip sysroot when DEBUG_BUILD is enabled |
| 118 | INHIBIT_SYSROOT_STRIP ?= "${@oe.utils.vartrue('DEBUG_BUILD', '1', '', d)}" |
| 119 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | python native_virtclass_handler () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 121 | pn = e.data.getVar("PN") |
| 122 | if not pn.endswith("-native"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | return |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 124 | bpn = e.data.getVar("BPN") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 126 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | return |
| 135 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 136 | def map_dependencies(varname, d, suffix = "", selfref=True): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 137 | if suffix: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 138 | varname = varname + ":" + suffix |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 139 | deps = d.getVar(varname) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 140 | if not deps: |
| 141 | return |
| 142 | deps = bb.utils.explode_deps(deps) |
| 143 | newdeps = [] |
| 144 | for dep in deps: |
| 145 | if dep == pn: |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 146 | if not selfref: |
| 147 | continue |
| 148 | newdeps.append(dep) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 149 | elif "-cross-" in dep: |
| 150 | newdeps.append(dep.replace("-cross", "-native")) |
| 151 | elif not dep.endswith("-native"): |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 152 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 156 | else: |
| 157 | newdeps.append(dep) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 158 | d.setVar(varname, " ".join(newdeps), parsing=True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 159 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 160 | map_dependencies("DEPENDS", e.data, selfref=False) |
| 161 | for pkg in e.data.getVar("PACKAGES", False).split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 167 | map_dependencies("PACKAGES", e.data) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 168 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 169 | provides = e.data.getVar("PROVIDES") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 170 | 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 III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 175 | nprovides.append(prov + "-native") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | else: |
| 177 | nprovides.append(prov) |
| 178 | e.data.setVar("PROVIDES", ' '.join(nprovides)) |
| 179 | |
| 180 | |
| 181 | } |
| 182 | |
| 183 | addhandler native_virtclass_handler |
| 184 | native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" |
| 185 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 186 | python do_addto_recipe_sysroot () { |
| 187 | bb.build.exec_func("extend_recipe_sysroot", d) |
| 188 | } |
| 189 | addtask addto_recipe_sysroot after do_populate_sysroot |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 190 | do_addto_recipe_sysroot[deptask] = "do_populate_sysroot" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 191 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 192 | inherit nopackages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 193 | |
| 194 | do_packagedata[stamp-extra-info] = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 | |
| 196 | USE_NLS = "no" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 197 | |
| 198 | RECIPERDEPTASK = "do_populate_sysroot" |
| 199 | do_populate_sysroot[rdeptask] = "${RECIPERDEPTASK}" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 200 | |
| 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 | # |
| 216 | python 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 | } |
| 230 | SSTATECREATEFUNCS += "native_add_do_populate_sysroot_deps" |