2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-12-23 17:55:04 +01:00
waf/demos/pch/wscript
Thomas Nagy e70cd20398 docs
2012-02-07 09:20:32 +01:00

54 lines
1.3 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2006 (ita)
"""
for some obscure reason, the precompiled header will not be taken if
all.h is in the same directory as main.cpp
we recommend to add the header to compile in a separate directory without any sources
Note: the #warning will come once when the .h is compiled, it will not come when the .cpp is compiled
Note: do not forget to set the include paths (include=...)
"""
from waflib.TaskGen import feature, after
from waflib.Task import Task
from waflib.Tools import c_preproc
@feature('cxx')
@after('apply_link')
def process_pch(self):
if getattr(self, 'pch', ''):
nodes = self.to_nodes(self.pch)
for x in nodes:
self.create_task('gchx', x, x.change_ext('.h.gch'))
class gchx(Task):
run_str = '${CXX} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}'
scan = c_preproc.scan
ext_out = ['.h']
color = 'BLUE'
from waflib.Task import update_outputs
update_outputs(gchx)
#################################################
# example below
VERSION='0.0.1'
APPNAME='pch_test'
top = '.'
out = 'build'
def configure(conf):
conf.load('g++')
def build(bld):
bld.program(
source = 'main.cpp',
includes = '. subdir',
target = 'test',
pch = 'subdir/all.h')