diff options
Diffstat (limited to 'mesonbuild/backend/vs2010backend.py')
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index feae79e..46eab11 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -427,8 +427,7 @@ class Vs2010Backend(backends.Backend): ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd) ET.SubElement(customstep, 'Message').text = 'Running custom command.' ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') - tree = ET.ElementTree(root) - tree.write(ofname, encoding='utf-8', xml_declaration=True) + self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname) def gen_custom_target_vcxproj(self, target, ofname, guid): root = self.create_basic_crap(target) @@ -438,6 +437,7 @@ class Vs2010Backend(backends.Backend): # from the target dir, not the build root. target.absolute_paths = True (srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True) + depend_files = self.get_custom_target_depend_files(target, True) # Always use a wrapper because MSBuild eats random characters when # there are many arguments. tdir_abs = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) @@ -449,11 +449,10 @@ class Vs2010Backend(backends.Backend): '--internal', 'exe', exe_data] ET.SubElement(customstep, 'Command').text = ' '.join(self.quote_arguments(wrapper_cmd)) ET.SubElement(customstep, 'Outputs').text = ';'.join(ofilenames) - ET.SubElement(customstep, 'Inputs').text = ';'.join(srcs) + ET.SubElement(customstep, 'Inputs').text = ';'.join([exe_data] + srcs + depend_files) ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') self.generate_custom_generator_commands(target, root) - tree = ET.ElementTree(root) - tree.write(ofname, encoding='utf-8', xml_declaration=True) + self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname) @classmethod def lang_from_source_file(cls, src): @@ -579,6 +578,13 @@ class Vs2010Backend(backends.Backend): return c raise MesonException('Could not find a C or C++ compiler. MSVC can only build C/C++ projects.') + def _prettyprint_vcxproj_xml(self, tree, ofname): + tree.write(ofname, encoding='utf-8', xml_declaration=True) + # ElementTree can not do prettyprinting so do it manually + doc = xml.dom.minidom.parse(ofname) + with open(ofname, 'w') as of: + of.write(doc.toprettyxml()) + def gen_vcxproj(self, target, ofname, guid): mlog.debug('Generating vcxproj %s.' % target.name) entrypoint = 'WinMainCRTStartup' @@ -1023,19 +1029,7 @@ class Vs2010Backend(backends.Backend): ig = ET.SubElement(root, 'ItemGroup') pref = ET.SubElement(ig, 'ProjectReference', Include=os.path.join(self.environment.get_build_dir(), 'REGEN.vcxproj')) ET.SubElement(pref, 'Project').text = self.environment.coredata.regen_guid - tree = ET.ElementTree(root) - tree.write(ofname, encoding='utf-8', xml_declaration=True) - # ElementTree can not do prettyprinting so do it manually - doc = xml.dom.minidom.parse(ofname) - with open(ofname, 'w') as of: - of.write(doc.toprettyxml()) - # World of horror! Python insists on not quoting quotes and - # fixing the escaped " into " whereas MSVS - # requires quoted but not fixed elements. Enter horrible hack. - with open(ofname, 'r') as of: - txt = of.read() - with open(ofname, 'w') as of: - of.write(txt.replace('"', '"')) + self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname) def gen_regenproj(self, project_name, ofname): root = ET.Element('Project', {'DefaultTargets': 'Build', @@ -1114,8 +1108,7 @@ if %%errorlevel%% neq 0 goto :VCEnd''' ET.SubElement(custombuild, 'AdditionalInputs').text = ';'.join(deps) ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') ET.SubElement(root, 'ImportGroup', Label='ExtensionTargets') - tree = ET.ElementTree(root) - tree.write(ofname, encoding='utf-8', xml_declaration=True) + self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname) def gen_testproj(self, target_name, ofname): project_name = target_name @@ -1189,8 +1182,4 @@ if %%errorlevel%% neq 0 goto :VCEnd''' ET.SubElement(postbuild, 'Command').text =\ cmd_templ % ('" "'.join(test_command)) ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') - tree = ET.ElementTree(root) - tree.write(ofname, encoding='utf-8', xml_declaration=True) - # ElementTree can not do prettyprinting so do it manually - # doc = xml.dom.minidom.parse(ofname) - # open(ofname, 'w').write(doc.toprettyxml()) + self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname) |