github.com/linuxboot/fiano@v1.2.0/pkg/intel/metadata/README.md (about) 1 Prequesites: 2 Open another terminal and go get the sm2/sm3 crypto library into your gopath. 3 The code generator disables go modules. 4 ``` 5 GOPATH=your/go/path go get github.com/tjfoc/gmsm/sm2 6 ``` 7 8 To generalize all the logic related to Boot Policy Manifest and Key Manifest 9 we use code generation. Therefore it is enough to create structure declarations 10 and run command from this directory: 11 ``` 12 go run ./../common/manifestcodegen/cmd/manifestcodegen/ . ./bootpolicy ./key 13 ``` 14 15 It will performe the code autogeneration in directories: 16 * Current directory (`.`), which contains common structures for different manifests; 17 * Boot Policy Manifest directory (`./bootpolicy`); 18 * and Key Manifest directory (`./key`). 19 20 To check if the files are in the up-to-date state, one may add option `-check`: 21 ``` 22 go run ./../common/manifestcodegen/cmd/manifestcodegen/ -check . ./bootpolicy ./key 23 ``` 24 25 Or if it is required to debug/trace the behavior of autogenerated code, one 26 may add option `-trace`: 27 ``` 28 go run ./../common/manifestcodegen/cmd/manifestcodegen/ -trace . ./bootpolicy ./key 29 ``` 30 31 In this case the code will write a verbose log into stdout. 32 33 If you need to edit the template, please edit file: `./common/manifestcodegen/cmd/manifestcodegen/template_methods.tpl.go`. 34 35 # Field tags 36 37 There are few special struct field tags which are recognized by the code 38 generator: 39 * `id` -- defines the element Structure ID string (for example `__TXTS__`). 40 * `version` -- defines the value of `StructVersion` (see document #575623). 41 * `countType` -- used only for slices and it defines which variable type is 42 used to store amount of items of the slice. Arrays in a structure in a Manifest 43 is almost always prepended with a count variable, and we automatically map 44 it to the real amount of elements of our slice. And to do that we need to know 45 the bitsize of the counter, therefore this tag exists. 46 * `countValue` -- (see also `countType`) sometimes a counter requires special 47 transformations before it could be maped into the real amount of elements 48 of a slice. `countValue` allows to define a function to calculate the 49 real count value. 50 * `require` -- defines the value required by the document #575623. 51 * `default` -- defines the default value. 52 * `prettyValue` -- defines the function which prints the value in a pretty format. 53 * `rehashValue` -- is used to receive an auto-updated value, for example it could 54 be handy to automatically update size-fields. 55 56 See also: 57 ``` 58 grep -RIn field.TagGet ./ 59 ```