Back to Bazel

Apple Common

docs/versions/7.2.0/rules/lib/toplevel/apple_common.mdx

9.1.023.6 KB
Original Source
<html devsite> <head> <meta name="project_path" value="/_project.yaml"> <meta name="book_path" value="/versions/7.2.0/_book.yaml"> </head> <body> <h1 class="page-title" id="modules.apple_common">apple_common</h1>

{% dynamic setvar source_file "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java" %} {% dynamic setvar version "7.2.0" %} {% dynamic setvar original_path "/rules/lib/toplevel/apple_common" %} {% include "_buttons.html" %}

<!-- {% raw %} -->

Functions for Starlark to access internals of the apple rule implementations.

<h2>Members</h2> <ul> <li> <a href="#apple_host_system_env">apple_host_system_env</a> </li> <li> <a href="#apple_toolchain">apple_toolchain</a> </li> <li> <a href="#AppleDebugOutputs">AppleDebugOutputs</a> </li> <li> <a href="#AppleDynamicFramework">AppleDynamicFramework</a> </li> <li> <a href="#AppleExecutableBinary">AppleExecutableBinary</a> </li> <li> <a href="#dotted_version">dotted_version</a> </li> <li> <a href="#link_multi_arch_binary">link_multi_arch_binary</a> </li> <li> <a href="#link_multi_arch_static_library">link_multi_arch_static_library</a> </li> <li> <a href="#new_dynamic_framework_provider">new_dynamic_framework_provider</a> </li> <li> <a href="#new_executable_binary_provider">new_executable_binary_provider</a> </li> <li> <a href="#new_objc_provider">new_objc_provider</a> </li> <li> <a href="#Objc">Objc</a> </li> <li> <a href="#platform">platform</a> </li> <li> <a href="#platform_type">platform_type</a> </li> <li> <a href="#target_apple_env">target_apple_env</a> </li> <li> <a href="#XcodeProperties">XcodeProperties</a> </li> <li> <a href="#XcodeVersionConfig">XcodeVersionConfig</a> </li> </ul>
  <h2 id="apple_host_system_env">apple_host_system_env</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../core/dict.html">dict</a> apple_common.apple_host_system_env(xcode_config)</pre></p>

Returns a <a href='../core/dict.html'>dict</a> of environment variables that should be set for actions that need to run build tools on an Apple host system, such as the  version of Xcode that should be used. The keys are variable names and the values  are their corresponding values.

      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="apple_host_system_env.xcode_config">
          <code>xcode_config</code>
        </td>
        <td>
                                 required

                      A provider containing information about the xcode configuration.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="apple_toolchain">apple_toolchain</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/apple_toolchain.html">apple_toolchain</a> apple_common.apple_toolchain()</pre></p>

Utilities for resolving items from the apple toolchain.


    <h2 id="AppleDebugOutputs">AppleDebugOutputs</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/Provider.html">Provider</a> apple_common.AppleDebugOutputs</pre></p>

The constructor/key for the <code>AppleDebugOutputs</code> provider.<p>If a target propagates the <code>AppleDebugOutputs</code> provider, use this as the key with which to retrieve it. Example:
<pre class='language-python'> dep = ctx.attr.deps[0] p = dep[apple_common.AppleDebugOutputs] </pre>
    <h2 id="AppleDynamicFramework">AppleDynamicFramework</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/Provider.html">Provider</a> apple_common.AppleDynamicFramework</pre></p>

The constructor/key for the <code>AppleDynamicFramework</code> provider.<p>If a target propagates the <code>AppleDynamicFramework</code> provider, use this as the key with which to retrieve it. Example:
<pre class='language-python'> dep = ctx.attr.deps[0] p = dep[apple_common.AppleDynamicFramework] </pre>
    <h2 id="AppleExecutableBinary">AppleExecutableBinary</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/Provider.html">Provider</a> apple_common.AppleExecutableBinary</pre></p>

The constructor/key for the <code>AppleExecutableBinary</code> provider.<p>If a target propagates the <code>AppleExecutableBinary</code> provider, use this as the key with which to retrieve it. Example:
<pre class='language-python'> dep = ctx.attr.deps[0] p = dep[apple_common.AppleExecutableBinary] </pre>
    <h2 id="dotted_version">dotted_version</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/DottedVersion.html">DottedVersion</a> apple_common.dotted_version(version)</pre></p>

Creates a new <a href="../builtins/DottedVersion.html">DottedVersion</a> instance.

      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="dotted_version.version">
          <code>version</code>
        </td>
        <td>
                                 required

                      The string representation of the DottedVersion.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="link_multi_arch_binary">link_multi_arch_binary</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/struct.html">struct</a> apple_common.link_multi_arch_binary(ctx, avoid_deps=None, extra_linkopts=[], extra_link_inputs=[], extra_requested_features=[], extra_disabled_features=[], stamp=-1)</pre></p>

