-
Notifications
You must be signed in to change notification settings - Fork 822
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
Allow specifying run script and copy files phase ordering #402
Conversation
@@ -194,7 +195,8 @@ class SourceGenerator { | |||
guard targetType == .staticLibrary else { return nil } | |||
return .copyFiles(TargetSource.BuildPhase.CopyFilesSettings( | |||
destination: .productsDirectory, | |||
subpath: "include/$(PRODUCT_NAME)" | |||
subpath: "include/$(PRODUCT_NAME)", | |||
phaseOrder: .preCompile |
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.
This being .preCompile
is a prime example of why these changes are needed.
Even with these changes the new build system is broken. That doesn't make these changes not needed though. Eventually Xcode 10 will be fixed, but being fixed will still warrant these changes. |
Question: What do you expect for remaining 1% of them? Also I think buildPhase:
copyFiles:
destination: productsDirectory
subpath: include
compileSources: // <- This simply makes the processing order clearer.
runScript:
path: my-script.sh |
When you want to post-process something that has been copied into the products folder (like adjusting application icons for debug versus releases). |
With how we specify sources and run scripts, that wouldn't be possible right now. |
Looks like the tests need to be updated |
With Xcode 10 dependent targets won't start compiling until compilation and all run scripts are done for the target. This means that your run script should run before Copy Files (and Copy Resources, etc.) phases unless it needs to run later, to allow dependent targets to compile faster.
Will be reused similar to `generateBuildScript()` for copy files phases at different orders.
Copy Files phases don't stop dependent targets from starting to compile. If some of the files being copied are needed for the dependent target to compile then they need to happen before the Compile Sources phase. This change allows specifying that.
With Xcode 10 run scripts will prevent dependent targets from starting to compile. The Carthage copy-frameworks script should be right after compilation to speed up compilation.
Also cleanup the documentation and add more tests for the newly added `postCompileScripts`.
61f2040
to
296b938
Compare
@yonaskolb Rebased and tests fixed. |
@yonaskolb Care to give this another look? |
@@ -279,8 +283,9 @@ extension Target: NamedJSONDictionaryConvertible { | |||
directlyEmbedCarthageDependencies = jsonDictionary.json(atKeyPath: "directlyEmbedCarthageDependencies") | |||
requiresObjCLinking = jsonDictionary.json(atKeyPath: "requiresObjCLinking") | |||
|
|||
prebuildScripts = jsonDictionary.json(atKeyPath: "prebuildScripts") ?? [] | |||
postbuildScripts = jsonDictionary.json(atKeyPath: "postbuildScripts") ?? [] | |||
preBuildScripts = jsonDictionary.json(atKeyPath: "preBuildScripts") ?? jsonDictionary.json(atKeyPath: "prebuildScripts") ?? [] |
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.
Makes me think the lint
command in #214 could also be used to highlight deprecations
Docs/ProjectSpec.md
Outdated
@@ -275,6 +276,9 @@ A source can be provided via a string (the path) or an object of the form: | |||
- `sharedSupport` | |||
- `plugins` | |||
- [ ] **subpath**: **String** - The path inside of the destination to copy the files. | |||
- [ ] **phaseOrder**: **String** - When the Copy Files phase should execute in relation to other phases. This can be one of the following values: |
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.
Does this need to be exposed to users? Would it ever be required? I'd rather keep the options we expose low. XcodeGen is supposed to remove all those sorts of decisions.
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.
I felt it should be exposed since a user could choose to have a specific set of resources copied before compilation. We currently have those covered, AFAIK, but others might have more exotic needs.
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.
I'd rather leave this out for now, and only add it if it someone has a need for it 👍
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.
@yonaskolb Coming back from WWDC I've learned that the way I'm doing module map copying currently isn't the best. While hacking through a local solution before figuring out how XcodeGen should be updated I ran into wanting to specify the phase order of the copy phase. Essentially I need to copy files before compilation. Wondering how you feel about me exposing this option now?
Hi @brentleyjones. Would you be able to get this branch up to date to resolve the conflicts? |
@yonaskolb Yeah, I'll try to get to it today 😄. |
88aa9e6
to
ef0c87e
Compare
@yonaskolb Assuming tests pass, I believe this is all merged up. I also removed the ability to specify copy files phase ordering. |
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.
Fantastic, thanks @brentleyjones! 😄
Fixes #400.
postbuildScripts
99% of the time).