Lines Matching +full:if +full:- +full:no +full:- +full:files +full:- +full:found
1 # Copyright (c) 2020-2021 The Linux Foundation
3 # SPDX-License-Identifier: Apache-2.0
29 # should also analyze for included header files?
36 # build files, and corresponding source and SDK files, and gathers the
43 # configuration - WalkerConfig
56 # queue of pending source Files to create, process and assign
75 if not url:
81 …|http(s)?:\/\/)(?P<base_url>[\w\.@]+)(\/|:))(?P<namespace>[\w,\-,\_]+)\/(?P<package>[\w,\-,\_]+)(.…
84 if match:
87 if purl and (version or len(version) > 0):
110 # check if meta file is generated
111 if not self.metaFile:
112 log.err("CONFIG_BUILD_OUTPUT_META must be enabled to generate spdx files; bailing")
116 log.inf("parsing CMake Codemodel files")
118 if not self.cm:
125 if not retval:
132 # walk through pending sources and create corresponding files
133 log.inf("walking through pending sources files")
146 if self.cmakeCache:
151 # determine path from build dir to CMake file-based API index file, then
154 log.dbg("getting codemodel from CMake API reply files")
158 if not os.path.exists(cmakeReplyDirPath):
162 if not os.path.isdir(cmakeReplyDirPath):
169 if f.startswith("index"):
172 if indexFilePath == "":
174 log.err(f'cmake api reply index file not found in {cmakeReplyDirPath}')
183 cfgApp.name = "app-sources"
185 cfgApp.docRefID = "DocumentRef-app"
190 cfgPackageApp.name = "app-sources"
191 cfgPackageApp.spdxID = "SPDXRef-app-sources"
205 cfgBuild.docRefID = "DocumentRef-build"
225 cfgZephyr.name = "zephyr-sources"
227 cfgZephyr.docRefID = "DocumentRef-zephyr"
239 cfgPackageZephyr.name = "zephyr-sources"
240 cfgPackageZephyr.spdxID = "SPDXRef-zephyr-sources"
244 if zephyr_url:
247 if zephyr.get("revision"):
252 if zephyr_tags:
258 if purl:
262 if cfgPackageZephyr.version == "" and version:
265 if len(cfgPackageZephyr.version) > 0:
266 cpe = f'cpe:2.3:o:zephyrproject:zephyr:{cfgPackageZephyr.version}:-:*:*:*:*:*:*'
280 if not module_name:
286 cfgPackageZephyrModule.name = module_name + "-sources"
287 cfgPackageZephyrModule.spdxID = "SPDXRef-" + module_name + "-sources"
291 if module_revision:
294 if module_url:
309 cfgSDK.docRefID = "DocumentRef-sdk"
315 cfgPackageSDK.spdxID = "SPDXRef-sdk"
335 cfgModuleExtRef.name = "modules-deps"
336 cfgModuleExtRef.namespace = self.cfg.namespacePrefix + "/modules-deps"
337 cfgModuleExtRef.docRefID = "DocumentRef-modules-deps"
344 if not module_name:
349 if module_security:
350 module_ext_ref = module_security.get("external-references")
354 cfgPackageModuleExtRef.name = module_name + "-deps"
355 cfgPackageModuleExtRef.spdxID = "SPDXRef-" + module_name + "-deps"
375 if not self.setupZephyrDocument(content["zephyr"], content["modules"]):
383 if self.cfg.includeSDK:
401 if len(cfgTarget.target.artifacts) > 0:
404 if pkg.cfg.name == "zephyr_final":
409 # get its source files if build file is found
410 if bf:
413 log.dbg(f" - target {cfgTarget.name} has no build artifacts")
420 log.dbg(f" - initializing Package for target: {cfgTarget.name}")
425 cfg.spdxID = "SPDXRef-" + zspdx.spdxids.convertToSPDXIDSafe(cfgTarget.name)
443 log.dbg(f" - adding File {artifactPath}")
444 log.dbg(f" - relativeBaseDir: {pkg.cfg.relativeBaseDir}")
445 log.dbg(f" - artifacts[0]: {cfgTarget.target.artifacts[0]}")
447 # don't create build File if artifact path points to nonexistent file
448 if not os.path.exists(artifactPath):
449 …log.dbg(f" - target {cfgTarget.name} lists build artifact {artifactPath} but file not found after…
461 pkg.files[bf.spdxID] = bf
472 # collect a target's source files, add to pending sources queue, and
479 log.dbg(f" - collecting source files and adding to pending queue")
485 log.dbg(f" - add pending source file and relationship for {src.path}")
486 # get absolute path if we don't have it
488 if not os.path.isabs(src.path):
492 if not (os.path.exists(srcAbspath) and os.path.isfile(srcAbspath)):
493 …log.dbg(f" - {srcAbspath} does not exist but is referenced in sources for target {pkg.cfg.name}; …
496 # add it to pending source files queue
511 if self.cfg.analyzeIncludes and self.compilerPath:
516 # make relationships for the overall included files,
517 # avoiding duplicates for multiple source files including
522 # add it to pending source files queue
536 # collect the include files corresponding to this source file
542 # returns: sorted list of include files for this source file
545 if len(cfgTarget.target.compileGroups) < (src.compileGroupIndex + 1):
546 … - {cfgTarget.target.name} has compileGroupIndex {src.compileGroupIndex} but only {len(cfgTarget.…
551 if cg.language != "C":
552 …f" - {cfgTarget.target.name} has compile group language {cg.language} but currently only search…
556 if src.path[0] != "/":
566 log.dbg(f" - collecting target dependencies for {pkg.cfg.name}")
573 log.dbg(f" - adding pending relationship for {depName}")
586 # if this is a target with any build artifacts (e.g. non-UTILITY),
587 # also create STATIC_LINK relationship for dependency build files,
589 if len(cfgTarget.target.artifacts) == 0:
597 if ct.name == depName:
599 if len(ct.target.artifacts) == 0:
605 if depAbspath == "":
608 # create relationship data between build files
619 # walk through pending sources and create corresponding files,
627 if self.cfg.includeSDK:
634 if srcDoc:
635 log.dbg(f" - {srcAbspath}: already seen, assigned to {srcDoc.cfg.name}")
642 if pkgBuild:
643 … log.dbg(f" - {srcAbspath}: assigning to build document, package {pkgBuild.cfg.name}")
647 log.dbg(f" - {srcAbspath}: assigning to sdk document")
651 log.dbg(f" - {srcAbspath}: assigning to app document")
655 log.dbg(f" - {srcAbspath}: assigning to zephyr document")
659 log.dbg(f" - {srcAbspath}: can't determine which document should own; skipping")
671 srcPkg.files[sf.spdxID] = sf
677 # figure out which Package contains the given file, if any
681 # Multiple target Packages might "contain" the file path, if they
682 # are nested. If so, the one with the longest path would be the
683 # most deeply-nested target directory, so that's the one which
687 if os.path.commonpath([srcAbspath, pkg.cfg.relativeBaseDir]) == pkg.cfg.relativeBaseDir:
689 if pkgLongestMatch:
690 if len(pkg.cfg.relativeBaseDir) > len(pkgLongestMatch.cfg.relativeBaseDir):
705 # Relationships, and assign them to the applicable Files / Packages
711 if not docA or not spdxIDA:
716 if not spdxIDB:
721 … log.dbg(f" - adding relationship to {docA.cfg.name}: {rln.refA} {rln.rlnType} {rln.refB}")
726 if rlnData.ownerType == RelationshipDataElementType.FILENAME:
729 if not ownerDoc:
730 …log.dbg(f" - searching for relationship, can't find document with file {rlnData.ownerFileAbspath}…
733 if not sf:
734 …log.dbg(f" - searching for relationship for file {rlnData.ownerFileAbspath} points to document {o…
736 # found it
737 if not sf.spdxID:
738 …log.dbg(f" - searching for relationship for file {rlnData.ownerFileAbspath} found file, but empty…
747 if pkg.cfg.name == rlnData.ownerTargetName:
748 if not pkg.cfg.spdxID:
749 …log.dbg(f" - searching for relationship for target {rlnData.ownerTargetName} found package, but e…
752 …log.dbg(f" - searching for relationship for target {rlnData.ownerTargetName}, target not found in…
755 # will always be SPDXRef-DOCUMENT
756 return rlnData.ownerDocument, "SPDXRef-DOCUMENT", rlnData.ownerDocument.relationships
758 log.dbg(f" - unknown relationship type {rlnData.ownerType}; skipping")
763 if rlnData.otherType == RelationshipDataElementType.FILENAME:
766 if not otherDoc:
767 …log.dbg(f" - searching for relationship, can't find document with file {rlnData.otherFileAbspath}…
770 if not bf:
771 …log.dbg(f" - searching for relationship for file {rlnData.otherFileAbspath} points to document {o…
773 # found it
774 if not bf.spdxID:
775 …log.dbg(f" - searching for relationship for file {rlnData.otherFileAbspath} found file, but empty…
779 if otherDoc != docA:
789 if pkg.cfg.name == rlnData.otherTargetName:
790 if not pkg.cfg.spdxID:
791 …log.dbg(f" - searching for relationship for target {rlnData.otherTargetName} found package, but e…
794 if otherDoc != docA:
798 …log.dbg(f" - searching for relationship for target {rlnData.otherTargetName}, target not found in…
804 log.dbg(f" - unknown relationship type {rlnData.otherType}; skipping")