add file includes

This commit is contained in:
swaldhoer 2020-04-22 13:52:12 +02:00
parent 816f466e32
commit c7b2a5628e
14 changed files with 858 additions and 796 deletions

View File

@ -0,0 +1,4 @@
#ifndef HEADER_H
#define HEADER_H
#define HELLO_WORLD "Hello World"
#endif /* HEADER_H */

View File

@ -4,5 +4,6 @@ extern void foo();
int main() {
foo();
printf("%s", HELLO_WORLD);
return 0;
}

View File

@ -21,7 +21,7 @@ def build(bld):
bld.shlib(source='a.cpp', target='mylib', vnum='9.8.7')
bld.shlib(source='a.cpp', target='mylib2', vnum='9.8.7', cnum='9.8')
bld.shlib(source='a.cpp', target='mylib3')
bld.program(source='main.cpp', target='app', use='mylib')
bld.program(source='main.cpp', target='app', include_files='file-include/inc-file/header.h', use='mylib')
bld.stlib(target='foo', source='b.cpp')
# just a test to check if the .c is compiled as c++ when no c compiler is found

View File

@ -0,0 +1,4 @@
#ifndef HEADER_H
#define HEADER_H
#define HELLO_WORLD "Hello World"
#endif /* HEADER_H */

View File

@ -0,0 +1,7 @@
#include<stdio.h>
int main()
{
printf("%s", HELLO_WORLD);
return 0;
}

View File

@ -0,0 +1 @@
bld(features='c cprogram', source='main.c', include_files='inc-file/header.h', target='app')

View File

@ -78,7 +78,7 @@ def configure(conf):
def build(bld):
bld.env.DEFINES=['WAF=1']
bld.recurse('program stlib stlib-deps shlib')
bld.recurse('program stlib stlib-deps shlib file-include')
#bld.install_files('/tmp/foo', 'wscript')
#bld.env.PREFIX='/tmp/foo'
bld.install_files('${PREFIX}/', 'program/a.h program/main.c', relative_trick=False)

View File

@ -518,6 +518,22 @@ class Node(object):
else:
return self.abspath()
def is_file(self):
"""
Returns True if the Node object is a file.
:rtype: bool
"""
return os.path.isfile(self.abspath())
def is_directory(self):
"""
Returns True if the Node object is a directory.
:rtype: bool
"""
return os.path.isdir(self.abspath())
def abspath(self):
"""
Returns the absolute path. A cache is kept in the context as ``cache_node_abspath``

View File

@ -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} ${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} ${CPPFILES_ST:INCFILES} ${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

File diff suppressed because it is too large Load Diff

View File

@ -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} ${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} ${CPPFILES_ST:INCFILES} ${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

View File

@ -36,6 +36,7 @@ def gcc_common_flags(conf):
v.CCLNK_SRC_F = []
v.CCLNK_TGT_F = ['-o']
v.CPPPATH_ST = '-I%s'
v.CPPFILES_ST = '-include%s'
v.DEFINES_ST = '-D%s'
v.LIB_ST = '-l%s' # template for adding libs

View File

@ -36,6 +36,7 @@ def gxx_common_flags(conf):
v.CXXLNK_SRC_F = []
v.CXXLNK_TGT_F = ['-o']
v.CPPPATH_ST = '-I%s'
v.CPPFILES_ST = '-include%s'
v.DEFINES_ST = '-D%s'
v.LIB_ST = '-l%s' # template for adding libs

View File

@ -909,7 +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.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:'