-
Notifications
You must be signed in to change notification settings - Fork 1.1k
XcodeBuild: extend build parameters #18668
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
base: develop2
Are you sure you want to change the base?
XcodeBuild: extend build parameters #18668
Conversation
# Conflicts: # conan/tools/apple/xcodebuild.py
7f6da61
to
d842224
Compare
@jcar87 could you have a look? |
@@ -77,7 +77,7 @@ def build(self): | |||
xcode.build("app.xcodeproj") | |||
|
|||
def package(self): | |||
copy(self, "build/{}/app".format(self.settings.build_type), self.source_folder, | |||
copy(self, "{}/app".format(self.settings.build_type), self.build_folder, |
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.
These changes to existing tests typically evidence a possible breaking behavior.
Is this stylistic, or necessary for the test to pass? If stylistic, better keep the previous test.
if not stylistic, it needs to be clarified as a bug, not as an improvement.
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.
it is necessary due to my changes, I've also mentioned it in the PR description:
And one more point here: as soon as I have redirected SYMROOT+OBJROOT, tests started failing because they rely on hardcoded default value, see 2da70f5
Not sure why it should be a bug, if it's not really broken in upstream.
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.
Well, any user that has recipes with such a package()
method will have their recipes broken.
In general we don't change existing tests code or behavior unless something is declared as a bug fix. Existing tests needs to keep passing as they are, that is what guarantees as much as possible that we are not breaking users code.
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.
Would it be possible to activate new behavior via a new conf
then?
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 is too tied to the current recipe, activating a conf
that enables this will still break existing recipes. And if recipes need to be ported one by one, then the way to introduce it is via an options new opt-in argument to XcodeBuild
constructor or the the XcodeBuild.build()
method
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, I agree with your points. Added new param to constructor.
Thanks a lot for your contribution. Overall, it looks good, but we need to add at least some basic tests and do a bit more investigation. I'm moving it to the 2.21 milestone so we can tackle it as soon as we start working on that. |
Changelog: Fix: [XcodeBuild] place all intermediate build files in the cache build folder
Changelog: Feature: [XcodeBuild] allow passing build configuration and arbitrary command line params
Docs: conan-io/docs#4171
develop
branch, documenting this one.Build configuration
Xcode projects come with 2 build configurations by default: Debug and Release. In my recipe I pass the following property as
configuration
param:Maybe this logic should even be moved to Conan?
Arbitrary xcodebuild params
For example, in my recipe I pass the following xcodebuild variables:
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
- plays an important role in building Swift code as it enables "library evolution" which allows consuming prebuilt binary/module by a later Swift compiler versionMACH_O_TYPE=mh_dylib
(andEXECUTABLE_EXTENSION=dylib
) to make a static library/framework target produce a shared library. The same variables with respective values could be used the other way around - to produce static library from a shared library/framework.RUN_CLANG_STATIC_ANALYZER=NO
to disable static analyzer launch (when a project enables it) that is useless for Conan build where I simply want to obtain a binaryA couple of other commonly used xcodebuild params would be
-workspace
to use .xcworkspace instead of .xcodeproj and-destination
to select target device.Redirecting build artifacts to the cache build folder via
SYMROOT
+OBJROOT
variablesActivated via constructor parameter, off by default for backward compatibility.
Will copy my arguments in favor of this change from #18496
it solves 2 things:
by default, SYMROOT is set to
build
directory inside the source directory and OBJROOT has the same value as SYMROOT. But projects can override any of those settings in the Xcode project file and you'll never know where the build files are. Since Conan has a dedicated build directory, it's better to keep build artifacts in there. Having build files in the source directory looks even worse to me whenno_copy_source
isTrue
.it makes it easy to access build artifacts, here's an example from my recipe:
and now you simply copy .framework / .dylib / .a from the
artifactsDir
I can't really agree with this.
~/Library/Developer/Xcode/DerivedData/<dir>
. They will be used only when project is configured in such a way, but AFAIK it's rarely done nowadays. This is configured in File - Project settings... - Advanced - set to Legacy. This behavior was changed to Legacy like 10 years ago or even more.xcodebuild -showBuildSettings
to see the actual value of all settings and grepSYMROOT
. Do you really expect every recipe to include such a piece of code (or have a Conan helper function)? To me it looks like an unnecessary complication when you can set a reliable path at build time. And also polluting source directory by default which we have already discussed. And one more point here: as soon as I have redirected SYMROOT+OBJROOT, tests started failing because they rely on hardcoded default value, see 2da70f5