Commit Graph

44 Commits

Author SHA1 Message Date
Hamish Knight
8503ce0604 [xcodegen] Stop at shell operator in parseKnownCommandOnly
We're dealing with a potentially arbitary shell command here, so make
sure we don't continue parsing after a shell operator such as `&&`.
2025-05-07 13:48:45 +01:00
Hamish Knight
71d367a7d9 [xcodegen] Remove duplicate file check from tryAddTarget
I don't recall why I added this, a file can be in multiple targets
and xcodegen handles that case just fine.
2025-05-07 13:48:45 +01:00
Hamish Knight
a404893f26 [xcodegen] Ignore -fdiagnostics-color
Avoid introducing ANSI escape sequences in the Xcode build log.
2025-05-07 13:48:45 +01:00
Hamish Knight
abc099cfa9 [xcodegen] Match common prefix in CommandArgTree
Rather than forming a set intersection, only look for a common prefix
with the parent arguments. This is both quicker and more correct
since arguments can be order-dependent. This does mean we'll end up
with more per-file arguments for "umbrella" targets, but that at
least will no longer prevent us from forming buildable folders for
them.
2025-05-07 13:48:45 +01:00
Hamish Knight
555bc1b54f [xcodegen] Clean up file extension handling
Factor out `FileExtension.matches` and add some tests.
2025-05-06 10:26:00 +01:00
Hamish Knight
2199031b0f [xcodegen] Allow buildable folders in more cases
We can define exceptions to handle targets with sources that either
have unique arguments or are unbuildable. Eventually this ought to
allow us to ditch the "no outside-target source file" rule, but I'm
leaving that be for now since ideally we'd handle automatically
splitting up umbrella Clang targets such as `stdlib` such that e.g
`swiftCore` is its own buildable folder instead of an exception.
2025-05-04 20:46:20 +01:00
Hamish Knight
2a00a65f05 [xcodegen] Add a couple more source file extensions
And handle case differences.
2025-05-04 20:46:20 +01:00
Hamish Knight
b612b5edd9 [xcodegen] Add a couple more known Swift options 2025-05-04 20:46:20 +01:00
Hamish Knight
45b22ecb5d [xcodegen] NFC: Factor out xcodeClassName in serialization logic 2025-05-04 20:46:20 +01:00
Hamish Knight
a3d5f7376b [xcodegen] NFC: Fold Xcodeproj library into SwiftXcodeGen
This was originally a separate library since it was copied directly
from the legacy SwiftPM library. However it's since been changed a
bunch, and ought to be able leverage SwiftXcodeGen utilities such as
RelativePath. Fold it into SwiftXcodeGen.

I considered splitting out the utility code from SwiftXcodeGen into
a new library, but unfortunately that currently regresses performance
(even with max CMO). The module organization doesn't really currently
matter since we don't expose any products.
2025-05-04 20:46:20 +01:00
Hamish Knight
063341b563 [xcodegen] Print the time taken to generate 2025-04-04 13:50:52 +01:00
Alex Martini
633f101e0a Fix double 'the the' in various places 2025-02-14 17:27:51 -08:00
Rintaro Ishizaki
59a1272821 [XcodeGen] Pattern match by KeyPath<T, Bool>
Simpler pattern match by `is` properties. E.g. `\.isNewline`
2025-01-28 22:14:35 -08:00
Rintaro Ishizaki
2d64ef2528 [XcodeGen] Make 'Byte' comform 'ExpressibleByUnicodeScalarLiteral'
Instead of comparing with 'UnicodeScalar', construct 'Byte' from
literals and compare with them. Make it less evil :)
2025-01-28 21:43:15 -08:00
Rintaro Ishizaki
8d2ac00015 [XcodeGen] Handle 'rule' declarations and generate command line args
* Rename 'BuildRule to 'BuildEdige' because it is the official term
* NinjaParser to handle 'include' and 'rule' directives
* NinjaParser to handle parse "rule name" in 'build' correctly
* Make variable table a simple `[String: String]` and keep any bindings
  to make the substitutions possible.
* Generate command line argumets using 'command' variable in the 'rule'
  and use it as the source of truth, istead of using random known
  bindings like 'FLAGS'.
