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

Bazel: Improve dependency situation per #410 #411

Merged
merged 2 commits into from
Nov 14, 2023
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
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ jobs:
- uses: actions/checkout@v3
- name: bazel test
run: |
go get github.com/bazelbuild/bazelisk
bazelisk test --build_tests_only -c "${{ matrix.MODE }}" //...
bazel test --build_tests_only -c "${{ matrix.MODE }}" //...
pod-lib-lint:
runs-on: macos-latest
strategy:
Expand Down
1 change: 0 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_build_test")

Expand Down
1 change: 0 additions & 1 deletion DebugUtils/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_build_test")

Expand Down
1 change: 0 additions & 1 deletion Foundation/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_build_test")

Expand Down
3 changes: 3 additions & 0 deletions USING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pod 'GoogleToolboxForMac/GeometryUtils'
GTM can be consumed via Bazel, to do so add the following to your `WORKSPACE` file:

```WORKSPACE
# Make sure you've brought in rules_apple per their release snippet
# https://github.com/bazelbuild/rules_apple/releases

GTM_GIT_SHA = "SOME_SHA"
http_archive(
name = "google_toolbox_for_mac",
Expand Down
1 change: 0 additions & 1 deletion UnitTesting/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_build_test")

Expand Down
23 changes: 17 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
workspace(name = "google_toolbox_for_mac")

load(
"@google_toolbox_for_mac//bazel_support:repositories.bzl",
"google_toolbox_for_mac_rules_dependencies",
)

google_toolbox_for_mac_rules_dependencies()
# Per https://github.com/bazelbuild/rules_apple/releases

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

http_archive(
name = "build_bazel_rules_apple",
sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7",
url = "https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz",
)

load(
"@build_bazel_rules_apple//apple:repositories.bzl",
Expand All @@ -21,9 +25,16 @@ load(

swift_rules_dependencies()

load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)

apple_support_dependencies()
apple_support_dependencies()
29 changes: 3 additions & 26 deletions bazel_support/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
"""Definitions for handling Bazel repositories for GoogleToolboxForMac. """

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

def _maybe(repo_rule, name, **kwargs):
"""Executes the given repository rule if it hasn't been executed already.

Args:
repo_rule: The repository rule to be executed (e.g., `http_archive`.)
name: The name of the repository to be defined by the rule.
**kwargs: Additional arguments passed directly to the repository rule.
"""
if not native.existing_rule(name):
repo_rule(name = name, **kwargs)

def google_toolbox_for_mac_rules_dependencies():
"""Fetches repositories that are dependencies of GoogleToolboxForMac.

Users should call this macro in their `WORKSPACE` to ensure that all of the
dependencies are downloaded and that they are isolated
from changes to those dependencies.
"""
_maybe(
http_archive,
name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.1/rules_cc-0.0.1.tar.gz"],
sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
)

_maybe(
http_archive,
name = "build_bazel_rules_apple",
sha256 = "a5f00fd89eff67291f6cd3efdc8fad30f4727e6ebb90718f3f05bbf3c3dd5ed7",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.33.0/rules_apple.0.33.0.tar.gz",
)
# Nothing for now, since rules_apple has so many waves of transitive deps.
# Preserved to maintain API stability and for future flexibility.
pass
1 change: 0 additions & 1 deletion iPhone/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test")

objc_library(
Expand Down