How to compile C ++ source files created at runtime using waf?

Protobuf prototypes have a source tree. I want to generate source files from proto files each time I change and the first time I start (for example, I create a new proto file). Then I want to compile a common library from these source files and save them in the source tree.

What is the best way to achieve my goal?

+4
source share
1 answer

I found the solution 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)) 
+5
source

Source: https://habr.com/ru/post/1386336/


All Articles