4

I have protobuf proto-files in source tree. I want to generate the source files from proto-files on every change and on first run (e.g. I create new proto-file). Then, I want to compile shared library from these source files and preserve them in source tree.

What is the best way to achieve my goal?

abyss.7
  • 13,882
  • 11
  • 56
  • 100

1 Answers1

5

I have found the solution by myself:

from waflib import Build, Utils, TaskGen

def build(bld):
    bld.post_mode = Build.POST_LAZY

    # some bld(...) tasks that generate source files.

    bld.shlib(source='main.cc', dynamic_source='**/*.cc', target='test')

@TaskGen.feature('cxxshlib')
@TaskGen.before('process_source')
def dynamic_post(self):
    if not getattr(self, 'dynamic_source', None):
        return
    self.source = Utils.to_list(self.source)
    self.source.extend(self.path.get_bld().ant_glob(self.dynamic_source))
abyss.7
  • 13,882
  • 11
  • 56
  • 100