From bc7a490af90d2ec2e68a6385d6daf9720e9b6dd6 Mon Sep 17 00:00:00 2001 From: Gulsah Kose Date: Fri, 27 Nov 2015 20:28:10 +0200 Subject: tdf#84628 Generated eclipse setting file for per module. This patch generated a setting file for per module. When imported the eclipsesettingfile.xml, underlined include lines are clearing up. Setting file includes included file paths for per module and provides correct build. .project file generator deleted because eclipse is creating .project file and overriding it. This adds a new property to the parser that stores each module. Change-Id: Ia10bb37c7c3fdb444a5b79ddf502b962e8ee5736 Signed-off-by: Gulsah Kose --- .gitignore | 5 +++ Makefile.in | 3 +- bin/gbuild-to-ide | 123 ++++++++++++++++++++++++++++++++++++------------------ 3 files changed, 90 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index 7999ec4d8896..6bab9f9a2f42 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,11 @@ *.kdev4 .kdev_include_paths .directory +.cproject +.project +.settings +.eclipsesettingfile +eclipsesettingfile.xml # things below this point are targeted for elimination diff --git a/Makefile.in b/Makefile.in index 2a4748eb7270..51a2e61f8252 100644 --- a/Makefile.in +++ b/Makefile.in @@ -368,7 +368,8 @@ $(foreach ide,\ vs2013 \ vim \ xcode \ - qtcreator,\ + qtcreator \ + eclipsecdt,\ $(eval $(call gb_Top_GbuildToIdeIntegration,$(ide)))) endif # MAKE_RESTARTS diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide index 953747e204ef..0ca502217aac 100755 --- a/bin/gbuild-to-ide +++ b/bin/gbuild-to-ide @@ -103,8 +103,8 @@ class GbuildParser: warningpattern = re.compile('-W\S+') def __init__(self): - (self.makecmd, self.srcdir, self.builddir, self.instdir, self.libs, - self.exes, self.libnames, self.exenames, self.target_by_path, self.target_by_location) = ('', '', '', '', [], [], {}, {}, {}, {}) + (self.makecmd, self.srcdir, self.builddir, self.instdir, self.libs, self.exes, + self.libnames, self.exenames, self.target_by_path, self.target_by_location, self.modulenamelist) = ('', '', '', '', [], [], {}, {}, {}, {}, []) def __mapping_to_dict(self, mapping): mapping_dict = {} @@ -232,7 +232,8 @@ class GbuildParser: if len(set(self.target_by_path[path])) > 1: print('fdo#70422: multiple target use dir %s: %s' % ( path, ', '.join([target.short_name() for target in set(self.target_by_path[path])]))) - + for location in self.target_by_location: + self.modulenamelist.append(os.path.split(location)[1]) return self @@ -245,49 +246,91 @@ class IdeIntegrationGenerator: def emit(self): pass - class EclipseCDTIntegrationGenerator(IdeIntegrationGenerator): def __init__(self, gbuildparser, ide): IdeIntegrationGenerator.__init__(self, gbuildparser, ide) - self.oe_cdt = 'org.eclipse.cdt' - self.cdt_mb = self.oe_cdt + '.managebuilder.core' - self.cdt_core = self.oe_cdt + '.core' - - def generate_project_file(self, name, comment, xmlversion, encoding): - - projectfiletemplate = """ - - - %(name)s - %(comment)s - - - - - """ + self.cdt_mb + """.genmakebuilder - clean,full,incremental, - - - - - """ + self.cdt_mb + """.ScannerConfigBuilder - full,incremental, - - - - - - """ + self.cdt_core + """.cnature - """ + self.cdt_core + """.ccnature - """ + self.cdt_mb + """.managedBuildNature - """ + self.cdt_mb + """.ScannerConfigNature - - -""" - return projectfiletemplate % {'name': name, 'comment': comment, 'xmlversion': xmlversion, 'encoding': encoding} + def create_include_paths(self): + for module in self.gbuildparser.modulenamelist: + modulepath = os.path.join(self.gbuildparser.builddir, module) + includedirfile = open(os.path.join(modulepath, '.eclipsesettingfile'), 'w') + modulelibs = [] + for lib in self.gbuildparser.target_by_path.keys(): + if lib.startswith(module+'/'): + modulelibs.append(lib) + include = set() + for lib in modulelibs: + for target in self.gbuildparser.target_by_path[lib]: + include |= set(target.include) + includedirfile.write('\n'.join(include)) + includedirfile.close() + + def create_settings_file(self): + + settingsfiletemplate = """\ + + +
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+
+""" + + for module in self.gbuildparser.modulenamelist: + tempxml = [] + modulepath = os.path.join(self.gbuildparser.builddir, module) + + settingsfile = open(os.path.join(modulepath, 'eclipsesettingfile.xml'), 'w') + settingsfile.write(settingsfiletemplate) + settingsfile.close() + + settingsfile = open(os.path.join(modulepath, 'eclipsesettingfile.xml'), 'r') + tempxml = settingsfile.readlines() + tempinclude = open(os.path.join(modulepath, '.eclipsesettingfile'), 'r') + for includepath in tempinclude: + if includepath[-1:] == "\n": + includepath = includepath[:-1] + templine = "%s\n" % includepath + tempxml.insert(5, templine) + tempxml="".join(tempxml) + settingsfile.close + + settingsfile = open(os.path.join(modulepath, 'eclipsesettingfile.xml'), 'w') + settingsfile.write(tempxml) + settingsfile.close() + os.remove(os.path.join(modulepath, '.eclipsesettingfile')) + + def emit(self): + self.create_include_paths() + self.create_settings_file() class DebugIntegrationGenerator(IdeIntegrationGenerator): -- cgit v1.2.3