diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1f6f98..5df7471 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,6 @@ jobs: - name: Setup environment shell: bash run: | - echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV echo "${{ github.workspace }}/bin" >> $GITHUB_PATH - name: Check out code @@ -69,7 +68,6 @@ jobs: - name: Setup environment shell: bash run: | - echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV echo "${{ github.workspace }}/bin" >> $GITHUB_PATH - name: Check out code @@ -118,7 +116,6 @@ jobs: - name: Setup environment shell: bash run: | - echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV echo "${{ github.workspace }}/bin" >> $GITHUB_PATH - name: Check out code diff --git a/Protobuild.toml b/Protobuild.toml index 7d9d2f3..f467535 100644 --- a/Protobuild.toml +++ b/Protobuild.toml @@ -136,3 +136,6 @@ target = "examples/next.pb.txt" # [[descriptors]] # target = "examples/foo/descriptors.pb.txt" # prefix = "github.com/containerd/protobuild/examples/foo" + +[parameters.go] +paths = "source_relative" diff --git a/main.go b/main.go index c1dc400..86382ff 100644 --- a/main.go +++ b/main.go @@ -194,11 +194,11 @@ func main() { includes = append(includes, gopathJoin(gopath, pkg)) } - includes = append(includes, gopath) + includes = append(includes, pkg.Dir) includes = append(includes, c.Includes.After...) protoc := protocCmd{ - Generators: generators(c.Generators, outputDir), + Generators: generators(c.Generators, pkg.Dir), Files: pkg.ProtoFiles, OutputDir: outputDir, Includes: includes, @@ -246,7 +246,7 @@ func main() { } var ( - genDescriptors = shouldGenerateDescriptors(importDirPath) + genDescriptors = shouldGenerateDescriptors(pkg.GoImportPath) dfp *os.File // tempfile for descriptors ) @@ -291,7 +291,7 @@ func main() { } for path, set := range descriptorSets { - if strings.HasPrefix(importDirPath, path) { + if strings.HasPrefix(pkg.GoImportPath, path) { set.add(desc.File...) } } diff --git a/v2.toml b/v2.toml index dfe0f9a..03a3b6f 100644 --- a/v2.toml +++ b/v2.toml @@ -8,3 +8,8 @@ generators = ["go", "go-grpc"] [[descriptors]] prefix = "github.com/containerd/protobuild/examples/v2" target = "examples/v2/next.pb.txt" + +# The default mode is paths=import which makes a directory that mirrors its Go import path. +# https://protobuf.dev/reference/go/go-generated/ +[parameters.go] +paths = "source_relative"