Skip to content
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

make: build without code gen by default #3911

Merged
merged 3 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ steps:
command:
- mkdir -p /tmp/test-artifacts
- cp go.mod go.sum go_deps.bzl /tmp/test-artifacts/
- make godeps -B
- make go_deps.bzl -B
- bazel-${BUILDKITE_PIPELINE_SLUG}/external/go_sdk/bin/go mod tidy
- diff -u /tmp/test-artifacts/go.mod go.mod
- diff -u /tmp/test-artifacts/go.sum go.sum
Expand Down
66 changes: 23 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,41 @@
.PHONY: all clean protobuf protobuf_clean godeps gogen mocks bazel gazelle setcap licenses
.PHONY: all bazel clean gazelle gogen licenses mocks protobuf setcap
.NOTPARALLEL:

GAZELLE_MODE?=fix
GAZELLE_DIRS=./go ./acceptance

all: bazel
build: bazel

# all: performs the code-generation steps and then builds; the generated code
# is git controlled, and therefore this is only necessary when changing the
# sources for the code generation.
# Note: built in correct order, because .NOTPARALLEL.
all: go_deps.bzl gogen protobuf mocks gazelle licenses build

clean:
bazel clean
rm -f bin/*
if [ -e go/vendor ]; then rm -r go/vendor; fi # Cleanup from old setup with vendor

gogen:
$(MAKE) -C go/proto

ifndef GODEPS_SKIP
godeps: go_deps.bzl
else
godeps:
@echo "godeps: skipped"
endif
bazel:
rm -f bin/*
bazel build //:scion //:scion-ci
tar -kxf bazel-bin/scion.tar -C bin
tar -kxf bazel-bin/scion-ci.tar -C bin

go_deps.bzl: protobuf go.mod
go_deps.bzl: go.mod
@tools/godeps.sh

protobuf: protobuf_clean
bazel build //go/pkg/proto/control_plane:proto_srcs
tar -kxf bazel-bin/go/pkg/proto/control_plane/proto_srcs.tar -C go/pkg/proto/control_plane
chmod 0644 go/pkg/proto/control_plane/*.pb.go

bazel build //go/pkg/proto/crypto:proto_srcs
tar -kxf bazel-bin/go/pkg/proto/crypto/proto_srcs.tar -C go/pkg/proto/crypto
chmod 0644 go/pkg/proto/crypto/*.pb.go

bazel build //go/pkg/proto/discovery:proto_srcs
tar -kxf bazel-bin/go/pkg/proto/discovery/proto_srcs.tar -C go/pkg/proto/discovery
chmod 0644 go/pkg/proto/discovery/*.pb.go

bazel build //go/pkg/proto/daemon:proto_srcs
tar -kxf bazel-bin/go/pkg/proto/daemon/proto_srcs.tar -C go/pkg/proto/daemon
chmod 0644 go/pkg/proto/daemon/*.pb.go

bazel build //go/pkg/proto/gateway:proto_srcs
tar -kxf bazel-bin/go/pkg/proto/gateway/proto_srcs.tar -C go/pkg/proto/gateway
chmod 0644 go/pkg/proto/gateway/*.pb.go
gogen:
$(MAKE) -C go/proto

protobuf_clean:
protobuf:
bazel build --output_groups=go_generated_srcs //go/pkg/proto/...
rm -f go/pkg/proto/*/*.pb.go
cp -r bazel-bin/go/pkg/proto/*/go_default_library_/github.com/scionproto/scion/go/pkg/proto/* go/pkg/proto
chmod 0644 go/pkg/proto/*/*.pb.go

bazel: godeps gogen
rm -f bin/*
bazel build //:scion //:scion-ci
tar -kxf bazel-bin/scion.tar -C bin
tar -kxf bazel-bin/scion-ci.tar -C bin

mocks: protobuf
./tools/gomocks
bazel run //:gazelle -- update -mode=$(GAZELLE_MODE) -index=false -external=external -exclude go/vendor -exclude docker/_build $(GAZELLE_DIRS)
mocks:
tools/gomocks

gazelle:
bazel run //:gazelle -- update -mode=$(GAZELLE_MODE) -index=false -external=external -exclude go/vendor -exclude docker/_build $(GAZELLE_DIRS)
Expand Down
12 changes: 0 additions & 12 deletions go/pkg/proto/control_plane/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

go_proto_library(
name = "go_default_library",
Expand All @@ -11,14 +10,3 @@ go_proto_library(
"//go/pkg/proto/crypto:go_default_library",
],
)

filegroup(
name = "proto_src_files",
srcs = [":go_default_library"],
output_group = "go_generated_srcs",
)

pkg_tar(
name = "proto_srcs",
srcs = [":proto_src_files"],
)
12 changes: 0 additions & 12 deletions go/pkg/proto/crypto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

go_proto_library(
name = "go_default_library",
Expand All @@ -8,14 +7,3 @@ go_proto_library(
proto = "//proto/crypto/v1:crypto",
visibility = ["//visibility:public"],
)

filegroup(
name = "proto_src_files",
srcs = [":go_default_library"],
output_group = "go_generated_srcs",
)

pkg_tar(
name = "proto_srcs",
srcs = [":proto_src_files"],
)
12 changes: 0 additions & 12 deletions go/pkg/proto/daemon/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

go_proto_library(
name = "go_default_library",
Expand All @@ -8,14 +7,3 @@ go_proto_library(
proto = "//proto/daemon/v1:daemon",
visibility = ["//visibility:public"],
)

filegroup(
name = "proto_src_files",
srcs = [":go_default_library"],
output_group = "go_generated_srcs",
)

pkg_tar(
name = "proto_srcs",
srcs = [":proto_src_files"],
)
12 changes: 0 additions & 12 deletions go/pkg/proto/discovery/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

go_proto_library(
name = "go_default_library",
Expand All @@ -11,14 +10,3 @@ go_proto_library(
"//go/pkg/proto/crypto:go_default_library",
],
)

filegroup(
name = "proto_src_files",
srcs = [":go_default_library"],
output_group = "go_generated_srcs",
)

pkg_tar(
name = "proto_srcs",
srcs = [":proto_src_files"],
)
12 changes: 0 additions & 12 deletions go/pkg/proto/gateway/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

go_proto_library(
name = "go_default_library",
Expand All @@ -8,14 +7,3 @@ go_proto_library(
proto = "//proto/gateway/v1:gateway",
visibility = ["//visibility:public"],
)

filegroup(
name = "proto_src_files",
srcs = [":go_default_library"],
output_group = "go_generated_srcs",
)

pkg_tar(
name = "proto_srcs",
srcs = [":proto_src_files"],
)
2 changes: 1 addition & 1 deletion tools/godeps.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# This script uses gazelle to generate go_deps.bzl from go.mod.
# You don't need to invoke this directly, just run `make godeps`.
# You don't need to invoke this directly, just run `make go_deps.bzl`.

set -e

Expand Down