mirror of https://gitlab.com/ita1024/waf.git
add the idea as documentation
This commit is contained in:
parent
13f337b8b4
commit
9389f5d5cc
|
@ -23,7 +23,7 @@ def build(bld):
|
|||
bld.shlib(source='a.cpp', target='mylib3')
|
||||
bld.program(source='main.cpp', target='app', use='mylib')
|
||||
bld.stlib(target='foo', source='b.cpp')
|
||||
bld.program(source='c.cpp', target='file-include', include_files='file-include/inc-file/header.h')
|
||||
bld.program(source='c.cpp', target='file-include', includes='file-include/inc-file/header.h')
|
||||
|
||||
# just a test to check if the .c is compiled as c++ when no c compiler is found
|
||||
bld.program(features='cxx cxxprogram', source='main.c', target='app2')
|
||||
|
|
|
@ -1 +1 @@
|
|||
bld(features='c cprogram', source='main.c', include_files='inc-file/header.h', target='app')
|
||||
bld(features='c cprogram', source='main.c', includes='inc-file/header.h', target='app')
|
||||
|
|
|
@ -518,7 +518,7 @@ class Node(object):
|
|||
else:
|
||||
return self.abspath()
|
||||
|
||||
def is_file(self):
|
||||
def isfile(self):
|
||||
"""
|
||||
Returns True if the Node object is a file.
|
||||
|
||||
|
@ -526,7 +526,7 @@ class Node(object):
|
|||
"""
|
||||
return os.path.isfile(self.abspath())
|
||||
|
||||
def is_directory(self):
|
||||
def isdir(self):
|
||||
"""
|
||||
Returns True if the Node object is a directory.
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ def c_hook(self, node):
|
|||
|
||||
class c(Task.Task):
|
||||
"Compiles C files into object files"
|
||||
run_str = '${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPFILES_ST:INCFILES} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
|
||||
run_str = '${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
|
||||
vars = ['CCDEPS'] # unused variable to depend on, just in case
|
||||
ext_in = ['.h'] # set the build order easily by using ext_out=['.h']
|
||||
scan = c_preproc.scan
|
||||
|
|
|
@ -119,29 +119,12 @@ def apply_incpaths(self):
|
|||
"""
|
||||
|
||||
lst = self.to_incnodes(self.to_list(getattr(self, 'includes', [])) + self.env.INCLUDES)
|
||||
self.includes_nodes = lst
|
||||
inc_files = [x for x in lst if x.isfile()]
|
||||
self.includes_nodes = list(set(lst) - set(inc_files)) # diff only holds directory
|
||||
cwd = self.get_cwd()
|
||||
self.env.INCPATHS = [x.path_from(cwd) for x in lst]
|
||||
|
||||
@feature('c', 'cxx', 'include_files')
|
||||
@after_method('propagate_uselib_vars', 'process_source')
|
||||
def apply_incfiles(self):
|
||||
"""
|
||||
Task generator method that processes the attribute *include_files*::
|
||||
|
||||
tg = bld(features='include_files', include_files='my-header.h')
|
||||
|
||||
The files need to be given relative to the current directory.
|
||||
|
||||
This method will add a list of header file nodes to ``tg.env.INCFILES``.
|
||||
"""
|
||||
node_lst = []
|
||||
for x in self.to_list(getattr(self, 'include_files', [])) + self.env.INCLUDE_FILES:
|
||||
if isinstance(x, Node.Node):
|
||||
node_lst.append(x)
|
||||
else:
|
||||
node_lst.append(self.path.find_node(x))
|
||||
self.env.INCFILES = [x.abspath() for x in node_lst if x.is_file()]
|
||||
self.env.INCPATHS = [x.path_from(cwd) for x in self.includes_nodes]
|
||||
self.env.prepend_value('CFLAGS', [self.env.CPPFILES_ST % x for x in inc_files])
|
||||
self.env.prepend_value('CXXFLAGS', [self.env.CPPFILES_ST % x for x in inc_files])
|
||||
|
||||
class link_task(Task.Task):
|
||||
"""
|
||||
|
|
|
@ -18,7 +18,7 @@ if not '.c' in TaskGen.task_gen.mappings:
|
|||
|
||||
class cxx(Task.Task):
|
||||
"Compiles C++ files into object files"
|
||||
run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPFILES_ST:INCFILES} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
|
||||
run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT[0].abspath()} ${CPPFLAGS}'
|
||||
vars = ['CXXDEPS'] # unused variable to depend on, just in case
|
||||
ext_in = ['.h'] # set the build order easily by using ext_out=['.h']
|
||||
scan = c_preproc.scan
|
||||
|
|
|
@ -909,8 +909,8 @@ def msvc_common_flags(conf):
|
|||
v.CC_TGT_F = ['/FC'] + v.CC_TGT_F
|
||||
v.CXX_TGT_F = ['/FC'] + v.CXX_TGT_F
|
||||
|
||||
v.CPPPATH_ST = '/I%s' # template for adding include paths
|
||||
v.CPPFILES_ST = '/FI%s'
|
||||
v.CPPPATH_ST = '/I%s' # template for adding include paths
|
||||
v.CPPFILES_ST = '/FI%s'
|
||||
|
||||
v.AR_TGT_F = v.CCLNK_TGT_F = v.CXXLNK_TGT_F = '/OUT:'
|
||||
|
||||
|
|
Loading…
Reference in New Issue