-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor GoVPP usage and generation #22
Changes from 10 commits
271c7c2
cb53be3
d65f225
61d8be7
555595f
978243d
34c3420
73a75ba
e42fd8a
f3c58bf
2c6d006
b5ba734
bc31ac3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package consumer | ||
//go:build generate | ||
|
||
package examples | ||
|
||
import ( | ||
_ "go.fd.io/govpp/binapi" | ||
_ "go.fd.io/govpp/cmd/binapi-generator" | ||
|
||
_ "github.com/calico-vpp/vpplink/pkg" | ||
) | ||
|
||
//go:generate go build -buildmode=plugin -o ./.bin/vpplink_plugin.so github.com/calico-vpp/vpplink/pkg | ||
//go:generate go run go.fd.io/govpp/cmd/binapi-generator --plugin ./.bin/vpplink_plugin.so --vpp $VPP_DIR -o ./impl | ||
//go:generate go run go.fd.io/govpp/cmd/binapi-generator --gen ./.bin/vpplink_plugin.so,rpc --input ../../vpp -o ./impl |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
github.com/bennyscetbun/jsongo v1.1.0 h1:ZDSks3aLP13jhY139lWaUqZaU8G0tELMohzumut/KDM= | ||
github.com/bennyscetbun/jsongo v1.1.0/go.mod h1:suxbVmjBV8+A2BBAM5EYVh6Uj8j3rqJhzWf3hv7Ff8U= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= | ||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= | ||
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= | ||
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe h1:ewr1srjRCmcQogPQ/NCx6XCk6LGVmsVCc9Y3vvPZj+Y= | ||
github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= | ||
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= | ||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= | ||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= | ||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= | ||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= | ||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= | ||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
go.fd.io/govpp v0.6.1-0.20220928122602-005dba9b1759 h1:HK0Vnnq2fwEW7dSygqsUs+U36Stg0pzp7qJgLmaJHhQ= | ||
go.fd.io/govpp v0.6.1-0.20220928122602-005dba9b1759/go.mod h1:oTfy7wk/8MSmC796s1OBI1TLLGpI6bwOwed7Htp0uh8= | ||
go.fd.io/govpp v0.6.1-0.20220928123720-fe96cac6bad7 h1:WYc0Ja3ai7F5+d/pIUwbQ4mfMBawiIktfm5mGcMT9yE= | ||
go.fd.io/govpp v0.6.1-0.20220928123720-fe96cac6bad7/go.mod h1:oTfy7wk/8MSmC796s1OBI1TLLGpI6bwOwed7Htp0uh8= | ||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= | ||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||
go.fd.io/govpp v0.8.0-alpha.0.20230207075433-b71f13cf4640 h1:gdxIVZCKmuyRhXVNUb+VvR+JOAPxzeEwBWhDDReclHE= | ||
go.fd.io/govpp v0.8.0-alpha.0.20230207075433-b71f13cf4640/go.mod h1:CP9b1rXbEow1suEDn0k1nwHQdrV0YpuIo7LUPw3+/H4= | ||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60= | ||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= | ||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | ||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,11 @@ package main | |
import ( | ||
"embed" | ||
_ "embed" | ||
|
||
"fmt" | ||
"io/fs" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/sirupsen/logrus" | ||
"go.fd.io/govpp/binapigen" | ||
"go.fd.io/govpp/version" | ||
|
||
"github.com/calico-vpp/vpplink/pkg/wrappergen" | ||
) | ||
|
@@ -57,7 +51,9 @@ func init() { | |
|
||
} | ||
|
||
func GenerateFile(gen *binapigen.Generator) { | ||
func GenerateFile(gen *binapigen.Generator, file *binapigen.File) *binapigen.GenFile { | ||
logrus.Infof("[WRAPPERGEN] GenerateFile: %v", file.Desc.Path) | ||
|
||
// We output vpplink one directory higher than the regular bindings | ||
basePkgName := filepath.Join(gen.GetOpts().ImportPrefix, "..") | ||
outputDir := filepath.Join(gen.GetOpts().OutputDir, "..") | ||
|
@@ -69,15 +65,17 @@ func GenerateFile(gen *binapigen.Generator) { | |
) | ||
|
||
// Execute all the templates | ||
err := parsedTemplates.ExecuteAll(outputDir, data) | ||
err := parsedTemplates.ExecuteAll(outputDir, data, gen) | ||
if err != nil { | ||
logrus.Fatalf("failed to execute template: %s", err) | ||
} | ||
|
||
createGenerateLog(gen.GetOpts().ApiDir, filepath.Join(outputDir, generateLogFname)) | ||
//createGenerateLog(gen.GetOpts().ApiDir, filepath.Join(outputDir, generateLogFname)) | ||
|
||
return nil | ||
} | ||
|
||
func createGenerateLog(apiDir string, fname string) { | ||
/*func createGenerateLog(apiDir string, fname string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's debatable whether we want to keep this or not. I'd arguee it's always good to have a trail of what generated the bindings. The file headers can serve for this as well, the good thing about having a dedicated file though is that it can be parsed/copied to a container where the file headers are more for human consumption. |
||
vppSrcDir, err := binapigen.FindGitRepoRootDir(apiDir) | ||
if err != nil { | ||
return | ||
|
@@ -88,7 +86,7 @@ func createGenerateLog(apiDir string, fname string) { | |
logrus.Fatalf("Unable to get vpp version : %s", err) | ||
} | ||
|
||
cmd := exec.Command("bash", "-c", "git log $(git log origin/master..HEAD --oneline | tail -1 | awk '{print $1}')^ --oneline -1") | ||
cmd := exec.Command("bash", "-c", "git log --oneline -1 $(git log origin/master..HEAD --oneline | tail -1 | awk '{print $1}')") | ||
cmd.Dir = binapigen.ExpandPaths(vppSrcDir) | ||
cmd.Stderr = os.Stderr | ||
out, err := cmd.Output() | ||
|
@@ -126,4 +124,4 @@ func createGenerateLog(apiDir string, fname string) { | |
logrus.Fatalf("Unable to close file %s %s", fname, err) | ||
} | ||
|
||
} | ||
}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of a Govpp comment, but anyway, the issue with this is we are going to be called once for every file even though the generation we are doing does not depend on the files being passed.
That's why I originally went with changing the signature for
GenerateFile
in https://github.com/FDio/govpp/pull/68/files#diff-4d2bacb13fc145b9d2f0e4f6a3771998ef6f3ff8d78dde2682c577febfa0f16eR30