Skip to content

Commit

Permalink
use a for loop, check more linker options
Browse files Browse the repository at this point in the history
  • Loading branch information
matyalatte authored and dcbaker committed May 1, 2024
1 parent e3db7af commit f1f2481
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions mesonbuild/backend/vs2010backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,6 @@ def get_non_primary_lang_intellisense_fields(vslite_ctx: dict,
defs_paths_opts_per_lang_and_buildtype[src_lang][buildtype] = Vs2010Backend._extract_nmake_fields(args_list)
return defs_paths_opts_per_lang_and_buildtype

# Returns if a target generates a manifest or not.
def get_gen_manifest(target):
if isinstance(target, build.BuildTarget):
upper_args = [arg.upper() for arg in target.link_args]
manifest_args = [arg for arg in upper_args if arg == '/MANIFEST' or arg.startswith('/MANIFEST:')]
return len(manifest_args) == 0 or manifest_args[-1] != '/MANIFEST:NO'
return True

class Vs2010Backend(backends.Backend):

name = 'vs2010'
Expand Down Expand Up @@ -706,7 +698,7 @@ def gen_run_target_vcxproj(self, target: build.RunTarget, ofname: str, guid: str
(root, type_config) = self.create_basic_project(target.name,
temp_dir=target.get_id(),
guid=guid,
gen_manifest=get_gen_manifest(target))
gen_manifest=self.get_gen_manifest(target))
depend_files = self.get_target_depend_files(target)

if not target.command:
Expand Down Expand Up @@ -742,7 +734,7 @@ def gen_custom_target_vcxproj(self, target: build.CustomTarget, ofname: str, gui
temp_dir=target.get_id(),
guid=guid,
target_platform=platform,
gen_manifest=get_gen_manifest(target))
gen_manifest=self.get_gen_manifest(target))
# We need to always use absolute paths because our invocation is always
# from the target dir, not the build root.
target.absolute_paths = True
Expand Down Expand Up @@ -783,7 +775,7 @@ def gen_compile_target_vcxproj(self, target: build.CompileTarget, ofname: str, g
temp_dir=target.get_id(),
guid=guid,
target_platform=platform,
gen_manifest=get_gen_manifest(target))
gen_manifest=self.get_gen_manifest(target))
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
target.generated = [self.compile_target_to_generator(target)]
target.sources = []
Expand Down Expand Up @@ -1616,7 +1608,7 @@ def gen_vcxproj(self, target: build.BuildTarget, ofname: str, guid: str, vslite_
conftype=conftype,
target_ext=tfilename[1],
target_platform=platform,
gen_manifest=get_gen_manifest(target))
gen_manifest=self.get_gen_manifest(target))

generated_files, custom_target_output_files, generated_files_include_dirs = self.generate_custom_generator_commands(
target, root)
Expand Down Expand Up @@ -2095,3 +2087,25 @@ def add_regen_dependency(self, root: ET.Element) -> None:

def generate_lang_standard_info(self, file_args: T.Dict[str, CompilerArgs], clconf: ET.Element) -> None:
pass

# Returns if a target generates a manifest or not.
def get_gen_manifest(self, target):
if not isinstance(target, build.BuildTarget):
return True

compiler = self._get_cl_compiler(target)
link_args = compiler.compiler_args()
if not isinstance(target, build.StaticLibrary):
link_args += self.build.get_project_link_args(compiler, target.subproject, target.for_machine)
link_args += self.build.get_global_link_args(compiler, target.for_machine)
link_args += self.environment.coredata.get_external_link_args(
target.for_machine, compiler.get_language())
link_args += target.link_args

for arg in reversed(link_args):
arg = arg.upper()
if arg == '/MANIFEST:NO':
return False
if arg == '/MANIFEST' or arg.startswith('/MANIFEST:'):
break
return True

0 comments on commit f1f2481

Please sign in to comment.