-
Notifications
You must be signed in to change notification settings - Fork 1
Description
-
Should the sbom.py be placed into
linux/toolsorlinux/scripts?linux/ └── tools/ └── sbom/ ├── lib/ ├── tests/ ├── Makefile └── sbom.pylinux/ └── scripts/ └── lib/ ├── sbom/ │ ├── cmd_graph/ │ ├── spdx/ │ └── spdx_graph/ └── sbom.pyA: I am leaning towards
toolsbecause tools seem to be more commonly invoked within themakebuild process. We could for example do things similar to howobjtooldoes it. -
How to call the tool via make?
A: If we put the sbom.py script intotoolswe can call it manually viamake -C tools sbom. For that, a make rule needs to be added to the top leveltools/Makefile:sbom: FORCE $(call descend,sbom)This
descendsinto the customtools/sbom/Makefilewhich then invokes the python script. However, this would create an entirely new process separate to the kernel build itself. In this process we would not have access to make variables such asARCHorHOSTCC. Therefore, we need to call the sbom script directly from within the main make process.
We could do things similar to howobjtooldoes it, i.e., definining aCONFIG_SBOMoption (similar toCONFIG_OBJTOOLin linux/lib/Kconfig.debug). Then we can conditionally check if this option is set similar to here:ifdef CONFIG_OBJTOOL prepare: tools/objtool endif
In our case we would do:
ifdef CONFIG_SBOM all: tools/sbom endif
In theory via a pattern rule the make command would already be delegated to
tools/Makefile. However, the tool should only run after the build has finished. This requires an explicit rule that depends on some targets. Probably something like this:ifdef CONFIG_SBOM all: tools/sbom tools/sbom: vmlinux modules $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ sbom endif
Note: There is a comment that states that for new tools no new tools/* entry should be added but instead the "hostprogs" syntax should be used, see documentation/kbuild/makefiles. This seems to only be relevant for compiled tools.