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
removing toolset from msbuild generator and toolchain #7825
removing toolset from msbuild generator and toolchain #7825
Conversation
client.out) | ||
vs_path = vs_installation_path("15") | ||
vcvars_path = os.path.join(vs_path, "VC/Auxiliary/Build/vcvarsall.bat") | ||
|
||
# FIXME: This is cheating, pass the toolset on the command line, nothing that devs would do |
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 am not sure I understand what is cheating here? I guess it's legal to pass toolset on command line, and developers can do that, correct?
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.
99% of developers will double click on the solution to open it, not build it in the command line with msbuild
command, don't you think? It is not that it is not doable, but that it will fit in the developers flow. Building from the command line for Visual definitely doesn't fit a vast majority of cases IMHO.
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.
@solvingj WDYT?
I understand, it might not be common for majority of users, but still possible and legal.
still I believe most of CI scripts invoke msbuild or devenv, so it should be supported case IMO.
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 will be managed by the toolchain, so still very possible in CI. The only thing is that it will not be possible to build different toolset configurations in the same run, with the same build. You can do different conan install
with different toolsets and still build with them, just not build sequentially for different toolsets.
What we are really trying to avoid as much as possible here is to have something that is done only in CI, but developers cannot easily replicate. The problem is that if we add the toolset variability to the generated files, we need the build helper to pass the toolset definition in the command line. If the build helper passes that definition in the command line, then developers are no longer able to reproduce the build from their IDE, which is a major goal for this integration approach. We cannot have a build from the build()
method that a developer cannot achieve as a consumer, with their native tools.
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.
so, if toolchain from msbuild is in general a .props
file, then:
- conan flow runs
msbuild project.sln -p conan.props
in inject toolchain via command line - developer locally opens project.sln via IDE and...
2.1. developer loadsconan.props
via property manager into the solution?
2.2. developer opens solution withconan.props
somehow already injected by conan?
2.3. developer needs to use command line to inject toolchain file (conan.props)
what is the best workflow here? IMO 2.1
for 2.2, I guess this is something we're going away (e.g injecting conanbuildinfo.cmake was proven to be a bad practice for many reasons).
for 2.3, if for CMake we think that command line is okay, why do we think it's not okay for msbuild then? don't we expect feature parity here? even for CMake, modern IDEs (Visual Studio, CLion, VSCode, etc.) allow to directly open CMakeLists.txt
, so how would you include you toolchain in such case?
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, 2.1: the flow is to add the properties file to the visual project. This can be done from the IDE or editing the .vcxproj. I think this flow has several advantages:
- It is completely explicit, no magic.
- The addition of the .props file needs to be done only once, as the .vcxproj is typically commited to source control
- It can be done without command line (besides Conan commands). Note that typically
msbuild
is NOT in the path, so developer needs to open a matching VS-prompt. More complicated than double click on the .sln
From our experience Microsoft and Visual Studio developers are extremely reluctant to use command line, and this is already complicated for Conan adoption. Companies sysdmins/devops/build-responsibles are going to large extends to avoid their developers to touch the terminal.
We should optimize for user stories that are as close to the current dev experience as possible. I see a common user story in Msft/VS devs is:
- Get the source code, with git clone or similar
- Double click the .sln to open the project
Here, we aim to only introduce an extra step, the conan install
of dependencies. Some will use MSBuild tasks or plugins, others will add a .bat file in the root to double click (that contains the conan install).
In the cmake user story, it is more like:
- Get the source code, git clone
- cmake .. something something # to create the project
- OpenIDE, editor, build command line...
So the user is already doing the cmake
command, it is very necessary, a majority of cmake users will call cmake themselves to generate the project. In this case, we should optimize so users can keep doing the cmake
command as close as their current one as possible.
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.
okay, in that case, if I open solution and inject conan.props
(via PropertyManager or manually), it will update RuntimeLibrary
accordingly, right?
same way, I could edit property file via PropertyManager (or via text editor) and update the RuntimeLibrary
to the value I need.
everything without command line, only via IDE.
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, as the conan_toolchain.props
is injected, doing a conan install ... -s compiler.runtime=MT
or similar will update the toolchain and it will be taken into account.
same way, I could edit property file via PropertyManager (or via text editor) and update the RuntimeLibrary to the value I need.
It depends on the evaluation order. It seems that including the toolchain in the right position, it will have priority and define the final value of the toolset.
@SSE4 sorry to be a bit late to the discussion, but I will add what I can to what @memsharded said (there are some good points). There are a few factors that distinguish these scenarios. I'll cut those factors down to what I consider the cases we're trying hardest to address with this discussion. Of note, we use the word "most" frequently and loosely because there are exceptions to every statement.
As @memsharded said, most enterprise IDE users assume that all necessary "Configurations" are predefined with all the valid project-specific variables included. And, most CI workflows with Regarding import strategy, in terms of real-world implementation of Conan, here is something else to think about. Most large-scale implementations will need to support a period of time where the projects can be built successfully both without Conan, and with Conan. Many will want time to verify that the new binaries from Conan builds are identical/equivalent to ones built without it, and it takes a long time to work through all possible builds with Conan. It doesn't happen over night. In these cases, most implementers will choose some strategy that involves making Conan props imports conditional. It might be based on environment variable, command-line property, or whether or not the file exists. The "else" condition will usually be to fall back to whatever existing dependency strategy they are using prior to Conan. All of that is fairly easy to do in The point is that, in these specific cases I outlined above, it will be rare for users to manually import a Conan props file on the fly (as described in 2.1) for production development. There will more likely be a team implementing Conan which will gradually add conditional imports to all projects throughout the codebase, and in many cases automate the running of Conan in the background without the users intervention (similar to |
To clarify, as I see 2.1, the import is not on the fly. It is added by the first developer adding Conan support to the .vcxproj. Other users will just open the project from the IDE, and rely on the conditional, the automation to do the conan install or whatever. But it is not a "dynamically" added import. The import is hardcoded in the .vcxproj |
so, in summary, we want to use 2.1, but it may look like: here it's not important how props was imported by user - either via Property Manager, or via direct editing of .vcxproj file, or via some script or extension, in either way we will have the same result here - conan props import line is hard-coded into the .vcxproj file. in any case, user is able to edit RuntimeLibrary property (and others) of conan props file (yes, of that specific file, or globablly, doesn't matter much). yes, it's more clicks than changing Debug->Release, but I still believe it's incorrect to call it "cheating" - it's uncommon, but still legit and documented feature available from the IDE. I would call something "cheating" only if we use something undocumented, e.g. hacking directly into the internals of Visual Studio. do we still have any problems with it? probably, the very first developer has to inject props file and then push these changes to the source control (if they ever use source control system). what will happen to other developers who update .vcxproj file from the source control? there are few possible scenarios here: a. conan.props is not checked in into the repository, only import line I am not sure which is the right scenario here (maybe all of them), @solvingj if you could clarify would be nice |
Sure, users can do a bunch of stuff, but it is impossible that we can manage any possible change that the user can do in the project. I am not fully sure that what I am communicating succesfully what I am proposing here in this PR. Let me try to clarify: Lets say that we have a specific toolchain file for every different conan setting: # assume same Release Visual Studio 15 x64
$ conan install . -s compiler.toolset=v140 -s compiler.runtime=MT -s compiler.cppstd=14
# generates conan_toolchain_Release_x64_v140_MT_14.props
$ conan install . -s compiler.toolset=v141 -s compiler.runtime=MD -s compiler.cppstd=11
# generates conan_toolchain_Release_x64_v141_MD_11.props
.... Those files will have inside something like: <ClCompile>
<RuntimeLibrary>MultithreadedDLL</RuntimeLibrary>
<LanguageStandard>cppstd14</LanguageStandard>
<PlatformToolset>v141</PlatformToolset>
</ClCompile> And these files will be included from the .vcxproj with something like: <ImportGroup Label="PropertySheets"
Condition="'$(Configuration)|$(Platform)'=='Release|x64' and $(PlatformToolset)=='v140'
and $(LanguageStandard) == "cppstd14"....>
<Import Project="conan_toolchain_Release_x64_v140_MT_14.props" />
</ImportGroup> This would be completely useless, as it requires as a condition the value that it will be setting in the toolchain file. So my proposal here is:
Please let me know if this makes sense. |
I've written two long responses (this is my third) to this PR, and then stopped short of posting them because I had significant realizations at the end each time. I started over each time. Hopefully these are my final thoughts. Note: We probably should have started the discussion in the original issue instead of here because it had the original justification, which I only realized just now: #7824 But, it doesn't make sense to jump over there now since all the comments are here for historical purposes, so I'll continue here. Edit: Also, after writing this, I thought it was important to come back here and add a preface. The perspectives below come from visual studio projects and solutions in private enterprise codebases. While there are open-source projects with visual studio build systems defined, they are not subject to the scalability and manageability challenges as enterprise projects, which are the focus of this conversation. They're not being ignored, but it's too difficult to talk about both cases in one discussion. I think the important question that got lost was: "What is the benefit of adding the MSBuild Toolchain in your Conan Recipe?" Without Toolchain So, we should pause here and say that a stripped down
With Toolchain So, people in the position stated above can choose to use the toolchain in their recipes, with a significant, but easy to understand tradeoff:
If you compare the two, you find this important conclusion:
Differences
Summary As a final note, I would never expect or want the |
Hi @solvingj I agree with the analysis and the conclusions. Those are 2 different modes of operation, that define different purposes and goals, and which approach is decided by users, as a tradeoff.
This is one of the great reasons I wanted to do this. I think there is a misunderstanding in the scope of the other variables in the current implementation. The <!-- conan_toolchain_release_x64_v140.props -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>
{};%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<RuntimeLibrary>{}</RuntimeLibrary>
<LanguageStandard>{}</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
</Project> This PR is the first step, but not the complete thing yet. Next step (I am working on it on another branch, maybe I should have put everything together) is to have the toolchain.props file defining: <!-- conan_toolchain_release_x64.props -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>
{};%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<RuntimeLibrary>{}</RuntimeLibrary>
<LanguageStandard>{}</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<PropertyGroup Label="Configuration">
<PlatformToolset>{}</PlatformToolset>
</PropertyGroup>
</Project> I think the difference in these 2 files is what summarizes my proposal |
Ok, that makes sense and sounds good to me now. The last props file seems like the one I want, with just one thing missing. I notice it has the placeholder for preprocessor definitions, but I don't see a placeholder for arbitrary |
@solvingj yes, thank you very much, now it's much more clear |
Changelog: Fix: Remove toolset variability from the
msbuild
generator andMSBuildToolchain
.Docs: Omit
From: #7824