2025-01-28 10:07:17 -08:00
Hamish Knight
ddfe63bdc8 [xcodegen] Avoid tracking inferArgs per target/source
This is unnecessary since we never configure it
per target, just check the global setting.
2025-01-02 15:06:24 +00:00
Hamish Knight
38c1d28197 [xcodegen] Fix hasPrefix for paths
The intention here was to do a component-wise
prefix check, not sure why I did a string prefix
check. Switch to component prefix and rename to
`starts(with:)` to match `FilePath`.
2025-01-02 15:06:24 +00:00
Hamish Knight
b3b538ef62 [xcodegen] Generalize target naming deduplication 2025-01-02 15:06:24 +00:00
Hamish Knight
1667925c9b [xcodegen] Avoid an intermediate String
We don't need to create an intermediate String
when escaping characters in the plist.
2024-12-19 12:35:12 +00:00
Hamish Knight
f6304a0b9a Merge pull request #78194 from hamishknight/xcodegen-runtimes
[xcodegen] Add support for new 'Runtimes' build
2024-12-16 21:36:40 +00:00
Hamish Knight
33e8c2fb83 Merge pull request #78204 from hamishknight/buildable-folder-cleanup
[xcodegen] Clean up buildable folder checking a bit
2024-12-16 02:21:50 +00:00
Hamish Knight
a7b34855ed [xcodegen] Allow swift-plugin-server to be added
Previously we would avoid adding this since it has
an invalid module name, but we can follow the same
logic as the driver and set the module name to
`main`.
2024-12-15 18:31:49 +00:00
Hamish Knight
14aec1bd3d [xcodegen] Clean up buildable folder checking a bit
Factor out the checking and consistently apply the
"all sources files must be covered" rule across
both Clang and Swift targets.
2024-12-15 17:47:54 +00:00
Anthony Latsis
7f50c1ebfe Merge pull request #78108 from AnthonyLatsis/coffea-arabica
xcodegen: Show absolute path in skipping warning
2024-12-15 02:15:56 +00:00
Hamish Knight
5408b1643a [xcodegen] Add support for new 'Runtimes' build
Generate a new 'SwiftRuntimes' xcodeproj if a build directory
for 'Runtimes' is specified with `--runtimes-build-dir`, along with a
combined 'Swift+Runtimes' workspace.
2024-12-14 21:28:59 +00:00
Hamish Knight
486cd42bba [xcodegen] Avoid buildable folders for mixed Swift targets
If a Swift target has sources in its folder that
aren't part of the target, we can't form a buildable
folder.
2024-12-14 19:53:51 +00:00
Hamish Knight
54bf65b2e9 [xcodegen] Include Obj-C(++) sources
Can't believe I missed these for so long.
2024-12-14 19:53:51 +00:00
Hamish Knight
71eeb612f0 [xcodegen] Avoid emitting Swift Obj-C header
This isn't needed currently and works around
an assertion failure.
2024-12-14 19:53:51 +00:00
Hamish Knight
780a546646 [xcodegen] Restrict dependency computation a bit
Only consider `.o` and `.swiftmodule` inputs for now. Previously
we could end up with unnecessary dependencies for e.g plugin
dylibs, but we don't build and patch those in currently.
2024-12-14 19:53:51 +00:00
Hamish Knight
dfe1f9cc53 [xcodegen] Infer project root from xcodegen location
Instead of inferring from the build directory location,
infer from the location of swift-xcodegen itself since
we know that's in the swift repo.
2024-12-14 14:30:55 +00:00
Anthony Latsis
6a76c92803 xcodegen: Show absolute path in skipping warning
This would have saved me the time I spent figuring out why something
went wrong with the project generation. In my case, the absolute path
shown by this warning would have been overtly invalid because the tool
was failing to infer the source root directory.
2024-12-11 11:37:22 +00:00
Hamish Knight
7f313a6621 Merge pull request #77791 from hamishknight/enable-buildable-folders 2024-12-02 09:19:47 +00:00
Hamish Knight
dade4217db [xcodegen] Show caveat for --stdlib-swift too
While here, also add a caveat for the fact that
`--stdlib-swift` is disabled by default since it's
surprised a couple of folks now.
2024-11-29 16:07:13 +00:00
Hamish Knight
e04efdd2bb [xcodegen] Enable buildable folders by default
I've been living on this for a bit without issue,
enable by default.
2024-11-29 16:05:12 +00:00
Hamish Knight
b0d91b016c Fix typo
Co-authored-by: Jamie <2119834+jamieQ@users.noreply.github.com>
2024-11-22 16:00:09 +00:00
Hamish Knight
ac4d52d5c3 [xcodegen] Update help text for --stdlib-swift
Clarify why a development snapshot is needed
for stdlib Swift targets.
2024-11-22 15:50:36 +00:00
Hamish Knight
9a53db6b9a [xcodegen] Add --buildable-folders
This enables the use of folder references for
compatible targets, allowing new source files to
be added without needing to regenerate the project.
Currently disabled by default; I'd like to get
some living-on before enabling.
2024-11-09 20:16:45 +00:00
Hamish Knight
a596880b65 [xcodegen] Add --prefer-folder-refs flag 2024-11-09 20:01:37 +00:00
Hamish Knight
84ba92dbe8 [xcodegen] Add serialization support for buildable folders 2024-11-09 20:01:37 +00:00
Hamish Knight
29cfe90869 [xcodegen] Remove isImportant
This only existed to avoid adding anything under
a folder reference. Now that we add those
references first, this is no longer needed.
2024-11-09 20:01:37 +00:00
Hamish Knight
5ff60d014b [xcodegen] Add file references to project first
This requires ensuring we check that we're not
ever attempting to add a group under an existing
folder reference. This will be required for
buildable folders.
2024-11-09 20:01:37 +00:00
Hamish Knight
94b744ce4f [xcodegen] Fix typo 2024-11-06 12:20:44 +00:00
Hamish Knight
43be5456b1 [xcodegen] Allow output to be missing in compile_commands.json
This may not always be present for CI builds.
2024-11-06 12:20:44 +00:00
Hamish Knight
03d8ea5248 Introduce swift-xcodegen
This is a tool specifically designed to generate
Xcode projects for the Swift repo (as well as a
couple of adjacent repos such as LLVM and Clang).
It aims to provide a much more user-friendly experience
than the CMake Xcode generation (`build-script --xcode`).
2024-11-05 22:42:10 +00:00