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