From cc849a029df0ab8b66086df2b9d9e720d7f4b269 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 10 Oct 2019 08:23:23 -0700 Subject: [PATCH 1/8] Remove code to support pre-framework-cleanup-migration RELNOTES: None PiperOrigin-RevId: 273962322 --- lib/framework_migration.bzl | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 lib/framework_migration.bzl diff --git a/lib/framework_migration.bzl b/lib/framework_migration.bzl deleted file mode 100644 index 3aa13e7..0000000 --- a/lib/framework_migration.bzl +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Helper functions related to apple framework cleanup migration.""" - -def _is_post_framework_migration(): - """Determine whether bazel is pre- or post- framework infrastructure migration. - - Returns: - Whether bazel has been updated to use the new framework infrastructure. - """ - - return hasattr(apple_common.new_objc_provider(), "static_framework_names") - -framework_migration = struct( - is_post_framework_migration = _is_post_framework_migration, -) From 9605c3da1c5bcdddc20d1704b52415a6f3a5f422 Mon Sep 17 00:00:00 2001 From: Sergio Campama Date: Fri, 11 Oct 2019 14:57:44 -0700 Subject: [PATCH 2/8] Remove CI tests for versioned releases of Bazel and dependencies. Unfortunately, the team maintaining this repository does not have the resources to keep the versioned releases up to date. Going forward, the recommended approach for depending on this repository is to select a specific commit and to use the `git_repository` WORKSPACE rule available in `@bazel_tools//tools/build_defs/repo:git.bzl`. RELNOTES: None PiperOrigin-RevId: 274255348 --- .bazelci/presubmit.yml | 14 --------- .bazelci/update_workspace_to_deps_heads.sh | 33 ---------------------- README.md | 5 +++- 3 files changed, 4 insertions(+), 48 deletions(-) delete mode 100755 .bazelci/update_workspace_to_deps_heads.sh diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 2463212..c4fb714 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -10,23 +10,9 @@ x_defaults: - "//..." tasks: - macos_latest: - name: "Latest Bazel" - bazel: latest - <<: *common - macos_last_green: name: "Last Green Bazel" bazel: last_green <<: *common - macos_latest_head_deps: - name: "Latest Bazel with Head Deps" - bazel: latest - shell_commands: - # Update the WORKSPACE to use head versions of some deps to ensure nothing - # has landed on them breaking this project. - - .bazelci/update_workspace_to_deps_heads.sh - <<: *common - buildifier: latest diff --git a/.bazelci/update_workspace_to_deps_heads.sh b/.bazelci/update_workspace_to_deps_heads.sh deleted file mode 100755 index 0864d57..0000000 --- a/.bazelci/update_workspace_to_deps_heads.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# Copyright 2019 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eu - -# Modify the WORKSPACE to pull in the master branches of some deps. -sed \ - -i "" \ - -e \ - '/^workspace.*/a \ -\ -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")\ -\ -git_repository(\ -\ name = "bazel_skylib",\ -\ remote = "https://github.com/bazelbuild/bazel-skylib.git",\ -\ branch = "master",\ -)\ -' \ - WORKSPACE diff --git a/README.md b/README.md index 6dc64a5..a2d54bc 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,13 @@ Add the following to your `WORKSPACE` file to add this repository as a dependenc ```python load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +# apple_support no longer supports releases. If you'd like to pin down these +# dependencies to a specific commit, please add the following to the top of your +# WORKSPACE, using the commit you'd like to pin the repository. git_repository( name = "build_bazel_apple_support", remote = "https://github.com/bazelbuild/apple_support.git", - tag = "0.7.0", + commit = "[SOME_HASH_VALUE]", ) load( From ddc4a53c765bd512452d103cacbf442d453bb806 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 27 Dec 2019 13:56:50 -0800 Subject: [PATCH 3/8] Set execution requirements for Starlark rules that use apple_support based on the availability of the selected Xcode. This is part of a series of changes that set the execution requirements for actions generated by rules that require Xcodes. The dynamic scheduler will later be modified to run those actions locally/remotely accordingly, but this does not currently change behavior. RELNOTES: None. PiperOrigin-RevId: 287338096 --- lib/apple_support.bzl | 19 ++++++++++++++++--- rules/apple_genrule.bzl | 2 +- test/apple_support_test.bzl | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/apple_support.bzl b/lib/apple_support.bzl index 261f452..1b9c171 100644 --- a/lib/apple_support.bzl +++ b/lib/apple_support.bzl @@ -98,7 +98,7 @@ def _kwargs_for_apple_platform(ctx, additional_env = None, **kwargs): execution_requirement_dicts.append(original_execution_requirements) # Add the execution requirements last to avoid clients overriding this value. - execution_requirement_dicts.append(_action_required_execution_requirements()) + execution_requirement_dicts.append(_action_required_execution_requirements(ctx)) processed_args["env"] = _add_dicts(*env_dicts) processed_args["execution_requirements"] = _add_dicts(*execution_requirement_dicts) @@ -184,7 +184,7 @@ def _action_required_env(ctx): apple_common.target_apple_env(xcode_config, platform), ) -def _action_required_execution_requirements(): +def _action_required_execution_requirements(ctx): """Returns a dictionary with the execution requirements for running actions on Apple platforms. In most cases, you should _not_ use this API. It exists solely for using it on test rules, @@ -194,10 +194,23 @@ def _action_required_execution_requirements(): `testing.TestExecution` provider, which takes a dictionary with execution requirements for the test action. + Args: + ctx: The context of the rule registering the action. + Returns: A dictionary with execution requirements for running actions on Apple platforms. """ - return {"requires-darwin": "1"} + + # TODO(steinman): Replace this with xcode_config.execution_info once it is exposed. + execution_requirements = {"requires-darwin": "1"} + xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig] + if xcode_config: + if xcode_config.availability() == "remote": + execution_requirements["no-local"] = "1" + elif xcode_config.availability() == "local": + execution_requirements["no-remote"] = "1" + execution_requirements["supports-xcode-requirements-set"] = "1" + return execution_requirements def _run(ctx, xcode_path_resolve_level = _XCODE_PATH_RESOLVE_LEVEL.none, **kwargs): """Registers an action to run on an Apple machine. diff --git a/rules/apple_genrule.bzl b/rules/apple_genrule.bzl index b832484..fbfeb74 100644 --- a/rules/apple_genrule.bzl +++ b/rules/apple_genrule.bzl @@ -66,7 +66,7 @@ def _apple_genrule_impl(ctx): ), tools = ctx.attr.tools, label_dict = label_dict, - execution_requirements = apple_support.action_required_execution_requirements(), + execution_requirements = apple_support.action_required_execution_requirements(ctx), ) message = ctx.attr.message or "Executing apple_genrule" diff --git a/test/apple_support_test.bzl b/test/apple_support_test.bzl index 02820de..4816af0 100644 --- a/test/apple_support_test.bzl +++ b/test/apple_support_test.bzl @@ -193,7 +193,7 @@ def _apple_support_test_impl(ctx): ), is_executable = True) return [ - testing.ExecutionInfo(apple_support.action_required_execution_requirements()), + testing.ExecutionInfo(apple_support.action_required_execution_requirements(ctx)), testing.TestEnvironment(apple_support.action_required_env(ctx)), DefaultInfo( executable = test_script, From 501b4afb27745c4813a88ffa28acd901408014e4 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Mon, 30 Dec 2019 10:13:26 -0800 Subject: [PATCH 4/8] Update the docs. RELNOTES: None. PiperOrigin-RevId: 287566250 --- doc/apple_support.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/apple_support.md b/doc/apple_support.md index 780db7e..313a4cb 100644 --- a/doc/apple_support.md +++ b/doc/apple_support.md @@ -93,7 +93,7 @@ A dictionary with environment variables required for Xcode path resolution. ## apple_support.action_required_execution_requirements
-apple_support.action_required_execution_requirements()
+apple_support.action_required_execution_requirements(ctx)
 
Returns a dictionary with the execution requirements for running actions on Apple platforms. @@ -105,6 +105,22 @@ To use these environment variables for a test, your test rule needs to propagate `testing.TestExecution` provider, which takes a dictionary with execution requirements for the test action. + +### Arguments + + + + + + + + + + + + +
ctx

Required

The context of the rule registering the action.

+ ### Returns From c0e65ebce0824f1ef444a3e7283b735cb9ab7d82 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 9 Jul 2020 08:12:50 -0700 Subject: [PATCH 5/8] bzl_library improvements. - Add missing deps - Make granular subtargets that are complete. RELNOTES: None PiperOrigin-RevId: 320398637 --- BUILD | 11 ++++++----- lib/BUILD | 19 ++++++++++++++----- rules/BUILD | 13 +++++++++---- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/BUILD b/BUILD index 2089c7f..3d9aab5 100644 --- a/BUILD +++ b/BUILD @@ -4,15 +4,16 @@ licenses(["notice"]) exports_files(["LICENSE"]) -# A bzl_library incase anything needs to depend on this for other libraries -# (like to then use stardoc). +# An umbrella bzl_library for anything that needs it (like to then use stardoc), +# but odds are using the specific sub libraries go wo with the public bzl files +# are a better choice. bzl_library( name = "bzl_library", - srcs = glob(["*.bzl"]), visibility = ["//visibility:public"], deps = [ - "//lib:bzl_library", - "//rules:bzl_library", + "//lib:apple_support", + "//lib:xcode_support", + "//rules:apple_genrule", ], ) diff --git a/lib/BUILD b/lib/BUILD index ebdac59..f445120 100644 --- a/lib/BUILD +++ b/lib/BUILD @@ -2,12 +2,21 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") licenses(["notice"]) -# For the bzl_library at the root of the apple_support. +# Public bzl_library for anything that needs to depend on apple_support.bzl. bzl_library( - name = "bzl_library", - srcs = glob(["*.bzl"]), - visibility = ["//:__pkg__"], - deps = ["@bazel_skylib//lib:types"], + name = "apple_support", + srcs = ["apple_support.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@bazel_skylib//lib:types", + ], +) + +# Public bzl_library for anything that needs to depend on xcode_support.bzl. +bzl_library( + name = "xcode_support", + srcs = ["xcode_support.bzl"], + visibility = ["//visibility:public"], ) # Consumed by bazel tests. diff --git a/rules/BUILD b/rules/BUILD index a5e5954..1509569 100644 --- a/rules/BUILD +++ b/rules/BUILD @@ -2,11 +2,16 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") licenses(["notice"]) -# For the bzl_library at the root of the apple_support. +# Public bzl_library for anything that needs to depend on apple_genrule.bzl. bzl_library( - name = "bzl_library", - srcs = glob(["*.bzl"]), - visibility = ["//:__pkg__"], + name = "apple_genrule", + srcs = ["apple_genrule.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//lib:apple_support", + "@bazel_skylib//lib:dicts", + "@bazel_skylib//lib:paths", + ], ) # Consumed by bazel tests. From a7b18716274df276f32b8ae59ca651d0ca58a051 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Fri, 10 Jul 2020 11:52:12 -0700 Subject: [PATCH 6/8] Rename the bzl library, but nudge folks to the targeted one. RELNOTES: None PiperOrigin-RevId: 320645636 --- BUILD | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index 3d9aab5..2ed22e2 100644 --- a/BUILD +++ b/BUILD @@ -5,10 +5,10 @@ licenses(["notice"]) exports_files(["LICENSE"]) # An umbrella bzl_library for anything that needs it (like to then use stardoc), -# but odds are using the specific sub libraries go wo with the public bzl files -# are a better choice. +# but odds are using the specific sub bzl_library to with the public bzl files +# are a better choice to get the proper subset of dependencies. bzl_library( - name = "bzl_library", + name = "apple_support", visibility = ["//visibility:public"], deps = [ "//lib:apple_support", @@ -17,6 +17,17 @@ bzl_library( ], ) +alias( + name = "bzl_library", + actual = ":apple_support", + deprecation = ( + "bzl_library will go away in the future, please directly depend on the" + + " public file's bzl_library being used: lib:apple_support," + + " lib:xcode_support, or rules:apple_genrule." + ), + visibility = ["//visibility:public"], +) + # Consumed by bazel tests. filegroup( name = "for_bazel_tests", From 647480b45440131b34d9cc8ffbbba39b72acccb2 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 16 Jul 2020 15:22:52 -0700 Subject: [PATCH 7/8] Add rest of bzl_library instances. RELNOTES: None PiperOrigin-RevId: 321657656 --- lib/BUILD | 7 +++++++ test/BUILD | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/BUILD b/lib/BUILD index f445120..9584be4 100644 --- a/lib/BUILD +++ b/lib/BUILD @@ -19,6 +19,13 @@ bzl_library( visibility = ["//visibility:public"], ) +# Public bzl_library for anything that needs to depend on repositories.bzl. +bzl_library( + name = "repositories", + srcs = ["repositories.bzl"], + visibility = ["//visibility:public"], +) + # Consumed by bazel tests. filegroup( name = "for_bazel_tests", diff --git a/test/BUILD b/test/BUILD index 744df57..103bae8 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,4 +1,5 @@ load("//rules:apple_genrule.bzl", "apple_genrule") +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load(":apple_support_test.bzl", "apple_support_test") load(":xcode_support_test.bzl", "xcode_support_test") @@ -23,3 +24,12 @@ apple_genrule( outs = ["simple_genrule.txt"], cmd = "printenv | grep \"^\\(DEVELOPER_DIR\\|SDKROOT\\)\" > $(@)", ) + +bzl_library( + name = "starlark_tests_bzls", + srcs = glob(["*.bzl"]), + deps = [ + "//lib:apple_support", + "//lib:xcode_support", + ], +) From 24bb4d6b21a22c309df8e7d322030615b541fad3 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Fri, 7 Aug 2020 11:18:31 -0400 Subject: [PATCH 8/8] Enable more CI configs again. Mostly a revert of commit 9605c3da1c5bcdddc20d1704b52415a6f3a5f422. --- .bazelci/presubmit.yml | 14 +++++++++ .bazelci/update_workspace_to_deps_heads.sh | 33 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 .bazelci/update_workspace_to_deps_heads.sh diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index c4fb714..2463212 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -10,9 +10,23 @@ x_defaults: - "//..." tasks: + macos_latest: + name: "Latest Bazel" + bazel: latest + <<: *common + macos_last_green: name: "Last Green Bazel" bazel: last_green <<: *common + macos_latest_head_deps: + name: "Latest Bazel with Head Deps" + bazel: latest + shell_commands: + # Update the WORKSPACE to use head versions of some deps to ensure nothing + # has landed on them breaking this project. + - .bazelci/update_workspace_to_deps_heads.sh + <<: *common + buildifier: latest diff --git a/.bazelci/update_workspace_to_deps_heads.sh b/.bazelci/update_workspace_to_deps_heads.sh new file mode 100755 index 0000000..0864d57 --- /dev/null +++ b/.bazelci/update_workspace_to_deps_heads.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright 2019 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +# Modify the WORKSPACE to pull in the master branches of some deps. +sed \ + -i "" \ + -e \ + '/^workspace.*/a \ +\ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")\ +\ +git_repository(\ +\ name = "bazel_skylib",\ +\ remote = "https://github.com/bazelbuild/bazel-skylib.git",\ +\ branch = "master",\ +)\ +' \ + WORKSPACE