Skip to content

Commit

Permalink
storage: Simplify makefile to remove docker
Browse files Browse the repository at this point in the history
Also, all output goes into gen/ instead of v1/gen.

Signed-off-by: Ben Walker <[email protected]>
  • Loading branch information
Ben Walker committed Oct 24, 2022
1 parent 283e60e commit e76d648
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 33 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Go
uses: actions/setup-go@v2

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325
- name: Install Protoc
uses: arduino/setup-protoc@v1

- name: Install protoc-gen-go
run: go install google.golang.org/protobuf/cmd/[email protected]

- name: Build protobufs
run: make
run: make python go cpp
working-directory: storage

- name: Check uncomitted auto generated protobufs
Expand All @@ -50,5 +52,5 @@ jobs:
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
path: storage/v1/gen/go/*.pb.go
path: storage/gen/v1/go/*.pb.go
retention-days: 1
1 change: 1 addition & 0 deletions storage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gen/
43 changes: 28 additions & 15 deletions storage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,35 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (c) 2022 Dell Inc, or its subsidiaries.

all:
rm -rf ./v1/{autogen.md,gen}
mkdir -p ./v1/gen/{go,cpp,python}
# Make a variable named ','. Used to pass arguments with commas to protoc_compile.
, := ,

docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l go -o ./v1/gen/go/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l cpp -o ./v1/gen/cpp/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l python -o ./v1/gen/python/ --go-source-relative
CURRENT_VERSION := v1

# protoc-gen-doc doesn't support proto include paths parameter so we have to copy
# common included files to the proto directory
cp ../common/v1/uuid.proto "${PWD}"/v1
cp ../common/v1/object_key.proto "${PWD}"/v1
define protoc_compile
mkdir -p gen/$(CURRENT_VERSION)/$(1)
protoc --proto_path=../common/$(CURRENT_VERSION) --proto_path=$(CURRENT_VERSION) \
--$(1)_out=gen/$(CURRENT_VERSION)/$(1) \
$(2) \
$(CURRENT_VERSION)/*.proto
endef

docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -v "${PWD}"/v1:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,autogen.md
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -w /out --entrypoint=sh ghcr.io/docker-multiarch/google-api-linter:1.36.0 -c "api-linter /out/*.proto --output-format summary"
all: python cpp go doc lint

# remove common included files from the proto directory
rm "${PWD}"/v1/uuid.proto
rm "${PWD}"/v1/object_key.proto
python:
$(call protoc_compile,python,)

cpp:
$(call protoc_compile,cpp,)

go:
$(call protoc_compile,go,)

doc:
$(call protoc_compile,doc,--doc_opt=markdown$(,)autogen.md)

lint:
$(call protoc_compile,lint)

clean:
rm -rf gen
2 changes: 1 addition & 1 deletion storage/v1/backend_aio.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";

import "google/protobuf/empty.proto";
import "object_key.proto";
Expand Down
2 changes: 1 addition & 1 deletion storage/v1/backend_iscsi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";

// Back End (network-facing) APIs.

Expand Down
2 changes: 1 addition & 1 deletion storage/v1/backend_null.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";
import "uuid.proto";

// Back End (network-facing) APIs.
Expand Down
2 changes: 1 addition & 1 deletion storage/v1/backend_nvme_pcie.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";

// Back End (network-facing) APIs.

Expand Down
2 changes: 1 addition & 1 deletion storage/v1/backend_nvme_tcp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";

// Back End (network-facing) APIs.

Expand Down
2 changes: 1 addition & 1 deletion storage/v1/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";

// The controller PCI-ID is used to address a given virtual controller. Virtual
// controllers are organized into devices with Physical functions and SRIOV
Expand Down
2 changes: 1 addition & 1 deletion storage/v1/frontend_nvme_pcie.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";
import "common.proto";
import "uuid.proto";

Expand Down
2 changes: 1 addition & 1 deletion storage/v1/frontend_virtio_blk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";
import "common.proto";

// Front End (host-facing) APIs.
Expand Down
2 changes: 1 addition & 1 deletion storage/v1/frontend_virtio_fs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";

// Front End (host-facing) APIs.

Expand Down
2 changes: 1 addition & 1 deletion storage/v1/frontend_virtio_scsi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";
import "common.proto";

// Front End (host-facing) APIs.
Expand Down
2 changes: 1 addition & 1 deletion storage/v1/middleend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

syntax = "proto3";
package opi_api.storage.v1;
option go_package = "github.com/opiproject/opi-api/storage/v1/gen/go";
option go_package = "github.com/opiproject/opi-api/storage/gen/v1/go";

// Middle End (Storage Services) APIs.

Expand Down

0 comments on commit e76d648

Please sign in to comment.