diff options
-rw-r--r-- | meta/classes/package.bbclass | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 67351b2510..07bf5eb426 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -574,26 +574,16 @@ def copydebugsources(debugsrcdir, sources, d): | |||
574 | objcopy = d.getVar("OBJCOPY") | 574 | objcopy = d.getVar("OBJCOPY") |
575 | workdir = d.getVar("WORKDIR") | 575 | workdir = d.getVar("WORKDIR") |
576 | sdir = d.getVar("S") | 576 | sdir = d.getVar("S") |
577 | sparentdir = os.path.dirname(os.path.dirname(sdir)) | 577 | cflags = d.expand("${CFLAGS}") |
578 | sbasedir = os.path.basename(os.path.dirname(sdir)) + "/" + os.path.basename(sdir) | ||
579 | workparentdir = os.path.dirname(os.path.dirname(workdir)) | ||
580 | workbasedir = os.path.basename(os.path.dirname(workdir)) + "/" + os.path.basename(workdir) | ||
581 | |||
582 | # If S isnt based on WORKDIR we can infer our sources are located elsewhere, | ||
583 | # e.g. using externalsrc; use S as base for our dirs | ||
584 | if workdir in sdir or 'work-shared' in sdir: | ||
585 | basedir = workbasedir | ||
586 | parentdir = workparentdir | ||
587 | else: | ||
588 | basedir = sbasedir | ||
589 | parentdir = sparentdir | ||
590 | 578 | ||
591 | # If build path exists in sourcefile, it means toolchain did not use | 579 | prefixmap = {} |
592 | # -fdebug-prefix-map to compile | 580 | for flag in cflags.split(): |
593 | if checkbuildpath(sourcefile, d): | 581 | if not flag.startswith("-fdebug-prefix-map"): |
594 | localsrc_prefix = parentdir + "/" | 582 | continue |
595 | else: | 583 | if "recipe-sysroot" in flag: |
596 | localsrc_prefix = "/usr/src/debug/" | 584 | continue |
585 | flag = flag.split("=") | ||
586 | prefixmap[flag[1]] = flag[2] | ||
597 | 587 | ||
598 | nosuchdir = [] | 588 | nosuchdir = [] |
599 | basepath = dvar | 589 | basepath = dvar |
@@ -604,28 +594,26 @@ def copydebugsources(debugsrcdir, sources, d): | |||
604 | bb.utils.mkdirhier(basepath) | 594 | bb.utils.mkdirhier(basepath) |
605 | cpath.updatecache(basepath) | 595 | cpath.updatecache(basepath) |
606 | 596 | ||
607 | # Ignore files from the recipe sysroots (target and native) | 597 | for pmap in prefixmap: |
608 | processdebugsrc = "LC_ALL=C ; sort -z -u '%s' | egrep -v -z '((<internal>|<built-in>)$|/.*recipe-sysroot.*/)' | " | 598 | # Ignore files from the recipe sysroots (target and native) |
609 | # We need to ignore files that are not actually ours | 599 | cmd = "LC_ALL=C ; sort -z -u '%s' | egrep -v -z '((<internal>|<built-in>)$|/.*recipe-sysroot.*/)' | " % sourcefile |
610 | # we do this by only paying attention to items from this package | 600 | # We need to ignore files that are not actually ours |
611 | processdebugsrc += "fgrep -zw '%s' | " | 601 | # we do this by only paying attention to items from this package |
612 | # Remove prefix in the source paths | 602 | cmd += "fgrep -zw '%s' | " % prefixmap[pmap] |
613 | processdebugsrc += "sed 's#%s##g' | " | 603 | # Remove prefix in the source paths |
614 | processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" | 604 | cmd += "sed 's#%s/##g' | " % (prefixmap[pmap]) |
615 | 605 | cmd += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" % (pmap, dvar, prefixmap[pmap]) | |
616 | cmd = processdebugsrc % (sourcefile, basedir, localsrc_prefix, parentdir, dvar, debugsrcdir) | ||
617 | try: | ||
618 | subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) | ||
619 | except subprocess.CalledProcessError: | ||
620 | # Can "fail" if internal headers/transient sources are attempted | ||
621 | pass | ||
622 | |||
623 | # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced. | ||
624 | # Work around this by manually finding and copying any symbolic links that made it through. | ||
625 | cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \ | ||
626 | (dvar, debugsrcdir, dvar, debugsrcdir, parentdir, dvar, debugsrcdir) | ||
627 | subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) | ||
628 | 606 | ||
607 | try: | ||
608 | subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) | ||
609 | except subprocess.CalledProcessError: | ||
610 | # Can "fail" if internal headers/transient sources are attempted | ||
611 | pass | ||
612 | # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced. | ||
613 | # Work around this by manually finding and copying any symbolic links that made it through. | ||
614 | cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s')" % \ | ||
615 | (dvar, prefixmap[pmap], dvar, prefixmap[pmap], pmap, dvar, prefixmap[pmap]) | ||
616 | subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) | ||
629 | 617 | ||
630 | # debugsources.list may be polluted from the host if we used externalsrc, | 618 | # debugsources.list may be polluted from the host if we used externalsrc, |
631 | # cpio uses copy-pass and may have just created a directory structure | 619 | # cpio uses copy-pass and may have just created a directory structure |