Skip to content

Commit

Permalink
Implement overlay-based solution to resolve third party dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerC committed Jan 7, 2022
1 parent d1bce8d commit a3ba942
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 5 deletions.
9 changes: 5 additions & 4 deletions dart/build_rules/proto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,18 @@ _dart_proto_aspect_attrs = {
"_protocol_compiler": attr.label(
executable=True,
cfg="host",
default=Label("//third_party:protoc"),
default=Label("@com_google_protobuf//:protoc"),
),
"_protoc_gen_dart": attr.label(
# TODO: FIX
default=Label(
"//third_party/dart/protoc_plugin:protoc_gen_dart"),
"@dart_protobuf_protoc_plugin//:protoc_gen_dart"),
executable=True,
cfg="host",
),
"_proto_libs_dart": attr.label_list(default=[
Label("//third_party/dart/fixnum:fixnum"),
Label("//third_party/dart/protobuf:protobuf"),
Label("@dart_fixnum//:fixnum_lib"),
Label("@dart_protobuf_protobuf//:protobuf_lib"),
])
}

Expand Down
75 changes: 74 additions & 1 deletion dart/build_rules/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Repositories for Dart."""

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

Expand Down Expand Up @@ -81,7 +81,80 @@ def dart_repositories():
)


_FIXNUM_BUILD_FILE = """
load("@//dart/build_rules:core.bzl", "dart_library")
load("@//dart/build_rules:vm.bzl", "dart_vm_test")
package(default_visibility = ["//visibility:public"])
dart_library(
name = "fixnum_lib",
srcs = glob(["lib/**/*.dart"]),
)
"""

_PROTOBUF_BUILD_FILE = """
load("@//dart/build_rules:core.bzl", "dart_library")
load("@//dart/build_rules:vm.bzl", "dart_vm_binary")
package(default_visibility = ["//visibility:public"])
dart_library(
name = "protobuf_lib",
srcs = glob(["lib/**/*.dart"]),
)
"""

_PROTOC_PLUGIN_BUILD_FILE = """
load("@//dart/build_rules:core.bzl", "dart_library")
load("@//dart/build_rules:vm.bzl", "dart_vm_binary")
package(default_visibility = ["//visibility:public"])
dart_library(
name = "protoc_plugin_lib",
srcs = glob(["lib/**/*.dart"]),
)
dart_vm_binary(
name = "protoc_gen_dart",
srcs = ["bin/protoc_plugin.dart"],
script_file = "bin/protoc_plugin.dart",
deps = [":protoc_plugin_lib"],
)
"""

def proto_repositories():

new_git_repository(
name = "dart_fixnum",
# tag = "1.0.0",
commit = "762b74f61696d414d0090c5dfc430572f5b4be0f",
shallow_since = "1612551835 -0800",
remote = "https://github.com/dart-lang/fixnum",
build_file_content = _FIXNUM_BUILD_FILE
)

new_git_repository(
name = "dart_protobuf_protobuf",
# tag = "protobuf-v2.0.1",
commit = "23136dc01cf3daccf66ebb7f5a7578ec7c0dc7e6",
shallow_since = "1638456183 +0100",
remote = "https://github.com/google/protobuf.dart",
build_file_content = _PROTOBUF_BUILD_FILE,
strip_prefix = "protobuf"
)

new_git_repository(
name = "dart_protobuf_protoc_plugin",
# tag = "protobuf-v2.0.1",
commit = "23136dc01cf3daccf66ebb7f5a7578ec7c0dc7e6",
shallow_since = "1638456183 +0100",
remote = "https://github.com/google/protobuf.dart",
build_file_content = _PROTOC_PLUGIN_BUILD_FILE,
strip_prefix = "protoc_plugin"
)

git_repository(
name = "com_google_protobuf",
# tag = "v3.19.1",
Expand Down

0 comments on commit a3ba942

Please sign in to comment.