Skip to content
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 conflict of filenames with generator #8073

Merged
merged 1 commit into from Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions conans/client/toolchain/msbuild.py
Expand Up @@ -46,6 +46,8 @@ def get_version(settings):

class MSBuildToolchain(object):

filename = "conantoolchain.props"

def __init__(self, conanfile):
self._conanfile = conanfile
self.preprocessor_definitions = {}
Expand All @@ -63,7 +65,7 @@ def _name_condition(settings):

def write_toolchain_files(self):
name, condition = self._name_condition(self._conanfile.settings)
config_filename = "conan_toolchain{}.props".format(name)
config_filename = "conantoolchain{}.props".format(name)
self._write_config_toolchain(config_filename)
self._write_main_toolchain(config_filename, condition)

Expand Down Expand Up @@ -108,7 +110,7 @@ def format_macro(k, value):
save(config_filepath, config_props)

def _write_main_toolchain(self, config_filename, condition):
main_toolchain_path = os.path.abspath("conan_toolchain.props")
main_toolchain_path = os.path.abspath(self.filename)
if os.path.isfile(main_toolchain_path):
content = load(main_toolchain_path)
else:
Expand All @@ -125,7 +127,7 @@ def _write_main_toolchain(self, config_filename, condition):
try:
import_group = dom.getElementsByTagName('ImportGroup')[0]
except Exception:
raise ConanException("Broken conan_toolchain.props. Remove the file and try again")
raise ConanException("Broken {}. Remove the file and try again".format(self.filename))
children = import_group.getElementsByTagName("Import")
for node in children:
if (config_filename == node.getAttribute("Project") and
Expand All @@ -139,5 +141,5 @@ def _write_main_toolchain(self, config_filename, condition):

conan_toolchain = dom.toprettyxml()
conan_toolchain = "\n".join(line for line in conan_toolchain.splitlines() if line.strip())
self._conanfile.output.info("MSBuildToolchain writing %s" % "conan_toolchain.props")
self._conanfile.output.info("MSBuildToolchain writing {}".format(self.filename))
save(main_toolchain_path, conan_toolchain)
6 changes: 3 additions & 3 deletions conans/test/integration/toolchains/test_msbuild.py
Expand Up @@ -104,7 +104,7 @@
If it goes after, the Toolset definition is ignored -->
<ImportGroup Label="PropertySheets">
<Import Project="..\conan\conan_Hello.props" />
<Import Project="..\conan\conan_toolchain.props" />
<Import Project="..\conan\conantoolchain.props" />
</ImportGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -289,7 +289,7 @@ def test_toolchain_win(self):

# Run the configure corresponding to this test case
client.run("install . %s -if=conan" % (settings, ))
self.assertIn("conanfile.py: MSBuildToolchain created conan_toolchain_release_win32.props",
self.assertIn("conanfile.py: MSBuildToolchain created conantoolchain_release_win32.props",
client.out)
client.run("build . -if=conan")

Expand Down Expand Up @@ -333,7 +333,7 @@ def test_toolchain_win_debug(self):

# Run the configure corresponding to this test case
client.run("install . %s -if=conan" % (settings, ))
self.assertIn("conanfile.py: MSBuildToolchain created conan_toolchain_debug_x64.props",
self.assertIn("conanfile.py: MSBuildToolchain created conantoolchain_debug_x64.props",
client.out)
client.run("build . -if=conan")
self.assertIn("Visual Studio 2017", client.out)
Expand Down