summaryrefslogtreecommitdiffstats
path: root/meta/classes-global/base.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes-global/base.bbclass')
-rw-r--r--meta/classes-global/base.bbclass112
1 files changed, 47 insertions, 65 deletions
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
index b6940bbb6f..6be1f5c2df 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -19,6 +19,22 @@ PACKAGECONFIG_CONFARGS ??= ""
19 19
20inherit metadata_scm 20inherit metadata_scm
21 21
22PREFERRED_TOOLCHAIN_TARGET ??= "gcc"
23PREFERRED_TOOLCHAIN_NATIVE ??= "gcc"
24PREFERRED_TOOLCHAIN_SDK ??= "gcc"
25
26PREFERRED_TOOLCHAIN = "${PREFERRED_TOOLCHAIN_TARGET}"
27PREFERRED_TOOLCHAIN:class-native = "${PREFERRED_TOOLCHAIN_NATIVE}"
28PREFERRED_TOOLCHAIN:class-cross = "${PREFERRED_TOOLCHAIN_NATIVE}"
29PREFERRED_TOOLCHAIN:class-crosssdk = "${PREFERRED_TOOLCHAIN_SDK}"
30PREFERRED_TOOLCHAIN:class-nativesdk = "${PREFERRED_TOOLCHAIN_SDK}"
31
32TOOLCHAIN ??= "${PREFERRED_TOOLCHAIN}"
33TOOLCHAIN_NATIVE ??= "${PREFERRED_TOOLCHAIN_NATIVE}"
34
35inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native
36inherit_defer toolchain/${TOOLCHAIN}
37
22def lsb_distro_identifier(d): 38def lsb_distro_identifier(d):
23 adjust = d.getVar('LSB_DISTRO_ADJUST') 39 adjust = d.getVar('LSB_DISTRO_ADJUST')
24 adjust_func = None 40 adjust_func = None
@@ -48,13 +64,13 @@ def get_base_dep(d):
48 return "" 64 return ""
49 return "${BASE_DEFAULT_DEPS}" 65 return "${BASE_DEFAULT_DEPS}"
50 66
51BASE_DEFAULT_DEPS = "virtual/${HOST_PREFIX}gcc virtual/${HOST_PREFIX}compilerlibs virtual/libc" 67BASE_DEFAULT_DEPS = "virtual/cross-cc virtual/compilerlibs virtual/libc"
52 68
53BASEDEPENDS = "" 69BASEDEPENDS = ""
54BASEDEPENDS:class-target = "${@get_base_dep(d)}" 70BASEDEPENDS:class-target = "${@get_base_dep(d)}"
55BASEDEPENDS:class-nativesdk = "${@get_base_dep(d)}" 71BASEDEPENDS:class-nativesdk = "${@get_base_dep(d)}"
56 72
57DEPENDS:prepend="${BASEDEPENDS} " 73DEPENDS:prepend = "${BASEDEPENDS} "
58 74
59FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}" 75FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}"
60# THISDIR only works properly with imediate expansion as it has to run 76# THISDIR only works properly with imediate expansion as it has to run
@@ -139,6 +155,7 @@ do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
139do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}" 155do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}"
140do_fetch[prefuncs] += "fetcher_hashes_dummyfunc" 156do_fetch[prefuncs] += "fetcher_hashes_dummyfunc"
141do_fetch[network] = "1" 157do_fetch[network] = "1"
158do_fetch[umask] = "${OE_SHARED_UMASK}"
142python base_do_fetch() { 159python base_do_fetch() {
143 160
144 src_uri = (d.getVar('SRC_URI') or "").split() 161 src_uri = (d.getVar('SRC_URI') or "").split()
@@ -168,23 +185,16 @@ python base_do_unpack() {
168 185
169 basedir = None 186 basedir = None
170 unpackdir = d.getVar('UNPACKDIR') 187 unpackdir = d.getVar('UNPACKDIR')
171 workdir = d.getVar('WORKDIR') 188 if sourcedir.startswith(unpackdir):
172 if sourcedir.startswith(workdir) and not sourcedir.startswith(unpackdir): 189 basedir = sourcedir.replace(unpackdir, '').strip("/").split('/')[0]
173 basedir = sourcedir.replace(workdir, '').strip("/").split('/')[0]
174 if basedir: 190 if basedir:
175 bb.utils.remove(workdir + '/' + basedir, True) 191 d.setVar("SOURCE_BASEDIR", unpackdir + '/' + basedir)
176 d.setVar("SOURCE_BASEDIR", workdir + '/' + basedir)
177 192
178 try: 193 try:
179 fetcher = bb.fetch2.Fetch(src_uri, d) 194 fetcher = bb.fetch2.Fetch(src_uri, d)
180 fetcher.unpack(d.getVar('UNPACKDIR')) 195 fetcher.unpack(d.getVar('UNPACKDIR'))
181 except bb.fetch2.BBFetchException as e: 196 except bb.fetch2.BBFetchException as e:
182 bb.fatal("Bitbake Fetcher Error: " + repr(e)) 197 bb.fatal("Bitbake Fetcher Error: " + repr(e))
183
184 if basedir and os.path.exists(unpackdir + '/' + basedir):
185 # Compatibility magic to ensure ${WORKDIR}/git and ${WORKDIR}/${BP}
186 # as often used in S work as expected.
187 shutil.move(unpackdir + '/' + basedir, workdir + '/' + basedir)
188} 198}
189 199
190SSTATETASKS += "do_deploy_source_date_epoch" 200SSTATETASKS += "do_deploy_source_date_epoch"
@@ -267,10 +277,19 @@ def buildcfg_neededvars(d):
267 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)) 277 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))
268 278
269addhandler base_eventhandler 279addhandler base_eventhandler
270base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed" 280base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed bb.event.RecipePreDeferredInherits"
271python base_eventhandler() { 281python base_eventhandler() {
272 import bb.runqueue 282 import bb.runqueue
273 283
284 if isinstance(e, bb.event.RecipePreDeferredInherits):
285 # Use this to snoop on class extensions and set these up before the deferred inherits
286 # are processed which allows overrides on conditional variables.
287 for c in ['native', 'nativesdk', 'crosssdk', 'cross']:
288 if c in e.inherits:
289 d.setVar('CLASSOVERRIDE', 'class-' + c)
290 break
291 return
292
274 if isinstance(e, bb.event.ConfigParsed): 293 if isinstance(e, bb.event.ConfigParsed):
275 if not d.getVar("NATIVELSBSTRING", False): 294 if not d.getVar("NATIVELSBSTRING", False):
276 d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d)) 295 d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))
@@ -312,16 +331,6 @@ python base_eventhandler() {
312 if statusheader: 331 if statusheader:
313 bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines))) 332 bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines)))
314 333
315 # This code is to silence warnings where the SDK variables overwrite the
316 # target ones and we'd see duplicate key names overwriting each other
317 # for various PREFERRED_PROVIDERS
318 if isinstance(e, bb.event.RecipePreFinalise):
319 if d.getVar("TARGET_PREFIX") == d.getVar("SDK_PREFIX"):
320 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils")
321 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc")
322 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++")
323 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs")
324
325 if isinstance(e, bb.event.RecipeParsed): 334 if isinstance(e, bb.event.RecipeParsed):
326 # 335 #
327 # If we have multiple providers of virtual/X and a PREFERRED_PROVIDER_virtual/X is set 336 # If we have multiple providers of virtual/X and a PREFERRED_PROVIDER_virtual/X is set
@@ -330,7 +339,7 @@ python base_eventhandler() {
330 # particular. 339 # particular.
331 # 340 #
332 pn = d.getVar('PN') 341 pn = d.getVar('PN')
333 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) 342 source_mirror_fetch = bb.utils.to_boolean(d.getVar('SOURCE_MIRROR_FETCH', False))
334 if not source_mirror_fetch: 343 if not source_mirror_fetch:
335 provs = (d.getVar("PROVIDES") or "").split() 344 provs = (d.getVar("PROVIDES") or "").split()
336 multiprovidersallowed = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split() 345 multiprovidersallowed = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split()
@@ -471,10 +480,10 @@ python () {
471 def appendVar(varname, appends): 480 def appendVar(varname, appends):
472 if not appends: 481 if not appends:
473 return 482 return
474 if varname.find("DEPENDS") != -1: 483 if "DEPENDS" in varname or varname.startswith("RRECOMMENDS"):
475 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) : 484 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) :
476 appends = expandFilter(appends, "", "nativesdk-") 485 appends = expandFilter(appends, "", "nativesdk-")
477 elif bb.data.inherits_class('native', d): 486 elif bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d):
478 appends = expandFilter(appends, "-native", "") 487 appends = expandFilter(appends, "-native", "")
479 elif mlprefix: 488 elif mlprefix:
480 appends = expandFilter(appends, "", mlprefix) 489 appends = expandFilter(appends, "", mlprefix)
@@ -528,8 +537,8 @@ python () {
528 bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn) 537 bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn)
529 538
530 if bb.data.inherits_class('license', d): 539 if bb.data.inherits_class('license', d):
531 check_license_format(d) 540 oe.license.check_license_format(d)
532 unmatched_license_flags = check_license_flags(d) 541 unmatched_license_flags = oe.license.check_license_flags(d)
533 if unmatched_license_flags: 542 if unmatched_license_flags:
534 for unmatched in unmatched_license_flags: 543 for unmatched in unmatched_license_flags:
535 message = "Has a restricted license '%s' which is not listed in your LICENSE_FLAGS_ACCEPTED." % unmatched 544 message = "Has a restricted license '%s' which is not listed in your LICENSE_FLAGS_ACCEPTED." % unmatched
@@ -553,7 +562,7 @@ python () {
553 d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') 562 d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
554 563
555 need_machine = d.getVar('COMPATIBLE_MACHINE') 564 need_machine = d.getVar('COMPATIBLE_MACHINE')
556 if need_machine and not d.getVar('PARSE_ALL_RECIPES', False): 565 if need_machine and not bb.utils.to_boolean(d.getVar('PARSE_ALL_RECIPES', False)):
557 import re 566 import re
558 compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":") 567 compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":")
559 for m in compat_machines: 568 for m in compat_machines:
@@ -562,7 +571,8 @@ python () {
562 else: 571 else:
563 raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE')) 572 raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE'))
564 573
565 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) or d.getVar('PARSE_ALL_RECIPES', False) 574 source_mirror_fetch = bb.utils.to_boolean(d.getVar('SOURCE_MIRROR_FETCH', False)) or \
575 bb.utils.to_boolean(d.getVar('PARSE_ALL_RECIPES', False))
566 if not source_mirror_fetch: 576 if not source_mirror_fetch:
567 need_host = d.getVar('COMPATIBLE_HOST') 577 need_host = d.getVar('COMPATIBLE_HOST')
568 if need_host: 578 if need_host:
@@ -573,46 +583,18 @@ python () {
573 583
574 bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split() 584 bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split()
575 585
576 check_license = False if pn.startswith("nativesdk-") else True 586 pkgs = d.getVar('PACKAGES').split()
577 for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}", 587 if pkgs:
578 "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}", 588 skipped_pkgs = oe.license.skip_incompatible_package_licenses(d, pkgs)
579 "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]: 589 unskipped_pkgs = [p for p in pkgs if p not in skipped_pkgs]
580 if pn.endswith(d.expand(t)):
581 check_license = False
582 if pn.startswith("gcc-source-"):
583 check_license = False
584
585 if check_license and bad_licenses:
586 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
587
588 exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
589
590 for lic_exception in exceptions:
591 if ":" in lic_exception:
592 lic_exception = lic_exception.split(":")[1]
593 if lic_exception in oe.license.obsolete_license_list():
594 bb.fatal("Obsolete license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception)
595
596 pkgs = d.getVar('PACKAGES').split()
597 skipped_pkgs = {}
598 unskipped_pkgs = []
599 for pkg in pkgs:
600 remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
601
602 incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg)
603 if incompatible_lic:
604 skipped_pkgs[pkg] = incompatible_lic
605 else:
606 unskipped_pkgs.append(pkg)
607 590
608 if unskipped_pkgs: 591 if unskipped_pkgs:
609 for pkg in skipped_pkgs: 592 for pkg in skipped_pkgs:
610 bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg]))) 593 bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
611 d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
612 for pkg in unskipped_pkgs: 594 for pkg in unskipped_pkgs:
613 bb.debug(1, "Including the package %s" % pkg) 595 bb.debug(1, "Including the package %s" % pkg)
614 else: 596 else:
615 incompatible_lic = incompatible_license(d, bad_licenses) 597 incompatible_lic = oe.license.incompatible_license(d, bad_licenses)
616 for pkg in skipped_pkgs: 598 for pkg in skipped_pkgs:
617 incompatible_lic += skipped_pkgs[pkg] 599 incompatible_lic += skipped_pkgs[pkg]
618 incompatible_lic = sorted(list(set(incompatible_lic))) 600 incompatible_lic = sorted(list(set(incompatible_lic)))
@@ -682,9 +664,9 @@ python () {
682 elif path.endswith('.deb'): 664 elif path.endswith('.deb'):
683 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') 665 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
684 666
685 # *.7z should DEPEND on p7zip-native for unpacking 667 # *.7z should DEPEND on 7zip-native for unpacking
686 elif path.endswith('.7z'): 668 elif path.endswith('.7z'):
687 d.appendVarFlag('do_unpack', 'depends', ' p7zip-native:do_populate_sysroot') 669 d.appendVarFlag('do_unpack', 'depends', ' 7zip-native:do_populate_sysroot')
688 670
689 set_packagetriplet(d) 671 set_packagetriplet(d)
690 672