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