File bazel-apple-support-0.7.1.obscpio of Package bazel-apple-support

07070100000000000041ED000003E800000064000000025D4DB8B500000000000000000000000000000000000000000000002300000000bazel-apple-support-0.7.1/.bazelci07070100000001000081A4000003E800000064000000015D4DB8B5000002FC000000000000000000000000000000000000003100000000bazel-apple-support-0.7.1/.bazelci/presubmit.yml---
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
    build_targets:
    - "//..."
    test_targets:
    - "//..."

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
07070100000002000081ED000003E800000064000000015D4DB8B5000003C9000000000000000000000000000000000000004500000000bazel-apple-support-0.7.1/.bazelci/update_workspace_to_deps_heads.sh#!/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
07070100000003000081A4000003E800000064000000015D4DB8B500000131000000000000000000000000000000000000002200000000bazel-apple-support-0.7.1/AUTHORS# This the official list of Bazel authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS files.
# See the latter for an explanation.

# Names should be added to this file as:
# Name or Organization <email address>
# The email address is not required for organizations.

Google Inc.
07070100000004000081A4000003E800000064000000015D4DB8B50000035D000000000000000000000000000000000000002000000000bazel-apple-support-0.7.1/BUILDload("@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",
    testonly = 1,
    srcs = [
        "WORKSPACE",
        "//lib:for_bazel_tests",
        "//rules:for_bazel_tests",
        "//tools:for_bazel_tests",
    ],
    # Exposed publicly just so other rules can use this if they set up
    # integration tests that need to copy all the support files into
    # a temporary workspace for the tests.
    visibility = ["//visibility:public"],
)
07070100000005000081A4000003E800000064000000015D4DB8B50000099C000000000000000000000000000000000000002A00000000bazel-apple-support-0.7.1/CONTRIBUTING.md# 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 <https://cla.developers.google.com/> 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/).
07070100000006000081A4000003E800000064000000015D4DB8B500000228000000000000000000000000000000000000002700000000bazel-apple-support-0.7.1/CONTRIBUTORS# People who have agreed to one of the CLAs and can contribute patches.
# The AUTHORS file lists the copyright holders; this file
# lists people.  For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
# https://developers.google.com/open-source/cla/individual
# https://developers.google.com/open-source/cla/corporate
#
# Names should be added to this file as:
#     Name <email address>

Sergio Campamá <kaipi@google.com>
Thomas Van Lenten <thomasvl@google.com>
Tony Allevato <allevato@google.com>
07070100000007000081A4000003E800000064000000015D4DB8B500002C5E000000000000000000000000000000000000002200000000bazel-apple-support-0.7.1/LICENSE
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   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.
07070100000008000081A4000003E800000064000000015D4DB8B500000302000000000000000000000000000000000000002400000000bazel-apple-support-0.7.1/README.md# Apple Support for [Bazel](https://bazel.build)

