2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-23 02:16:01 +01:00

eclipse: generate configuration just for languages that are effecitvely used in wscript and not all of them all the time

This commit is contained in:
fedepell 2017-05-19 10:21:23 +02:00 committed by Thomas Nagy
parent 372c801472
commit b639668c3b

View File

@ -49,6 +49,7 @@ class eclipse(Build.BuildContext):
"Unresolved Inclusion" errors in the Eclipse editor "Unresolved Inclusion" errors in the Eclipse editor
@param pythonpath Optional project specific python paths @param pythonpath Optional project specific python paths
""" """
hasc = hasjava = haspython = False
source_dirs = [] source_dirs = []
cpppath = self.env['CPPPATH'] cpppath = self.env['CPPPATH']
javasrcpath = [] javasrcpath = []
@ -68,6 +69,7 @@ class eclipse(Build.BuildContext):
if py_installfrom: if py_installfrom:
pypath += os.sep + py_installfrom pypath += os.sep + py_installfrom
pythonpath.append(pypath) pythonpath.append(pypath)
haspython = True
# Add Java source directories so object resolving works in IDE # Add Java source directories so object resolving works in IDE
@ -80,6 +82,7 @@ class eclipse(Build.BuildContext):
else: else:
java_src += os.sep + java_srcdir java_src += os.sep + java_srcdir
javasrcpath.append(java_src) javasrcpath.append(java_src)
hasjava = True
tg.post() tg.post()
if not getattr(tg, 'link_task', None): if not getattr(tg, 'link_task', None):
@ -101,20 +104,25 @@ class eclipse(Build.BuildContext):
if is_cc and path not in source_dirs: if is_cc and path not in source_dirs:
source_dirs.append(path) source_dirs.append(path)
project = self.impl_create_project(sys.executable, appname) hasc = True
project = self.impl_create_project(sys.executable, appname, hasc, hasjava, haspython)
self.srcnode.make_node('.project').write(project.toprettyxml()) self.srcnode.make_node('.project').write(project.toprettyxml())
if hasc:
waf = os.path.abspath(sys.argv[0]) waf = os.path.abspath(sys.argv[0])
project = self.impl_create_cproject(sys.executable, waf, appname, workspace_includes, cpppath, source_dirs) project = self.impl_create_cproject(sys.executable, waf, appname, workspace_includes, cpppath, source_dirs)
self.srcnode.make_node('.cproject').write(project.toprettyxml()) self.srcnode.make_node('.cproject').write(project.toprettyxml())
if haspython:
project = self.impl_create_pydevproject(sys.path, pythonpath) project = self.impl_create_pydevproject(sys.path, pythonpath)
self.srcnode.make_node('.pydevproject').write(project.toprettyxml()) self.srcnode.make_node('.pydevproject').write(project.toprettyxml())
if hasjava:
project = self.impl_create_javaproject(javasrcpath) project = self.impl_create_javaproject(javasrcpath)
self.srcnode.make_node('.classpath').write(project.toprettyxml()) self.srcnode.make_node('.classpath').write(project.toprettyxml())
def impl_create_project(self, executable, appname): def impl_create_project(self, executable, appname, hasc, hasjava, haspython):
doc = Document() doc = Document()
projectDescription = doc.createElement('projectDescription') projectDescription = doc.createElement('projectDescription')
self.add(doc, projectDescription, 'name', appname) self.add(doc, projectDescription, 'name', appname)
@ -136,6 +144,8 @@ class eclipse(Build.BuildContext):
self.addDictionary(doc, arguments, k, v) self.addDictionary(doc, arguments, k, v)
natures = self.add(doc, projectDescription, 'natures') natures = self.add(doc, projectDescription, 'natures')
if hasc:
nature_list = """ nature_list = """
core.ccnature core.ccnature
managedbuilder.core.ScannerConfigNature managedbuilder.core.ScannerConfigNature
@ -145,7 +155,9 @@ class eclipse(Build.BuildContext):
for n in nature_list: for n in nature_list:
self.add(doc, natures, 'nature', oe_cdt + '.' + n) self.add(doc, natures, 'nature', oe_cdt + '.' + n)
if haspython:
self.add(doc, natures, 'nature', 'org.python.pydev.pythonNature') self.add(doc, natures, 'nature', 'org.python.pydev.pythonNature')
if hasjava:
self.add(doc, natures, 'nature', 'org.eclipse.jdt.core.javanature') self.add(doc, natures, 'nature', 'org.eclipse.jdt.core.javanature')
doc.appendChild(projectDescription) doc.appendChild(projectDescription)