From f4be6f6d859938b22dd62785a13ef3df2f80143d Mon Sep 17 00:00:00 2001 From: Reka Norman Date: Thu, 16 Sep 2021 10:50:02 +1000 Subject: [PATCH] util/spd_tools: Add 'Generated by' string to part_id_gen output files Add a 'Generated by' string to the generated Makefile.inc and dram_id.generated.txt, showing the command used to generate the files. BUG=b:191776301 TEST=Run part_id_gen, check that the generated files contain the string Signed-off-by: Reka Norman Change-Id: Ic9a7826212a732288f36f111b7bc20365a1f702d Reviewed-on: https://review.coreboot.org/c/coreboot/+/57692 Tested-by: build bot (Jenkins) Reviewed-by: Maxim Polyakov Reviewed-by: Furquan Shaikh --- util/spd_tools/src/part_id_gen/part_id_gen.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/util/spd_tools/src/part_id_gen/part_id_gen.go b/util/spd_tools/src/part_id_gen/part_id_gen.go index 10388bfbf9..781c244cd4 100644 --- a/util/spd_tools/src/part_id_gen/part_id_gen.go +++ b/util/spd_tools/src/part_id_gen/part_id_gen.go @@ -244,6 +244,13 @@ type partIds struct { memParts string } +func getFileHeader() string { + return `# SPDX-License-Identifier: GPL-2.0-or-later +# This is an auto-generated file. Do not edit!! +# Generated by: +` + fmt.Sprintf("# %s\n\n", strings.Join(os.Args[0:], " ")) +} + /* * For each part used by the variant, check if the SPD (as per the manifest) already has an ID * assigned to it. If yes, then add the part name to the list of memory parts supported by the @@ -339,22 +346,19 @@ func genPartIdInfo(parts []usedPart, partToSPDMap map[string]string, SPDToIndexM } fmt.Printf("%s", s) + + s = getFileHeader() + s err := ioutil.WriteFile(filepath.Join(makefileDirName, DRAMIdFileName), []byte(s), 0644) return partIdList, err } -var generatedCodeLicense string = "## SPDX-License-Identifier: GPL-2.0-or-later" -var autoGeneratedInfo string = "## This is an auto-generated file. Do not edit!!" - /* * This function generates Makefile.inc under the variant directory path and adds assigned SPDs * to SPD_SOURCES. */ func genMakefile(partIdList []partIds, makefileDirName string, SPDDir string) error { - var s string - - s += fmt.Sprintf("%s\n%s\n\n", generatedCodeLicense, autoGeneratedInfo) + s := getFileHeader() s += fmt.Sprintf("SPD_SOURCES =\n") for i := 0; i < len(partIdList); i++ {