Skip to content

Commit 547ab31

Browse files
author
Karim Alweheshy
committed
lint
1 parent 6aa41d8 commit 547ab31

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

test/internal/custom_toolchain/BUILD

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# buildifier: disable=bzl-visibility
12
load("//xcodeproj/internal:custom_toolchain.bzl", "custom_toolchain")
23

34
# Example swiftc override for testing
@@ -10,17 +11,17 @@ filegroup(
1011
# Test target for custom_toolchain
1112
custom_toolchain(
1213
name = "test_toolchain",
13-
toolchain_name = "TestCustomToolchain",
1414
overrides = {
1515
# Key is a label target, value is the tool name
1616
":test_swiftc": "swiftc",
1717
},
18+
toolchain_name = "TestCustomToolchain",
1819
)
1920

2021
# Add a simple test rule that depends on the toolchain
2122
sh_test(
2223
name = "custom_toolchain_test",
2324
srcs = ["custom_toolchain_test.sh"],
24-
data = [":test_toolchain"],
2525
args = ["$(location :test_toolchain)"],
26-
)
26+
data = [":test_toolchain"],
27+
)

xcodeproj/defs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ load(
44
"//xcodeproj/internal:automatic_target_info.bzl",
55
_XcodeProjAutomaticTargetProcessingInfo = "XcodeProjAutomaticTargetProcessingInfo",
66
)
7+
load("//xcodeproj/internal:custom_toolchain.bzl", _custom_toolchain = "custom_toolchain")
78
load(
89
"//xcodeproj/internal:project_options.bzl",
910
_project_options = "project_options",
@@ -24,7 +25,6 @@ load(
2425
)
2526
load("//xcodeproj/internal:xcodeprojinfo.bzl", _XcodeProjInfo = "XcodeProjInfo")
2627
load("//xcodeproj/internal/xcschemes:xcschemes.bzl", _xcschemes = "xcschemes")
27-
load("//xcodeproj/internal:custom_toolchain.bzl", _custom_toolchain = "custom_toolchain")
2828

2929
# Re-exporting providers
3030
XcodeProjAutomaticTargetProcessingInfo = _XcodeProjAutomaticTargetProcessingInfo

xcodeproj/internal/custom_toolchain.bzl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Implementation of the `custom_toolchain` rule."""
12

23
def _get_xcode_product_version(*, xcode_config):
34
raw_version = str(xcode_config.xcode_version())
@@ -14,15 +15,14 @@ def _get_xcode_product_version(*, xcode_config):
1415

1516
return version_components[3]
1617

17-
1818
def _custom_toolchain_impl(ctx):
1919
xcode_version = _get_xcode_product_version(
2020
xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
2121
)
2222

2323
toolchain_name_base = ctx.attr.toolchain_name
2424
toolchain_dir = ctx.actions.declare_directory(
25-
toolchain_name_base + ".{}".format(xcode_version) + ".xctoolchain"
25+
toolchain_name_base + ".{}".format(xcode_version) + ".xctoolchain",
2626
)
2727

2828
resolved_overrides = {}
@@ -35,7 +35,9 @@ def _custom_toolchain_impl(ctx):
3535

3636
if len(files) > 1:
3737
fail("ERROR: Override for '{}' produces multiple files ({}). Each override must have exactly one file.".format(
38-
tool_name, len(files)))
38+
tool_name,
39+
len(files),
40+
))
3941

4042
override_file = files[0]
4143
override_files.append(override_file)
@@ -50,9 +52,9 @@ def _custom_toolchain_impl(ctx):
5052
output = script_file,
5153
is_executable = True,
5254
substitutions = {
53-
"%toolchain_name_base%": toolchain_name_base,
54-
"%toolchain_dir%": toolchain_dir.path,
5555
"%overrides_list%": overrides_list,
56+
"%toolchain_dir%": toolchain_dir.path,
57+
"%toolchain_name_base%": toolchain_name_base,
5658
"%xcode_version%": xcode_version,
5759
},
5860
)
@@ -64,9 +66,9 @@ def _custom_toolchain_impl(ctx):
6466
mnemonic = "CreateCustomToolchain",
6567
command = script_file.path,
6668
execution_requirements = {
67-
"no-sandbox": "1",
68-
"no-cache": "1",
6969
"local": "1",
70+
"no-cache": "1",
71+
"no-sandbox": "1",
7072
"requires-darwin": "1",
7173
},
7274
use_default_shell_env = True,
@@ -83,10 +85,12 @@ def _custom_toolchain_impl(ctx):
8385
custom_toolchain = rule(
8486
implementation = _custom_toolchain_impl,
8587
attrs = {
86-
"toolchain_name": attr.string(mandatory = True),
8788
"overrides": attr.label_keyed_string_dict(
88-
allow_files = True, mandatory = False, default = {}
89+
allow_files = True,
90+
mandatory = False,
91+
default = {},
8992
),
93+
"toolchain_name": attr.string(mandatory = True),
9094
"_symlink_template": attr.label(
9195
allow_single_file = True,
9296
default = Label("//xcodeproj/internal/templates:custom_toolchain_symlink.sh"),
@@ -99,4 +103,3 @@ custom_toolchain = rule(
99103
),
100104
},
101105
)
102-

0 commit comments

Comments
 (0)