summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-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 af0923a63f..ba0d326781 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -1038,6 +1038,49 @@ def copydebugsources(debugsrcdir, sources, d):
1038 if os.path.exists(p) and not os.listdir(p): 1038 if os.path.exists(p) and not os.listdir(p):
1039 os.rmdir(p) 1039 os.rmdir(p)
1040 1040
1041def save_debugsources_info(debugsrcdir, sources_raw, d):
1042 import json
1043 import bb.compress.zstd
1044 if debugsrcdir and sources_raw:
1045 debugsources_file = d.expand("${PKGDESTWORK}/debugsources/${PN}-debugsources.json.zstd")
1046 debugsources_dir = os.path.dirname(debugsources_file)
1047 if not os.path.isdir(debugsources_dir):
1048 bb.utils.mkdirhier(debugsources_dir)
1049 bb.utils.remove(debugsources_file)
1050
1051 workdir = d.getVar("WORKDIR")
1052 pn = d.getVar('PN')
1053
1054 # Kernel sources are in a different directory and are special case
1055 # we format the sources as expected by spdx by replacing /usr/src/kernel/
1056 # into BP/
1057 kernel_src = d.getVar('KERNEL_SRC_PATH')
1058 pf = d.getVar('PF')
1059 sources_dict = {}
1060 for file, src_files in sources_raw:
1061 file_clean = file.replace(f"{workdir}/package/","")
1062 sources_clean = [
1063 src.replace(f"{debugsrcdir}/{pn}/", "")
1064 if not kernel_src else src.replace(f"{kernel_src}/", f"{pf}/")
1065 for src in src_files
1066 if not any(keyword in src for keyword in ("<internal>", "<built-in>")) and not src.endswith("/")
1067 ]
1068 sources_dict[file_clean] = sorted(sources_clean)
1069 num_threads = int(d.getVar("BB_NUMBER_THREADS"))
1070 with bb.compress.zstd.open(debugsources_file, "wt", encoding="utf-8", num_threads=num_threads) as f:
1071 json.dump(sources_dict, f, sort_keys=True)
1072
1073def read_debugsources_info(d):
1074 import json
1075 import bb.compress.zstd
1076 try:
1077 fn = d.expand("${PKGDESTWORK}/debugsources/${PN}-debugsources.json.zstd")
1078 num_threads = int(d.getVar("BB_NUMBER_THREADS"))
1079 with bb.compress.zstd.open(fn, "rt", encoding="utf-8", num_threads=num_threads) as f:
1080 return json.load(f)
1081 except FileNotFoundError:
1082 bb.debug(1, f"File not found: {fn}")
1083 return None
1041 1084
1042def process_split_and_strip_files(d): 1085def process_split_and_strip_files(d):
1043 cpath = oe.cachedpath.CachedPath() 1086 cpath = oe.cachedpath.CachedPath()
@@ -1269,6 +1312,9 @@ def process_split_and_strip_files(d):
1269 # Process the dv["srcdir"] if requested... 1312 # Process the dv["srcdir"] if requested...
1270 # This copies and places the referenced sources for later debugging... 1313 # This copies and places the referenced sources for later debugging...
1271 copydebugsources(dv["srcdir"], sources, d) 1314 copydebugsources(dv["srcdir"], sources, d)
1315
1316 # Save source info to be accessible to other tasks
1317 save_debugsources_info(dv["srcdir"], results, d)
1272 # 1318 #
1273 # End of debug splitting 1319 # End of debug splitting
1274 # 1320 #