diff options
author | jan Iversen <jani@documentfoundation.org> | 2017-01-26 10:38:32 +0100 |
---|---|---|
committer | jan Iversen <jani@documentfoundation.org> | 2017-01-26 10:39:44 +0100 |
commit | fc68a2677006467455eb064c1ddc3666a660af7c (patch) | |
tree | 9cdffde4218311af7bf1003db189cc894e18dcc9 /bin | |
parent | 13aa595069250cc4b52ff4795a90317b2e9f50f0 (diff) |
gbuild-to-ide finalized split of maintained code
Added "testIde-ide-integration" to allow test of new vs2013 generator.
Change-Id: Ia7d286f06e287ce97faa0a262ee4f93172d4ed28
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gbuild-to-ide | 560 |
1 files changed, 286 insertions, 274 deletions
diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide index 6d59d6a5effb..3d9460ce74c2 100755 --- a/bin/gbuild-to-ide +++ b/bin/gbuild-to-ide @@ -75,9 +75,6 @@ class GbuildParser: return [cxxflag.strip() for cxxflag in GbuildParser._warningpattern.sub('', '%s %s' % (flagsline, flagslineappend)).split(' ') if len(cxxflag) > 1] - - - def parse(self): # Relation between json object and file extension jsonSrc = { @@ -154,6 +151,8 @@ class GbuildParser: headersof=[] return headersof + + class IdeIntegrationGenerator: def __init__(self, gbuildparser, ide): @@ -162,7 +161,9 @@ class IdeIntegrationGenerator: def emit(self): pass -class testide(IdeIntegrationGenerator): + + +class testWinIde(IdeIntegrationGenerator): def __init__(self, gbuildparser, ide): IdeIntegrationGenerator.__init__(self, gbuildparser, ide) @@ -415,6 +416,7 @@ class testide(IdeIntegrationGenerator): self.write_pretty_xml(proj_node, filters_path) + class XcodeIntegrationGenerator(IdeIntegrationGenerator): def __init__(self, gbuildparser, ide): IdeIntegrationGenerator.__init__(self, gbuildparser, ide) @@ -627,7 +629,281 @@ class XcodeIntegrationGenerator(IdeIntegrationGenerator): 'sourceTree': '<group>'} return objects -# ---- LO supported ide ------- + + +class VisualStudioIntegrationGenerator(IdeIntegrationGenerator): + + def __init__(self, gbuildparser, ide): + IdeIntegrationGenerator.__init__(self, gbuildparser, ide) + self.toolset = self.retrieve_toolset() + self.solution_directory = './windows' + self.configurations = { + 'Build': { + 'build': self.module_make_command('%(target)s'), + 'clean': self.module_make_command('%(target)s.clean'), + 'rebuild': self.module_make_command('%(target)s.clean %(target)s') + }, + 'Unit Tests': { + 'build': self.module_make_command('unitcheck'), + 'clean': self.module_make_command('clean'), + 'rebuild': self.module_make_command('clean unitcheck'), + }, + 'Integration tests': { + 'build': self.module_make_command('unitcheck slowcheck screenshot subsequentcheck'), + 'clean': self.module_make_command('clean'), + 'rebuild': self.module_make_command('clean unitcheck slowcheck screenshot subsequentcheck') + } + } + + def retrieve_toolset(self): + return {'vs2013': 'v120', 'vs2015': 'v140'}.get(self.ide, None) + + def module_make_command(self, targets): + return '%(sh)s -c "PATH=\\"/bin:$PATH\\";BUILDDIR=\\"%(builddir)s\\" %(makecmd)s -rsC %(location)s ' + targets + '"' + + class Project: + + def __init__(self, guid, target, project_path): + self.guid = guid + self.target = target + self.path = project_path + + def emit(self): + all_projects = [] + for module in self.gbuildparser.modules: + projects = [] + module_directory = os.path.join(self.solution_directory, module) + if module != 'include': #FIXME + for target in self.gbuildparser.modules[module]['targets']: + project_path = os.path.join(module_directory, '%s.vcxproj' % target['target_name']) + project_guid = self.write_project(project_path, target) + p = VisualStudioIntegrationGenerator.Project(project_guid, target, project_path) + projects.append(p) + self.write_solution(os.path.join(module_directory, '%s.sln' % module), projects) + all_projects += projects + + self.write_solution(os.path.join(self.solution_directory, 'LibreOffice.sln'), all_projects) + + nmake_project_guid = '8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942' + + def get_dependency_libs(self, linked_libs, library_projects): + dependency_libs = {} + for linked_lib in linked_libs: + for library_project in library_projects: + if library_project.target['name'] == linked_lib: + dependency_libs[library_project.guid] = library_project + return dependency_libs + + def write_solution(self, solution_path, projects): + print('Solution %s:' % os.path.splitext(os.path.basename(solution_path))[0], end='') + library_projects = [project for project in projects if project.target['build_type'] == 'Library'] + with open(solution_path, 'w') as f: + f.write('Microsoft Visual Studio Solution File, Format Version 12.00\n') + for project in projects: + target = project.target + print(' %s' % target['target_name'], end='') + proj_path = os.path.relpath(project.path, os.path.abspath(os.path.dirname(solution_path))) + f.write('Project("{%s}") = "%s", "%s", "{%s}"\n' % + (VisualStudioIntegrationGenerator.nmake_project_guid, + target['target_name'], proj_path, project.guid)) + libs_in_solution = self.get_dependency_libs(target['LINKED_LIBS'], library_projects) + if libs_in_solution: + f.write('\tProjectSection(ProjectDependencies) = postProject\n') + for lib_guid in libs_in_solution.keys(): + f.write('\t\t{%(guid)s} = {%(guid)s}\n' % {'guid': lib_guid}) + f.write('\tEndProjectSection\n') + f.write('EndProject\n') + f.write('Global\n') + platform = 'Win32' + f.write('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n') + for cfg in self.configurations: + f.write('\t\t%(cfg)s|%(platform)s = %(cfg)s|%(platform)s\n' % {'cfg': cfg, 'platform': platform}) + f.write('\tEndGlobalSection\n') + f.write('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n') + # Specifies project configurations for solution configuration + for project in projects: + for cfg in self.configurations: + params = {'guid': project.guid, 'sol_cfg': cfg, 'proj_cfg': cfg, 'platform': platform} + f.write('\t\t{%(guid)s}.%(sol_cfg)s|%(platform)s.ActiveCfg = %(proj_cfg)s|%(platform)s\n' % params) + # Build.0 is basically 'Build checkbox' in configuration manager + f.write('\t\t{%(guid)s}.%(sol_cfg)s|%(platform)s.Build.0 = %(proj_cfg)s|%(platform)s\n' % params) + f.write('\tEndGlobalSection\n') + f.write('EndGlobal\n') + print('') + + def write_project(self, project_path, target): + # See info at http://blogs.msdn.com/b/visualstudio/archive/2010/05/14/a-guide-to-vcxproj-and-props-file-structure.aspx + folder = os.path.dirname(project_path) + if not os.path.exists(folder): + os.makedirs(folder) + project_guid = str(uuid.uuid4()).upper() + ns = 'http://schemas.microsoft.com/developer/msbuild/2003' + ET.register_namespace('', ns) + proj_node = ET.Element('{%s}Project' % ns, DefaultTargets='Build', ToolsVersion='4.0') + proj_confs_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns, Label='ProjectConfigurations') + platform = 'Win32' + for configuration in self.configurations: + proj_conf_node = ET.SubElement(proj_confs_node, + '{%s}ProjectConfiguration' % ns, + Include='%s|%s' % (configuration, platform)) + conf_node = ET.SubElement(proj_conf_node, '{%s}Configuration' % ns) + conf_node.text = configuration + platform_node = ET.SubElement(proj_conf_node, '{%s}Platform' % ns) + platform_node.text = platform + + globals_node = ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, Label='Globals') + proj_guid_node = ET.SubElement(globals_node, '{%s}ProjectGuid' % ns) + proj_guid_node.text = '{%s}' % project_guid + proj_keyword_node = ET.SubElement(globals_node, '{%s}Keyword' % ns) + proj_keyword_node.text = 'MakeFileProj' + proj_name_node = ET.SubElement(globals_node, '{%s}ProjectName' % ns) + proj_name_node.text = target['target_name'] + + ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props') + for configuration in self.configurations: + conf_node = ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, Label="Configuration", + Condition="'$(Configuration)|$(Platform)'=='%s|%s'" % (configuration, platform)) + # Type of project used by the MSBuild to determine build process, see Microsoft.Makefile.targets + conf_type_node = ET.SubElement(conf_node, '{%s}ConfigurationType' % ns) + conf_type_node.text = 'Makefile' + # VS2012: I need to have this otherwise the names of projects will contain text Visual Studio 2010 in the Solution Explorer + platform_toolset_node = ET.SubElement(conf_node, '{%s}PlatformToolset' % ns) + platform_toolset_node.text = self.toolset + + ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.props') + ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='ExtensionSettings') + for configuration in self.configurations: + prop_sheets_node = ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='Configuration', + Condition="'$(Configuration)|$(Platform)'=='%s|%s'" % (configuration, platform)) + ET.SubElement(prop_sheets_node, '{%s}Import' % ns, + Project='$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props', + Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')", + Label='LocalAppDataPlatform') + + ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, Label='UserMacros') + for cfg_name, cfg_targets in self.configurations.items(): + conf_node = ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, + Condition="'$(Configuration)|$(Platform)'=='%s|%s'" % (cfg_name, platform)) + nmake_params = { + 'sh': os.path.join(self.gbuildparser.binpath, 'dash.exe'), + 'builddir': self.gbuildparser.builddir, + 'location': target['location'], + 'makecmd': self.gbuildparser.makecmd, + 'target': target['target_name']} + nmake_build_node = ET.SubElement(conf_node, '{%s}NMakeBuildCommandLine' % ns) + nmake_build_node.text = cfg_targets['build'] % nmake_params + nmake_clean_node = ET.SubElement(conf_node, '{%s}NMakeCleanCommandLine' % ns) + nmake_clean_node.text = cfg_targets['clean'] % nmake_params + nmake_rebuild_node = ET.SubElement(conf_node, '{%s}NMakeReBuildCommandLine' % ns) + nmake_rebuild_node.text = cfg_targets['rebuild'] % nmake_params + nmake_output_node = ET.SubElement(conf_node, '{%s}NMakeOutput' % ns) + nmake_output_node.text = os.path.join(self.gbuildparser.instdir, 'program', 'soffice.exe') + nmake_defs_node = ET.SubElement(conf_node, '{%s}NMakePreprocessorDefinitions' % ns) + nmake_defs_node.text = ';'.join(list(target['DEFS']) + ['$(NMakePreprocessorDefinitions)']) + include_path_node = ET.SubElement(conf_node, '{%s}IncludePath' % ns) + include_path_node.text = ';'.join(target['include'] + ['$(IncludePath)']) + + ET.SubElement(proj_node, '{%s}ItemDefinitionGroup' % ns) + + cxxobjects_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) + for cxxobject in target['CXXOBJECTS']: + cxxabspath = os.path.join(self.gbuildparser.srcdir, cxxobject) + cxxfile = cxxabspath + '.cxx' + if os.path.isfile(cxxfile): + ET.SubElement(cxxobjects_node, '{%s}ClCompile' % ns, Include='../../' + cxxobject + '.cxx') + else: + print('Source %s in project %s does not exist' % (cxxfile, target['target_name'])) + + includes_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) + for cxxobject in target['CXXOBJECTS']: + include_abs_path = os.path.join(self.gbuildparser.srcdir, cxxobject) + hxxfile = include_abs_path + '.hxx' + if os.path.isfile(hxxfile): + ET.SubElement(includes_node, '{%s}ClInclude' % ns, Include='../../' + cxxobject + '.hxx') + # Few files have corresponding .h files + hfile = include_abs_path + '.h' + if os.path.isfile(hfile): + ET.SubElement(includes_node, '{%s}ClInclude' % ns, Include='../../' + cxxobject + '.h') + ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.targets') + ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='ExtensionTargets') + self.write_pretty_xml(proj_node, project_path) + self.write_filters(project_path + '.filters', + os.path.join(self.gbuildparser.srcdir, os.path.basename(target['location'])), + [cxx_node.get('Include') for cxx_node in cxxobjects_node.findall('{%s}ClCompile' % ns)], + [include_node.get('Include') for include_node in includes_node.findall('{%s}ClInclude' % ns)]) + return project_guid + + def get_filter(self, module_dir, proj_file): + return '\\'.join(os.path.relpath(proj_file, module_dir).split('/')[:-1]) + + def get_subfilters(self, proj_filter): + parts = proj_filter.split('\\') + subfilters = set([proj_filter]) + for i in range(1, len(parts)): + subfilters.add('\\'.join(parts[:i])) + return subfilters + + def write_pretty_xml(self, node, file_path): + xml_str = ET.tostring(node, encoding='unicode') + pretty_str = minidom.parseString(xml_str).toprettyxml(encoding='utf-8') + with open(file_path, 'w') as f: + f.write(pretty_str.decode()) + + def add_nodes(self, files_node, module_dir, tag, project_files): + ns = 'http://schemas.microsoft.com/developer/msbuild/2003' + filters = set() + for project_file in project_files: + file_node = ET.SubElement(files_node, tag, Include=project_file) + if os.path.commonprefix([module_dir, project_file]) == module_dir: + project_filter = self.get_filter(module_dir, project_file) + filter_node = ET.SubElement(file_node, '{%s}Filter' % ns) + filter_node.text = project_filter + filters |= self.get_subfilters(project_filter) + return filters + + def write_filters(self, filters_path, module_dir, compile_files, include_files): + ns = 'http://schemas.microsoft.com/developer/msbuild/2003' + ET.register_namespace('', ns) + proj_node = ET.Element('{%s}Project' % ns, ToolsVersion='4.0') + filters = set() + compiles_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) + filters |= self.add_nodes(compiles_node, module_dir, '{%s}ClCompile' % ns, compile_files) + include_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) + filters |= self.add_nodes(include_node, module_dir, '{%s}ClInclude' % ns, include_files) + + filters_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) + for proj_filter in filters: + filter_node = ET.SubElement(filters_node, '{%s}Filter' % ns, Include=proj_filter) + filter_id_node = ET.SubElement(filter_node, '{%s}UniqueIdentifier' % ns) + filter_id_node.text = '{%s}' % str(uuid.uuid4()) + self.write_pretty_xml(proj_node, filters_path) + + +class DebugIntegrationGenerator(IdeIntegrationGenerator): + + def __init__(self, gbuildparser, ide): + IdeIntegrationGenerator.__init__(self, gbuildparser, ide) + + def emit(self): + print(self.gbuildparser.srcdir) + print(self.gbuildparser.builddir) + for f in self.gbuildparser.modules: + for j in self.gbuildparser.modules[f]['targets']: + print(j) + + VisualStudioIntegrationGenerator(self.gbuildparser, self.ide).emit() + XcodeIntegrationGenerator(self.gbuildparser, self.ide).emit() + + EclipseCDTIntegrationGenerator(self.gbuildparser, self.ide).emit() + KdevelopIntegrationGenerator(self.gbuildparser, self.ide).emit() + VimIntegrationGenerator(self.gbuildparser, self.ide).emit() + QtCreatorIntegrationGenerator(self.gbuildparser, self.ide).emit() + + + +# ---- Classes below this point are not actively maintained ------- + + class EclipseCDTIntegrationGenerator(IdeIntegrationGenerator): @@ -763,25 +1039,6 @@ class EclipseCDTIntegrationGenerator(IdeIntegrationGenerator): self.create_macros() self.create_settings_file() -class DebugIntegrationGenerator(IdeIntegrationGenerator): - - def __init__(self, gbuildparser, ide): - IdeIntegrationGenerator.__init__(self, gbuildparser, ide) - - def emit(self): - print(self.gbuildparser.srcdir) - print(self.gbuildparser.builddir) - for f in self.gbuildparser.modules: - for j in self.gbuildparser.modules[f]['targets']: - print(j) - - VisualStudioIntegrationGenerator(self.gbuildparser, self.ide).emit() - XcodeIntegrationGenerator(self.gbuildparser, self.ide).emit() - - EclipseCDTIntegrationGenerator(self.gbuildparser, self.ide).emit() - KdevelopIntegrationGenerator(self.gbuildparser, self.ide).emit() - VimIntegrationGenerator(self.gbuildparser, self.ide).emit() - QtCreatorIntegrationGenerator(self.gbuildparser, self.ide).emit() class VimIntegrationGenerator(IdeIntegrationGenerator): @@ -832,6 +1089,7 @@ class VimIntegrationGenerator(IdeIntegrationGenerator): return command + class KdevelopIntegrationGenerator(IdeIntegrationGenerator): def encode_int(self, i): @@ -1008,256 +1266,6 @@ VersionControl=kdevgit - - -class VisualStudioIntegrationGenerator(IdeIntegrationGenerator): - - def __init__(self, gbuildparser, ide): - IdeIntegrationGenerator.__init__(self, gbuildparser, ide) - self.toolset = self.retrieve_toolset() - self.solution_directory = './windows' - self.configurations = { - 'Build': { - 'build': self.module_make_command('%(target)s'), - 'clean': self.module_make_command('%(target)s.clean'), - 'rebuild': self.module_make_command('%(target)s.clean %(target)s') - }, - 'Unit Tests': { - 'build': self.module_make_command('unitcheck'), - 'clean': self.module_make_command('clean'), - 'rebuild': self.module_make_command('clean unitcheck'), - }, - 'Integration tests': { - 'build': self.module_make_command('unitcheck slowcheck screenshot subsequentcheck'), - 'clean': self.module_make_command('clean'), - 'rebuild': self.module_make_command('clean unitcheck slowcheck screenshot subsequentcheck') - } - } - - def retrieve_toolset(self): - return {'vs2013': 'v120', 'vs2015': 'v140'}.get(self.ide, None) - - def module_make_command(self, targets): - return '%(sh)s -c "PATH=\\"/bin:$PATH\\";BUILDDIR=\\"%(builddir)s\\" %(makecmd)s -rsC %(location)s ' + targets + '"' - - class Project: - - def __init__(self, guid, target, project_path): - self.guid = guid - self.target = target - self.path = project_path - - def emit(self): - all_projects = [] - for module in self.gbuildparser.modules: - projects = [] - module_directory = os.path.join(self.solution_directory, module) - if module != 'include': #FIXME - for target in self.gbuildparser.modules[module]['targets']: - project_path = os.path.join(module_directory, '%s.vcxproj' % target['target_name']) - project_guid = self.write_project(project_path, target) - p = VisualStudioIntegrationGenerator.Project(project_guid, target, project_path) - projects.append(p) - self.write_solution(os.path.join(module_directory, '%s.sln' % module), projects) - all_projects += projects - - self.write_solution(os.path.join(self.solution_directory, 'LibreOffice.sln'), all_projects) - - nmake_project_guid = '8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942' - - def get_dependency_libs(self, linked_libs, library_projects): - dependency_libs = {} - for linked_lib in linked_libs: - for library_project in library_projects: - if library_project.target['name'] == linked_lib: - dependency_libs[library_project.guid] = library_project - return dependency_libs - - def write_solution(self, solution_path, projects): - print('Solution %s:' % os.path.splitext(os.path.basename(solution_path))[0], end='') - library_projects = [project for project in projects if project.target['build_type'] == 'Library'] - with open(solution_path, 'w') as f: - f.write('Microsoft Visual Studio Solution File, Format Version 12.00\n') - for project in projects: - target = project.target - print(' %s' % target['target_name'], end='') - proj_path = os.path.relpath(project.path, os.path.abspath(os.path.dirname(solution_path))) - f.write('Project("{%s}") = "%s", "%s", "{%s}"\n' % - (VisualStudioIntegrationGenerator.nmake_project_guid, - target['target_name'], proj_path, project.guid)) - libs_in_solution = self.get_dependency_libs(target['LINKED_LIBS'], library_projects) - if libs_in_solution: - f.write('\tProjectSection(ProjectDependencies) = postProject\n') - for lib_guid in libs_in_solution.keys(): - f.write('\t\t{%(guid)s} = {%(guid)s}\n' % {'guid': lib_guid}) - f.write('\tEndProjectSection\n') - f.write('EndProject\n') - f.write('Global\n') - platform = 'Win32' - f.write('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n') - for cfg in self.configurations: - f.write('\t\t%(cfg)s|%(platform)s = %(cfg)s|%(platform)s\n' % {'cfg': cfg, 'platform': platform}) - f.write('\tEndGlobalSection\n') - f.write('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n') - # Specifies project configurations for solution configuration - for project in projects: - for cfg in self.configurations: - params = {'guid': project.guid, 'sol_cfg': cfg, 'proj_cfg': cfg, 'platform': platform} - f.write('\t\t{%(guid)s}.%(sol_cfg)s|%(platform)s.ActiveCfg = %(proj_cfg)s|%(platform)s\n' % params) - # Build.0 is basically 'Build checkbox' in configuration manager - f.write('\t\t{%(guid)s}.%(sol_cfg)s|%(platform)s.Build.0 = %(proj_cfg)s|%(platform)s\n' % params) - f.write('\tEndGlobalSection\n') - f.write('EndGlobal\n') - print('') - - def write_project(self, project_path, target): - # See info at http://blogs.msdn.com/b/visualstudio/archive/2010/05/14/a-guide-to-vcxproj-and-props-file-structure.aspx - folder = os.path.dirname(project_path) - if not os.path.exists(folder): - os.makedirs(folder) - project_guid = str(uuid.uuid4()).upper() - ns = 'http://schemas.microsoft.com/developer/msbuild/2003' - ET.register_namespace('', ns) - proj_node = ET.Element('{%s}Project' % ns, DefaultTargets='Build', ToolsVersion='4.0') - proj_confs_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns, Label='ProjectConfigurations') - platform = 'Win32' - for configuration in self.configurations: - proj_conf_node = ET.SubElement(proj_confs_node, - '{%s}ProjectConfiguration' % ns, - Include='%s|%s' % (configuration, platform)) - conf_node = ET.SubElement(proj_conf_node, '{%s}Configuration' % ns) - conf_node.text = configuration - platform_node = ET.SubElement(proj_conf_node, '{%s}Platform' % ns) - platform_node.text = platform - - globals_node = ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, Label='Globals') - proj_guid_node = ET.SubElement(globals_node, '{%s}ProjectGuid' % ns) - proj_guid_node.text = '{%s}' % project_guid - proj_keyword_node = ET.SubElement(globals_node, '{%s}Keyword' % ns) - proj_keyword_node.text = 'MakeFileProj' - proj_name_node = ET.SubElement(globals_node, '{%s}ProjectName' % ns) - proj_name_node.text = target['target_name'] - - ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props') - for configuration in self.configurations: - conf_node = ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, Label="Configuration", - Condition="'$(Configuration)|$(Platform)'=='%s|%s'" % (configuration, platform)) - # Type of project used by the MSBuild to determine build process, see Microsoft.Makefile.targets - conf_type_node = ET.SubElement(conf_node, '{%s}ConfigurationType' % ns) - conf_type_node.text = 'Makefile' - # VS2012: I need to have this otherwise the names of projects will contain text Visual Studio 2010 in the Solution Explorer - platform_toolset_node = ET.SubElement(conf_node, '{%s}PlatformToolset' % ns) - platform_toolset_node.text = self.toolset - - ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.props') - ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='ExtensionSettings') - for configuration in self.configurations: - prop_sheets_node = ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='Configuration', - Condition="'$(Configuration)|$(Platform)'=='%s|%s'" % (configuration, platform)) - ET.SubElement(prop_sheets_node, '{%s}Import' % ns, - Project='$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props', - Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')", - Label='LocalAppDataPlatform') - - ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, Label='UserMacros') - for cfg_name, cfg_targets in self.configurations.items(): - conf_node = ET.SubElement(proj_node, '{%s}PropertyGroup' % ns, - Condition="'$(Configuration)|$(Platform)'=='%s|%s'" % (cfg_name, platform)) - nmake_params = { - 'sh': os.path.join(self.gbuildparser.binpath, 'dash.exe'), - 'builddir': self.gbuildparser.builddir, - 'location': target['location'], - 'makecmd': self.gbuildparser.makecmd, - 'target': target['target_name']} - nmake_build_node = ET.SubElement(conf_node, '{%s}NMakeBuildCommandLine' % ns) - nmake_build_node.text = cfg_targets['build'] % nmake_params - nmake_clean_node = ET.SubElement(conf_node, '{%s}NMakeCleanCommandLine' % ns) - nmake_clean_node.text = cfg_targets['clean'] % nmake_params - nmake_rebuild_node = ET.SubElement(conf_node, '{%s}NMakeReBuildCommandLine' % ns) - nmake_rebuild_node.text = cfg_targets['rebuild'] % nmake_params - nmake_output_node = ET.SubElement(conf_node, '{%s}NMakeOutput' % ns) - nmake_output_node.text = os.path.join(self.gbuildparser.instdir, 'program', 'soffice.exe') - nmake_defs_node = ET.SubElement(conf_node, '{%s}NMakePreprocessorDefinitions' % ns) - nmake_defs_node.text = ';'.join(list(target['DEFS']) + ['$(NMakePreprocessorDefinitions)']) - include_path_node = ET.SubElement(conf_node, '{%s}IncludePath' % ns) - include_path_node.text = ';'.join(target['include'] + ['$(IncludePath)']) - - ET.SubElement(proj_node, '{%s}ItemDefinitionGroup' % ns) - - cxxobjects_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) - for cxxobject in target['CXXOBJECTS']: - cxxabspath = os.path.join(self.gbuildparser.srcdir, cxxobject) - cxxfile = cxxabspath + '.cxx' - if os.path.isfile(cxxfile): - ET.SubElement(cxxobjects_node, '{%s}ClCompile' % ns, Include='../../' + cxxobject + '.cxx') - else: - print('Source %s in project %s does not exist' % (cxxfile, target['target_name'])) - - includes_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) - for cxxobject in target['CXXOBJECTS']: - include_abs_path = os.path.join(self.gbuildparser.srcdir, cxxobject) - hxxfile = include_abs_path + '.hxx' - if os.path.isfile(hxxfile): - ET.SubElement(includes_node, '{%s}ClInclude' % ns, Include='../../' + cxxobject + '.hxx') - # Few files have corresponding .h files - hfile = include_abs_path + '.h' - if os.path.isfile(hfile): - ET.SubElement(includes_node, '{%s}ClInclude' % ns, Include='../../' + cxxobject + '.h') - ET.SubElement(proj_node, '{%s}Import' % ns, Project='$(VCTargetsPath)\Microsoft.Cpp.targets') - ET.SubElement(proj_node, '{%s}ImportGroup' % ns, Label='ExtensionTargets') - self.write_pretty_xml(proj_node, project_path) - self.write_filters(project_path + '.filters', - os.path.join(self.gbuildparser.srcdir, os.path.basename(target['location'])), - [cxx_node.get('Include') for cxx_node in cxxobjects_node.findall('{%s}ClCompile' % ns)], - [include_node.get('Include') for include_node in includes_node.findall('{%s}ClInclude' % ns)]) - return project_guid - - def get_filter(self, module_dir, proj_file): - return '\\'.join(os.path.relpath(proj_file, module_dir).split('/')[:-1]) - - def get_subfilters(self, proj_filter): - parts = proj_filter.split('\\') - subfilters = set([proj_filter]) - for i in range(1, len(parts)): - subfilters.add('\\'.join(parts[:i])) - return subfilters - - def write_pretty_xml(self, node, file_path): - xml_str = ET.tostring(node, encoding='unicode') - pretty_str = minidom.parseString(xml_str).toprettyxml(encoding='utf-8') - with open(file_path, 'w') as f: - f.write(pretty_str.decode()) - - def add_nodes(self, files_node, module_dir, tag, project_files): - ns = 'http://schemas.microsoft.com/developer/msbuild/2003' - filters = set() - for project_file in project_files: - file_node = ET.SubElement(files_node, tag, Include=project_file) - if os.path.commonprefix([module_dir, project_file]) == module_dir: - project_filter = self.get_filter(module_dir, project_file) - filter_node = ET.SubElement(file_node, '{%s}Filter' % ns) - filter_node.text = project_filter - filters |= self.get_subfilters(project_filter) - return filters - - def write_filters(self, filters_path, module_dir, compile_files, include_files): - ns = 'http://schemas.microsoft.com/developer/msbuild/2003' - ET.register_namespace('', ns) - proj_node = ET.Element('{%s}Project' % ns, ToolsVersion='4.0') - filters = set() - compiles_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) - filters |= self.add_nodes(compiles_node, module_dir, '{%s}ClCompile' % ns, compile_files) - include_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) - filters |= self.add_nodes(include_node, module_dir, '{%s}ClInclude' % ns, include_files) - - filters_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) - for proj_filter in filters: - filter_node = ET.SubElement(filters_node, '{%s}Filter' % ns, Include=proj_filter) - filter_id_node = ET.SubElement(filter_node, '{%s}UniqueIdentifier' % ns) - filter_id_node.text = '{%s}' % str(uuid.uuid4()) - self.write_pretty_xml(proj_node, filters_path) - - class QtCreatorIntegrationGenerator(IdeIntegrationGenerator): def __init__(self, gbuildparser, ide): @@ -1895,6 +1903,8 @@ DEFINES += %(defines)s SUBDIRS = %(subdirs)s """ + + class CodeliteIntegrationGenerator(IdeIntegrationGenerator): def __init__(self, gbuildparser, ide): @@ -1974,6 +1984,7 @@ def get_options(): return parser.parse_args() + if __name__ == '__main__': args = get_options() # FIXME: Hack @@ -1988,6 +1999,7 @@ if __name__ == '__main__': 'vs2013': VisualStudioIntegrationGenerator, 'xcode': XcodeIntegrationGenerator, 'debug': DebugIntegrationGenerator, + 'testIde': testWinIde, # Old platforms 'eclipsecdt': EclipseCDTIntegrationGenerator, |