def _GetProjectFileWriter(self, output_version): """Retrieves a Visual Studio project file writer. Args: output_version (str): output version of the Visual Studio solution. Returns: VSProjectFileWriter: Visual Studio project file writer or None if version is not supported. """ if output_version == '2008': return writers.VS2008ProjectFileWriter() if output_version == '2010': return writers.VS2010ProjectFileWriter() if output_version == '2012': return writers.VS2012ProjectFileWriter() if output_version == '2013': return writers.VS2013ProjectFileWriter() if output_version == '2015': return writers.VS2015ProjectFileWriter() if output_version == '2017': return writers.VS2017ProjectFileWriter() if output_version == '2019': return writers.VS2019ProjectFileWriter() return None
def testWriteItemDefinitionGroup(self): """Tests the _WriteItemDefinitionGroup function.""" project_configuration = resources.VSProjectConfiguration() file_writer = writers.VS2012ProjectFileWriter() file_writer._file = io.BytesIO() file_writer._WriteItemDefinitionGroup(project_configuration) file_writer._file.seek(0, os.SEEK_SET) output_data = file_writer._file.read() expected_output_data = ( b' <ItemDefinitionGroup ' b'Condition="\'$(Configuration)|$(Platform)\'==\'|\'">\r\n' b' <ClCompile>\r\n' b' <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)' b'</AdditionalIncludeDirectories>\r\n' b' <PreprocessorDefinitions>%(PreprocessorDefinitions)' b'</PreprocessorDefinitions>\r\n' b' <RuntimeLibrary></RuntimeLibrary>\r\n' b' <WarningLevel></WarningLevel>\r\n' b' </ClCompile>\r\n' b' </ItemDefinitionGroup>\r\n') self.assertEqual(output_data, expected_output_data)
def testWriteOutIntDirConditions(self): """Tests the _WriteOutIntDirConditions function.""" configuration_name = 'Release' project_configurations = resources.VSConfigurations() file_writer = writers.VS2012ProjectFileWriter() file_writer._file = io.BytesIO() file_writer._WriteOutIntDirConditions( configuration_name, project_configurations) file_writer._file.seek(0, os.SEEK_SET) output_data = file_writer._file.read() self.assertEqual(output_data, b'')
def testWriteLinkerSection(self): """Tests the _WriteLinkerSection function.""" project_configuration = resources.VSProjectConfiguration() file_writer = writers.VS2012ProjectFileWriter() file_writer._file = io.BytesIO() file_writer._WriteLinkerSection(project_configuration) file_writer._file.seek(0, os.SEEK_SET) output_data = file_writer._file.read() expected_output_data = ( b' <Link>\r\n' b' </Link>\r\n') self.assertEqual(output_data, expected_output_data)
def testWriteOutIntDirPropertyGroups(self): """Tests the _WriteOutIntDirPropertyGroups function.""" project_configurations = resources.VSConfigurations() file_writer = writers.VS2012ProjectFileWriter() file_writer._file = io.BytesIO() file_writer._WriteOutIntDirPropertyGroups(project_configurations) file_writer._file.seek(0, os.SEEK_SET) output_data = file_writer._file.read() expected_output_data = ( b' <PropertyGroup>\r\n' b' <_ProjectFileVersion>11.0.61030.0</_ProjectFileVersion>\r\n' b' </PropertyGroup>\r\n') self.assertEqual(output_data, expected_output_data)
def testWriteConfigurationPropertyGroup(self): """Tests the _WriteConfigurationPropertyGroup function.""" project_configuration = resources.VSProjectConfiguration() file_writer = writers.VS2012ProjectFileWriter() file_writer._file = io.BytesIO() file_writer._WriteConfigurationPropertyGroup(project_configuration) file_writer._file.seek(0, os.SEEK_SET) output_data = file_writer._file.read() expected_output_data = ( b' <PropertyGroup Condition="\'$(Configuration)|$(Platform)\'==\'|\'"' b' Label="Configuration">\r\n' b' <ConfigurationType></ConfigurationType>\r\n' b' <PlatformToolset>v110</PlatformToolset>\r\n' b' </PropertyGroup>\r\n') self.assertEqual(output_data, expected_output_data)