Skip to content

Support proto_compiled_sources with ts_project #378

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ tasks:
- -//pkg/plugin/grpc/grpc:grpc_test # TODO(pcj): error "bazel_testing: read-only filesystem"
test_flags:
- --config=bazelci
- --deleted_packages=//plugin/grpc-ecosystem/grpc-gateway
default_workspace_macos:
platform: macos
build_targets:
Expand All @@ -32,5 +31,3 @@ tasks:
- //plugin/...
- //rules/...
- //toolchain/...
test_flags:
- --deleted_packages=//plugin/grpc-ecosystem/grpc-gateway
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
common --enable_bzlmod=false

common --jvmopt=-Djava.security.manager=allow
build --java_language_version=17
Expand All @@ -12,6 +13,8 @@ build:linux --cxxopt='-std=c++14'
build:linux --host_cxxopt='-std=c++14'
build:macos --cxxopt='-std=c++14'
build:macos --host_cxxopt='-std=c++14'
build:macos --copt='-Wno-gnu-offsetof-extensions'
build:macos --host_copt='-Wno-gnu-offsetof-extensions'
build:freebsd --cxxopt='-std=c++14'
build:freebsd --host_cxxopt='-std=c++14'

Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: bazelbuild/setup-bazelisk@v2
- uses: bazelbuild/setup-bazelisk@v3

- name: Mount bazel action cache
uses: actions/cache@v3
uses: actions/cache@v4
if: always()
with:
path: "~/.cache/bazel"
key: bazel

- name: Mount bazel repo cache
uses: actions/cache@v3
uses: actions/cache@v4
if: always()
with:
path: "~/.cache/bazel-repo"
Expand All @@ -45,7 +45,6 @@ jobs:
--bazelrc=.github/workflows/ci.bazelrc
--bazelrc=.bazelrc
test
--deleted_packages=//plugin/grpc-ecosystem/grpc-gateway
//example/...
//pkg/...
//plugin/...
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: bazelbuild/setup-bazelisk@v2
- uses: bazelbuild/setup-bazelisk@v3

- name: Mount bazel action cache
uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
Expand Down
30 changes: 30 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,36 @@ gazelle(
command = "update-repos",
)

genrule(
name = "gendeps",
srcs = [
"//deps:closure_deps.bzl",
"//deps:core_deps.bzl",
"//deps:go_core_deps.bzl",
"//deps:grpc_core_deps.bzl",
"//deps:grpc_java_deps.bzl",
"//deps:grpc_js_deps.bzl",
"//deps:grpc_node_deps.bzl",
"//deps:grpc_web_deps.bzl",
"//deps:js_core_deps.bzl",
"//deps:nodejs_deps.bzl",
"//deps:prebuilt_protoc_deps.bzl",
"//deps:protobuf_core_deps.bzl",
"//deps:scala_deps.bzl",
"//deps:ts_proto_deps.bzl",
],
outs = ["deps.tar"],
cmd = """
output="$$PWD/$@"
tar -cf $$output --files-from /dev/null
for file in $(SRCS); do
base=$$(basename $$file)
cp $$file ./$$base
tar -rf $$output $$base
done
""",
)

# ----------------------------------------------------
# Test-Related
# ----------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ gazelle:

