Handle backfilling
389 oe.utils.features_backfill("DISTRO_FEATURES", d)
390 oe.utils.features_backfill("MACHINE_FEATURES", d)
--110 def features_backfill(var,d):
111 # This construct allows the addition of new features to variable specified
112 # as var
113 # Example for var = "DISTRO_FEATURES"
114 # This construct allows the addition of new features to DISTRO_FEATURES
115 # that if not present would disable existing functionality, without
116 # disturbing distributions that have already set DISTRO_FEATURES.
117 # Distributions wanting to elide a value in DISTRO_FEATURES_BACKFILL should
118 # add the feature to DISTRO_FEATURES_BACKFILL_CONSIDERED
119 features = (d.getVar(var) or "").split()
120 backfill = (d.getVar(var+"_BACKFILL") or "").split()
121 considered = (d.getVar(var+"_BACKFILL_CONSIDERED") or "").split()
122
123 addfeatures = []
124 for feature in backfill:
125 | if feature not in features and feature not in considered:
126 | | addfeatures.append(feature)
127
128 if addfeatures:
129 | d.appendVar(var, " " + " ".join(addfeatures))
Handle PACKAGECONFIG
用到的方法
d.expand(varname) 如果變量中有${}朴皆,就展開
-- 398 def expandWithRefs(self, s, varname):
399
>> 400 | if not isinstance(s, str): # sanity check
401 | | return VariableParse(varname, self, s)
402
403 | varparse = VariableParse(varname, self)
404
405 | while s.find('${') != -1:
406 | | olds = s
407 | | try:
408 | | | s = __expand_var_regexp__.sub(varparse.var_sub, s)
409 | | | try:
410 | | | | s = __expand_python_regexp__.sub(varparse.python_sub, s)
-- 411 | | | except SyntaxError as e:
>> 412 | | | | # Likely unmatched brackets, just don't expand the expression
>> 413 | | | | if e.msg != "EOL while scanning string literal" and not e.msg.startswith("unterminated string literal"):
414 | | | | | raise
415 | | | if s == olds:
416 | | | | break
-- 417 | | except ExpansionError as e:
418 | | | e.addVar(varname)
419 | | | raise
420 | | except bb.parse.SkipRecipe:
421 | | | raise
422 | | except bb.BBHandledException:
423 | | | raise
424 | | except Exception as exc:
-- 425 | | | tb = sys.exc_info()[2]
>> 426 | | | raise ExpansionError(varname, s, exc).with_traceback(tb) from exc
427
428 | varparse.value = s
429
430 | return varparse
431
-- 432 def expand(self, s, varname = None):
433 | return self.expandWithRefs(s, varname).value
bb.utils.explode_deps
160 def explode_deps(s):
161 """ 格式化
162 Take an RDEPENDS style string of format:
163 "DEPEND1 (optional version) DEPEND2 (optional version) ..."
164 and return a list of dependencies.
165 Version information is ignored.
166 """
根據(jù)PACKAGECONFIG和其flags([])以及MLPREFIX去擴(kuò)展變量 DEPENDS RDEPENDS:${PN} RRECOMMENDS:${PN} PACKAGECONFIG_CONFARGS
408 pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {}
409 if pkgconfigflags:
410 | pkgconfig = (d.getVar('PACKAGECONFIG') or "").split()
411 | pn = d.getVar("PN")
412
413 | mlprefix = d.getVar("MLPREFIX")
414
415 | def expandFilter(appends, extension, prefix):
416 | | appends = bb.utils.explode_deps(d.expand(" ".join(appends)))
417 | | newappends = []
418 | | for a in appends:
419 | | | if a.endswith("-native") or ("-cross-" in a):
420 | | | | newappends.append(a)
421 | | | elif a.startswith("virtual/"):
422 | | | | subs = a.split("/", 1)[1]
423 | | | | if subs.startswith(prefix):
424 | | | | | newappends.append(a + extension)
425 | | | | else:
>>426 | | | | | newappends.append("virtual/" + prefix + subs + extension)
427 | | | else:
428 | | | | if a.startswith(prefix):
429 | | | | | newappends.append(a + extension)
430 | | | | else:
431 | | | | | newappends.append(prefix + a + extension)
432 | | return newappends
433
434 | def appendVar(varname, appends):
435 | | if not appends:
436 | | | return
437 | | if varname.find("DEPENDS") != -1:
>>438 | | | if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) :
439 | | | | appends = expandFilter(appends, "", "nativesdk-")
440 | | | elif bb.data.inherits_class('native', d):
441 | | | | appends = expandFilter(appends, "-native", "")
442 | | | elif mlprefix:
443 | | | | appends = expandFilter(appends, "", mlprefix)
444 | | varname = d.expand(varname)
445 | | d.appendVar(varname, " " + " ".join(appends))
446
447 | extradeps = []
448 | extrardeps = []
449 | extrarrecs = []
450 | extraconf = []
451 | for flag, flagval in sorted(pkgconfigflags.items()):
452 | | items = flagval.split(",")
453 | | num = len(items)
454 | | if num > 6:
>>455 | | | bb.error("%s: PACKAGECONFIG[%s] Only enable,disable,depend,rdepend,rrecommend,conflict_packageconfig can be specified!"
>>456 | | | | % (d.getVar('PN'), flag))
457
458 +-- 24 lines: if flag in pkgconfig:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
482
483 | appendVar('DEPENDS', extradeps)
484 | appendVar('RDEPENDS:${PN}', extrardeps)
485 | appendVar('RRECOMMENDS:${PN}', extrarrecs)
486 | appendVar('PACKAGECONFIG_CONFARGS', extraconf)
license處理
不看
非(沒有繼承)native|cross的recipe
>>507 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
>>508 | d.appendVarFlag('do_prepare_recipe_sysroot', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
>>509 | d.appendVarFlag('do_install', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
510 | d.setVarFlag('do_install', 'fakeroot', '1')
>>511 | d.appendVarFlag('do_package', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
512 | d.setVarFlag('do_package', 'fakeroot', '1')
513 | d.setVarFlag('do_package_setscene', 'fakeroot', '1')
>>514 | d.appendVarFlag('do_package_setscene', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
515 | d.setVarFlag('do_devshell', 'fakeroot', '1')
>>516 | d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
添加do_prepare_recipe_sysroot do_install do_package do_package_setscene do_devshell
對 virtual/fakeroot
的依賴项戴。
兼容主機(jī)處理
518 need_machine = d.getVar('COMPATIBLE_MACHINE')
519 if need_machine and not d.getVar('PARSE_ALL_RECIPES', False):
520 | import re
521 | compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":")
522 | for m in compat_machines:
523 | | if re.match(need_machine, m):
524 | | | break
525 | else:
>>526 | | raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE'))
PARSE_ALL_RECIPES 和 SOURCE_MIRROR_FETCH
這塊感覺跟編譯沒啥關(guān)系汉柒,看注釋把
11098 # $SOURCE_MIRROR_FETCH
11099 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/documentation.conf:390
11100 # [doc] "Switch marking build as source fetcher. Used to skip COMPATIBLE_* checking."
fetch處理
主要是 不同的下載內(nèi)容關(guān)聯(lián)不同的依賴,比如下載內(nèi)容是git鳍刷,則do_fetch[deps] += git-native:do_populate_sysroot
592 needsrcrev = False
593 srcuri = d.getVar('SRC_URI')
594 for uri_string in srcuri.split():
595 | uri = bb.fetch.URI(uri_string)
>>596 | # Also check downloadfilename as the URL path might not be useful for sniffing
597 | path = uri.params.get("downloadfilename", uri.path)
598
599 | # HTTP/FTP use the wget fetcher
600 | if uri.scheme in ("http", "https", "ftp"):
>>601 | | d.appendVarFlag('do_fetch', 'depends', ' wget-native:do_populate_sysroot')
602
603 +-- 5 lines: Svn packages should DEPEND on subversion-native---------------------------------------------------------------------------------------------------------------------------------------------------
608 | # Git packages should DEPEND on git-native
609 | elif uri.scheme in ("git", "gitsm"):
610 | | needsrcrev = True
>>611 | | d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot')
612
613 +-- 17 lines: Mercurial packages should DEPEND on mercurial-native----------------------------------------------------------------------------------------------------------------------------------------------
630 | # *.lz4 should DEPEND on lz4-native for unpacking
631 | if path.endswith('.lz4'):
>>632 | | d.appendVarFlag('do_unpack', 'depends', ' lz4-native:do_populate_sysroot')
633
634 | # *.zst should DEPEND on zstd-native for unpacking
635 +-- 11 lines: elif path.endswith('.zst'):-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
646 | # .zip should DEPEND on unzip-native for unpacking
647 | elif path.endswith('.zip') or path.endswith('.jar'):
>>648 | | d.appendVarFlag('do_unpack', 'depends', ' unzip-native:do_populate_sysroot')
649
>>650 | # Some rpm files may be compressed internally using xz (for example, rpms from Fedora)
651 | elif path.endswith('.rpm'):
>>652 | | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
653
654 | # *.deb should DEPEND on xz-native for unpacking
655 | elif path.endswith('.deb'):
>>656 | | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
657
658 if needsrcrev:
659 | d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
660
661 | # Gather all named SRCREVs to add to the sstate hash calculation
662 | # This anonymous python snippet is called multiple times so we
663 | # need to be careful to not double up the appends here and cause
664 | # the base hash to mismatch the task hash
665 | for uri in srcuri.split():
666 | | parm = bb.fetch.decodeurl(uri)[5]
667 | | uri_names = parm.get("name", "").split(",")
668 | | for uri_name in filter(None, uri_names):
669 | | | srcrev_name = "SRCREV_{}".format(uri_name)
>>670 | | | if srcrev_name not in (d.getVarFlag("do_fetch", "vardeps") or "").split():
>>671 | | | | d.appendVarFlag("do_fetch", "vardeps", " {}".format(srcrev_name))
set_packagetriplet
>>354 def set_packagetriplet(d):
>>355 archs = []
356 tos = []
357 tvs = []
358
359 archs.append(d.getVar("PACKAGE_ARCHS").split())
360 tos.append(d.getVar("TARGET_OS"))
361 tvs.append(d.getVar("TARGET_VENDOR"))
362
363 def settriplet(d, varname, archs, tos, tvs):
364 | triplets = []
365 | for i in range(len(archs)):
366 | | for arch in archs[i]:
367 | | | triplets.append(arch + tvs[i] + "-" + tos[i])
368 | triplets.reverse()
369 | d.setVar(varname, " ".join(triplets))
370
371 settriplet(d, "PKGTRIPLETS", archs, tos, tvs)
372
373 variants = d.getVar("MULTILIB_VARIANTS") or ""
374 for item in variants.split():
375 | localdata = bb.data.createCopy(d)
>>376 | overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item
377 | localdata.setVar("OVERRIDES", overrides)
378
379 | archs.append(localdata.getVar("PACKAGE_ARCHS").split())
380 | tos.append(localdata.getVar("TARGET_OS"))
381 | tvs.append(localdata.getVar("TARGET_VENDOR"))
382
383 settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs)
初始化變量 PKGTRIPLETS PKGMLTRIPLETS
奸忽,由變量 PACKAGE_ARCHS TARGET_OS TARGET_VENDOR
組成何鸡;相應(yīng)示例:
4690 # $PACKAGE_ARCHS [3 operations]
4691 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/bitbake.conf:154
4692 # "all any noarch ${PACKAGE_EXTRA_ARCHS} ${MACHINE_ARCH}"
4693 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/bitbake.conf:157
4694 # [vardepsexclude] "MACHINE_ARCH"
4695 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/documentation.conf:311
4696 # [doc] "A list of architectures compatible with the given target in order of priority."
4697 # pre-expansion value:
4698 # "all any noarch ${PACKAGE_EXTRA_ARCHS} ${MACHINE_ARCH}"
4699 PACKAGE_ARCHS="all any noarch x86_64 core2-64 genericx86_64"
12054 # $TARGET_VENDOR [2 operations]
12055 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/bitbake.conf:132
12056 # "-oe"
12057 # set /home/zhangsong/work/about_yocto/sources/poky/meta-poky/conf/distro/poky.conf:11
12058 # "-poky"
12059 # pre-expansion value:
12060 # "-poky"
12061 TARGET_VENDOR="-poky"
12027 # $TARGET_OS [2 operations]
12028 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/bitbake.conf:131
12029 # "linux${LIBCEXTENSION}${ABIEXTENSION}"
12030 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/documentation.conf:421
12031 # [doc] "Specifies the target's operating system."
12032 # pre-expansion value:
12033 # "linux${LIBCEXTENSION}${ABIEXTENSION}"
12034 TARGET_OS="linux"
5007 # $PKGTRIPLETS
5008 # set base.bbclass:369 [settriplet]
5009 # "genericx86_64-poky-linux core2-64-poky-linux x86_64-poky-linux noarch-poky-linux any-poky-linux all-poky-linux"
5010 PKGTRIPLETS="genericx86_64-poky-linux core2-64-poky-linux x86_64-poky-linux noarch-poky-linux any-poky-linux all-poky-linux"
4997 # $PKGMLTRIPLETS
4998 # set base.bbclass:369 [settriplet]
4999 # "genericx86_64-poky-linux core2-64-poky-linux x86_64-poky-linux noarch-poky-linux any-poky-linux all-poky-linux"
5000 PKGMLTRIPLETS="genericx86_64-poky-linux core2-64-poky-linux x86_64-poky-linux noarch-poky-linux any-poky-linux all-poky-linux"
PACKAGE_ARCH 與 MACHINE_ARCH 不一致的情況
# $PACKAGE_ARCHS
[doc] "A list of architectures compatible with the given target in order of priority."
4679 # $PACKAGE_ARCH [3 operations]
4680 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/bitbake.conf:151
4681 # [_defaultval] "${TUNE_PKGARCH}"
4682 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/documentation.conf:310
4683 # [doc] "The architecture of the resulting package or packages."
4684 # set /home/zhangsong/work/about_yocto/sources/poky/meta/classes/grub-efi-cfg.bbclass:30
4685 # "${MACHINE_ARCH}"
4686 # pre-expansion value:
4687 # "${MACHINE_ARCH}"
4688 PACKAGE_ARCH="genericx86_64"
4229 # $MACHINE_ARCH
4230 # set /home/zhangsong/work/about_yocto/sources/poky/meta/conf/bitbake.conf:152
4231 # "${@[d.getVar('TUNE_PKGARCH'), d.getVar('MACHINE')][bool(d.getVar('MACHINE'))].replace('-', '_')}"
4232 MACHINE_ARCH="genericx86_64"
# $MACHINE
[doc] "Specifies the target device for which the image is built. You define MACHINE in the conf/local.conf file in the Build Directory."
不知道 MACHINE 與 PACKAGE_ARCH 不一致是什么情況渐北,不管這個~