2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-23 02:16:01 +01:00
waf/demos/c/program/wscript_build
2016-06-05 00:39:04 +02:00

40 lines
1002 B
Python

#! /usr/bin/env python
def write_header(tsk):
tsk.outputs[0].write('int abc = 423;\n')
bld(rule=write_header, target='b.h', ext_out=['.h'])
tg = bld.program(
features = 'aaa',
source = 'main.c',
includes = '. ..',
#cflags = ['-O3'], # for example
defines = ['foo=bar'],
target = 'myprogram',
use = 'M')
# just for fun, make main.c depend on wscript_build
bld.add_manual_dependency('main.c', bld.path.find_resource('wscript_build'))
# ----------------------------------------
from waflib import TaskGen
@TaskGen.feature('aaa')
@TaskGen.before('apply_link')
def add_one_task(self):
"""this is a task generator method, it is bound to the feature 'aaa' """
tsk = self.create_task('foo')
tsk.outputs = [self.bld.path.find_or_declare('abc.h')]
import waflib.Task
class foo(waflib.Task.Task):
"""this is a task class"""
before = ['c']
color = 'BLUE'
def run(self):
self.outputs[0].write('int kik = 343;\n')
if bld.env.CC_NAME == 'msvc':
tg.source += ' msvc_resource.rc'