.PHONY: deps
deps:
bazel build //deps:*
cp -f ./bazel-bin/deps/*.bzl deps/
bazel build //:gendeps
(cd deps/ && tar -xvf ../bazel-bin/deps.tar)
chmod 0644 deps/*.bzl
bazel run //:buildifier -- deps/

.PHONY: site
site:
bazel build //example/golden:*
Expand All @@ -34,8 +34,7 @@ example_test:

.PHONY: test
test:
bazel test --keep_going //example/... //pkg/... //plugin/... //language/... //rules/... //toolchain/... \
--deleted_packages=//plugin/grpc-ecosystem/grpc-gateway
bazel test --keep_going //example/... //pkg/... //plugin/... //language/... //rules/... //toolchain/...

.PHONY: get
get:
Expand Down
17 changes: 11 additions & 6 deletions cmd/gencopy/gencopy.bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ CONFIG_SHORT_PATH=@@CONFIG_SHORT_PATH@@

# env
# set -x
# echo "PWD: $PWD"
# find .
# find ..

# Get the directory of the current script (part of the runfiles tree)
script_dir=$(dirname "$0")

# find_runfile prints the location of a runfile in the source workspace,
# either by reading the symbolic link or reading the runfiles manifest.
Expand Down Expand Up @@ -45,18 +50,18 @@ fi
# Note that we don't change directories first; if we did, Generator wouldn't be
# able to find runfiles, and some extensions rely on that. Generator can use
# BUILD_WORKSPACE_DIRECTORY to interpret relative paths on the command line.
GENCOPY_short_path=$(find_runfile "$GENCOPY_SHORT_PATH")
if [ -z "$GENCOPY_short_path" ]; then
GENCOPY_path=$(find_runfile "$GENCOPY_SHORT_PATH")
if [ -z "$GENCOPY_path" ]; then
echo "error: could not locate gencopy binary" >&2
exit 1
fi

CONFIG_short_path=$(find_runfile "$CONFIG_SHORT_PATH")
if [ -z "$CONFIG_short_path" ]; then
CONFIG_path=$(find_runfile "$CONFIG_SHORT_PATH")
if [ -z "$CONFIG_path" ]; then
echo "error: could not locate gencopy configuration file" >&2
exit 1
fi

"$GENCOPY_short_path" \
-config="$CONFIG_short_path" \
"$GENCOPY_path" \
-config="$CONFIG_path" \
-workspace_root_directory="${BUILD_WORKSPACE_DIRECTORY:-""}"
6 changes: 5 additions & 1 deletion cmd/gencopy/gencopy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ gencopy_attrs = {
doc = "The label.name used to regenerate targets",
mandatory = True,
),
"extension": attr.string(
doc = "optional file extension to add to the copied file",
mandatory = False,
),
"_gencopy_script": attr.label(
doc = "The gencopy script template",
default = str(Label("//cmd/gencopy:gencopy.bash.in")),
Expand All @@ -43,7 +47,7 @@ def gencopy_config(ctx):
)

def gencopy_action(ctx, config, runfiles):
"""gencopy_action declared a bazel action that runs the gencopy.bash script.
"""gencopy_action declares a bazel action that runs the gencopy.bash script.

Args:
ctx: the context object.
Expand Down
2 changes: 0 additions & 2 deletions cmd/gencopy/gencopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"strconv"
"strings"

"github.com/google/go-cmp/cmp"
)
Expand Down Expand Up @@ -174,7 +173,6 @@ func makePkgSrcDstPairs(cfg *Config, pkg *PackageConfig) []*SrcDst {

func makePkgSrcDstPair(cfg *Config, pkg *PackageConfig, src, dst string) *SrcDst {
if pkg.TargetWorkspaceRoot != "" {
src = filepath.Join("external", strings.TrimPrefix(src, ".."))
dst = filepath.Join(pkg.TargetWorkspaceRoot, dst)
}
dst = filepath.Join(cfg.WorkspaceRootDirectory, dst)
Expand Down
4 changes: 2 additions & 2 deletions cmd/gencopy/gencopy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestMakePkgSrcDstPair(t *testing.T) {
pkg: PackageConfig{TargetWorkspaceRoot: "external/foo"},
src: "../foo/file.txt",
dst: "file.txt",
want: SrcDst{Src: "external/foo/file.txt", Dst: "/home/external/foo/file.txt"},
want: SrcDst{Src: "../foo/file.txt", Dst: "/home/external/foo/file.txt"},
},
} {
t.Run(name, func(t *testing.T) {
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestRunPkg(t *testing.T) {
t.Fatal(err)
}
listFiles(t, ".")
if err := run(&tc.cfg, t.Logf); err != nil {
if err := run(&tc.cfg); err != nil {
t.Fatal(err)
}

Expand Down
11 changes: 5 additions & 6 deletions deps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
load("@build_stack_rules_proto//rules:proto_dependency.bzl", "proto_dependency")
load("@build_stack_rules_proto//rules:depsgen.bzl", "depsgen")

package(default_visibility = ["//:__pkg__"])

depsgen(
name = "core",
deps = [
Expand Down Expand Up @@ -153,12 +155,9 @@ proto_dependency(
name = "zlib",
build_file = "@build_stack_rules_proto//third_party:zlib.BUILD",
repository_rule = "http_archive",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
],
sha256 = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
strip_prefix = "zlib-1.3.1",
urls = ["https://zlib.net/zlib-1.3.1.tar.gz"],
visibility = ["//visibility:public"],
)

Expand Down
7 changes: 3 additions & 4 deletions deps/grpc_core_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ def zlib():
_maybe(
http_archive,
name = "zlib",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
sha256 = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
strip_prefix = "zlib-1.3.1",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.3.1.tar.gz",
],
build_file = "@build_stack_rules_proto//third_party:zlib.BUILD",
)
Expand Down
87 changes: 0 additions & 87 deletions deps/grpc_deps.bzl

This file was deleted.

7 changes: 3 additions & 4 deletions deps/grpc_node_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ def zlib():
_maybe(
http_archive,
name = "zlib",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
sha256 = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
strip_prefix = "zlib-1.3.1",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.3.1.tar.gz",
],
build_file = "@build_stack_rules_proto//third_party:zlib.BUILD",
)
Expand Down
7 changes: 3 additions & 4 deletions deps/protobuf_core_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ def zlib():
_maybe(
http_archive,
name = "zlib",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
sha256 = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
strip_prefix = "zlib-1.3.1",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.3.1.tar.gz",
],
build_file = "@build_stack_rules_proto//third_party:zlib.BUILD",
)
Expand Down
Loading
Loading