Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | BB_DEFAULT_TASK ?= "build" |
| 2 | CLASSOVERRIDE ?= "class-target" |
| 3 | |
| 4 | inherit patch |
| 5 | inherit staging |
| 6 | |
| 7 | inherit mirrors |
| 8 | inherit utils |
| 9 | inherit utility-tasks |
| 10 | inherit metadata_scm |
| 11 | inherit logging |
| 12 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 13 | OE_EXTRA_IMPORTS ?= "" |
| 14 | |
Andrew Jeffery | ecdf5f1 | 2022-03-01 01:09:46 +1030 | [diff] [blame] | 15 | OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible oe.rust ${OE_EXTRA_IMPORTS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | OE_IMPORTS[type] = "list" |
| 17 | |
Brad Bishop | f3fd288 | 2019-06-21 08:06:37 -0400 | [diff] [blame] | 18 | PACKAGECONFIG_CONFARGS ??= "" |
| 19 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | def oe_import(d): |
| 21 | import sys |
| 22 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 23 | bbpath = d.getVar("BBPATH").split(":") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath] |
| 25 | |
| 26 | def inject(name, value): |
| 27 | """Make a python object accessible from the metadata""" |
| 28 | if hasattr(bb.utils, "_context"): |
| 29 | bb.utils._context[name] = value |
| 30 | else: |
| 31 | __builtins__[name] = value |
| 32 | |
| 33 | import oe.data |
| 34 | for toimport in oe.data.typed_value("OE_IMPORTS", d): |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 35 | try: |
| 36 | imported = __import__(toimport) |
| 37 | inject(toimport.split(".", 1)[0], imported) |
| 38 | except AttributeError as e: |
| 39 | bb.error("Error importing OE modules: %s" % str(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | return "" |
| 41 | |
| 42 | # We need the oe module name space early (before INHERITs get added) |
| 43 | OE_IMPORTED := "${@oe_import(d)}" |
| 44 | |
| 45 | def lsb_distro_identifier(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 46 | adjust = d.getVar('LSB_DISTRO_ADJUST') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | adjust_func = None |
| 48 | if adjust: |
| 49 | try: |
| 50 | adjust_func = globals()[adjust] |
| 51 | except KeyError: |
| 52 | pass |
| 53 | return oe.lsb.distro_identifier(adjust_func) |
| 54 | |
| 55 | die() { |
| 56 | bbfatal_log "$*" |
| 57 | } |
| 58 | |
| 59 | oe_runmake_call() { |
| 60 | bbnote ${MAKE} ${EXTRA_OEMAKE} "$@" |
| 61 | ${MAKE} ${EXTRA_OEMAKE} "$@" |
| 62 | } |
| 63 | |
| 64 | oe_runmake() { |
| 65 | oe_runmake_call "$@" || die "oe_runmake failed" |
| 66 | } |
| 67 | |
| 68 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 69 | def get_base_dep(d): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 70 | if d.getVar('INHIBIT_DEFAULT_DEPS', False): |
| 71 | return "" |
| 72 | return "${BASE_DEFAULT_DEPS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 74 | BASE_DEFAULT_DEPS = "virtual/${HOST_PREFIX}gcc virtual/${HOST_PREFIX}compilerlibs virtual/libc" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 76 | BASEDEPENDS = "" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 77 | BASEDEPENDS:class-target = "${@get_base_dep(d)}" |
| 78 | BASEDEPENDS:class-nativesdk = "${@get_base_dep(d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 80 | DEPENDS:prepend="${BASEDEPENDS} " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | |
| 82 | FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}" |
| 83 | # THISDIR only works properly with imediate expansion as it has to run |
| 84 | # in the context of the location its used (:=) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 85 | THISDIR = "${@os.path.dirname(d.getVar('FILE'))}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | |
| 87 | def extra_path_elements(d): |
| 88 | path = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 89 | elements = (d.getVar('EXTRANATIVEPATH') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | for e in elements: |
| 91 | path = path + "${STAGING_BINDIR_NATIVE}/" + e + ":" |
| 92 | return path |
| 93 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 94 | PATH:prepend = "${@extra_path_elements(d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | |
| 96 | def get_lic_checksum_file_list(d): |
| 97 | filelist = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 98 | lic_files = d.getVar("LIC_FILES_CHKSUM") or '' |
| 99 | tmpdir = d.getVar("TMPDIR") |
| 100 | s = d.getVar("S") |
| 101 | b = d.getVar("B") |
| 102 | workdir = d.getVar("WORKDIR") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | |
| 104 | urls = lic_files.split() |
| 105 | for url in urls: |
| 106 | # We only care about items that are absolute paths since |
| 107 | # any others should be covered by SRC_URI. |
| 108 | try: |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 109 | (method, host, path, user, pswd, parm) = bb.fetch.decodeurl(url) |
| 110 | if method != "file" or not path: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 111 | raise bb.fetch.MalformedUrl(url) |
| 112 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | if path[0] == '/': |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 114 | if path.startswith((tmpdir, s, b, workdir)): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | continue |
| 116 | filelist.append(path + ":" + str(os.path.exists(path))) |
| 117 | except bb.fetch.MalformedUrl: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 118 | bb.fatal(d.getVar('PN') + ": LIC_FILES_CHKSUM contains an invalid URL: " + url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 | return " ".join(filelist) |
| 120 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 121 | def setup_hosttools_dir(dest, toolsvar, d, fatal=True): |
| 122 | tools = d.getVar(toolsvar).split() |
| 123 | origbbenv = d.getVar("BB_ORIGENV", False) |
| 124 | path = origbbenv.getVar("PATH") |
| 125 | bb.utils.mkdirhier(dest) |
| 126 | notfound = [] |
| 127 | for tool in tools: |
| 128 | desttool = os.path.join(dest, tool) |
| 129 | if not os.path.exists(desttool): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 130 | # clean up dead symlink |
| 131 | if os.path.islink(desttool): |
| 132 | os.unlink(desttool) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 133 | srctool = bb.utils.which(path, tool, executable=True) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 134 | # gcc/g++ may link to ccache on some hosts, e.g., |
| 135 | # /usr/local/bin/ccache/gcc -> /usr/bin/ccache, then which(gcc) |
| 136 | # would return /usr/local/bin/ccache/gcc, but what we need is |
| 137 | # /usr/bin/gcc, this code can check and fix that. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 138 | if "ccache" in srctool: |
| 139 | srctool = bb.utils.which(path, tool, executable=True, direction=1) |
| 140 | if srctool: |
| 141 | os.symlink(srctool, desttool) |
| 142 | else: |
| 143 | notfound.append(tool) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 144 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 145 | if notfound and fatal: |
| 146 | bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound)) |
| 147 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 148 | addtask fetch |
| 149 | do_fetch[dirs] = "${DL_DIR}" |
| 150 | do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}" |
| 151 | do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}" |
| 152 | do_fetch[vardeps] += "SRCREV" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 153 | do_fetch[network] = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | python base_do_fetch() { |
| 155 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 156 | src_uri = (d.getVar('SRC_URI') or "").split() |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 157 | if not src_uri: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 158 | return |
| 159 | |
| 160 | try: |
| 161 | fetcher = bb.fetch2.Fetch(src_uri, d) |
| 162 | fetcher.download() |
| 163 | except bb.fetch2.BBFetchException as e: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 164 | bb.fatal("Bitbake Fetcher Error: " + repr(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | addtask unpack after do_fetch |
| 168 | do_unpack[dirs] = "${WORKDIR}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 169 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 170 | do_unpack[cleandirs] = "${@d.getVar('S') if os.path.normpath(d.getVar('S')) != os.path.normpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 171 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 172 | python base_do_unpack() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 173 | src_uri = (d.getVar('SRC_URI') or "").split() |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 174 | if not src_uri: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 175 | return |
| 176 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | try: |
| 178 | fetcher = bb.fetch2.Fetch(src_uri, d) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 179 | fetcher.unpack(d.getVar('WORKDIR')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | except bb.fetch2.BBFetchException as e: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 181 | bb.fatal("Bitbake Fetcher Error: " + repr(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | } |
| 183 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 184 | SSTATETASKS += "do_deploy_source_date_epoch" |
| 185 | |
| 186 | do_deploy_source_date_epoch () { |
| 187 | mkdir -p ${SDE_DEPLOYDIR} |
| 188 | if [ -e ${SDE_FILE} ]; then |
| 189 | echo "Deploying SDE from ${SDE_FILE} -> ${SDE_DEPLOYDIR}." |
| 190 | cp -p ${SDE_FILE} ${SDE_DEPLOYDIR}/__source_date_epoch.txt |
| 191 | else |
| 192 | echo "${SDE_FILE} not found!" |
| 193 | fi |
| 194 | } |
| 195 | |
| 196 | python do_deploy_source_date_epoch_setscene () { |
| 197 | sstate_setscene(d) |
| 198 | bb.utils.mkdirhier(d.getVar('SDE_DIR')) |
| 199 | sde_file = os.path.join(d.getVar('SDE_DEPLOYDIR'), '__source_date_epoch.txt') |
| 200 | if os.path.exists(sde_file): |
| 201 | target = d.getVar('SDE_FILE') |
| 202 | bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target)) |
| 203 | bb.utils.rename(sde_file, target) |
| 204 | else: |
| 205 | bb.debug(1, "%s not found!" % sde_file) |
| 206 | } |
| 207 | |
| 208 | do_deploy_source_date_epoch[dirs] = "${SDE_DEPLOYDIR}" |
| 209 | do_deploy_source_date_epoch[sstate-plaindirs] = "${SDE_DEPLOYDIR}" |
| 210 | addtask do_deploy_source_date_epoch_setscene |
| 211 | addtask do_deploy_source_date_epoch before do_configure after do_patch |
| 212 | |
| 213 | python create_source_date_epoch_stamp() { |
| 214 | source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) |
| 215 | oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d) |
| 216 | } |
| 217 | do_unpack[postfuncs] += "create_source_date_epoch_stamp" |
| 218 | |
| 219 | def get_source_date_epoch_value(d): |
| 220 | return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d) |
| 221 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 222 | def get_layers_branch_rev(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 223 | layers = (d.getVar("BBLAYERS") or "").split() |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 224 | layers_branch_rev = ["%-20s = \"%s:%s\"" % (os.path.basename(i), \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 225 | base_get_metadata_git_branch(i, None).strip(), \ |
| 226 | base_get_metadata_git_revision(i, None)) \ |
| 227 | for i in layers] |
| 228 | i = len(layers_branch_rev)-1 |
| 229 | p1 = layers_branch_rev[i].find("=") |
| 230 | s1 = layers_branch_rev[i][p1:] |
| 231 | while i > 0: |
| 232 | p2 = layers_branch_rev[i-1].find("=") |
| 233 | s2= layers_branch_rev[i-1][p2:] |
| 234 | if s1 == s2: |
| 235 | layers_branch_rev[i-1] = layers_branch_rev[i-1][0:p2] |
| 236 | i -= 1 |
| 237 | else: |
| 238 | i -= 1 |
| 239 | p1 = layers_branch_rev[i].find("=") |
| 240 | s1= layers_branch_rev[i][p1:] |
| 241 | return layers_branch_rev |
| 242 | |
| 243 | |
| 244 | BUILDCFG_FUNCS ??= "buildcfg_vars get_layers_branch_rev buildcfg_neededvars" |
| 245 | BUILDCFG_FUNCS[type] = "list" |
| 246 | |
| 247 | def buildcfg_vars(d): |
| 248 | statusvars = oe.data.typed_value('BUILDCFG_VARS', d) |
| 249 | for var in statusvars: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 250 | value = d.getVar(var) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 251 | if value is not None: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 252 | yield '%-20s = "%s"' % (var, value) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 253 | |
| 254 | def buildcfg_neededvars(d): |
| 255 | needed_vars = oe.data.typed_value("BUILDCFG_NEEDEDVARS", d) |
| 256 | pesteruser = [] |
| 257 | for v in needed_vars: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 258 | val = d.getVar(v) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 259 | if not val or val == 'INVALID': |
| 260 | pesteruser.append(v) |
| 261 | |
| 262 | if pesteruser: |
| 263 | bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser)) |
| 264 | |
| 265 | addhandler base_eventhandler |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 266 | base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 267 | python base_eventhandler() { |
| 268 | import bb.runqueue |
| 269 | |
| 270 | if isinstance(e, bb.event.ConfigParsed): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 271 | if not d.getVar("NATIVELSBSTRING", False): |
| 272 | d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d)) |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 273 | d.setVar("ORIGNATIVELSBSTRING", d.getVar("NATIVELSBSTRING", False)) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 274 | d.setVar('BB_VERSION', bb.__version__) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 275 | |
| 276 | # There might be no bb.event.ConfigParsed event if bitbake server is |
| 277 | # running, so check bb.event.BuildStarted too to make sure ${HOSTTOOLS_DIR} |
| 278 | # exists. |
| 279 | if isinstance(e, bb.event.ConfigParsed) or \ |
| 280 | (isinstance(e, bb.event.BuildStarted) and not os.path.exists(d.getVar('HOSTTOOLS_DIR'))): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 281 | # Works with the line in layer.conf which changes PATH to point here |
| 282 | setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d) |
| 283 | setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_NONFATAL', d, fatal=False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 284 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 285 | if isinstance(e, bb.event.MultiConfigParsed): |
| 286 | # We need to expand SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS in each of the multiconfig data stores |
| 287 | # own contexts so the variables get expanded correctly for that arch, then inject back into |
| 288 | # the main data store. |
| 289 | deps = [] |
| 290 | for config in e.mcdata: |
| 291 | deps.append(e.mcdata[config].getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS")) |
| 292 | deps = " ".join(deps) |
| 293 | e.mcdata[''].setVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", deps) |
| 294 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 295 | if isinstance(e, bb.event.BuildStarted): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 296 | localdata = bb.data.createCopy(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 297 | statuslines = [] |
| 298 | for func in oe.data.typed_value('BUILDCFG_FUNCS', localdata): |
| 299 | g = globals() |
| 300 | if func not in g: |
| 301 | bb.warn("Build configuration function '%s' does not exist" % func) |
| 302 | else: |
| 303 | flines = g[func](localdata) |
| 304 | if flines: |
| 305 | statuslines.extend(flines) |
| 306 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 307 | statusheader = d.getVar('BUILDCFG_HEADER') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 308 | if statusheader: |
| 309 | bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 310 | |
| 311 | # This code is to silence warnings where the SDK variables overwrite the |
| 312 | # target ones and we'd see dulpicate key names overwriting each other |
| 313 | # for various PREFERRED_PROVIDERS |
| 314 | if isinstance(e, bb.event.RecipePreFinalise): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 315 | if d.getVar("TARGET_PREFIX") == d.getVar("SDK_PREFIX"): |
| 316 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 317 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc") |
| 318 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++") |
| 319 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 320 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 321 | if isinstance(e, bb.event.RecipeParsed): |
| 322 | # |
| 323 | # If we have multiple providers of virtual/X and a PREFERRED_PROVIDER_virtual/X is set |
| 324 | # skip parsing for all the other providers which will mean they get uninstalled from the |
| 325 | # sysroot since they're now "unreachable". This makes switching virtual/kernel work in |
| 326 | # particular. |
| 327 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 328 | pn = d.getVar('PN') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 329 | source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) |
| 330 | if not source_mirror_fetch: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 331 | provs = (d.getVar("PROVIDES") or "").split() |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame^] | 332 | multiprovidersallowed = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 333 | for p in provs: |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame^] | 334 | if p.startswith("virtual/") and p not in multiprovidersallowed: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 335 | profprov = d.getVar("PREFERRED_PROVIDER_" + p) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 336 | if profprov and pn != profprov: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 337 | raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (p, profprov, pn)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate" |
| 341 | CLEANBROKEN = "0" |
| 342 | |
| 343 | addtask configure after do_patch |
| 344 | do_configure[dirs] = "${B}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 345 | base_do_configure() { |
| 346 | if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then |
| 347 | if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then |
| 348 | cd ${B} |
| 349 | if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then |
| 350 | oe_runmake clean |
| 351 | fi |
Brad Bishop | c4ea075 | 2018-11-15 14:30:15 -0800 | [diff] [blame] | 352 | # -ignore_readdir_race does not work correctly with -delete; |
| 353 | # use xargs to avoid spurious build failures |
| 354 | find ${B} -ignore_readdir_race -name \*.la -type f -print0 | xargs -0 rm -f |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 355 | fi |
| 356 | fi |
| 357 | if [ -n "${CONFIGURESTAMPFILE}" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 358 | mkdir -p `dirname ${CONFIGURESTAMPFILE}` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 359 | echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} |
| 360 | fi |
| 361 | } |
| 362 | |
| 363 | addtask compile after do_configure |
| 364 | do_compile[dirs] = "${B}" |
| 365 | base_do_compile() { |
| 366 | if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then |
| 367 | oe_runmake || die "make failed" |
| 368 | else |
| 369 | bbnote "nothing to compile" |
| 370 | fi |
| 371 | } |
| 372 | |
| 373 | addtask install after do_compile |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 374 | do_install[dirs] = "${B}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 375 | # Remove and re-create ${D} so that is it guaranteed to be empty |
| 376 | do_install[cleandirs] = "${D}" |
| 377 | |
| 378 | base_do_install() { |
| 379 | : |
| 380 | } |
| 381 | |
| 382 | base_do_package() { |
| 383 | : |
| 384 | } |
| 385 | |
| 386 | addtask build after do_populate_sysroot |
| 387 | do_build[noexec] = "1" |
| 388 | do_build[recrdeptask] += "do_deploy" |
| 389 | do_build () { |
| 390 | : |
| 391 | } |
| 392 | |
| 393 | def set_packagetriplet(d): |
| 394 | archs = [] |
| 395 | tos = [] |
| 396 | tvs = [] |
| 397 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 398 | archs.append(d.getVar("PACKAGE_ARCHS").split()) |
| 399 | tos.append(d.getVar("TARGET_OS")) |
| 400 | tvs.append(d.getVar("TARGET_VENDOR")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 401 | |
| 402 | def settriplet(d, varname, archs, tos, tvs): |
| 403 | triplets = [] |
| 404 | for i in range(len(archs)): |
| 405 | for arch in archs[i]: |
| 406 | triplets.append(arch + tvs[i] + "-" + tos[i]) |
| 407 | triplets.reverse() |
| 408 | d.setVar(varname, " ".join(triplets)) |
| 409 | |
| 410 | settriplet(d, "PKGTRIPLETS", archs, tos, tvs) |
| 411 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 412 | variants = d.getVar("MULTILIB_VARIANTS") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 413 | for item in variants.split(): |
| 414 | localdata = bb.data.createCopy(d) |
| 415 | overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item |
| 416 | localdata.setVar("OVERRIDES", overrides) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 417 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 418 | archs.append(localdata.getVar("PACKAGE_ARCHS").split()) |
| 419 | tos.append(localdata.getVar("TARGET_OS")) |
| 420 | tvs.append(localdata.getVar("TARGET_VENDOR")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 421 | |
| 422 | settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs) |
| 423 | |
| 424 | python () { |
| 425 | import string, re |
| 426 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 427 | # Handle backfilling |
| 428 | oe.utils.features_backfill("DISTRO_FEATURES", d) |
| 429 | oe.utils.features_backfill("MACHINE_FEATURES", d) |
| 430 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 431 | if d.getVar("S")[-1] == '/': |
| 432 | bb.warn("Recipe %s sets S variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("S"))) |
| 433 | if d.getVar("B")[-1] == '/': |
| 434 | bb.warn("Recipe %s sets B variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("B"))) |
| 435 | |
| 436 | if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("S")): |
| 437 | d.appendVar("PSEUDO_IGNORE_PATHS", ",${S}") |
| 438 | if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("B")): |
| 439 | d.appendVar("PSEUDO_IGNORE_PATHS", ",${B}") |
| 440 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 441 | # To add a recipe to the skip list , set: |
| 442 | # SKIP_RECIPE[pn] = "message" |
| 443 | pn = d.getVar('PN') |
| 444 | skip_msg = d.getVarFlag('SKIP_RECIPE', pn) |
| 445 | if skip_msg: |
| 446 | bb.debug(1, "Skipping %s %s" % (pn, skip_msg)) |
| 447 | raise bb.parse.SkipRecipe("Recipe will be skipped because: %s" % (skip_msg)) |
| 448 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 449 | # Handle PACKAGECONFIG |
| 450 | # |
| 451 | # These take the form: |
| 452 | # |
| 453 | # PACKAGECONFIG ??= "<default options>" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 454 | # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends,foo_runtime_recommends,foo_conflict_packageconfig" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 455 | pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {} |
| 456 | if pkgconfigflags: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 457 | pkgconfig = (d.getVar('PACKAGECONFIG') or "").split() |
| 458 | pn = d.getVar("PN") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 459 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 460 | mlprefix = d.getVar("MLPREFIX") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 461 | |
| 462 | def expandFilter(appends, extension, prefix): |
| 463 | appends = bb.utils.explode_deps(d.expand(" ".join(appends))) |
| 464 | newappends = [] |
| 465 | for a in appends: |
| 466 | if a.endswith("-native") or ("-cross-" in a): |
| 467 | newappends.append(a) |
| 468 | elif a.startswith("virtual/"): |
| 469 | subs = a.split("/", 1)[1] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 470 | if subs.startswith(prefix): |
| 471 | newappends.append(a + extension) |
| 472 | else: |
| 473 | newappends.append("virtual/" + prefix + subs + extension) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 474 | else: |
| 475 | if a.startswith(prefix): |
| 476 | newappends.append(a + extension) |
| 477 | else: |
| 478 | newappends.append(prefix + a + extension) |
| 479 | return newappends |
| 480 | |
| 481 | def appendVar(varname, appends): |
| 482 | if not appends: |
| 483 | return |
| 484 | if varname.find("DEPENDS") != -1: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 485 | if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) : |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 486 | appends = expandFilter(appends, "", "nativesdk-") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 487 | elif bb.data.inherits_class('native', d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 488 | appends = expandFilter(appends, "-native", "") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 489 | elif mlprefix: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 490 | appends = expandFilter(appends, "", mlprefix) |
| 491 | varname = d.expand(varname) |
| 492 | d.appendVar(varname, " " + " ".join(appends)) |
| 493 | |
| 494 | extradeps = [] |
| 495 | extrardeps = [] |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 496 | extrarrecs = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 497 | extraconf = [] |
| 498 | for flag, flagval in sorted(pkgconfigflags.items()): |
| 499 | items = flagval.split(",") |
| 500 | num = len(items) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 501 | if num > 6: |
| 502 | bb.error("%s: PACKAGECONFIG[%s] Only enable,disable,depend,rdepend,rrecommend,conflict_packageconfig can be specified!" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 503 | % (d.getVar('PN'), flag)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 504 | |
| 505 | if flag in pkgconfig: |
| 506 | if num >= 3 and items[2]: |
| 507 | extradeps.append(items[2]) |
| 508 | if num >= 4 and items[3]: |
| 509 | extrardeps.append(items[3]) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 510 | if num >= 5 and items[4]: |
| 511 | extrarrecs.append(items[4]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 512 | if num >= 1 and items[0]: |
| 513 | extraconf.append(items[0]) |
| 514 | elif num >= 2 and items[1]: |
| 515 | extraconf.append(items[1]) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 516 | |
| 517 | if num >= 6 and items[5]: |
| 518 | conflicts = set(items[5].split()) |
| 519 | invalid = conflicts.difference(set(pkgconfigflags.keys())) |
| 520 | if invalid: |
| 521 | bb.error("%s: PACKAGECONFIG[%s] Invalid conflict package config%s '%s' specified." |
| 522 | % (d.getVar('PN'), flag, 's' if len(invalid) > 1 else '', ' '.join(invalid))) |
| 523 | |
| 524 | if flag in pkgconfig: |
| 525 | intersec = conflicts.intersection(set(pkgconfig)) |
| 526 | if intersec: |
| 527 | bb.fatal("%s: PACKAGECONFIG[%s] Conflict package config%s '%s' set in PACKAGECONFIG." |
| 528 | % (d.getVar('PN'), flag, 's' if len(intersec) > 1 else '', ' '.join(intersec))) |
| 529 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 530 | appendVar('DEPENDS', extradeps) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 531 | appendVar('RDEPENDS:${PN}', extrardeps) |
| 532 | appendVar('RRECOMMENDS:${PN}', extrarrecs) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 533 | appendVar('PACKAGECONFIG_CONFARGS', extraconf) |
| 534 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 535 | pn = d.getVar('PN') |
| 536 | license = d.getVar('LICENSE') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 537 | if license == "INVALID" and pn != "defaultpkgname": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 538 | bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn) |
| 539 | |
| 540 | if bb.data.inherits_class('license', d): |
| 541 | check_license_format(d) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 542 | unmatched_license_flags = check_license_flags(d) |
| 543 | if unmatched_license_flags: |
| 544 | if len(unmatched_license_flags) == 1: |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 545 | message = "because it has a restricted license '{0}'. Which is not listed in LICENSE_FLAGS_ACCEPTED".format(unmatched_license_flags[0]) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 546 | else: |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 547 | message = "because it has restricted licenses {0}. Which are not listed in LICENSE_FLAGS_ACCEPTED".format( |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 548 | ", ".join("'{0}'".format(f) for f in unmatched_license_flags)) |
| 549 | bb.debug(1, "Skipping %s %s" % (pn, message)) |
| 550 | raise bb.parse.SkipRecipe(message) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 551 | |
| 552 | # If we're building a target package we need to use fakeroot (pseudo) |
| 553 | # in order to capture permissions, owners, groups and special files |
| 554 | if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d): |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 555 | d.appendVarFlag('do_prepare_recipe_sysroot', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 556 | d.appendVarFlag('do_install', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 557 | d.setVarFlag('do_install', 'fakeroot', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 558 | d.appendVarFlag('do_package', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 559 | d.setVarFlag('do_package', 'fakeroot', '1') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 560 | d.setVarFlag('do_package_setscene', 'fakeroot', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 561 | d.appendVarFlag('do_package_setscene', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 562 | d.setVarFlag('do_devshell', 'fakeroot', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 563 | d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 564 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 565 | need_machine = d.getVar('COMPATIBLE_MACHINE') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 566 | if need_machine and not d.getVar('PARSE_ALL_RECIPES', False): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 567 | import re |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 568 | compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 569 | for m in compat_machines: |
| 570 | if re.match(need_machine, m): |
| 571 | break |
| 572 | else: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 573 | raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE')) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 574 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 575 | source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) or d.getVar('PARSE_ALL_RECIPES', False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 576 | if not source_mirror_fetch: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 577 | need_host = d.getVar('COMPATIBLE_HOST') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 578 | if need_host: |
| 579 | import re |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 580 | this_host = d.getVar('HOST_SYS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 581 | if not re.match(need_host, this_host): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 582 | raise bb.parse.SkipRecipe("incompatible with host %s (not in COMPATIBLE_HOST)" % this_host) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 583 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 584 | bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 585 | |
| 586 | check_license = False if pn.startswith("nativesdk-") else True |
| 587 | for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}", |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 588 | "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 589 | "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]: |
| 590 | if pn.endswith(d.expand(t)): |
| 591 | check_license = False |
| 592 | if pn.startswith("gcc-source-"): |
| 593 | check_license = False |
| 594 | |
| 595 | if check_license and bad_licenses: |
| 596 | bad_licenses = expand_wildcard_licenses(d, bad_licenses) |
| 597 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame^] | 598 | exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split() |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 599 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame^] | 600 | for lic_exception in exceptions: |
| 601 | if ":" in lic_exception: |
| 602 | lic_exception.split(":")[0] |
| 603 | if lic_exception in oe.license.obsolete_license_list(): |
| 604 | bb.fatal("Invalid license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception) |
| 605 | |
| 606 | pkgs = d.getVar('PACKAGES').split() |
| 607 | skipped_pkgs = {} |
| 608 | unskipped_pkgs = [] |
| 609 | for pkg in pkgs: |
| 610 | remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions) |
| 611 | |
| 612 | incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg) |
| 613 | if incompatible_lic: |
| 614 | skipped_pkgs[pkg] = incompatible_lic |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 615 | else: |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame^] | 616 | unskipped_pkgs.append(pkg) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 617 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame^] | 618 | if unskipped_pkgs: |
| 619 | for pkg in skipped_pkgs: |
| 620 | bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg]))) |
| 621 | d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg])) |
| 622 | for pkg in unskipped_pkgs: |
| 623 | bb.debug(1, "Including the package %s" % pkg) |
| 624 | else: |
| 625 | incompatible_lic = incompatible_license(d, bad_licenses) |
| 626 | for pkg in skipped_pkgs: |
| 627 | incompatible_lic += skipped_pkgs[pkg] |
| 628 | incompatible_lic = sorted(list(set(incompatible_lic))) |
| 629 | |
| 630 | if incompatible_lic: |
| 631 | bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic))) |
| 632 | raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 633 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 634 | needsrcrev = False |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 635 | srcuri = d.getVar('SRC_URI') |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 636 | for uri_string in srcuri.split(): |
| 637 | uri = bb.fetch.URI(uri_string) |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 638 | # Also check downloadfilename as the URL path might not be useful for sniffing |
| 639 | path = uri.params.get("downloadfilename", uri.path) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 640 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 641 | # HTTP/FTP use the wget fetcher |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 642 | if uri.scheme in ("http", "https", "ftp"): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 643 | d.appendVarFlag('do_fetch', 'depends', ' wget-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 644 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 645 | # Svn packages should DEPEND on subversion-native |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 646 | if uri.scheme == "svn": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 647 | needsrcrev = True |
| 648 | d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 649 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 650 | # Git packages should DEPEND on git-native |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 651 | elif uri.scheme in ("git", "gitsm"): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 652 | needsrcrev = True |
| 653 | d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 654 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 655 | # Mercurial packages should DEPEND on mercurial-native |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 656 | elif uri.scheme == "hg": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 657 | needsrcrev = True |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 658 | d.appendVar("EXTRANATIVEPATH", ' python3-native ') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 659 | d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 660 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 661 | # Perforce packages support SRCREV = "${AUTOREV}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 662 | elif uri.scheme == "p4": |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 663 | needsrcrev = True |
| 664 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 665 | # OSC packages should DEPEND on osc-native |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 666 | elif uri.scheme == "osc": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 667 | d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 668 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 669 | elif uri.scheme == "npm": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 670 | d.appendVarFlag('do_fetch', 'depends', ' nodejs-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 671 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 672 | elif uri.scheme == "repo": |
| 673 | needsrcrev = True |
| 674 | d.appendVarFlag('do_fetch', 'depends', ' repo-native:do_populate_sysroot') |
| 675 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 676 | # *.lz4 should DEPEND on lz4-native for unpacking |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 677 | if path.endswith('.lz4'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 678 | d.appendVarFlag('do_unpack', 'depends', ' lz4-native:do_populate_sysroot') |
| 679 | |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 680 | # *.zst should DEPEND on zstd-native for unpacking |
| 681 | elif path.endswith('.zst'): |
| 682 | d.appendVarFlag('do_unpack', 'depends', ' zstd-native:do_populate_sysroot') |
| 683 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 684 | # *.lz should DEPEND on lzip-native for unpacking |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 685 | elif path.endswith('.lz'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 686 | d.appendVarFlag('do_unpack', 'depends', ' lzip-native:do_populate_sysroot') |
| 687 | |
| 688 | # *.xz should DEPEND on xz-native for unpacking |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 689 | elif path.endswith('.xz') or path.endswith('.txz'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 690 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') |
| 691 | |
| 692 | # .zip should DEPEND on unzip-native for unpacking |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 693 | elif path.endswith('.zip') or path.endswith('.jar'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 694 | d.appendVarFlag('do_unpack', 'depends', ' unzip-native:do_populate_sysroot') |
| 695 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 696 | # Some rpm files may be compressed internally using xz (for example, rpms from Fedora) |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 697 | elif path.endswith('.rpm'): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 698 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 699 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 700 | # *.deb should DEPEND on xz-native for unpacking |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 701 | elif path.endswith('.deb'): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 702 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') |
| 703 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 704 | if needsrcrev: |
| 705 | d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 706 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 707 | # Gather all named SRCREVs to add to the sstate hash calculation |
| 708 | # This anonymous python snippet is called multiple times so we |
| 709 | # need to be careful to not double up the appends here and cause |
| 710 | # the base hash to mismatch the task hash |
| 711 | for uri in srcuri.split(): |
| 712 | parm = bb.fetch.decodeurl(uri)[5] |
| 713 | uri_names = parm.get("name", "").split(",") |
| 714 | for uri_name in filter(None, uri_names): |
| 715 | srcrev_name = "SRCREV_{}".format(uri_name) |
| 716 | if srcrev_name not in (d.getVarFlag("do_fetch", "vardeps") or "").split(): |
| 717 | d.appendVarFlag("do_fetch", "vardeps", " {}".format(srcrev_name)) |
| 718 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 719 | set_packagetriplet(d) |
| 720 | |
| 721 | # 'multimachine' handling |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 722 | mach_arch = d.getVar('MACHINE_ARCH') |
| 723 | pkg_arch = d.getVar('PACKAGE_ARCH') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 724 | |
| 725 | if (pkg_arch == mach_arch): |
| 726 | # Already machine specific - nothing further to do |
| 727 | return |
| 728 | |
| 729 | # |
| 730 | # We always try to scan SRC_URI for urls with machine overrides |
| 731 | # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0 |
| 732 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 733 | override = d.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 734 | if override != '0': |
| 735 | paths = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 736 | fpaths = (d.getVar('FILESPATH') or '').split(':') |
| 737 | machine = d.getVar('MACHINE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 738 | for p in fpaths: |
| 739 | if os.path.basename(p) == machine and os.path.isdir(p): |
| 740 | paths.append(p) |
| 741 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 742 | if paths: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 743 | for s in srcuri.split(): |
| 744 | if not s.startswith("file://"): |
| 745 | continue |
| 746 | fetcher = bb.fetch2.Fetch([s], d) |
| 747 | local = fetcher.localpath(s) |
| 748 | for mp in paths: |
| 749 | if local.startswith(mp): |
| 750 | #bb.note("overriding PACKAGE_ARCH from %s to %s for %s" % (pkg_arch, mach_arch, pn)) |
| 751 | d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}") |
| 752 | return |
| 753 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 754 | packages = d.getVar('PACKAGES').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 755 | for pkg in packages: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 756 | pkgarch = d.getVar("PACKAGE_ARCH_%s" % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 757 | |
| 758 | # We could look for != PACKAGE_ARCH here but how to choose |
| 759 | # if multiple differences are present? |
| 760 | # Look through PACKAGE_ARCHS for the priority order? |
| 761 | if pkgarch and pkgarch == mach_arch: |
| 762 | d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 763 | bb.warn("Recipe %s is marked as only being architecture specific but seems to have machine specific packages?! The recipe may as well mark itself as machine specific directly." % d.getVar("PN")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | addtask cleansstate after do_clean |
| 767 | python do_cleansstate() { |
| 768 | sstate_clean_cachefiles(d) |
| 769 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 770 | addtask cleanall after do_cleansstate |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 771 | do_cleansstate[nostamp] = "1" |
| 772 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 773 | python do_cleanall() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 774 | src_uri = (d.getVar('SRC_URI') or "").split() |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 775 | if not src_uri: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 776 | return |
| 777 | |
| 778 | try: |
| 779 | fetcher = bb.fetch2.Fetch(src_uri, d) |
| 780 | fetcher.clean() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 781 | except bb.fetch2.BBFetchException as e: |
| 782 | bb.fatal(str(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 783 | } |
| 784 | do_cleanall[nostamp] = "1" |
| 785 | |
| 786 | |
| 787 | EXPORT_FUNCTIONS do_fetch do_unpack do_configure do_compile do_install do_package |