In some cases, it is necessary to re-use object files generated by another task generator to avoid recompilations. This is similar to copy-pasting code, so it is discouraged in general. Another use for this is to enable some compilation flags for specific files. The attribute "add_objects" can be used, like in the following example:
def build(bld): some_objects = bld.new_task_gen( features = 'cc',source = 'test.c', ccflags = '-O3', target = 'my_objs') main = bld.new_task_gen( features = 'cc cprogram', source = 'main.c', ccflags = '-O2',
target = 'test_c_program', add_objects = 'my_objs')
![]()
Files will be compiled in c mode, but no program or library will be produced | |
Different compilation flags may be used | |
The objects will be added automatically in the link stage |