summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/package.py')
-rw-r--r--meta/lib/oe/package.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 0bcc04ea54..60392cbced 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -1049,6 +1049,49 @@ def copydebugsources(debugsrcdir, sources, d):
1049 if os.path.exists(p) and not os.listdir(p): 1049 if os.path.exists(p) and not os.listdir(p):
1050 os.rmdir(p) 1050 os.rmdir(p)
1051 1051
1052def save_debugsources_info(debugsrcdir, sources_raw, d):
1053 import json
1054 import bb.compress.zstd
1055 if debugsrcdir and sources_raw:
1056 debugsources_file = d.expand("${PKGDESTWORK}/debugsources/${PN}-debugsources.json.zstd")
1057 debugsources_dir = os.path.dirname(debugsources_file)
1058 if not os.path.isdir(debugsources_dir):
1059 bb.utils.mkdirhier(debugsources_dir)
1060 bb.utils.remove(debugsources_file)
1061
1062 workdir = d.getVar("WORKDIR")
1063 pn = d.getVar('PN')
1064
1065 # Kernel sources are in a different directory and are special case
1066 # we format the sources as expected by spdx by replacing /usr/src/kernel/
1067 # into BP/
1068 kernel_src = d.getVar('KERNEL_SRC_PATH')
1069 bp = d.getVar('BP')
1070 sources_dict = {}
1071 for file, src_files in sources_raw:
1072 file_clean = file.replace(f"{workdir}/package/","")
1073 sources_clean = [
1074 src.replace(f"{debugsrcdir}/{pn}/", "")
1075 if not kernel_src else src.replace(f"{kernel_src}/", f"{bp}/")
1076 for src in src_files
1077 if not any(keyword in src for keyword in ("<internal>", "<built-in>")) and not src.endswith("/")
1078 ]
1079 sources_dict[file_clean] = sorted(sources_clean)
1080 num_threads = int(d.getVar("BB_NUMBER_THREADS"))
1081 with bb.compress.zstd.open(debugsources_file, "wt", encoding="utf-8", num_threads=num_threads) as f:
1082 json.dump(sources_dict, f, sort_keys=True)
1083
1084def read_debugsources_info(d):
1085 import json
1086 import bb.compress.zstd
1087 try:
1088 fn = d.expand("${PKGDESTWORK}/debugsources/${PN}-debugsources.json.zstd")
1089 num_threads = int(d.getVar("BB_NUMBER_THREADS"))
1090 with bb.compress.zstd.open(fn, "rt", encoding="utf-8", num_threads=num_threads) as f:
1091 return json.load(f)
1092 except FileNotFoundError:
1093 bb.debug(1, f"File not found: {fn}")
1094 return None
1052 1095
1053def process_split_and_strip_files(d): 1096def process_split_and_strip_files(d):
1054 cpath = oe.cachedpath.CachedPath() 1097 cpath = oe.cachedpath.CachedPath()
@@ -1280,6 +1323,9 @@ def process_split_and_strip_files(d):
1280 # Process the dv["srcdir"] if requested... 1323 # Process the dv["srcdir"] if requested...
1281 # This copies and places the referenced sources for later debugging... 1324 # This copies and places the referenced sources for later debugging...
1282 copydebugsources(dv["srcdir"], sources, d) 1325 copydebugsources(dv["srcdir"], sources, d)
1326
1327 # Save source info to be accessible to other tasks
1328 save_debugsources_info(dv["srcdir"], results, d)
1283 # 1329 #
1284 # End of debug splitting 1330 # End of debug splitting
1285 # 1331 #