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: MSBuildDeps generator: CAExcludePath #8682
Changes from 1 commit
4aea5f6
66ced37
d3513b8
b3987be
42af4cc
8eb6746
350fc44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import fnmatch | ||
import os | ||
import textwrap | ||
from xml.dom import minidom | ||
|
@@ -25,6 +26,7 @@ class MSBuildDeps(object): | |
<Conan{name}BinaryDirectories>{bin_dirs}</Conan{name}BinaryDirectories> | ||
<Conan{name}Libraries>{libs}</Conan{name}Libraries> | ||
<Conan{name}SystemDeps>{system_libs}</Conan{name}SystemDeps> | ||
<Conan{name}CAExcludeDirectories>{ca_exclude_dirs}</Conan{name}CAExcludeDirectories> | ||
</PropertyGroup> | ||
</Project> | ||
""") | ||
|
@@ -42,6 +44,7 @@ class MSBuildDeps(object): | |
<PropertyGroup> | ||
<LocalDebuggerEnvironment>PATH=%PATH%;$(Conan{name}BinaryDirectories)$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment> | ||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | ||
<CAExcludePath>$(Conan{name}CAExcludeDirectories);$(CAExcludePath)</CAExcludePath> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put the conditional here, to define it or not (by default, this line shouldn't appear) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do I need condition here? |
||
</PropertyGroup> | ||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
|
@@ -74,6 +77,7 @@ def __init__(self, conanfile): | |
'x86_64': 'x64'}.get(str(conanfile.settings.arch)) | ||
# TODO: this is ugly, improve this | ||
self.output_path = os.getcwd() | ||
self.exclude_code_analysis = None | ||
|
||
def generate(self): | ||
# TODO: Apply config from command line, something like | ||
|
@@ -84,6 +88,14 @@ def generate(self): | |
# config_filename | ||
# TODO: This is duplicated in write_generators() function, would need to be moved | ||
# to generators and called from there | ||
exclude_code_analysis = self._conanfile.conf["tools.microsoft.msbuilddeps"].exclude_code_analysis | ||
if exclude_code_analysis: | ||
if isinstance(exclude_code_analysis, str): | ||
self.exclude_code_analysis = exclude_code_analysis.split(";") | ||
if self.exclude_code_analysis in [["True"], True]: | ||
self.exclude_code_analysis = ["*"] | ||
elif self.exclude_code_analysis in [["False"], False]: | ||
self.exclude_code_analysis = None | ||
SSE4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if self.configuration is None: | ||
raise ConanException("MSBuildDeps.configuration is None, it should have a value") | ||
if self.platform is None: | ||
|
@@ -152,6 +164,13 @@ def add_valid_ext(libname): | |
ext = os.path.splitext(libname)[1] | ||
return '%s;' % libname if ext in VALID_LIB_EXTENSIONS else '%s.lib;' % libname | ||
|
||
exclude_code_analisys = False | ||
if self.exclude_code_analysis: | ||
for pattern in self.exclude_code_analysis: | ||
if fnmatch.fnmatch(name, pattern): | ||
exclude_code_analisys = True | ||
break | ||
|
||
SSE4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fields = { | ||
'name': name, | ||
'root_folder': cpp_info.rootpath, | ||
|
@@ -164,7 +183,8 @@ def add_valid_ext(libname): | |
'definitions': "".join("%s;" % d for d in cpp_info.defines), | ||
'compiler_flags': " ".join(cpp_info.cxxflags + cpp_info.cflags), | ||
'linker_flags': " ".join(cpp_info.sharedlinkflags), | ||
'exe_flags': " ".join(cpp_info.exelinkflags) | ||
'exe_flags': " ".join(cpp_info.exelinkflags), | ||
'ca_exclude_dirs': '$(Conan%sIncludeDirectories)' % name if exclude_code_analisys else '' | ||
SSE4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
formatted_template = self._vars_conf_props.format(**fields) | ||
return formatted_template | ||
|
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 not new "data" definition, shouldn't be defined here, but just in the group below, as an
if ca_exclude_path
.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.
not sure I follow - it uses the same structure as another definitions...
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 section contains the pure translation of
cpp_info
fields, nothing more.The custom logic of this generator is not defined in this section, but somewhere else.
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.
got it, then I agree it shouldn't be there