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