diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile.in | 3 | ||||
-rwxr-xr-x | 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 = """ -<?xml version="%(xmlversion)s" encoding="%(encoding)s"?> -<projectDescription> - <name>%(name)s</name> - <comment>%(comment)s</comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>""" + self.cdt_mb + """.genmakebuilder</name> - <triggers>clean,full,incremental,</triggers> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>""" + self.cdt_mb + """.ScannerConfigBuilder</name> - <triggers>full,incremental,</triggers> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>""" + self.cdt_core + """.cnature</nature> - <nature>""" + self.cdt_core + """.ccnature</nature> - <nature>""" + self.cdt_mb + """.managedBuildNature</nature> - <nature>""" + self.cdt_mb + """.ScannerConfigNature</nature> - </natures> -</projectDescription> -""" - 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 = """\ +<?xml version="1.0" encoding="UTF-8"?> +<cdtprojectproperties> +<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths"> +<language name="C++ Source File"> + + +</language> +<language name="C Source File"> + +</language> +<language name="Object File"> + +</language> +<language name="Assembly Source File"> + +</language> +</section> +<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"> +<language name="C++ Source File"> + +</language> +<language name="C Source File"> + +</language> +<language name="Object File"> + +</language> +<language name="Assembly Source File"> + +</language> +</section> +</cdtprojectproperties> +""" + + 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 = "<includepath>%s</includepath>\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): |