diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-22 16:59:22 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-22 15:54:00 +0100 |
commit | a821d89646ef25428cf5992f86d8f31581313bdb (patch) | |
tree | 3f4227ff81c5f17bca020f5bfb2db39454b33d0a /bin | |
parent | ce43004ca4234010c5b7243e7bb90daa6a9b7f56 (diff) |
vs-ide-integration: Also add .c files
Change-Id: Icb4e879025278291270d908bb53178250c8e7007
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87192
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gbuild-to-ide | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide index b2a5f7bb714e..097f163d46ed 100755 --- a/bin/gbuild-to-ide +++ b/bin/gbuild-to-ide @@ -25,25 +25,25 @@ from sys import platform import collections class GbuildLinkTarget: - def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs): - (self.name, self.location, self.include, self.include_sys, self.defs, self.cxxobjects, self.cxxflags, self.linked_libs) = ( - name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs) + def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs): + (self.name, self.location, self.include, self.include_sys, self.defs, self.cxxobjects, self.cxxflags, self.cobjects, self.cflags, self.linked_libs) = ( + name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs) def short_name(self): return self.name def is_empty(self): - return not self.include and not self.defs and not self.cxxobjects and not self.linked_libs + return not self.include and not self.defs and not self.cxxobjects and not self.cobjects and not self.linked_libs def __str__(self): - return '%s at %s with include path: %s, isystem includes: %s, defines: %s, objects: %s, cxxflags: %s and linked libs: %s' % ( + return '%s at %s with include path: %s, isystem includes: %s, defines: %s, objects: %s, cxxflags: %s, cobjects: %s, cflags: %s and linked libs: %s' % ( self.short_name(), self.location, self.include, self.include_sys, self.defs, self.cxxobjects, - self.cxxflags, self.linked_libs) + self.cxxflags, self.cobjects, self.cflags, self.linked_libs) class GbuildLib(GbuildLinkTarget): - def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs): - GbuildLinkTarget.__init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs) + def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs): + GbuildLinkTarget.__init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs) def short_name(self): """Return the short name of target based on the Library_* makefile name""" @@ -56,8 +56,8 @@ class GbuildLib(GbuildLinkTarget): return self.name class GbuildTest(GbuildLinkTarget): - def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs): - GbuildLinkTarget.__init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs) + def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs): + GbuildLinkTarget.__init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs) def short_name(self): """Return the short name of target based n the CppunitTest_* makefile names""" @@ -67,8 +67,8 @@ class GbuildTest(GbuildLinkTarget): return 'CppunitTest_%s' % self.name class GbuildExe(GbuildLinkTarget): - def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs): - GbuildLinkTarget.__init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, linked_libs) + def __init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs): + GbuildLinkTarget.__init__(self, name, location, include, include_sys, defs, cxxobjects, cxxflags, cobjects, cflags, linked_libs) def short_name(self): """Return the short name of target based on the Executable_* makefile name""" @@ -110,7 +110,7 @@ class GbuildParser: @staticmethod def __split_objs(objsline): - return [obj for obj in objsline.strip().split(' ') if len(obj) > 0 and obj != 'CXXOBJECTS' and obj != '+='] + return [obj for obj in objsline.strip().split(' ') if len(obj) > 0 and obj != 'CXXOBJECTS' and obj != 'COBJECTS' and obj != '+='] @staticmethod def __split_defs(defsline): @@ -144,6 +144,8 @@ class GbuildParser: GbuildParser.__split_defs(json['DEFS']), GbuildParser.__split_objs(json['CXXOBJECTS']), GbuildParser.__split_flags(json['CXXFLAGS'], json['CXXFLAGSAPPEND']), + GbuildParser.__split_objs(json['COBJECTS']), + GbuildParser.__split_flags(json['CFLAGS'], json['CFLAGSAPPEND']), json['LINKED_LIBS'].strip().split(' ')) @staticmethod @@ -165,6 +167,8 @@ class GbuildParser: GbuildParser.__split_defs(json['DEFS']), GbuildParser.__split_objs(json['CXXOBJECTS']), GbuildParser.__split_flags(json['CXXFLAGS'], json['CXXFLAGSAPPEND']), + GbuildParser.__split_objs(json['COBJECTS']), + GbuildParser.__split_flags(json['CFLAGS'], json['CFLAGSAPPEND']), json['LINKED_LIBS'].strip().split(' ')) @staticmethod @@ -178,6 +182,8 @@ class GbuildParser: GbuildParser.__split_defs(json['DEFS']), GbuildParser.__split_objs(json['CXXOBJECTS']), GbuildParser.__split_flags(json['CXXFLAGS'], json['CXXFLAGSAPPEND']), + GbuildParser.__split_objs(json['COBJECTS']), + GbuildParser.__split_flags(json['CFLAGS'], json['CFLAGSAPPEND']), json['LINKED_LIBS'].strip().split(' ')) def parse(self): @@ -202,6 +208,11 @@ class GbuildParser: if path not in self.target_by_path: self.target_by_path[path] = set() self.target_by_path[path] |= set([target]) + for c in target.cobjects: + path = '/'.join(c.split('/')[:-1]) + if path not in self.target_by_path: + self.target_by_path[path] = set() + self.target_by_path[path] |= set([target]) for location in self.target_by_location: self.modulenamelist.append(os.path.split(location)[1]) return self @@ -1116,6 +1127,15 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator): else: print('Source %s in project %s does not exist' % (cxxfile, target.target_name())) + cobjects_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) + for cobject in target.cobjects: + cabspath = os.path.join(self.gbuildparser.srcdir, cobject) + cfile = cabspath + '.c' + if os.path.isfile(cfile): + ET.SubElement(cobjects_node, '{%s}ClCompile' % ns, Include=cfile) + else: + print('Source %s in project %s does not exist' % (cfile, 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) @@ -1126,12 +1146,18 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator): hfile = include_abs_path + '.h' if os.path.isfile(hfile): ET.SubElement(includes_node, '{%s}ClInclude' % ns, Include=hfile) + for cobject in target.cobjects: + include_abs_path = os.path.join(self.gbuildparser.srcdir, cobject) + hfile = include_abs_path + '.h' + if os.path.isfile(hfile): + ET.SubElement(includes_node, '{%s}ClInclude' % ns, Include=hfile) 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)], + [c_node.get('Include') for c_node in cobjects_node.findall('{%s}ClCompile' % ns)], [include_node.get('Include') for include_node in includes_node.findall('{%s}ClInclude' % ns)]) return project_guid @@ -1163,13 +1189,14 @@ class VisualStudioIntegrationGenerator(IdeIntegrationGenerator): filters |= self.get_subfilters(project_filter) return filters - def write_filters(self, filters_path, module_dir, compile_files, include_files): + def write_filters(self, filters_path, module_dir, cxx_files, c_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) + filters |= self.add_nodes(compiles_node, module_dir, '{%s}ClCompile' % ns, cxx_files) + filters |= self.add_nodes(compiles_node, module_dir, '{%s}ClCompile' % ns, c_files) include_node = ET.SubElement(proj_node, '{%s}ItemGroup' % ns) filters |= self.add_nodes(include_node, module_dir, '{%s}ClInclude' % ns, include_files) |