Esempio n. 1
0
if platform.system() == 'Linux':
    ns.append_env_flags('LDFLAGS', '-lpthread', '-latomic')

ns.append_env_flags('LDFLAGS', '-L' + out_root, '-lnut', '-lloofah')

# NOTE 这些 win 网络库必须放在最后,否则会出错
#      See http://stackoverflow.com/questions/2033608/mingw-linker-error-winsock
if platform.system() == 'Windows':
    ns.append_env_flags('LDFLAGS', '-lwininet', '-lws2_32', '-lwsock32')

## Dependencies

# Generate headers
for src in file_utils.iterfiles(src_root, '.h'):
    h = src
    ih = file_utils.chproot(src, src_root, header_root)
    ns.set_recipe(ih, file_op.copyfile)
    ns.add_chained_deps('@headers', ih, h)

program = join(out_root, 'test_pingpong' + ns['PROGRAM_SUFFIX'])
ns.set_recipe('@read_deps', compile_c.read_deps)
for src in file_utils.iterfiles(src_root, '.c', '.cpp'):
    c = src
    o = splitext(file_utils.chproot(src, src_root, obj_root))[0] + '.o'
    d = o + '.d'
    ns.add_dep(d, '@headers')
    ns.add_chained_deps(o, '@read_deps', d, c)
    ns.add_chained_deps(program, o, c)

ns.add_dep(program, join(out_root, 'libloofah' + ns['SHARED_LIB_SUFFIX']))
ns.set_recipe(program, compile_c.link_program)
# if platform.system() == 'Linux':
#     ns.append_env_flags('LDFLAGS', '-lpthread', '-ldl', '-latomic')

if platform.system() == 'Darwin':
    ns.append_env_flags('CXXFLAGS', '-stdlib=libc++')
    ns.append_env_flags('LDFLAGS', '-lc++')
else:
    ns.append_env_flags('LDFLAGS', '-lstdc++')

## Dependencies
so = join(out_root, 'libsqlitecpp' + ns['SHARED_LIB_SUFFIX'])

# Generate headers
for src in file_utils.iterfiles(sqlite_src_root, '.h'):
    ih = file_utils.chproot(src, sqlite_src_root, header_root)
    ns.set_recipe(ih, file_op.copyfile)
    ns.add_chained_deps('@headers', ih, src)

for src in file_utils.iterfiles(sqlite_encrypt_src_root, '.h'):
    ih = file_utils.chproot(src, sqlite_encrypt_src_root, header_root)
    ns.set_recipe(ih, file_op.copyfile)
    ns.add_chained_deps('@headers', ih, src)

for src in file_utils.iterfiles(src_root, '.h'):
    ih = file_utils.chproot(src, src_root, header_root)
    ns.set_recipe(ih, file_op.copyfile)
    ns.add_chained_deps('@headers', ih, src)

# Compile .c .cpp
ns.set_recipe('@read_deps', compile_c.read_deps)
Esempio n. 3
0
    ns.append_env_flags('CXXFLAGS', '-stdlib=libc++')
    ns.append_env_flags('LDFLAGS', '-lc++')
else:
    ns.append_env_flags('LDFLAGS', '-lstdc++')

if platform.system() == 'Linux':
    ns.append_env_flags('LDFLAGS', '-lpthread', '-latomic')

ns.append_env_flags('LDFLAGS', '-L' + out_root, '-lnut')

## Dependencies

# Generate headers
for src in file_utils.iterfiles(src_root, '.h'):
    h = src
    ih = file_utils.chproot(src, src_root, header_root)
    ns.set_recipe(ih, file_op.copyfile)
    ns.add_chained_deps('@headers', ih, h)

program = join(out_root, 'test_nut' + ns['PROGRAM_SUFFIX'])
ns.set_recipe('@read_deps', compile_c.read_deps)
for src in file_utils.iterfiles(src_root, '.c', '.cpp'):
    c = src
    o = splitext(file_utils.chproot(src, src_root, obj_root))[0] + '.o'
    d = o + '.d'
    ns.add_dep(d, '@headers')
    ns.add_chained_deps(o, '@read_deps', d, c)
    ns.add_chained_deps(program, o, c)

ns.add_dep(program, join(out_root, 'libnut' + ns['SHARED_LIB_SUFFIX']))
ns.set_recipe(program, compile_c.link_program)
Esempio n. 4
0
## Flags
ns.append_env_flags('CPPFLAGS', '-I' + realpath(header_root))
ns.append_env_flags('CFLAGS', '-std=c11')

if platform.system() != 'Windows':
    ns.append_env_flags('CFLAGS', '-fPIC')
    ns.append_env_flags('CXXFLAGS', '-fPIC')

## Dependencies
so = join(out_root, 'libsqlite' + ns['SHARED_LIB_SUFFIX'])
ns.set_default_target(so)

# Generate headers
for src in file_utils.iterfiles(src_root, '.h'):
    h = src
    ih = file_utils.chproot(src, src_root, header_root)
    ns.set_recipe(ih, file_op.copyfile)
    ns.add_chained_deps('@headers', ih, h)

# Compile .c
ns.set_recipe('@read_c_deps', compile_c.read_deps)
for src in file_utils.iterfiles(src_root, '.c'):
    c = src
    o = file_utils.chproot(src, src_root, obj_root)[:-2] + '.o'
    d = o + '.d'
    ns.add_dep(d, '@headers')
    ns.add_chained_deps(o, '@read_c_deps', d, c)
    ns.add_chained_deps(so, o, c)


# clean