Skip to content

Commit 05756a4

Browse files
Merge pull request #62224 from AnthonyLatsis/fix-xcode-build
build: Fix Xcode project generation
2 parents d03ee03 + 3abc478 commit 05756a4

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

utils/python_format.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def parse_args():
112112
parser.add_argument(
113113
"--check",
114114
action="store_true",
115-
help="Don't format the file, just return the status.",
115+
help="Don't write the files back, just return the status.",
116116
)
117117

118118
parser.add_argument(
@@ -122,6 +122,19 @@ def parse_args():
122122
help="Emit messages to stderr about files that were not changed.",
123123
)
124124

125+
parser.add_argument(
126+
"--diff",
127+
action="store_true",
128+
help="Don't write the files back, just output a diff for each file on stdout.",
129+
)
130+
131+
parser.add_argument(
132+
"-S",
133+
"--skip-string-normalization",
134+
action="store_true",
135+
help="Don't normalize string quotes or prefixes.",
136+
)
137+
125138
return parser.parse_args()
126139

127140

@@ -137,13 +150,17 @@ def main():
137150
"-m",
138151
"black",
139152
"--target-version",
140-
"py27",
153+
"py38",
141154
]
142155

143156
if args.check:
144157
command.append("--check")
145158
if args.verbose:
146159
command.append("--verbose")
160+
if args.diff:
161+
command.append("--diff")
162+
if args.skip_string_normalization:
163+
command.append("--skip-string-normalization")
147164

148165
requested_paths = [path.resolve() for path in args.paths]
149166

utils/swift_build_support/swift_build_support/products/cmake_product.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ def build_with_cmake(self, build_targets, build_type, build_args,
7171
env=env)
7272

7373
if not self.args.skip_build or self.product_name() == "llvm":
74+
cmake_opts = [self.build_dir, "--config", build_type]
75+
7476
if self.args.cmake_generator == "Xcode":
77+
# CMake automatically adds "--target ALL_BUILD" if we don't
78+
# pass this.
79+
cmake_opts += ["--target", "ZERO_CHECK"]
80+
7581
# Xcode generator uses "ALL_BUILD" instead of "all".
7682
# Also, xcodebuild uses -target instead of bare names.
7783
build_targets = build_targets[:]
@@ -82,12 +88,11 @@ def build_with_cmake(self, build_targets, build_type, build_args,
8288

8389
# Xcode can't restart itself if it turns out we need to reconfigure.
8490
# Do an advance build to handle that.
85-
shell.call(["env"] + cmake_build
86-
+ [self.build_dir, "--config", build_type])
91+
shell.call(["env"] + cmake_build + cmake_opts)
8792

88-
shell.call(["env"] + cmake_build
89-
+ [self.build_dir, "--config", build_type, "--"]
90-
+ build_args + build_targets)
93+
shell.call(
94+
["env"] + cmake_build + cmake_opts + ["--"] + build_args + build_targets
95+
)
9196

9297
def test_with_cmake(self, executable_target, results_targets,
9398
build_type, build_args, test_env=None):
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RUN: %empty-directory(%t)
2+
# RUN: mkdir -p %t
3+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --xcode --release --swift-darwin-supported-archs="$(uname -m)" --dry-run --cmake %cmake 2>&1 | %FileCheck %s
4+
5+
# REQUIRES: standalone_build
6+
# REQUIRES: OS=macosx
7+
8+
# Make sure we pass '--target ZERO_CHECK' (otherwise CMake automatically adds
9+
# '--target ALL_BUILD' and we end up building everything) and build the bare
10+
# minimum required to configure Swift.
11+
#
12+
# CHECK: --- Building llvm ---
13+
# CHECK: env {{.+}}/cmake --build {{.+}}/Xcode-ReleaseAssert/llvm-macosx-{{.+}} --config Release --target ZERO_CHECK{{$}}
14+
# CHECK-NEXT: env {{.+}}/cmake --build {{.+}}/Xcode-ReleaseAssert/llvm-macosx-{{.+}} --config Release --target ZERO_CHECK -- -target llvm-tblgen -target clang-resource-headers -target intrinsics_gen -target clang-tablegen-targets -target FileCheck -target not -target llvm-nm -target llvm-size{{$}}

0 commit comments

Comments
 (0)