-
Notifications
You must be signed in to change notification settings - Fork 9
/
codegen.go
31 lines (24 loc) · 1.09 KB
/
codegen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package create
import (
"context"
"namespacelabs.dev/foundation/internal/codegen/genpackage"
"namespacelabs.dev/foundation/internal/fnerrors"
"namespacelabs.dev/foundation/internal/fnfs"
"namespacelabs.dev/foundation/std/cfg"
"namespacelabs.dev/foundation/std/pkggraph"
)
func codegenNode(ctx context.Context, out pkggraph.MutableModule, env cfg.Context, loc fnfs.Location) error {
// Aggregates and prints all accumulated codegen errors on return.
var errorCollector fnerrors.ErrorCollector
// Generate protos before generating code for this extension as code (our generated code may depend on the protos).
if err := genpackage.ForLocationsGenProto(ctx, out, env, []fnfs.Location{loc}, errorCollector.Append); err != nil {
return err
}
if err := genpackage.ForLocationsGenCode(ctx, out, env, []fnfs.Location{loc}, errorCollector.Append); err != nil {
return err
}
return errorCollector.Error()
}