Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.
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
47 changes: 47 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

filegroup(
name = "standard_package",
srcs = glob([
Expand All @@ -8,3 +10,48 @@ filegroup(
]),
visibility = ["@//distro:__pkg__"],
)

bzl_library(
name = "java_repositories",
srcs = ["java_repositories.bzl"],
visibility = ["//visibility:public"],
# Temporarily omit @bazel_tools//... bzl files from the bzl_library until
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream change lives here: bazelbuild/bazel#12258

# they are `exports_files`'d in a released version of Bazel.
deps = [
#"@bazel_tools//tools/build_defs/repo:http.bzl",
#"@bazel_tools//tools/build_defs/repo:utils.bzl",
], # keep
)

bzl_library(
name = "repositories",
srcs = ["repositories.bzl"],
visibility = ["//visibility:public"],
# Temporarily omit @bazel_tools//... bzl files from the bzl_library until
# they are `exports_files`'d in a released version of Bazel.
deps = [
":third_party_repositories",
#"@bazel_tools//tools/build_defs/repo:git.bzl",
#"@bazel_tools//tools/build_defs/repo:http.bzl",
#"@bazel_tools//tools/build_defs/repo:utils.bzl",
], # keep
)

bzl_library(
name = "third_party_repositories",
srcs = ["third_party_repositories.bzl"],
visibility = ["//visibility:public"],
# Temporarily omit @bazel_tools//... bzl files from the bzl_library until
# they are `exports_files`'d in a released version of Bazel.
deps = [
#"@bazel_tools//tools/build_defs/repo:git.bzl",
#"@bazel_tools//tools/build_defs/repo:http.bzl",
#"@bazel_tools//tools/build_defs/repo:utils.bzl",
], # keep
)

bzl_library(
name = "version",
srcs = ["version.bzl"],
visibility = ["//visibility:public"],
)
11 changes: 11 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
workspace(name = "bazel_federation")

load("@bazel_federation//:repositories.bzl", "rules_pkg")

rules_pkg()

load("@bazel_federation//setup:rules_pkg.bzl", "rules_pkg_setup")

rules_pkg_setup()

load("@bazel_federation//:repositories.bzl", "bazel_skylib")

bazel_skylib()

load("@bazel_federation//setup:bazel_skylib.bzl", "bazel_skylib_setup")

bazel_skylib_setup()
7 changes: 2 additions & 5 deletions examples/stardoc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ package(default_visibility = ["//visibility:private"])

bzl_library(
name = "my_rule",
srcs = [
"my_rule.bzl",
],
srcs = ["my_rule.bzl"],
visibility = ["//visibility:public"],
)

Expand All @@ -22,12 +20,11 @@ stardoc(
deps = [":my_rule"],
)


my_rule(
name = "example",
out = "example.txt",
deps = [
":BUILD",
":my_rule.bzl",
],
out = "example.txt",
)
29 changes: 29 additions & 0 deletions internal/deps/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
name = "bazel_skylib",
srcs = ["bazel_skylib.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@bazel_skylib//:internal_deps"],
)

bzl_library(
name = "rules_cc",
srcs = ["rules_cc.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@rules_cc//:internal_deps"],
)

bzl_library(
name = "rules_java",
srcs = ["rules_java.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@rules_java//:internal_deps"],
)

bzl_library(
name = "rules_python",
srcs = ["rules_python.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@rules_python//:internal_deps"],
)
29 changes: 29 additions & 0 deletions internal/setup/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
name = "bazel_skylib",
srcs = ["bazel_skylib.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@bazel_skylib//:internal_setup"],
)

bzl_library(
name = "rules_cc",
srcs = ["rules_cc.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@rules_cc//:internal_setup"],
)

bzl_library(
name = "rules_java",
srcs = ["rules_java.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@rules_java//:internal_setup"],
)