Links a (potentially multi-architecture) binary targeting Apple platforms. This method comprises a bulk of the logic of the Starlark <code>apple_binary</code> rule in the rules_apple domain and exists to aid in the migration of its linking logic to Starlark in rules_apple.
<p>This API is <b>highly experimental</b> and subject to change at any time. Do not depend on the stability of this function at this time.
      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="link_multi_arch_binary.ctx">
          <code>ctx</code>
        </td>
        <td>
                                 required

                      The Starlark rule context.
        </td>
      </tr>
              <tr>
        <td id="link_multi_arch_binary.avoid_deps">
          <code>avoid_deps</code>
        </td>
        <td>
                      <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../builtins/Target.html">Target</a>s; or <code>None</code>;
                                 default is <code>None</code>

                      A list of <code>Target</code>s that are in the dependency graph of the binary but whose libraries should not be linked into the binary. This is the case for dependencies that will be found at runtime in another image, such as the bundle loader or any dynamic libraries/frameworks that will be loaded by this binary.
        </td>
      </tr>
              <tr>
        <td id="link_multi_arch_binary.extra_linkopts">
          <code>extra_linkopts</code>
        </td>
        <td>
                      <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s;
                                 default is <code>[]</code>

                      Extra linkopts to be passed to the linker action.
        </td>
      </tr>
              <tr>
        <td id="link_multi_arch_binary.extra_link_inputs">
          <code>extra_link_inputs</code>
        </td>
        <td>
                      <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../builtins/File.html">File</a>s;
                                 default is <code>[]</code>

                      Extra files to pass to the linker action.
        </td>
      </tr>
              <tr>
        <td id="link_multi_arch_binary.extra_requested_features">
          <code>extra_requested_features</code>
        </td>
        <td>
                      <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s;
                                 default is <code>[]</code>

                      Extra requested features to be passed to the linker action.
        </td>
      </tr>
              <tr>
        <td id="link_multi_arch_binary.extra_disabled_features">
          <code>extra_disabled_features</code>
        </td>
        <td>
                      <a class="anchor" href="../core/list.html">sequence</a> of <a class="anchor" href="../core/string.html">string</a>s;
                                 default is <code>[]</code>

                      Extra disabled features to be passed to the linker action.
        </td>
      </tr>
              <tr>
        <td id="link_multi_arch_binary.stamp">
          <code>stamp</code>
        </td>
        <td>
                                 default is <code>-1</code>

                      Whether to include build information in the linked binary. If 1, build information is always included. If 0, build information is always excluded. If -1 (the default), then the behavior is determined by the --[no]stamp flag. This should be set to 0 when generating the executable output for test rules.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="link_multi_arch_static_library">link_multi_arch_static_library</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/struct.html">struct</a> apple_common.link_multi_arch_static_library(ctx)</pre></p>

Links a (potentially multi-architecture) static library targeting Apple platforms. This method comprises a part of the Starlark <code>apple_static_library</code> rule logic, in the rules_apple domain and exists to aid in the migration of its linking logic to Starlark in rules_apple.
<p>This API is <b>highly experimental</b> and subject to change at any time. Do not depend on the stability of this function at this time.
      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="link_multi_arch_static_library.ctx">
          <code>ctx</code>
        </td>
        <td>
                                 required

                      The Starlark rule context.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="new_dynamic_framework_provider">new_dynamic_framework_provider</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../providers/AppleDynamicFramework.html">AppleDynamicFramework</a> apple_common.new_dynamic_framework_provider(binary=None, cc_info=None, objc=None, framework_dirs=None, framework_files=None)</pre></p>

Creates a new AppleDynamicFramework provider instance.

      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="new_dynamic_framework_provider.binary">
          <code>binary</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/File.html">File</a>; or <code>None</code>;
                                 default is <code>None</code>

                      The dylib binary artifact of the dynamic framework.
        </td>
      </tr>
              <tr>
        <td id="new_dynamic_framework_provider.cc_info">
          <code>cc_info</code>
        </td>
        <td>
                                 default is <code>None</code>

                      A CcInfo which contains information about the transitive dependencies linked into the binary.
        </td>
      </tr>
              <tr>
        <td id="new_dynamic_framework_provider.objc">
          <code>objc</code>
        </td>
        <td>
                                 default is <code>None</code>

                      An ObjcProvider which contains information about the transitive dependencies linked into the binary.
        </td>
      </tr>
              <tr>
        <td id="new_dynamic_framework_provider.framework_dirs">
          <code>framework_dirs</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/depset.html">depset</a> of <a class="anchor" href="../core/string.html">string</a>s; or <code>None</code>;
                                 default is <code>None</code>

                      The framework path names used as link inputs in order to link against the dynamic framework.
        </td>
      </tr>
              <tr>
        <td id="new_dynamic_framework_provider.framework_files">
          <code>framework_files</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/depset.html">depset</a> of <a class="anchor" href="../builtins/File.html">File</a>s; or <code>None</code>;
                                 default is <code>None</code>

                      The full set of artifacts that should be included as inputs to link against the dynamic framework
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="new_executable_binary_provider">new_executable_binary_provider</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../providers/AppleExecutableBinary.html">AppleExecutableBinary</a> apple_common.new_executable_binary_provider(binary=None, cc_info=None, objc=None)</pre></p>

