Skip to content

Commit

Permalink
scripts: sbom: Fix lookup for sysbuild case
Browse files Browse the repository at this point in the history
When sysbuild is enabled, check each domain.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
  • Loading branch information
pdunaj authored and rlubos committed Oct 11, 2024
1 parent cbad6dd commit 3924049
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions scripts/west_commands/sbom/input_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from args import args
from data_structure import Data, FileInfo
from common import SbomException, command_execute
import yaml


DEFAULT_BUILD_DIR = 'build'
Expand Down Expand Up @@ -399,7 +400,13 @@ def test_tool(arg_name: str, cmake_var_name: str) -> str:
return result

try:
with open(build_dir / 'CMakeCache.txt', 'r') as fd:
domains = yaml.safe_load(open(os.path.join(build_dir, 'domains.yaml'), 'r'))
cmakecache = os.path.join(build_dir, domains['default'], 'CMakeCache.txt')
except FileNotFoundError:
cmakecache = os.path.join(build_dir, 'CMakeCache.txt')

try:
with open(cmakecache, 'r') as fd:
cmake_cache = fd.read()
except FileNotFoundError as ex:
raise SbomException('Cannot find "CMakeCache.txt".\n'
Expand Down Expand Up @@ -427,9 +434,16 @@ def generate_input(data: Data):
log.wrn('Fetching input files from a build directory is experimental for now.')
check_external_tools(Path(args.build_dir[0][0]))
for build_dir, *targets in args.build_dir:
if len(targets) == 0:
targets = [DEFAULT_TARGET]
log.dbg(f'INPUT: build directory: {build_dir}, targets: {targets}')
b = InputBuild(data, build_dir)
for target in targets:
b.generate_from_target(target)
try:
domains = yaml.safe_load(open(os.path.join(build_dir, 'domains.yaml'), 'r'))
domains = [d['name'] for d in domains['domains']]
except FileNotFoundError:
domains = ['.']
for domain in domains:
domain_build_dir = Path(os.path.join(build_dir, domain))
if len(targets) == 0:
targets = [DEFAULT_TARGET]
log.dbg(f'INPUT: build directory: {domain_build_dir}, targets: {targets}')
b = InputBuild(data, domain_build_dir)
for target in targets:
b.generate_from_target(target)

0 comments on commit 3924049

Please sign in to comment.