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 <rekanorman@google.com>
Change-Id: Ic9a7826212a732288f36f111b7bc20365a1f702d
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57692
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Maxim Polyakov <max.senia.poliak@gmail.com>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Reka Norman 2021-09-16 10:50:02 +10:00 committed by Furquan Shaikh
parent 4e4e2d7ab1
commit f4be6f6d85
1 changed files with 10 additions and 6 deletions

View File

@ -244,6 +244,13 @@ type partIds struct {
memParts string 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 * 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 * 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) fmt.Printf("%s", s)
s = getFileHeader() + s
err := ioutil.WriteFile(filepath.Join(makefileDirName, DRAMIdFileName), []byte(s), 0644) err := ioutil.WriteFile(filepath.Join(makefileDirName, DRAMIdFileName), []byte(s), 0644)
return partIdList, err 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 * This function generates Makefile.inc under the variant directory path and adds assigned SPDs
* to SPD_SOURCES. * to SPD_SOURCES.
*/ */
func genMakefile(partIdList []partIds, makefileDirName string, SPDDir string) error { func genMakefile(partIdList []partIds, makefileDirName string, SPDDir string) error {
var s string s := getFileHeader()
s += fmt.Sprintf("%s\n%s\n\n", generatedCodeLicense, autoGeneratedInfo)
s += fmt.Sprintf("SPD_SOURCES =\n") s += fmt.Sprintf("SPD_SOURCES =\n")
for i := 0; i < len(partIdList); i++ { for i := 0; i < len(partIdList); i++ {