if platform.system() == 'Darwin': 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.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', '-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.append_env_flags('LDFLAGS', '-L' + out_root, '-lnut') # 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