[![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.

## Quick setup

Add the following to your `WORKSPACE` file to add this repository as a dependency:

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

git_repository(
    name = "build_bazel_apple_support",
    remote = "https://github.com/bazelbuild/apple_support.git",
    tag = "0.7.0",
)

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

apple_support_dependencies()
```
07070100000009000081A4000003E800000064000000015D4DB8B5000000AF000000000000000000000000000000000000002400000000bazel-apple-support-0.7.1/WORKSPACEworkspace(name = "build_bazel_apple_support")

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

apple_support_dependencies()
0707010000000A000041ED000003E800000064000000025D4DB8B500000000000000000000000000000000000000000000001E00000000bazel-apple-support-0.7.1/doc0707010000000B000081A4000003E800000064000000015D4DB8B5000004C6000000000000000000000000000000000000002800000000bazel-apple-support-0.7.1/doc/README.md# Apple Support Starlark Modules and Rules

Apple Support provides a collection of Starlark helpers for rule authors
targeting Apple Platforms (and Xcode) as well as some Rules directly.

## Starlark Modules

<table class="table table-condensed table-bordered table-params">
  <thead>
    <tr>
      <th><code>.bzl</code> file</th>
      <th>Module</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td valign="top"><code>@build_bazel_apple_support//lib:apple_support.bzl</code></td>
      <td valign="top"><code><a href="apple_support.md">apple_support</a></code><br/></td>
    </tr>
    <tr>
      <td valign="top"><code>@build_bazel_apple_support//lib:xcode_support.bzl</code></td>
      <td valign="top"><code><a href="xcode_support.md">xcode_support</a></code><br/></td>
    </tr>
  </tbody>
</table>

## Rules

<table class="table table-condensed table-bordered table-params">
  <thead>
    <tr>
      <th><code>.bzl</code> file</th>
      <th>Rules</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td valign="top"><code>@build_bazel_apple_support//rules:apple_genrule.bzl</code></td>
      <td valign="top"><code><a href="rules.md#apple_genrule">apple_genrule</a></code><br/></td>
    </tr>
  </tbody>
</table>
0707010000000C000081A4000003E800000064000000015D4DB8B500002B6F000000000000000000000000000000000000002F00000000bazel-apple-support-0.7.1/doc/apple_support.md# `apple_support` Starlark Module

<!-- Generated file, do not edit directly. -->


A module of helpers for rule authors to aid in writing actions that
target Apple platforms.

To use these in your Starlark code, simply load the module; for example:

```build
load("@build_bazel_apple_support//lib:apple_support.bzl", "apple_support")
```

<!-- BEGIN_TOC -->
On this page:

  * [apple_support.action_required_attrs](#apple_support.action_required_attrs)
  * [apple_support.action_required_env](#apple_support.action_required_env)
  * [apple_support.action_required_execution_requirements](#apple_support.action_required_execution_requirements)
  * [apple_support.path_placeholders.platform_frameworks](#apple_support.path_placeholders.platform_frameworks)
  * [apple_support.path_placeholders.sdkroot](#apple_support.path_placeholders.sdkroot)
  * [apple_support.path_placeholders.xcode](#apple_support.path_placeholders.xcode)
  * [apple_support.run](#apple_support.run)
  * [apple_support.run_shell](#apple_support.run_shell)
<!-- END_TOC -->


<a name="apple_support.action_required_attrs"></a>
## apple_support.action_required_attrs

<pre style="white-space: normal">
apple_support.action_required_attrs()
</pre>

Returns a dictionary with required attributes for registering actions on Apple platforms.

This method adds private attributes which should not be used outside of the apple_support
codebase. It also adds the following attributes which are considered to be public for rule
maintainers to use:

 * `_xcode_config`: Attribute that references a target containing the single
   `apple_common.XcodeVersionConfig` provider. This provider can be used to inspect Xcode-related
   properties about the Xcode being used for the build, as specified with the `--xcode_version`
   Bazel flag. The most common way to retrieve this provider is:
   `ctx.attr._xcode_config[apple_common.XcodeVersionConfig]`.

The returned `dict` can be added to the rule's attributes using Skylib's `dicts.add()` method.

<a name="apple_support.action_required_attrs.returns"></a>
### Returns

A `dict` object containing attributes to be added to rule implementations.

<a name="apple_support.action_required_env"></a>
## apple_support.action_required_env

<pre style="white-space: normal">
apple_support.action_required_env(<a href="#apple_support.action_required_env.ctx">ctx</a>)
</pre>

Returns a dictionary with the environment variables required for Xcode path resolution.

In most cases, you should _not_ use this API. It exists solely for using it on test rules,
where the test action registration API is not available in Starlark.

To use these environment variables for a test, your test rule needs to propagate the
`testing.TestEnvironment` provider, which takes a dictionary with environment variables to set
during the test execution.

<a name="apple_support.action_required_env.arguments"></a>
### Arguments

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="apple_support.action_required_env.ctx">
      <td><code>ctx</code></td>
      <td><p><code>Required</code></p><p>The context of the rule registering the action.</p></td>
    </tr>
  </tbody>
</table>

<a name="apple_support.action_required_env.returns"></a>
### Returns

A dictionary with environment variables required for Xcode path resolution.

<a name="apple_support.action_required_execution_requirements"></a>
## apple_support.action_required_execution_requirements

<pre style="white-space: normal">
apple_support.action_required_execution_requirements()
</pre>

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,
where the test action registration API is not available in Starlark.

To use these environment variables for a test, your test rule needs to propagate the
`testing.TestExecution` provider, which takes a dictionary with execution requirements for the
test action.

<a name="apple_support.action_required_execution_requirements.returns"></a>
### Returns

A dictionary with execution requirements for running actions on Apple platforms.


<a name="apple_support.path_placeholders.platform_frameworks"></a>
## apple_support.path_placeholders.platform_frameworks

<pre style="white-space: normal">
apple_support.path_placeholders.platform_frameworks(<a href="#apple_support.path_placeholders.platform_frameworks.ctx">ctx</a>)
</pre>

Returns the platform's frameworks directory, anchored to the Xcode path placeholder.

<a name="apple_support.path_placeholders.platform_frameworks.arguments"></a>
### Arguments

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="apple_support.path_placeholders.platform_frameworks.ctx">
      <td><code>ctx</code></td>
      <td><p><code>Required</code></p><p>The context of the rule that will register an action.</p></td>
    </tr>
  </tbody>
</table>

<a name="apple_support.path_placeholders.platform_frameworks.returns"></a>
### Returns

Returns a string with the platform's frameworks directory, anchored to the Xcode path
placeholder.

<a name="apple_support.path_placeholders.sdkroot"></a>
## apple_support.path_placeholders.sdkroot

<pre style="white-space: normal">
apple_support.path_placeholders.sdkroot()
</pre>

Returns a placeholder value to be replaced with SDKROOT during action execution.

In order to get this values replaced, you'll need to use the `apple_support.run()` API by
setting the `xcode_path_resolve_level` argument to either the
`apple_support.xcode_path_resolve_level.args` or
`apple_support.xcode_path_resolve_level.args_and_files` value.

<a name="apple_support.path_placeholders.sdkroot.returns"></a>
### Returns

Returns a placeholder value to be replaced with SDKROOT during action execution.

<a name="apple_support.path_placeholders.xcode"></a>
## apple_support.path_placeholders.xcode

<pre style="white-space: normal">
apple_support.path_placeholders.xcode()
</pre>

Returns a placeholder value to be replaced with DEVELOPER_DIR during action execution.

In order to get this values replaced, you'll need to use the `apple_support.run()` API by
setting the `xcode_path_resolve_level` argument to either the
`apple_support.xcode_path_resolve_level.args` or
`apple_support.xcode_path_resolve_level.args_and_files` value.

<a name="apple_support.path_placeholders.xcode.returns"></a>
### Returns

Returns a placeholder value to be replaced with DEVELOPER_DIR during action execution.


<a name="apple_support.run"></a>
## apple_support.run

<pre style="white-space: normal">
apple_support.run(<a href="#apple_support.run.ctx">ctx</a>, <a href="#apple_support.run.xcode_path_resolve_level">xcode_path_resolve_level</a>=None, <a href="#apple_support.run.**kwargs">**kwargs</a>)
</pre>

Registers an action to run on an Apple machine.

In order to use `apple_support.run()`, you'll need to modify your rule definition to add the
following:

  * `fragments = ["apple"]`
  * Add the `apple_support.action_required_attrs()` attributes to the `attrs` dictionary. This
    can be done using the `dicts.add()` method from Skylib.

This method registers an action to run on an Apple machine, configuring it to ensure that the
`DEVELOPER_DIR` and `SDKROOT` environment variables are set.

If the `xcode_path_resolve_level` is enabled, this method will replace the given `executable`
with a wrapper script that will replace all instances of the `__BAZEL_XCODE_DEVELOPER_DIR__` and
`__BAZEL_XCODE_SDKROOT__` placeholders in the given arguments with the values of `DEVELOPER_DIR`
and `SDKROOT`, respectively.

In your rule implementation, you can use references to Xcode through the
`apple_support.path_placeholders` API, which in turn uses the placeholder values as described
above. The available APIs are:

  * `apple_support.path_placeholders.xcode()`: Returns a reference to the Xcode.app
    installation path.
  * `apple_support.path_placeholders.sdkroot()`: Returns a reference to the SDK root path.
  * `apple_support.path_placeholders.platform_frameworks(ctx)`: Returns the Frameworks path
    within the Xcode installation, for the requested platform.

If the `xcode_path_resolve_level` value is:

  * `apple_support.xcode_path_resolve_level.none`: No processing will be done to the given
    `arguments`.
  * `apple_support.xcode_path_resolve_level.args`: Only instances of the placeholders in the
     argument strings will be replaced.
  * `apple_support.xcode_path_resolve_level.args_and_files`: Instances of the placeholders in
     the arguments strings and instances of the placeholders within response files (i.e. any
     path argument beginning with `@`) will be replaced.

<a name="apple_support.run.arguments"></a>
### Arguments

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="apple_support.run.ctx">
      <td><code>ctx</code></td>
      <td><p><code>Required</code></p><p>The context of the rule registering the action.</p></td>
    </tr>
    <tr id="apple_support.run.xcode_path_resolve_level">
      <td><code>xcode_path_resolve_level</code></td>
      <td><p><code>Optional; default is None</code></p><p>The level of Xcode path replacement required for the action.</p></td>
    </tr>
    <tr id="apple_support.run.**kwargs">
      <td><code>**kwargs</code></td>
      <td><p>See <code>ctx.actions.run</code> for the rest of the available arguments.</p></td>
    </tr>
  </tbody>
</table>

<a name="apple_support.run_shell"></a>
## apple_support.run_shell

<pre style="white-space: normal">
apple_support.run_shell(<a href="#apple_support.run_shell.ctx">ctx</a>, <a href="#apple_support.run_shell.**kwargs">**kwargs</a>)
</pre>

Registers a shell action to run on an Apple machine.

In order to use `apple_support.run_shell()`, you'll need to modify your rule definition to add
the following:

  * `fragments = ["apple"]`
  * Add the `apple_support.action_required_attrs()` attributes to the `attrs` dictionary. This
    can be done using the `dicts.add()` method from Skylib.

This method registers an action to run on an Apple machine, configuring it to ensure that the
`DEVELOPER_DIR` and `SDKROOT` environment variables are set.

`run_shell` does not support placeholder substitution. To achieve placeholder substitution,
please use `run` instead.

<a name="apple_support.run_shell.arguments"></a>
### Arguments

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="apple_support.run_shell.ctx">
      <td><code>ctx</code></td>
      <td><p><code>Required</code></p><p>The context of the rule registering the action.</p></td>
    </tr>
    <tr id="apple_support.run_shell.**kwargs">
      <td><code>**kwargs</code></td>
      <td><p>See <code>ctx.actions.run</code> for the rest of the available arguments.</p></td>
    </tr>
  </tbody>
</table>




0707010000000D000081A4000003E800000064000000015D4DB8B5000011DB000000000000000000000000000000000000002700000000bazel-apple-support-0.7.1/doc/rules.md# Build Rules

<!-- Generated file, do not edit directly. -->


Build Rules provided by Apple Support.

<!-- BEGIN_TOC -->
On this page:

  * [apple_genrule](#apple_genrule)
<!-- END_TOC -->

<a name="apple_genrule"></a>
## apple_genrule

<pre style="white-space: normal">
apple_genrule(<a href="#apple_genrule.name">name</a>, <a href="#apple_genrule.cmd">cmd</a>, <a href="#apple_genrule.executable">executable</a>=False, <a href="#apple_genrule.outs">outs</a>=[], <a href="#apple_genrule.srcs">srcs</a>=[], <a href="#apple_genrule.message">message</a>=None, <a href="#apple_genrule.tools">tools</a>=[],
<a href="#apple_genrule.no_sandbox">no_sandbox</a>=False, <a href="#apple_genrule.**kwargs">**kwargs</a>)
</pre>

Genrule which provides Apple specific environment and make variables.

This mirrors the native genrule except that it provides a different set of
make variables. This rule will only run on a Mac.

Example of use:

```
load("@build_bazel_apple_support//rules:apple_genrule.bzl", "apple_genrule")

apple_genrule(
    name = "world",
    outs = ["hi"],
    cmd = "touch $@",
)
```

This rule also does location expansion, much like the native genrule.
For example, `$(location hi)` may be used to refer to the output in the
above example.

The set of make variables that are supported for this rule:

* `OUTS`: The outs list. If you have only one output file, you can also use
          `$@`.
* `SRCS`: The srcs list (or more precisely, the pathnames of the files
          corresponding to labels in the srcs list). If you have only one
          source file, you can also use `$<`.
* `<`: srcs, if it's a single file.
* `@`: outs, if it's a single file.
* `@D`: The output directory. If there is only one filename in outs, this
        expands to the directory containing that file. If there are
        multiple filenames, this variable instead expands to the package's
        root directory in the genfiles tree, even if all the generated
        files belong to the same subdirectory.

The following environment variables are added to the rule action:

* `DEVELOPER_DIR`: The base developer directory as defined on Apple
                   architectures, most commonly used in invoking Apple
                   tools such as xcrun.
* `SDKROOT`: The base SDK directory as defined on Apple architectures, most
             commonly used in invoking Apple tools such as xcrun.

<a name="apple_genrule.arguments"></a>
### Arguments

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="apple_genrule.name">
      <td><code>name</code></td>
      <td><p><code>Required</code></p><p>The name of the target.</p></td>
    </tr>
    <tr id="apple_genrule.cmd">
      <td><code>cmd</code></td>
      <td><p><code>Required</code></p><p>The command to run. Subject the variable substitution.</p></td>
    </tr>
    <tr id="apple_genrule.executable">
      <td><code>executable</code></td>
      <td><p><code>Optional; default is False</code></p><p>Boolean. Declare output to be executable. Setting this flag to
1 means the output is an executable file and can be run using the run
command. The genrule must produce exactly one output in this case.</p></td>
    </tr>
    <tr id="apple_genrule.outs">
      <td><code>outs</code></td>
      <td><p><code>Optional; default is []</code></p><p>A list of files generated by this rule. If the executable flag is
set, outs must contain exactly one label.</p></td>
    </tr>
    <tr id="apple_genrule.srcs">
      <td><code>srcs</code></td>
      <td><p><code>Optional; default is []</code></p><p>A list of inputs for this rule, such as source files to process.</p></td>
    </tr>
    <tr id="apple_genrule.message">
      <td><code>message</code></td>
      <td><p><code>Optional; default is None</code></p><p>A progress message to be reported as the rule runs.</p></td>
    </tr>
    <tr id="apple_genrule.tools">
      <td><code>tools</code></td>
      <td><p><code>Optional; default is []</code></p><p>A list of tool dependencies for this rule, they will be available
when the action is run.</p></td>
    </tr>
    <tr id="apple_genrule.no_sandbox">
      <td><code>no_sandbox</code></td>
      <td><p><code>Optional; default is False</code></p><p>If the sandbox should be disabled when the action is run.</p></td>
    </tr>
    <tr id="apple_genrule.**kwargs">
      <td><code>**kwargs</code></td>
      <td><p>Extra args meant to just be the common rules for all rules
(tags, etc.).</p></td>
    </tr>
  </tbody>
</table>

0707010000000E000081A4000003E800000064000000015D4DB8B500000894000000000000000000000000000000000000002F00000000bazel-apple-support-0.7.1/doc/xcode_support.md# `xcode_support` Starlark Module

<!-- Generated file, do not edit directly. -->


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.

To use these in your Starlark code, simply load the module; for example:

```build
load("@build_bazel_apple_support//lib:xcode_support.bzl", "xcode_support")
```

<!-- BEGIN_TOC -->
On this page:

  * [xcode_support.is_xcode_at_least_version](#xcode_support.is_xcode_at_least_version)
<!-- END_TOC -->


<a name="xcode_support.is_xcode_at_least_version"></a>
## xcode_support.is_xcode_at_least_version

<pre style="white-space: normal">
xcode_support.is_xcode_at_least_version(<a href="#xcode_support.is_xcode_at_least_version.xcode_config">xcode_config</a>, <a href="#xcode_support.is_xcode_at_least_version.version">version</a>)
</pre>

Returns True if Xcode version is at least a given version.

This method takes as input an `XcodeVersionConfig` provider, which can be obtained from the
`_xcode_config` attribute (e.g. `ctx.attr._xcode_config[apple_common.XcodeVersionConfig]`). This
provider should contain the Xcode version parameters with which this rule is being built with.
If you need to add this attribute to your rule implementation, please refer to
`apple_support.action_required_attrs()`.

<a name="xcode_support.is_xcode_at_least_version.arguments"></a>
### Arguments

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="xcode_support.is_xcode_at_least_version.xcode_config">
      <td><code>xcode_config</code></td>
      <td><p><code>Required</code></p><p>The XcodeVersionConfig provider from the <code>_xcode_config</code> attribute's value.</p></td>
    </tr>
    <tr id="xcode_support.is_xcode_at_least_version.version">
      <td><code>version</code></td>
      <td><p><code>Required</code></p><p>The minimum desired Xcode version, as a dotted version string.</p></td>
    </tr>
  </tbody>
</table>

<a name="xcode_support.is_xcode_at_least_version.returns"></a>
### Returns

True if the given `xcode_config` version at least as high as the requested version.


0707010000000F000041ED000003E800000064000000025D4DB8B500000000000000000000000000000000000000000000001E00000000bazel-apple-support-0.7.1/lib07070100000010000081A4000003E800000064000000015D4DB8B5000001A8000000000000000000000000000000000000002400000000bazel-apple-support-0.7.1/lib/BUILDload("@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__"],
    deps = ["@bazel_skylib//lib:types"],
)

# Consumed by bazel tests.
filegroup(
    name = "for_bazel_tests",
    testonly = 1,
    srcs = glob(["**"]),
    visibility = ["//:__pkg__"],
)
07070100000011000081A4000003E800000064000000015D4DB8B500003821000000000000000000000000000000000000003000000000bazel-apple-support-0.7.1/lib/apple_support.bzl# Copyright 2018 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.
"""Definitions for registering actions on Apple platforms."""

load("@bazel_skylib//lib:types.bzl", "types")

# Options to declare the level of Xcode path resolving needed in an `apple_support.run()`
# invocation.
_XCODE_PATH_RESOLVE_LEVEL = struct(
    none = None,
    args = "args",
    args_and_files = "args_and_files",
)

def _platform_frameworks_path_placeholder(ctx):
    """Returns the platform's frameworks directory, anchored to the Xcode path placeholder.

    Args:
        ctx: The context of the rule that will register an action.

    Returns:
        Returns a string with the platform's frameworks directory, anchored to the Xcode path
        placeholder.
    """
    return "{xcode_path}/Platforms/{platform_name}.platform/Developer/Library/Frameworks".format(
        platform_name = ctx.fragments.apple.single_arch_platform.name_in_plist,
        xcode_path = _xcode_path_placeholder(),
    )

def _sdkroot_path_placeholder():
    """Returns a placeholder value to be replaced with SDKROOT during action execution.

    In order to get this values replaced, you'll need to use the `apple_support.run()` API by
    setting the `xcode_path_resolve_level` argument to either the
    `apple_support.xcode_path_resolve_level.args` or
    `apple_support.xcode_path_resolve_level.args_and_files` value.

    Returns:
        Returns a placeholder value to be replaced with SDKROOT during action execution.
    """
    return "__BAZEL_XCODE_SDKROOT__"

def _xcode_path_placeholder():
    """Returns a placeholder value to be replaced with DEVELOPER_DIR during action execution.

    In order to get this values replaced, you'll need to use the `apple_support.run()` API by
    setting the `xcode_path_resolve_level` argument to either the
    `apple_support.xcode_path_resolve_level.args` or
    `apple_support.xcode_path_resolve_level.args_and_files` value.

    Returns:
        Returns a placeholder value to be replaced with DEVELOPER_DIR during action execution.
    """
    return "__BAZEL_XCODE_DEVELOPER_DIR__"

def _add_dicts(*dictionaries):
    """Adds a list of dictionaries into a single dictionary."""

    # If keys are repeated in multiple dictionaries, the latter one "wins".
    result = {}
    for d in dictionaries:
        result.update(d)

    return result

def _kwargs_for_apple_platform(ctx, additional_env = None, **kwargs):
    """Returns a modified dictionary with required arguments to run on Apple platforms."""
    processed_args = dict(kwargs)

    # Make sure that _xcode_config is properly set.
    _validate_attribute_present(ctx, "_xcode_config")

    env_dicts = []
    original_env = processed_args.get("env")
    if original_env:
        env_dicts.append(original_env)
    if additional_env:
        env_dicts.append(additional_env)

    # Add the environment variables required for DEVELOPER_DIR and SDKROOT last to avoid clients
    # overriding this value.
    env_dicts.append(_action_required_env(ctx))

    execution_requirement_dicts = []
    original_execution_requirements = processed_args.get("execution_requirements")
    if original_execution_requirements:
        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())

    processed_args["env"] = _add_dicts(*env_dicts)
    processed_args["execution_requirements"] = _add_dicts(*execution_requirement_dicts)

    return processed_args

def _validate_attribute_present(ctx, attribute_name):
    """Validates that the given attribute is present for the rule, failing otherwise."""
    if not hasattr(ctx.attr, attribute_name):
        fail("\n".join([
            "",
            "ERROR: This rule requires the '{}' attribute to be present. ".format(attribute_name),
            "To add this attribute, modify your rule definition like this:",
            "",
            "load(\"@bazel_skylib//lib:dicts.bzl\", \"dicts\")",
            "load(",
            "    \"@build_bazel_apple_support//lib:apple_support.bzl\",",
            "    \"apple_support\",",
            ")",
            "",
            "your_rule_name = rule(",
            "    attrs = dicts.add(apple_support.action_required_attrs(), {",
            "        # other attributes",
            "    }),",
            "    # other rule arguments",
            ")",
            "",
        ]))

def _action_required_attrs():
    """Returns a dictionary with required attributes for registering actions on Apple platforms.

    This method adds private attributes which should not be used outside of the apple_support
    codebase. It also adds the following attributes which are considered to be public for rule
    maintainers to use:

     * `_xcode_config`: Attribute that references a target containing the single
       `apple_common.XcodeVersionConfig` provider. This provider can be used to inspect Xcode-related
       properties about the Xcode being used for the build, as specified with the `--xcode_version`
       Bazel flag. The most common way to retrieve this provider is:
       `ctx.attr._xcode_config[apple_common.XcodeVersionConfig]`.

    The returned `dict` can be added to the rule's attributes using Skylib's `dicts.add()` method.

    Returns:
        A `dict` object containing attributes to be added to rule implementations.
    """
    return {
        "_xcode_config": attr.label(
            default = configuration_field(
                name = "xcode_config_label",
                fragment = "apple",
            ),
        ),
        "_xcode_path_wrapper": attr.label(
            cfg = "host",
            executable = True,
            default = Label("@build_bazel_apple_support//tools:xcode_path_wrapper"),
        ),
    }

def _action_required_env(ctx):
    """Returns a dictionary with the environment variables required for Xcode path resolution.

    In most cases, you should _not_ use this API. It exists solely for using it on test rules,
    where the test action registration API is not available in Starlark.

    To use these environment variables for a test, your test rule needs to propagate the
    `testing.TestEnvironment` provider, which takes a dictionary with environment variables to set
    during the test execution.

    Args:
        ctx: The context of the rule registering the action.

    Returns:
        A dictionary with environment variables required for Xcode path resolution.
    """
    platform = ctx.fragments.apple.single_arch_platform
    xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]

    return _add_dicts(
        apple_common.apple_host_system_env(xcode_config),
        apple_common.target_apple_env(xcode_config, platform),
    )

def _action_required_execution_requirements():
    """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,
    where the test action registration API is not available in Starlark.

    To use these environment variables for a test, your test rule needs to propagate the
    `testing.TestExecution` provider, which takes a dictionary with execution requirements for the
    test action.

    Returns:
        A dictionary with execution requirements for running actions on Apple platforms.
    """
    return {"requires-darwin": "1"}

def _run(ctx, xcode_path_resolve_level = _XCODE_PATH_RESOLVE_LEVEL.none, **kwargs):
    """Registers an action to run on an Apple machine.

    In order to use `apple_support.run()`, you'll need to modify your rule definition to add the
    following:

      * `fragments = ["apple"]`
      * Add the `apple_support.action_required_attrs()` attributes to the `attrs` dictionary. This
        can be done using the `dicts.add()` method from Skylib.

    This method registers an action to run on an Apple machine, configuring it to ensure that the
    `DEVELOPER_DIR` and `SDKROOT` environment variables are set.

    If the `xcode_path_resolve_level` is enabled, this method will replace the given `executable`
    with a wrapper script that will replace all instances of the `__BAZEL_XCODE_DEVELOPER_DIR__` and
    `__BAZEL_XCODE_SDKROOT__` placeholders in the given arguments with the values of `DEVELOPER_DIR`
    and `SDKROOT`, respectively.

    In your rule implementation, you can use references to Xcode through the
    `apple_support.path_placeholders` API, which in turn uses the placeholder values as described
    above. The available APIs are:

      * `apple_support.path_placeholders.xcode()`: Returns a reference to the Xcode.app
        installation path.
      * `apple_support.path_placeholders.sdkroot()`: Returns a reference to the SDK root path.
      * `apple_support.path_placeholders.platform_frameworks(ctx)`: Returns the Frameworks path
        within the Xcode installation, for the requested platform.

    If the `xcode_path_resolve_level` value is:

      * `apple_support.xcode_path_resolve_level.none`: No processing will be done to the given
        `arguments`.
      * `apple_support.xcode_path_resolve_level.args`: Only instances of the placeholders in the
         argument strings will be replaced.
      * `apple_support.xcode_path_resolve_level.args_and_files`: Instances of the placeholders in
         the arguments strings and instances of the placeholders within response files (i.e. any
         path argument beginning with `@`) will be replaced.

    Args:
        ctx: The context of the rule registering the action.
        xcode_path_resolve_level: The level of Xcode path replacement required for the action.
        **kwargs: See `ctx.actions.run` for the rest of the available arguments.
    """
    if xcode_path_resolve_level == _XCODE_PATH_RESOLVE_LEVEL.none:
        ctx.actions.run(**_kwargs_for_apple_platform(ctx, **kwargs))
        return

    # If using the wrapper script, also make sure that it exists.
    _validate_attribute_present(ctx, "_xcode_path_wrapper")

    processed_kwargs = _kwargs_for_apple_platform(
        ctx,
        additional_env = {"XCODE_PATH_RESOLVE_LEVEL": xcode_path_resolve_level},
        **kwargs
    )

    all_arguments = []

    # If the client requires Xcode path resolving, push the original executable to be the first
    # argument, as the executable will be set to be the xcode_path_wrapper script.
    executable_args = ctx.actions.args()
    original_executable = processed_kwargs.pop("executable")
    executable_args.add(original_executable)
    all_arguments.append(executable_args)

    # Append the original arguments to the full list of arguments, after the original executable.
    original_args_list = processed_kwargs.pop("arguments", [])
    if original_args_list:
        all_arguments.extend(original_args_list)

    # We also need to include the user executable in the "tools" argument of the action, since it
    # won't be referenced by "executable" anymore.
    original_tools = processed_kwargs.pop("tools", None)
    if types.is_list(original_tools):
        all_tools = [original_executable] + original_tools
    elif types.is_depset(original_tools):
        all_tools = depset([original_executable], transitive = [original_tools])
    elif original_tools:
        fail("'tools' argument must be a sequence or depset.")
    elif not types.is_string(original_executable):
        # Only add the user_executable to the "tools" list if it's a File, not a string.
        all_tools = [original_executable]
    else:
        all_tools = []

    ctx.actions.run(
        executable = ctx.executable._xcode_path_wrapper,
        arguments = all_arguments,
        tools = all_tools,
        **processed_kwargs
    )

def _run_shell(ctx, **kwargs):
    """Registers a shell action to run on an Apple machine.

    In order to use `apple_support.run_shell()`, you'll need to modify your rule definition to add
    the following:

      * `fragments = ["apple"]`
      * Add the `apple_support.action_required_attrs()` attributes to the `attrs` dictionary. This
        can be done using the `dicts.add()` method from Skylib.

    This method registers an action to run on an Apple machine, configuring it to ensure that the
    `DEVELOPER_DIR` and `SDKROOT` environment variables are set.

    `run_shell` does not support placeholder substitution. To achieve placeholder substitution,
    please use `run` instead.

    Args:
        ctx: The context of the rule registering the action.
        **kwargs: See `ctx.actions.run` for the rest of the available arguments.
    """
    _validate_attribute_present(ctx, "_xcode_config")

    # TODO(b/77637734) remove "workaround" once the bazel issue is resolved.
    # Bazel doesn't always get the shell right for a single string `commands`;
    # so work around that case by faking it as a list of strings that forces
    # the shell correctly.
    command = kwargs.get("command")
    if command and types.is_string(command):
        processed_args = dict(kwargs)
        processed_args["command"] = ["/bin/sh", "-c", command]
        kwargs = processed_args

    ctx.actions.run_shell(**_kwargs_for_apple_platform(ctx, **kwargs))

apple_support = struct(
    action_required_attrs = _action_required_attrs,
    action_required_env = _action_required_env,
    action_required_execution_requirements = _action_required_execution_requirements,
    path_placeholders = struct(
        platform_frameworks = _platform_frameworks_path_placeholder,
        sdkroot = _sdkroot_path_placeholder,
        xcode = _xcode_path_placeholder,
    ),
    run = _run,
    run_shell = _run_shell,
    xcode_path_resolve_level = _XCODE_PATH_RESOLVE_LEVEL,
)
07070100000012000081A4000003E800000064000000015D4DB8B500000430000000000000000000000000000000000000003600000000bazel-apple-support-0.7.1/lib/framework_migration.bzl# 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,
)
07070100000013000081A4000003E800000064000000015D4DB8B5000006FF000000000000000000000000000000000000002F00000000bazel-apple-support-0.7.1/lib/repositories.bzl# Copyright 2018 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.

"""Definitions for handling Bazel repositories used by apple_support."""

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., `git_repository`.)
      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 apple_support_dependencies():
    """Fetches repository dependencies of the `apple_support` workspace.

    Users should call this macro in their `WORKSPACE` to ensure that all of the
    dependencies of the Swift rules are downloaded and that they are isolated from
    changes to those dependencies.
    """
    _maybe(
        http_archive,
        name = "bazel_skylib",
        urls = [
            "https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
        ],
        sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0",
    )
07070100000014000081A4000003E800000064000000015D4DB8B5000007F2000000000000000000000000000000000000003000000000bazel-apple-support-0.7.1/lib/xcode_support.bzl# 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.

"""Support functions for working with Xcode configurations."""

def _is_xcode_at_least_version(xcode_config, version):
    """Returns True if Xcode version is at least a given version.

    This method takes as input an `XcodeVersionConfig` provider, which can be obtained from the
    `_xcode_config` attribute (e.g. `ctx.attr._xcode_config[apple_common.XcodeVersionConfig]`). This
    provider should contain the Xcode version parameters with which this rule is being built with.
    If you need to add this attribute to your rule implementation, please refer to
    `apple_support.action_required_attrs()`.

    Args:
        xcode_config: The XcodeVersionConfig provider from the `_xcode_config` attribute's value.
        version: The minimum desired Xcode version, as a dotted version string.

    Returns:
        True if the given `xcode_config` version at least as high as the requested version.
    """
    current_version = xcode_config.xcode_version()
    if not current_version:
        fail("Could not determine Xcode version at all. This likely means Xcode isn't available; " +
             "if you think this is a mistake, please file an issue.")

    desired_version = apple_common.dotted_version(version)
    return current_version >= desired_version

# Define the loadable module that lists the exported symbols in this file.
xcode_support = struct(
    is_xcode_at_least_version = _is_xcode_at_least_version,
)
07070100000015000041ED000003E800000064000000025D4DB8B500000000000000000000000000000000000000000000002000000000bazel-apple-support-0.7.1/rules07070100000016000081A4000003E800000064000000015D4DB8B50000017F000000000000000000000000000000000000002600000000bazel-apple-support-0.7.1/rules/BUILDload("@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",
    testonly = 1,
    srcs = glob(["**"]),
    visibility = ["//:__pkg__"],
)
07070100000017000081A4000003E800000064000000015D4DB8B500002106000000000000000000000000000000000000003200000000bazel-apple-support-0.7.1/rules/apple_genrule.bzl# Copyright 2017 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.

"""Genrule which provides Apple's Xcode environment."""

load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//lib:apple_support.bzl", "apple_support")

def _compute_make_variables(
        genfiles_dir,
        label,
        resolved_srcs,
        files_to_build):
    resolved_srcs_list = resolved_srcs.to_list()
    files_to_build_list = files_to_build.to_list()
    variables = {
        "OUTS": " ".join([x.path for x in files_to_build_list]),
        "SRCS": " ".join([x.path for x in resolved_srcs_list]),
    }
    if len(resolved_srcs_list) == 1:
        variables["<"] = resolved_srcs_list[0].path
    if len(files_to_build_list) == 1:
        variables["@"] = files_to_build_list[0].path
        variables["@D"] = paths.dirname(variables["@"])
    else:
        variables["@D"] = genfiles_dir.path + "/" + label.package
    return variables

def _apple_genrule_impl(ctx):
    if not ctx.outputs.outs:
        fail("apple_genrule must have one or more outputs", attr = "outs")
    files_to_build = depset(ctx.outputs.outs)

    if ctx.attr.executable and len(files_to_build.to_list()) > 1:
        fail(
            "if genrules produce executables, they are allowed only one output. " +
            "If you need the executable=1 argument, then you should split this " +
            "genrule into genrules producing single outputs",
            attr = "executable",
        )

    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,
        attribute = "cmd",
        expand_locations = True,
        make_variables = _compute_make_variables(
            ctx.genfiles_dir,
            ctx.label,
            depset(resolved_srcs.to_list()),
            files_to_build,
        ),
        tools = ctx.attr.tools,
        label_dict = label_dict,
        execution_requirements = apple_support.action_required_execution_requirements(),
    )

    message = ctx.attr.message or "Executing apple_genrule"

    extra_args = {}
    if ctx.attr.no_sandbox:
        extra_args["execution_requirements"] = {"no-sandbox": "1"}

    apple_support.run_shell(
        ctx,
        inputs = resolved_srcs.to_list() + resolved_inputs,
        outputs = files_to_build.to_list(),
        env = ctx.configuration.default_shell_env,
        command = argv,
        progress_message = "%s %s" % (message, ctx.label),
        mnemonic = "Genrule",
        input_manifests = runfiles_manifests,
        **extra_args
    )

    return [
        DefaultInfo(
            files = files_to_build,
            data_runfiles = ctx.runfiles(transitive_files = files_to_build),
        ),
    ]

_apple_genrule_inner = rule(
    implementation = _apple_genrule_impl,
    attrs = dicts.add(apple_support.action_required_attrs(), {
        "srcs": attr.label_list(allow_files = True),
        "outs": attr.output_list(mandatory = True),
        "cmd": attr.string(mandatory = True),
        "executable": attr.bool(default = False),
        "message": attr.string(),
        "no_sandbox": attr.bool(),
        "tools": attr.label_list(cfg = "host", allow_files = True),
    }),
    output_to_genfiles = True,
    fragments = ["apple"],
)

def apple_genrule(
        name,
        cmd,
        executable = False,
        outs = [],
        srcs = [],
        message = None,
        tools = [],
        no_sandbox = False,
        **kwargs):
    """Genrule which provides Apple specific environment and make variables.

    This mirrors the native genrule except that it provides a different set of
    make variables. This rule will only run on a Mac.

    Example of use:

    ```
    load("@build_bazel_apple_support//rules:apple_genrule.bzl", "apple_genrule")

    apple_genrule(
        name = "world",
        outs = ["hi"],
        cmd = "touch $@",
    )
    ```

    This rule also does location expansion, much like the native genrule.
    For example, `$(location hi)` may be used to refer to the output in the
    above example.

    The set of make variables that are supported for this rule:

    * `OUTS`: The outs list. If you have only one output file, you can also use
              `$@`.
    * `SRCS`: The srcs list (or more precisely, the pathnames of the files
              corresponding to labels in the srcs list). If you have only one
              source file, you can also use `$<`.
    * `<`: srcs, if it's a single file.
    * `@`: outs, if it's a single file.
    * `@D`: The output directory. If there is only one filename in outs, this
            expands to the directory containing that file. If there are
            multiple filenames, this variable instead expands to the package's
            root directory in the genfiles tree, even if all the generated
            files belong to the same subdirectory.

    The following environment variables are added to the rule action:

    * `DEVELOPER_DIR`: The base developer directory as defined on Apple
                       architectures, most commonly used in invoking Apple
                       tools such as xcrun.
    * `SDKROOT`: The base SDK directory as defined on Apple architectures, most
                 commonly used in invoking Apple tools such as xcrun.

    Args:
      name: The name of the target.
      cmd: The command to run. Subject the variable substitution.
      executable: Boolean. Declare output to be executable. Setting this flag to
        1 means the output is an executable file and can be run using the run
        command. The genrule must produce exactly one output in this case.
      outs: A list of files generated by this rule. If the executable flag is
        set, outs must contain exactly one label.
      srcs: A list of inputs for this rule, such as source files to process.
      message: A progress message to be reported as the rule runs.
      tools: A list of tool dependencies for this rule, they will be available
        when the action is run.
      no_sandbox: If the sandbox should be disabled when the action is run.
      **kwargs: Extra args meant to just be the common rules for all rules
        (tags, etc.).
    """
    if executable:
        if len(outs) != 1:
            fail("apple_genrule, if executable, must have exactly one output")

        intermediate_out = outs[0] + ".nonexecutable"

        # Remove any visibility and make this sub rule private since it is an
        # implementation detail.
        sub_kwargs = dict(kwargs)
        sub_kwargs.pop("visibility", None)
        _apple_genrule_inner(
            name = name + "_nonexecutable",
            outs = [intermediate_out],
            cmd = cmd,
            srcs = srcs,
            message = message,
            tools = tools,
            no_sandbox = no_sandbox,
            executable = executable,
            visibility = ["//visibility:private"],
            **sub_kwargs
        )

        # Remove anything from kwargs that might have a meaning that isn't wanted
        # on the genrule that does the copy. Generally, we are just trying to
        # keep things like testonly, visibility, etc.
        trimmed_kwargs = dict(kwargs)
        trimmed_kwargs.pop("stamp", None)
        native.genrule(
            name = name,
            outs = outs,
            srcs = [intermediate_out],
            cmd = "cp $< $@",
            executable = True,
            **trimmed_kwargs
        )
    else:
        _apple_genrule_inner(
            name = name,
            outs = outs,
            cmd = cmd,
            srcs = srcs,
            message = message,
            tools = tools,
            executable = executable,
            no_sandbox = no_sandbox,
            **kwargs
        )
07070100000018000041ED000003E800000064000000025D4DB8B500000000000000000000000000000000000000000000001F00000000bazel-apple-support-0.7.1/test07070100000019000081A4000003E800000064000000015D4DB8B500000308000000000000000000000000000000000000002500000000bazel-apple-support-0.7.1/test/BUILDload("//rules:apple_genrule.bzl", "apple_genrule")
load(":apple_support_test.bzl", "apple_support_test")
load(":xcode_support_test.bzl", "xcode_support_test")

licenses(["notice"])

# Custom rules that test rule-context APIs. Check their implementations for more details.
apple_support_test(name = "apple_support_test")

xcode_support_test(name = "xcode_support_test")

# Test to ensure the environment variable contract of apple_genrule.
sh_test(
    name = "apple_genrule_test",
    size = "small",
    srcs = ["apple_genrule_test.sh"],
    args = ["$(location simple_genrule.txt)"],
    data = ["simple_genrule.txt"],
)

apple_genrule(
    name = "simple_genrule",
    outs = ["simple_genrule.txt"],
    cmd = "printenv | grep \"^\\(DEVELOPER_DIR\\|SDKROOT\\)\" > $(@)",
)
0707010000001A000081ED000003E800000064000000015D4DB8B50000048C000000000000000000000000000000000000003500000000bazel-apple-support-0.7.1/test/apple_genrule_test.sh#!/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

# Integration test for apple_genrule.

# This test checks that the first argument contains a file that contains
# Xcode environment variables. Since the file was generated using an
# apple_genrule using `printenv`, we enforce that the contract of providing the
# DEVELOPER_DIR and SDKROOT environment variables is maintained.

INPUT_FILE="$1"

if ! grep -Fq DEVELOPER_DIR "$INPUT_FILE"; then
  echo "FAILURE: DEVELOPER_DIR not found."
  exit 1
fi

if ! grep -Fq SDKROOT "$INPUT_FILE"; then
  echo "FAILURE: SDKROOT not found."
  exit 1
fi
0707010000001B000081A4000003E800000064000000015D4DB8B5000018C8000000000000000000000000000000000000003600000000bazel-apple-support-0.7.1/test/apple_support_test.bzl# Copyright 2018 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.
"""Definition of a test rule to test apple_support."""

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

# Contents of the tool that writes the state of the action into a file. The first argument to this
# script is the path to the output file.
_TEST_TOOL_CONTENTS = """#!/bin/bash

set -eu

OUTPUT_FILE="$1"
shift

echo "XCODE_PATH_ENV=$DEVELOPER_DIR" > "$OUTPUT_FILE"
echo "SDKROOT_PATH_ENV=$SDKROOT" >> "$OUTPUT_FILE"

for arg in "$@"; do
    if [[ "$arg" == @* ]]; then
        cat "${arg:1}" >> "$OUTPUT_FILE"
    else
        echo "$arg" >> "$OUTPUT_FILE"
    fi
done
"""

# Template for the test script used to validate that the action outputs contain the expected
# values.
_TEST_SCRIPT_CONTENTS = """
#!/bin/bash

set -eu

FILES=(
    {file_paths}
)

function assert_contains_line() {{
    file="$1"
    contents="$2"

    if [[ -f "$file" ]]; then
      grep -Fxq "$contents" "$file" || \
          (echo "In file: $file"; \
           echo "Expected contents not found: $contents"; \
           echo "File contents:"; \
           cat "$file"; \
           exit 1)
    else
      echo "$file doesn't exist"
      exit 1
    fi
}}

function assert_not_contains() {{
    file="$1"
    contents="$2"

    if [[ -f "$file" ]]; then
      grep -Fq "$contents" "$file" || return 0
    else
      echo "$file doesn't exist"
      exit 1
    fi

    echo "In file: $file"
    echo "Contents found but not expected: $contents"
    echo "File contents:"
    cat "$file"
    exit 1
}}

XCODE_PATH_ENV="$DEVELOPER_DIR"
SDKROOT_PATH_ENV="$SDKROOT"

for file in "${{FILES[@]}}"; do
    assert_contains_line "$file" "XCODE_PATH_ENV=$XCODE_PATH_ENV"
    assert_contains_line "$file" "SDKROOT_PATH_ENV=$SDKROOT_PATH_ENV"
    assert_not_contains "$file" "{xcode_path_placeholder}"
    assert_not_contains "$file" "{sdkroot_path_placeholder}"
done

echo "Test passed"

exit 0
"""

def _apple_support_test_impl(ctx):
    """Implementation of the apple_support_test rule."""

    # Declare all the action outputs
    run_output = ctx.actions.declare_file(
        "{}_run_output".format(ctx.label.name),
    )
    run_output_xcode_path_in_args = ctx.actions.declare_file(
        "{}_run_output_xcode_path_in_args".format(ctx.label.name),
    )
    run_output_xcode_path_in_file = ctx.actions.declare_file(
        "{}_run_output_xcode_path_in_file".format(ctx.label.name),
    )
    run_shell_output = ctx.actions.declare_file(
        "{}_run_shell_output".format(ctx.label.name),
    )

    test_tool = ctx.actions.declare_file("{}_test_tool".format(ctx.label.name))
    ctx.actions.write(test_tool, _TEST_TOOL_CONTENTS, is_executable = True)

    # Create one action per possible combination of inputs to the apple_support.run and
    # apple_support.run_shell helper methods.
    apple_support.run(
        ctx,
        outputs = [run_output],
        executable = test_tool,
        arguments = [run_output.path],
    )

    apple_support.run(
        ctx,
        outputs = [run_output_xcode_path_in_args],
        executable = test_tool,
        arguments = [
            run_output_xcode_path_in_args.path,
            "XCODE_PATH_ARG={}".format(apple_support.path_placeholders.xcode()),
            "FRAMEWORKS_PATH_ARG={}".format(
                apple_support.path_placeholders.platform_frameworks(ctx),
            ),
            "SDKROOT_PATH_ARG={}".format(apple_support.path_placeholders.sdkroot()),
        ],
        xcode_path_resolve_level = apple_support.xcode_path_resolve_level.args,
    )

    action_args = ctx.actions.args()
    action_args.add(
        "XCODE_PATH_ARG={}".format(apple_support.path_placeholders.xcode()),
    )
    action_args.add(
        "FRAMEWORKS_PATH_ARG={}".format(apple_support.path_placeholders.platform_frameworks(ctx)),
    )
    action_args.add(
        "SDKROOT_PATH_ARG={}".format(apple_support.path_placeholders.sdkroot()),
    )
    action_args.set_param_file_format("multiline")
    action_args.use_param_file("@%s", use_always = True)

    apple_support.run(
        ctx,
        outputs = [run_output_xcode_path_in_file],
        executable = test_tool,
        arguments = [
            run_output_xcode_path_in_file.path,
            action_args,
        ],
        xcode_path_resolve_level = apple_support.xcode_path_resolve_level.args_and_files,
    )

    apple_support.run_shell(
        ctx,
        outputs = [run_shell_output],
        tools = [test_tool],
        command = ["/bin/bash", "-c", "{tool} {output}".format(
            output = run_shell_output.path,
            tool = test_tool.path,
        )],
    )

    test_files = [
        run_output,
        run_output_xcode_path_in_args,
        run_output_xcode_path_in_file,
        run_shell_output,
    ]

    test_script = ctx.actions.declare_file("{}_test_script".format(ctx.label.name))
    ctx.actions.write(test_script, _TEST_SCRIPT_CONTENTS.format(
        file_paths = "\n    ".join([x.short_path for x in test_files]),
        sdkroot_path_placeholder = apple_support.path_placeholders.sdkroot(),
        xcode_path_placeholder = apple_support.path_placeholders.xcode(),
    ), is_executable = True)

    return [
        testing.ExecutionInfo(apple_support.action_required_execution_requirements()),
        testing.TestEnvironment(apple_support.action_required_env(ctx)),
        DefaultInfo(
            executable = test_script,
            files = depset([run_output_xcode_path_in_args]),
            runfiles = ctx.runfiles(
                files = test_files,
            ),
        ),
    ]

apple_support_test = rule(
    implementation = _apple_support_test_impl,
    attrs = apple_support.action_required_attrs(),
    fragments = ["apple"],
    test = True,
)
0707010000001C000081A4000003E800000064000000015D4DB8B5000007FF000000000000000000000000000000000000003600000000bazel-apple-support-0.7.1/test/xcode_support_test.bzl# 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.
"""Definition of a test rule to test xcode_support."""

load(
    "@build_bazel_apple_support//lib:apple_support.bzl",
    "apple_support",
)
load(
    "@build_bazel_apple_support//lib:xcode_support.bzl",
    "xcode_support",
)

# Template for the test script used to validate that the action outputs contain the expected
# values.
_TEST_SCRIPT_CONTENTS = """
#!/bin/bash

set -eu

if [[ "{past_version_is_true}" != "True" ]]; then
  echo "FAILURE: 'past_version_is_true' should be True, but it's {past_version_is_true}."
  exit 1
fi

if [[ "{future_version_is_false}" != "False" ]]; then
  echo "FAILURE: 'future_version_is_false' should be False, but it's {future_version_is_false}."
  exit 1
fi
"""

def _xcode_support_test_impl(ctx):
    """Implementation of the xcode_support_test rule."""

    test_script = ctx.actions.declare_file("{}_test_script".format(ctx.label.name))
    xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig]
    ctx.actions.write(test_script, _TEST_SCRIPT_CONTENTS.format(
        past_version_is_true = str(xcode_support.is_xcode_at_least_version(xcode_config, "1.0")),
        future_version_is_false = str(xcode_support.is_xcode_at_least_version(xcode_config, "999")),
    ), is_executable = True)

    return [DefaultInfo(executable = test_script)]

xcode_support_test = rule(
    implementation = _xcode_support_test_impl,
    attrs = apple_support.action_required_attrs(),
    test = True,
)
0707010000001D000041ED000003E800000064000000025D4DB8B500000000000000000000000000000000000000000000002000000000bazel-apple-support-0.7.1/tools0707010000001E000081A4000003E800000064000000015D4DB8B500000277000000000000000000000000000000000000002600000000bazel-apple-support-0.7.1/tools/BUILDlicenses(["notice"])

# Additional files, such as tools, that should be present in a test's runfiles
# during coverage collection.
filegroup(
    name = "coverage_support",
    # Public so other rules can add the dependencies via this group.
    visibility = ["//visibility:public"],
)

sh_binary(
    name = "xcode_path_wrapper",
    srcs = ["xcode_path_wrapper.sh"],
    # Added to rules as a private attribute, so it needs to be public.
    visibility = ["//visibility:public"],
)

# Consumed by bazel tests.
filegroup(
    name = "for_bazel_tests",
    testonly = 1,
    srcs = glob(["**"]),
    visibility = ["//:__pkg__"],
)
0707010000001F000081ED000003E800000064000000015D4DB8B500000F67000000000000000000000000000000000000003600000000bazel-apple-support-0.7.1/tools/xcode_path_wrapper.sh#!/bin/bash
#
# Copyright 2018 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.

# SYNOPSIS
#   Replaces Bazel placeholder values with DEVELOPER_DIR and SDKROOT in the
#   argument list or in params files with their actual values.
#
#   This script requires the XCODE_PATH_RESOLVE_LEVEL environment variable to be
#   set to either the `args` or `args_and_files` values. When the value is
#   `args`, only the given arguments will be processed to replace instances of
#   the Bazel placeholders with DEVELOPER_DIR and SDKROOT. When the value is
#   `args_and_files`, as well as processing the args as before, if an argument
#   begins with `@`, it will be treated as a response file and the contents of
#   such file will be processed to replaced the Bazel placeholder values.
#
# USAGE
#   xcode_path_wrapper.sh <executable> <arguments...>
#
# ARGUMENTS
#   executable: The actual executable to launch.
#   arguments...: Arguments that are processed and then passed to the
#     executable.

set -eu

if [[ -z "${XCODE_PATH_RESOLVE_LEVEL:-}" ]]; then
  cat <<END

ERROR: xcode_path_wrapper.sh requires to be invoked with the \
XCODE_PATH_RESOLVE_LEVEL environment variable set to either 'args' or \
'args_and_files'

END

  exit 1
fi

# SYNOPSIS
#   Rewrites any Bazel placeholder strings in the given argument string,
#   echoing the result.
#
# USAGE
#   rewrite_argument <argument>
function rewrite_argument {
  ARG="$1"
  ARG="${ARG//__BAZEL_XCODE_DEVELOPER_DIR__/$DEVELOPER_DIR}"
  ARG="${ARG//__BAZEL_XCODE_SDKROOT__/$SDKROOT}"
  echo "$ARG"
}

# SYNOPSIS
#   Rewrites any Bazel placeholder strings in the given params file, if any.
#   If there were no substitutions to be made, the original path is echoed back
#   out; otherwise, this function echoes the path to a temporary file
#   containing the rewritten file.
#
# USAGE
#   rewrite_params_file <path>
function rewrite_params_file {
  PARAMSFILE="$1"
  if grep -qe '__BAZEL_XCODE_\(DEVELOPER_DIR\|SDKROOT\)__' "$PARAMSFILE" ; then
    NEWFILE="$(mktemp "${TMPDIR%/}/bazel_xcode_wrapper_params.XXXXXXXXXX")"
    sed \
        -e "s#__BAZEL_XCODE_DEVELOPER_DIR__#$DEVELOPER_DIR#g" \
        -e "s#__BAZEL_XCODE_SDKROOT__#$SDKROOT#g" \
        "$PARAMSFILE" > "$NEWFILE"
    echo "$NEWFILE"
  else
    # There were no placeholders to substitute, so just return the original
    # file.
    echo "$PARAMSFILE"
  fi
}

TOOLNAME="$1"
shift

ARGS=()

if [[ "$XCODE_PATH_RESOLVE_LEVEL" == "args" ]]; then

  for ARG in "$@" ; do
    ARGS+=("$(rewrite_argument "$ARG")")
  done

  exec "$TOOLNAME" "${ARGS[@]}"

elif [[ "$XCODE_PATH_RESOLVE_LEVEL" == "args_and_files" ]]; then

  # If any temporary files are created (like rewritten response files), clean
  # them up when the script exits.
  TEMPFILES=()
  trap '[[ ${#TEMPFILES[@]} -ne 0 ]] && rm "${TEMPFILES[@]}"' EXIT

  for ARG in "$@" ; do
    case "$ARG" in
    @*)
      PARAMSFILE="${ARG:1}"
      NEWFILE=$(rewrite_params_file "$PARAMSFILE")
      if [[ "$PARAMSFILE" != "$NEWFILE" ]] ; then
        TEMPFILES+=("$NEWFILE")
      fi
      ARG="@$NEWFILE"
      ;;
    *)
      ARG=$(rewrite_argument "$ARG")
      ;;
    esac
    ARGS+=("$ARG")
  done

  # We can't use `exec` here because we need to make sure the `trap` runs
  # afterward.
  "$TOOLNAME" "${ARGS[@]}"
else
  cat <<END

ERROR: Unrecognized value for XCODE_PATH_RESOLVE_LEVEL: \
"$XCODE_PATH_RESOLVE_LEVEL"

END

  exit 1
fi
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!168 blocks
openSUSE Build Service is sponsored by