If two files depend on the same file we ended up overwriting the first written file which is problematic because the "internal" types would not be written the second time.
To update the codegen there are some subtleties because the code depends on generated code.
Build a working version
First step is to build a binary.
cd nomdl/codegen/
go build
Change templates
Not much to say here but you can see the result without breaking things
./codegen --in=test/struct.noms
This generates test.noms.go in the current directory. Iterate until it looks correct.
Change system go files
There are a few files that are generated that codegen itself depends on.
types/compound_blob_struct.noms.godatas/types.noms.go
Both of these can be updated by running go generate in their respective directories
There is also one more file that is generated but it requires manual intervention
types/package_set_of_ref.go
This one is generated from types/package_set_of_ref.noms. However, it uses the symbol
Package to refer to a types.Package. Currently we have no convenient way to make this work
out of the box. However, it is pretty straight forward to make it work.
- Open
nomdl/pkg/grammar.pg - Find
UInt64 - At that line, add one more builtin type called
Package. - Run
go generatein nomdl/pkg - Run
go run ../nomdl/codegen/codegen.go --in=package_set_of_ref.nomsintypes/.
Here is the diff:
--- a/nomdl/pkg/grammar.peg
+++ b/nomdl/pkg/grammar.peg
@@ -159,7 +159,7 @@ CompoundType <- `List` _ `(` _ t:Type _ `)` _ {
return types.MakeCompoundType(types.RefKind, t.(types.Type)), nil
}
-PrimitiveType <- p:(`UInt64` / `UInt32` / `UInt16` / `UInt8` / `Int64` / `Int32` / `Int16` / `Int8` / `Float64` / `Float32` / `Bool` / `String` / `Blob` / `Value` / `Type`) {
+PrimitiveType <- p:(`UInt64` / `UInt32` / `UInt16` / `UInt8` / `Int64` / `Int32` / `Int16` / `Int8` / `Float64` / `Float32` / `Bool` / `String` / `Blob` / `Value` / `Type` / `Package`) {
return types.MakePrimitiveTypeByString(string(p.([]uint8))), nil
}
Once #577 is fixed this will need no manual intervention.