Creates a new AppleExecutableBinaryInfo provider instance.

      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="new_executable_binary_provider.binary">
          <code>binary</code>
        </td>
        <td>
                      <a class="anchor" href="../builtins/File.html">File</a>; or <code>None</code>;
                                 default is <code>None</code>

                      The binary artifact of the executable.
        </td>
      </tr>
              <tr>
        <td id="new_executable_binary_provider.cc_info">
          <code>cc_info</code>
        </td>
        <td>
                                 default is <code>None</code>

                      A CcInfo which contains information about the transitive dependencies linked into the binary.
        </td>
      </tr>
              <tr>
        <td id="new_executable_binary_provider.objc">
          <code>objc</code>
        </td>
        <td>
                                 default is <code>None</code>

                      An ObjcProvider which contains information about the transitive dependencies linked into the binary.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="new_objc_provider">new_objc_provider</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../providers/ObjcProvider.html">ObjcProvider</a> apple_common.new_objc_provider(**kwargs)</pre></p>

Creates a new ObjcProvider instance.

      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="new_objc_provider.kwargs">
          <code>kwargs</code>
        </td>
        <td>
                                 default is <code>{}</code>

                      Dictionary of arguments.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="Objc">Objc</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/Provider.html">Provider</a> apple_common.Objc</pre></p>

The constructor/key for the <code>Objc</code> provider.<p>If a target propagates the <code>Objc</code> provider, use this as the key with which to retrieve it. Example:
<pre class='language-python'> dep = ctx.attr.deps[0] p = dep[apple_common.Objc] </pre>
    <h2 id="platform">platform</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/struct.html">struct</a> apple_common.platform</pre></p>

An enum-like struct that contains the following fields corresponding to Apple platforms:
<ul><li><code>ios_device</code></li><li><code>ios_simulator</code></li><li><code>macos</code></li><li><code>tvos_device</code></li><li><code>tvos_simulator</code></li><li><code>visionos_device</code></li><li><code>visionos_simulator</code></li><li><code>watchos_device</code></li><li><code>watchos_simulator</code></li></ul><p>These values can be passed to methods that expect a platform, like <a href='../providers/XcodeVersionConfig.html#sdk_version_for_platform'>XcodeVersionConfig.sdk_version_for_platform</a>.
    <h2 id="platform_type">platform_type</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/struct.html">struct</a> apple_common.platform_type</pre></p>

An enum-like struct that contains the following fields corresponding to Apple platform types:
<ul><li><code>ios</code></li><li><code>macos</code></li><li><code>tvos</code></li><li><code>visionos</code></li><li><code>watchos</code></li></ul><p>These values can be passed to methods that expect a platform type, like the 'apple' configuration fragment's <a href='../fragments/apple.html#multi_arch_platform'>multi_arch_platform</a> method.<p>Example:<p><pre class='language-python'> ctx.fragments.apple.multi_arch_platform(apple_common.platform_type.ios) </pre>
    <h2 id="target_apple_env">target_apple_env</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../core/dict.html">dict</a> apple_common.target_apple_env(xcode_config, platform)</pre></p>

Returns a <code>dict</code> of environment variables that should be set for actions that build targets of the given Apple platform type. For example, this dictionary contains variables that denote the platform name and SDK version with which to build. The keys are variable names and the values are their corresponding values.

      <!-- hide-from-toc is a class used by DevSite for the public Bazel site
  (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
  <h3 class="hide-from-toc">Parameters</h3>
  <table class="table table-bordered table-condensed table-params">
    <colgroup>
      <col class="col-param">
      <col class="param-description">
    </colgroup>
    <thead>
      <tr>
        <th>Parameter</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
              <tr>
        <td id="target_apple_env.xcode_config">
          <code>xcode_config</code>
        </td>
        <td>
                                 required

                      A provider containing information about the xcode configuration.
        </td>
      </tr>
              <tr>
        <td id="target_apple_env.platform">
          <code>platform</code>
        </td>
        <td>
                                 required

                      The apple platform.
        </td>
      </tr>
            </tbody>
  </table>

    <h2 id="XcodeProperties">XcodeProperties</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/Provider.html">Provider</a> apple_common.XcodeProperties</pre></p>

The constructor/key for the <code>XcodeVersionProperties</code> provider.<p>If a target propagates the <code>XcodeVersionProperties</code> provider, use this as the key with which to retrieve it. Example:
<pre class='language-python'> dep = ctx.attr.deps[0] p = dep[apple_common.XcodeVersionProperties] </pre>
    <h2 id="XcodeVersionConfig">XcodeVersionConfig</h2>
    <p><pre class="rule-signature"><a class="anchor" href="../builtins/Provider.html">Provider</a> apple_common.XcodeVersionConfig</pre></p>

The constructor/key for the <code>XcodeVersionConfig</code> provider.
</body> </html> <!-- {% endraw %} -->