New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid clean
on running xcodebuild
if New Build System is used.
#555
Conversation
This is promising, thank you! Although there's one slight problem: However, @keith recently discovered that even though So we could solve this by running But we still need a full build afterwards, because otherwise we get some types that resolve as internal func checkNewBuildSystem(xcodeBuildArguments: [String],
moduleName: String? = nil,
inPath path: String) -> [String]? {
- // Check `PROJECT_TEMP_ROOT`
+ // `-dry-run` generates the manifest file when using the new build system.
+ _ = XcodeBuild.run(arguments: xcodeBuildArguments + ["-dry-run"], inPath: path)
+
+ // Extract `PROJECT_TEMP_ROOT`
fputs("Checking xcodebuild -showBuildSettings\n", stderr)
guard let output = XcodeBuild.run(arguments: xcodeBuildArguments + ["-showBuildSettings"], inPath: path),
let match = regexForProjectTempRoot.firstMatch(in: output, range: NSRange(output.startIndex..<output.endIndex, in: output)),
@@ -254,7 +257,8 @@ internal func checkNewBuildSystem(xcodeBuildArguments: [String],
}.first.map { filter(arguments: $0) }
if result != nil {
- fputs("Assuming New Build System is used.\n", stderr)
+ fputs("Assuming New Build System is used.\nRunning xcodebuild\n", stderr)
+ _ = XcodeBuild.run(arguments: xcodeBuildArguments, inPath: path)
} |
If we still need to build after |
As below without reverting 4f130be: diff --git a/Source/SourceKittenFramework/Xcode.swift b/Source/SourceKittenFramework/Xcode.swift
index 78b22ac..b74090d 100644
--- a/Source/SourceKittenFramework/Xcode.swift
+++ b/Source/SourceKittenFramework/Xcode.swift
@@ -215,7 +215,11 @@ ${PROJECT_TEMP_ROOT}
internal func checkNewBuildSystem(xcodeBuildArguments: [String],
moduleName: String? = nil,
inPath path: String) -> [String]? {
- // Check `PROJECT_TEMP_ROOT`
+ // generates the manifest file when using the new build system.
+ fputs("Running xcodebuild\n", stderr)
+ _ = XcodeBuild.run(arguments: xcodeBuildArguments, inPath: path)
+
+ // Extract `PROJECT_TEMP_ROOT`
fputs("Checking xcodebuild -showBuildSettings\n", stderr)
guard let output = XcodeBuild.run(arguments: xcodeBuildArguments + ["-showBuildSettings"], inPath: path),
let match = regexForProjectTempRoot.firstMatch(in: output, range: NSRange(output.startIndex..<output.endIndex, in: output)), |
Yes, you're totally right. 👍 |
Can you get |
The minimum xcodebuild log is as follows: # Xcode 10
$ xcodebuild -workspace Carthage/Checkouts/Commandant/Commandant.xcworkspace/ -scheme Commandant build -verbose
note: Using new build system
note: Planning build
note: Constructing build description
** BUILD SUCCEEDED ** [0.731 sec]
# Xcode 9
$ DEVELOPER_DIR=/Applications/Xcode.app xcodebuild -workspace Carthage/Checkouts/Commandant/Commandant.xcworkspace/ -scheme Commandant build -verbose
=== BUILD TARGET Result-Mac OF PROJECT Result WITH CONFIGURATION Debug ===
Check dependencies
=== BUILD TARGET Commandant OF PROJECT Commandant WITH CONFIGURATION Debug ===
Check dependencies
** BUILD SUCCEEDED **
So using |
clean
on running xcodebuild
if New Build System is used.clean
on running xcodebuild
if New Build System is used.
4f130be
to
a07d671
Compare
Since Xcode’s New Build System uses `llbuild`, compiler arguments for `Module` can be retrieved from manifest of `llbuild` instead of parsing `xcodebuild`’s output. Until this changes, the `clean` action was used for `xcodebuild` to ensure compiler arguments, but it is not necessary when using the New Build System.
… on Xcode 10+ We do not need to avoid using same `derivedDataPath`, since `clean` action is not used in `Module.init(xcodeBuildArguments:name:inPath:)` with assuming that New Build System is used on Xcode 10.
a07d671
to
8464314
Compare
clean
on running xcodebuild
if New Build System is used.clean
on running xcodebuild
if New Build System is used.
Rewrote and rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think projects that don’t use the new build system will now be built twice 😬. It would still be worthwhile if most projects use the new build system.
What do you think?
That will be the worst case. If the target module is not updated by the first build, second build with |
For CI jobs that run jazzy for example (which relies on this functionality), the first build will build from scratch, then the second clean build will also build from scratch, doubling the time spent building the project. |
In that case, it should return after the first build. |
Sorry, I should mention that I also added |
Ah I missed that! Let me take another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Thanks! 🙏 |
Since Xcode’s New Build System uses
llbuild
, compiler arguments forModule
can be retrieved from manifest ofllbuild
instead of parsingxcodebuild
’s output. Until this changes, theclean
action was used forxcodebuild
to ensure compiler arguments, but it is not necessary when using the New Build System.