build: Support tools and examples with multiple translation units
Change-Id: I71a5690391464d8275b91f55e914c004eed4f360
Refs: #2344
diff --git a/examples/wscript b/examples/wscript
index 7db133e..52de33f 100644
--- a/examples/wscript
+++ b/examples/wscript
@@ -3,10 +3,22 @@
top = '..'
def build(bld):
- for app in bld.path.ant_glob('*.cpp'):
+ # List all .cpp files (whole example should be in one .cpp)
+ for i in bld.path.ant_glob(['*.cpp']):
+ name = str(i)[:-len(".cpp")]
bld(features=['cxx', 'cxxprogram'],
- target = '%s' % (str(app.change_ext('','.cpp'))),
- source = app,
- use = 'ndn-cxx',
- install_path = None,
+ target=name,
+ source=[i] + bld.path.ant_glob(['%s/**/*.cpp' % name]),
+ use='ndn-cxx',
+ install_path=None
+ )
+
+ # List all directories files (example can has multiple .cpp in the directory)
+ for name in bld.path.ant_glob(['*'], dir=True, src=False):
+ bld(features=['cxx', 'cxxprogram'],
+ target="%s/%s" % (name, name),
+ source=bld.path.ant_glob(['%s/**/*.cpp' % name]),
+ use='ndn-cxx',
+ install_path=None,
+ includes='%s' % name,
)