From 42ae4b3047d88a4e91493c0e614829c105a92bc5 Mon Sep 17 00:00:00 2001 From: thomasvl Date: Tue, 2 Apr 2019 14:08:50 -0400 Subject: [PATCH 01/11] Update contributing information. Since this isn't part of bazel's core projects, directly provide more info instead of linking to docs they have been evolving as they work on their processes. RELNOTES: None PiperOrigin-RevId: 241564130 --- CONTRIBUTING.md | 85 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9d3d1aa..beb9796 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,27 +1,58 @@ -Want to contribute? Great! First, read this page (including the small print at the end). - -### Before you contribute -**Before we can use your code, you must sign the -[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) -(CLA)**, which you can do online. - -The CLA is necessary mainly because you own the copyright to your changes, -even after your contribution becomes part of our codebase, so we need your -permission to use and distribute your code. We also need to be sure of -various other things — for instance that you'll tell us if you know that -your code infringes on other people's patents. You don't have to sign -the CLA until after you've submitted your code for review and a member has -approved it, but you must do it before we can put your code into our codebase. - -Before you start working on a larger contribution, you should get in touch -with us first. Use the issue tracker to explain your idea so we can help and -possibly guide you. - -### Code reviews and other contributions. -**All submissions, including submissions by project members, require review.** -Please follow the instructions in [the contributors documentation](http://bazel.io/contributing.html). - -### The small print -Contributions made by corporations are covered by a different agreement than -the one above, the -[Software Grant and Corporate Contributor License Agreement](https://cla.developers.google.com/about/google-corporate). +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## File or claim an issue + +Please let us know what you're working on if you want to change or add to the +project. Before undertaking something, please file an issue or claim an existing +issue. + +All significant changes/additions should also be discussed before they can be +accepted. This gives all participants a chance to validate the design and to +avoid duplication of effort. Ensuring that there is an issue for discussion +before working on a PR helps everyone provide input/discussion/advice and +avoid a PR having to get restarted based on useful feedback. + +We use [labels](https://github.com/bazelbuild/apple_support/labels) for the +issues and pull requests to help track priorities, things being considered, +deferred, etc. A project owner will try to update labels every week or so, as +workloads permit. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Setting up your development environment + +To enforce a consistent code style through our code base, we use `buildifier` +from the [bazelbuild/buildtools](https://github.com/bazelbuild/buildtools) to +format `BUILD` and `*.bzl` files. We also use `buildifier --lint=warn` to check +for common issues. + +You can download `buildifier` from +[bazelbuild/buildtools Releases Page](https://github.com/bazelbuild/buildtools/releases). + +Bazel's CI is configured to ensure that files in pull requests are formatted +correctly and that there are no lint issues. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows [Google's Open Source Community +Guidelines](https://opensource.google.com/conduct/). From 20e2b6d22f49cbb16ef0f3b03e830082b896489d Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 4 Apr 2019 07:53:04 -0700 Subject: [PATCH 02/11] Remove the CODEOWNERS file. Having all of us auto assigned to the PRs doesn't really help and it also causes even more email spam to with the new github pipeline. RELNOTES: None. PiperOrigin-RevId: 241929814 --- CODEOWNERS | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 5a63f1b..0000000 --- a/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @sergiocampama @allevato @thomasvl From fc8804eef70f136f103665d313bcc9fc5359bcba Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 4 Apr 2019 08:08:07 -0700 Subject: [PATCH 03/11] Add generate markers to the docs. RELNOTES: None PiperOrigin-RevId: 241931967 --- doc/apple_support.md | 2 ++ doc/rules.md | 2 ++ doc/xcode_support.md | 2 ++ 3 files changed, 6 insertions(+) diff --git a/doc/apple_support.md b/doc/apple_support.md index a1173f3..780db7e 100644 --- a/doc/apple_support.md +++ b/doc/apple_support.md @@ -1,5 +1,7 @@ # `apple_support` Starlark Module + + A module of helpers for rule authors to aid in writing actions that target Apple platforms. diff --git a/doc/rules.md b/doc/rules.md index 63cd1e9..7cd828f 100644 --- a/doc/rules.md +++ b/doc/rules.md @@ -1,5 +1,7 @@ # Build Rules + + Build Rules provided by Apple Support. diff --git a/doc/xcode_support.md b/doc/xcode_support.md index cabf42c..93603f5 100644 --- a/doc/xcode_support.md +++ b/doc/xcode_support.md @@ -1,5 +1,7 @@ # `xcode_support` Starlark Module + + A modules of helpers for rule authors to aid in writing rules that need to change what they do based on attributes of the active Xcode. From 577a71ba38cec60875f99556e924bc82c616edf4 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 4 Apr 2019 10:25:00 -0700 Subject: [PATCH 04/11] .../BUILD: fix build file/module bugs (#18) Change this pattern if foo [not] in native.existing_rules(): to if [not] native.existing_rule(foo): for efficiency. PiperOrigin-RevId: 241954724 --- lib/repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/repositories.bzl b/lib/repositories.bzl index 3ada98c..489ad71 100644 --- a/lib/repositories.bzl +++ b/lib/repositories.bzl @@ -24,7 +24,7 @@ def _maybe(repo_rule, name, **kwargs): name: The name of the repository to be defined by the rule. **kwargs: Additional arguments passed directly to the repository rule. """ - if name not in native.existing_rules(): + if not native.existing_rule(name): repo_rule(name = name, **kwargs) def apple_support_dependencies(): From 590e39f1d6b39c2b3bd3a9cc1c6ea230d386a40a Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 4 Apr 2019 13:36:31 -0700 Subject: [PATCH 05/11] Add a bzl_library incase something needs it from here. RELNOTES: None. PiperOrigin-RevId: 241996984 --- BUILD | 14 ++++++++++++++ lib/BUILD | 9 +++++++++ rules/BUILD | 9 +++++++++ 3 files changed, 32 insertions(+) diff --git a/BUILD b/BUILD index 731d0f2..2089c7f 100644 --- a/BUILD +++ b/BUILD @@ -1,7 +1,21 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + licenses(["notice"]) exports_files(["LICENSE"]) +# A bzl_library incase anything needs to depend on this for other libraries +# (like to then use stardoc). +bzl_library( + name = "bzl_library", + srcs = glob(["*.bzl"]), + visibility = ["//visibility:public"], + deps = [ + "//lib:bzl_library", + "//rules:bzl_library", + ], +) + # Consumed by bazel tests. filegroup( name = "for_bazel_tests", diff --git a/lib/BUILD b/lib/BUILD index a1630b9..a5e5954 100644 --- a/lib/BUILD +++ b/lib/BUILD @@ -1,5 +1,14 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + licenses(["notice"]) +# For the bzl_library at the root of the apple_support. +bzl_library( + name = "bzl_library", + srcs = glob(["*.bzl"]), + visibility = ["//:__pkg__"], +) + # Consumed by bazel tests. filegroup( name = "for_bazel_tests", diff --git a/rules/BUILD b/rules/BUILD index a1630b9..a5e5954 100644 --- a/rules/BUILD +++ b/rules/BUILD @@ -1,5 +1,14 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + licenses(["notice"]) +# For the bzl_library at the root of the apple_support. +bzl_library( + name = "bzl_library", + srcs = glob(["*.bzl"]), + visibility = ["//:__pkg__"], +) + # Consumed by bazel tests. filegroup( name = "for_bazel_tests", From 7f31f5817ac596d9367c1f7b1f6373a8d9553ce8 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 18 Apr 2019 11:37:42 -0700 Subject: [PATCH 06/11] Show the build status only for the master branch. Otherwise a test_* branch that doesn't currently pass turns the badge red because it was the "most recent" build on buildkite. RELNOTES: None PiperOrigin-RevId: 244227416 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 804e855..e068fb2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Apple Support for [Bazel](https://bazel.build) -[![Build Status](https://badge.buildkite.com/6739ca70cb485ecec4ec403f4d6775269728aece4bb984127f.svg)](https://buildkite.com/bazel/apple-support-darwin) +[![Build Status](https://badge.buildkite.com/6739ca70cb485ecec4ec403f4d6775269728aece4bb984127f.svg?branch=master)](https://buildkite.com/bazel/apple-support-darwin) This repository contains helper methods that support building rules that target Apple platforms. From e7d98eb937effa3527a3d021733d6bb2927e0352 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Wed, 8 May 2019 08:03:30 -0700 Subject: [PATCH 07/11] Ignore bazel-* folders RELNOTES: None PiperOrigin-RevId: 247213688 --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6ef824 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bazel-* From eb599953e382e33882cfb59409e2ee18c91ecde9 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Wed, 8 May 2019 08:14:26 -0700 Subject: [PATCH 08/11] Add config to test some deps at their heads. Add a helper script and new ci config to run the script modifying the WORKSPACE to get head versions of some dependencies to help catch if they were to land something that would break the build. RELNOTES: None PiperOrigin-RevId: 247215472 --- .bazelci/presubmit.yml | 13 +++++++++ .bazelci/update_workspace_to_deps_heads.sh | 33 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 .bazelci/update_workspace_to_deps_heads.sh diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 2b1104f..2c95b5a 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -18,4 +18,17 @@ tasks: test_targets: - "//..." + macos_latest_head_deps: + name: "Latest Bazel" + platform: macos + 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 + build_targets: + - "//..." + test_targets: + - "//..." + 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 From c116a3e8f55828eddbe61fd6c3f2ad3078fea3d3 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Wed, 8 May 2019 08:26:34 -0700 Subject: [PATCH 09/11] Rename the task for the buildkite ui. Forgot to do this in the previous change adding it. RELNOTES: None. PiperOrigin-RevId: 247217172 --- .bazelci/presubmit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 2c95b5a..c4c3967 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -19,7 +19,7 @@ tasks: - "//..." macos_latest_head_deps: - name: "Latest Bazel" + name: "Latest Bazel with Head Deps" platform: macos bazel: latest shell_commands: From 371f6863768c2cef0e02790a11bdbdc0a39f09fb Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Mon, 10 Jun 2019 10:23:33 -0700 Subject: [PATCH 10/11] Use yaml anchors, aliases, and merge to avoid repetition. RELNOTES: None. PiperOrigin-RevId: 252430973 --- .bazelci/presubmit.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index c4c3967..2463212 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,34 +1,32 @@ --- -tasks: - macos_latest: - name: "Latest Bazel" +x_defaults: + # YAML has a feature for "repeated nodes", BazelCI is fine with extra nodes + # it doesn't know about; so that is used to avoid repeating common subparts. + common: &common platform: macos - bazel: latest build_targets: - "//..." test_targets: - "//..." +tasks: + macos_latest: + name: "Latest Bazel" + bazel: latest + <<: *common + macos_last_green: name: "Last Green Bazel" - platform: macos bazel: last_green - build_targets: - - "//..." - test_targets: - - "//..." + <<: *common macos_latest_head_deps: name: "Latest Bazel with Head Deps" - platform: macos 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 - build_targets: - - "//..." - test_targets: - - "//..." + <<: *common buildifier: latest From 9dd3b169d3e57410fa3a46f0312675a8f6ef0638 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 30 Jul 2019 08:23:13 -0700 Subject: [PATCH 11/11] Use a list comp to build the depset to avoid overly nesting. RELNOTES: None. PiperOrigin-RevId: 260720040 --- rules/apple_genrule.bzl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rules/apple_genrule.bzl b/rules/apple_genrule.bzl index ccac883..b832484 100644 --- a/rules/apple_genrule.bzl +++ b/rules/apple_genrule.bzl @@ -39,7 +39,6 @@ def _compute_make_variables( return variables def _apple_genrule_impl(ctx): - resolved_srcs = depset() if not ctx.outputs.outs: fail("apple_genrule must have one or more outputs", attr = "outs") files_to_build = depset(ctx.outputs.outs) @@ -52,10 +51,8 @@ def _apple_genrule_impl(ctx): attr = "executable", ) - label_dict = {} - for dep in ctx.attr.srcs: - resolved_srcs = depset(transitive = [resolved_srcs, dep.files]) - label_dict[dep.label] = dep.files.to_list() + resolved_srcs = depset(transitive = [dep.files for dep in ctx.attr.srcs]) + label_dict = {dep.label: dep.files.to_list() for dep in ctx.attr.srcs} resolved_inputs, argv, runfiles_manifests = ctx.resolve_command( command = ctx.attr.cmd,