bzl_library(
name = "rules_python",
srcs = ["rules_python.bzl"],
visibility = ["//:__subpackages__"],
deps = ["@rules_python//:internal_setup"],
)
67 changes: 66 additions & 1 deletion setup/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files(glob(["*.bzl"]))

filegroup(
name = "standard_package",
srcs = glob(["BUILD", "*.bzl"]),
srcs = glob([
"BUILD",
"*.bzl",
]),
visibility = ["@//distro:__pkg__"],
)

bzl_library(
name = "bazel_skylib",
srcs = ["bazel_skylib.bzl"],
visibility = ["//visibility:public"],
deps = ["@bazel_skylib//:workspace"],
)

bzl_library(
name = "bazel_stardoc",
srcs = ["bazel_stardoc.bzl"],
visibility = ["//visibility:public"],
deps = ["@bazel_federation//setup:rules_java"],
)

bzl_library(
name = "rules_go",
srcs = ["rules_go.bzl"],
visibility = ["//visibility:public"],
deps = [
"@bazel_federation//setup:bazel_skylib",
"@io_bazel_rules_go//go:deps",
],
)

bzl_library(
name = "rules_java",
srcs = ["rules_java.bzl"],
visibility = ["//visibility:public"],
deps = ["@rules_java//java:repositories"],
)

bzl_library(
name = "rules_python",
srcs = ["rules_python.bzl"],
visibility = ["//visibility:public"],
deps = ["@rules_python//python:pip"],
)

bzl_library(
name = "rules_rust",
srcs = ["rules_rust.bzl"],
visibility = ["//visibility:public"],
deps = [
"@io_bazel_rules_rust//:workspace",
"@io_bazel_rules_rust//rust:repositories",
],
)

bzl_library(
name = "rules_cc",
srcs = ["rules_cc.bzl"],
visibility = ["//visibility:public"],
)

bzl_library(
name = "rules_pkg",
srcs = ["rules_pkg.bzl"],
visibility = ["//visibility:public"],
)
5 changes: 2 additions & 3 deletions tests/integration/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package(default_visibility=["//visibility:public"])
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entries for //tests/... can easily be excluded if you'd prefer they not exist, but they are technically importable by third parties since bzl files come with an implicit public visibility in the context of Bazel's load statements unless they live in a directory called private.


package(default_visibility = ["//visibility:public"])

filegroup(
name = "srcs",
srcs = [
"BUILD",
"WORKSPACE",
]
],
)
19 changes: 6 additions & 13 deletions tests/integration/hello_bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_binary")
load("@rules_java//java:defs.bzl", "java_library", "java_binary")
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_pkg//:pkg.bzl", "pkg_tar")

load(":my_rule.bzl", "my_rule")

bzl_library(
name = "my_rule",
srcs = [
"my_rule.bzl",
],
visibility = ["//visibility:public"],
)

stardoc(
name = "my_rule_doc",
out = "my_rule_doc.md",
Expand All @@ -27,7 +18,6 @@ stardoc(
deps = [":my_rule"],
)


my_rule(
name = "example",
deps = [
Expand All @@ -37,7 +27,6 @@ my_rule(
out = "example.txt",
)


# A C++ program

cc_binary(
Expand All @@ -52,7 +41,6 @@ cc_library(
hdrs = ["hello_lib.h"],
)


go_library(
name = "lib",
srcs = ["lib.go"],
Expand Down Expand Up @@ -106,7 +94,6 @@ rust_test(
deps = [":rust_lib"],
)


pkg_tar(
name = "tarball",
srcs = glob(["**"]) + [
Expand All @@ -120,3 +107,9 @@ pkg_tar(
strip_prefix = "/",
package_dir = "federation/sample",
)

bzl_library(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why buildifier thinks this should be at the bottom but it is very adamant about it. I can manually bump it back to the top if you'd like.

name = "my_rule",
srcs = ["my_rule.bzl"],
visibility = ["//visibility:public"],
)