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
Feature/msbuild toolchain generator #7754
Feature/msbuild toolchain generator #7754
Conversation
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.
Interesting. Some questions more related to the msbuild format than the feature itself.
Do you see other toolchains (like cmake) taking advantage of the generators declared there?
Could be an issue that the generator files are written twice if declared in the recipe?
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{6F392A05-B151-490C-9505-B2A49720C4D9}.Debug|x64.ActiveCfg = Debug|x64 |
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.
Why these removed lines?
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.
They were unused. Seems a legacy from a refactor or something. Dead code.
options = {"shared": [True, False]} | ||
default_options = {"shared": False} | ||
def toolchain(self): | ||
tc = MSBuildToolchain(self) | ||
if self.options["hello"].shared and self.settings.build_type == "Release": | ||
tc.configuration = "ReleaseShared" | ||
tc.generator.configuration = "ReleaseShared" |
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.
A Question: the generator configuration should follow always the configuration of the project or not necessarily? Should be the same by default or not really?
In other words, if the generator configuration is different, will the dependencies will be found for the configuration specified in the project?
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.
Yes, after conversation with users, it is very typical that the configuration of the project refers to the way it is linking dependencies. It could be both, of course, but users can do:
- ReleaseStatic: I am building my app executable, linking it statically with its dependencies
- ReleaseShared: My app executable links with shared libs.
While other users or other projects could define:
- ReleaseDLL: I am building a shared library myself
- ReleaseStatic: I am building a static library myself
So it seems that the system should be flexible to let the users define the logic they want differently to generators and toolchains.
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.
Mhhh, so answering my questions...
- The
tc.configuration
andtc.generator.configuration
might be different. - We don't want to default the
tc.generator.configuration
with the value adjusted in thetc.configuration
.
Did you mean the matrix is the following?:
- ReleaseStatic (
tc.configuration
): I am building my app executable, linking it statically with its dependencies - ReleaseShared (
tc.generator.configuration
) : My app executable links with shared libs.
While other users or other projects could define:
- ReleaseDLL (
tc.configuration
): I am building a shared library myself - ReleaseStatic (
tc.generator.configuration
): I am building a static library myself
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 think in the second case, it would be both tc.configuration
, assuming that dependencies in both cases do not change at all.
In the first case, it seems that tc.generator.configuration
=> "tc.configuration", in most cases both should be used, as it sounds difficult to consume that specific dependencies configuration unless your current project doesn't define that configuration. Though it might be possible to use the same toolchain file for different configurations, so maybe not in all cases.
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'm so sorry but I don't get it hahahah. Could you do a Matrix of possible values of tc.configuration
and tc.generator.configuration
and the meaning?
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.
The name of the config is irrelevant, it is just something a user will define. So lets define it from the other side:
-
toolchain()
definestc.configuration
only. This means that generators will keep generating the same standard files, likezlib_release.cmake
orzlib_release_x86_v140.props
. The dependencies will be exactly the same, using standard Conanbuild_type
settings.
This would be the case if the current project have several custom configurations in cmake or Visual for building different variants, like building a shared library or a static library. The dependencies are the same (static, shared, or whatever), they do not change, but the current project build from the IDE can be different. -
toolchain()
definesgenerator.configuration
only. This means that dependencies change based on some inputs, for example if the user wants to be creating an executable linked with static deps or with shared deps. The current toolchain files could be identical, and do not depend on the configuration, like building an executable, maybe the toolchain doesn't change at all: same generator, same architecture, etc. -
toolchain()
defines bothgenerator.configuration
andtc.configuration
: Both the dependencies and the current toolchain will change based on the current configuration. Like if the previous case, but building that executable against shared or static libraries would require some extra flags to be defined by the toolchain, e.g. passing-PIE
or some LinkTimeOptimization flag when building against static or shared libraries.
Please let me know if this makes sense.
Yes, I think this is a pattern we might want to define. There is the question how to handle some generators passed in the command line, but at least the build-system integration generators, that are always necessary, could always be defined in the recipe.
Yes, could be, maybe we need to differentiate "consumer" generators that can be passed in cli to other build-systems generator that need to be defined in the recipe. To think about and discuss. |
Had good discussion about this today. Here are some takeaways for future reference: To summarize the "new" logic being implemented: The primary innovation of this work is to enable users to explicitly map conan settings to One-File-Per-Configuration To do this, that single Producing MSBuild Conditions The current implementation takes a minimalistic approach to try to handle the common case, and do so with the least burden on the user. Thus, it exposes only the Generated Filenames The current implementation implicitly generates a unique filename that is based on the same variables that produce the condition string. This guarantees uniqueness and the user does not have to think about it. Future Ideas
Implementation Ideas for Future Ideas For both toolchains and generators, it seems like we'll need to at least make one major addition:
For generators, we had one novel idea so far:
For toolchains, it seems like there are only three variables:
But actually, we're planning to support arbitrary msbuild variables and preprocessor definitions, so users will need and want lots of flexibility in what is generated and under what
This doesn't look like something that would be reasonable or acceptable, but it's trying to push the boundaries on what would be possible for future thought. |
Changelog: Feature: Allow
MSBuildToolchain
custom configurations ingenerate()
method.Docs: conan-io/docs#1957
Note: the docs of this slipped into 1.32 release, the Docs PR is already merged.