eclipse: add support for generated files management for java and python

added support to search and add into source path also generated source
files for both java and python. this is useful when using generated code
(ie. protoc and pyqt5) so browsing in eclipse works correclty adding also
paths where generated code is done.

extended example in playground demostrating generated code
This commit is contained in:
fedepell 2018-04-21 15:44:13 +02:00 committed by ita1024
parent c4f8e20e69
commit 64a582ecc2
6 changed files with 195 additions and 19 deletions

View File

@ -0,0 +1,12 @@
package udp.tc.tests;
option java_package ="com.udp.tc.tests";
option java_outer_classname= "MessageProtos";
option cc_generic_services = false;
option java_generic_services = false;
option py_generic_services = false;
message Message {
required int32 test = 1;
optional uint32 blah = 2;
}

View File

@ -21,7 +21,7 @@ def options(opt):
pass
def configure(conf):
conf.load('java')
conf.load('java protoc')
try:
ret = conf.load('junit', tooldir='.')
@ -33,6 +33,7 @@ def configure(conf):
conf.check_java_class('FakeClass')
conf.env.CLASSPATH_NNN = ['aaaa.jar', 'bbbb.jar']
conf.env.CLASSPATH_PROTOBUF = ['/tmp/cp/protobuf-java-2.5.0.jar']
def build(bld):
@ -54,3 +55,12 @@ def build(bld):
bld.recurse('animals cats')
bld(
features = 'javac protoc',
name = 'pbjava',
srcdir = 'protoc/',
source = ['protoc/message.proto'],
use = 'PROTOBUF',
protoc_includes = ['protoc'])

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>myfirstgui</class>
<widget class="QDialog" name="myfirstgui">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>247</height>
</rect>
</property>
<property name="windowTitle">
<string>My First Gui!</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>20</x>
<y>210</y>
<width>381</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
<widget class="QLineEdit" name="myTextInput">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>101</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QListWidget" name="listWidget">
<property name="geometry">
<rect>
<x>120</x>
<y>10</y>
<width>281</width>
<height>192</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="clearBtn">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>clear</string>
</property>
</widget>
<widget class="QPushButton" name="addBtn">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>add</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>myfirstgui</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>258</x>
<y>274</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>myfirstgui</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>clearBtn</sender>
<signal>clicked()</signal>
<receiver>listWidget</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel">
<x>177</x>
<y>253</y>
</hint>
<hint type="destinationlabel">
<x>177</x>
<y>174</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,24 @@
import sys
from PySide2 import QtCore, QtGui, QtWidgets
from firstgui import Ui_myfirstgui
class MyFirstGuiProgram(Ui_myfirstgui):
def __init__(self, dialog):
Ui_myfirstgui.__init__(self)
self.setupUi(dialog)
# Connect "add" button with a custom function (addInputTextToListbox)
self.addBtn.clicked.connect(self.addInputTextToListbox)
def addInputTextToListbox(self):
txt = self.myTextInput.text()
self.listWidget.addItem(txt)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
dialog = QtWidgets.QDialog()
prog = MyFirstGuiProgram(dialog)
dialog.show()
sys.exit(app.exec_())

View File

@ -3,10 +3,10 @@
def options(opt):
opt.load('python')
opt.load('python pyqt5')
def configure(conf):
conf.load('python')
conf.load('python pyqt5')
conf.check_python_version(minver=(2, 7, 0))
@ -15,5 +15,7 @@ def build(bld):
bld(name='mod2', features='py', source=bld.path.ant_glob('mod2/src/**/*.py'), install_from='mod2/src')
bld(name='mod3', features='py', source=bld.path.ant_glob('mod3/src/**/*.py'), install_from='mod3/src')
bld(name='withqt5', features='py pyqt5', source=bld.path.ant_glob('withqt5/src/**/*'), install_from='withqt5/src')
# Example program with module dependencies
bld(name='prg', features='py', source=bld.path.ant_glob('prg/src/**/*.py'), install_from='prg/src', use='mod1 mod2 mod3')

View File

@ -75,38 +75,36 @@ class eclipse(Build.BuildContext):
if not isinstance(tg, TaskGen.task_gen):
continue
tg.post()
# Add local Python modules paths to configuration so object resolving will work in IDE
# This may also contain generated files (ie. pyqt5 or protoc) that get picked from build
if 'py' in tg.features:
pypath = tg.path.relpath()
py_installfrom = getattr(tg, 'install_from', None)
if py_installfrom:
if isinstance(py_installfrom, Node.Node):
py_installfrom = py_installfrom.path_from(tg.path)
pypath += os.sep + py_installfrom
pythonpath.append(pypath)
if isinstance(py_installfrom, Node.Node):
pypath = py_installfrom.path_from(self.root.make_node(self.top_dir))
if pypath not in pythonpath:
pythonpath.append(pypath)
haspython = True
# Add Java source directories so object resolving works in IDE
# This may also contain generated files (ie. protoc) that get picked from build
if 'javac' in tg.features:
java_src = tg.path.relpath()
java_srcdir = getattr(tg, 'srcdir', None)
java_srcdir = getattr(tg.javac_task, 'srcdir', None)
if java_srcdir:
if isinstance(java_srcdir, Node.Node):
java_srcdir = [java_srcdir]
for x in Utils.to_list(java_srcdir):
if isinstance(x, Node.Node):
x = x.name
if java_src == '.':
this_src = x
else:
this_src = java_src + os.sep + x
javasrcpath.append(this_src)
x = x.path_from(self.root.make_node(self.top_dir))
if x not in javasrcpath:
javasrcpath.append(x)
else:
javasrcpath.append(java_src)
if java_src not in javasrcpath:
javasrcpath.append(java_src)
hasjava = True
tg.post()
if not getattr(tg, 'link_task', None):
continue