aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/build_defs/apple/shared.bzl
blob: 70c6ae623975cd092390178b1a32d687f2bb9966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2016 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.

"""Common definitions for Apple rules."""

APPLE_SIMULATOR_ARCHITECTURES = ["i386", "x86_64"]
"""Architectures that are used by the simulator (iOS, tvOS and watchOS)."""

IOS_DEVICE_ARCHITECTURES = ["armv6", "armv7", "arm64"]
"""Architectures that are used by iOS devices."""

TVOS_DEVICE_ARCHITECTURES  = ["arm64"]
"""Architectures that are used by tvOS devices."""

WATCHOS_DEVICE_ARCHITECTURES = ["armv7k"]
"""Architectures that are used by watchOS devices."""

APPLE_DEFAULT_ARCHITECTURES = ["x86_64", "arm64", "armv7k"]
"""Architectures commonly used for building/testing on simulators/devices."""

APPLE_FRAGMENTS = ["apple"]
"""Configuration fragments containing Apple specific information."""

DARWIN_EXECUTION_REQUIREMENTS = {"requires-darwin": ""}
"""Standard execution requirements to force building on Mac.

See :func:`apple_action`."""

def apple_action(ctx, **kw):
  """Creates an action that only runs on MacOS/Darwin.

  Call it similar to how you would call ctx.action:
    apple_action(ctx, outputs=[...], inputs=[...],...)
  """
  execution_requirements = kw.get('execution_requirements', {})
  execution_requirements += DARWIN_EXECUTION_REQUIREMENTS
  kw['execution_requirements'] = execution_requirements

  ctx.action(**kw)