Using two compiler in one sconscript (nvcc, g++)
How can I use both of the compiler in one sconscript?? Some of the details of the sconscript is shown below:
-
I have a .cu file and with nvcc -c test.cu, I could generate a .o file. How can I import this .o file to the existing sconscript, so that the .o file can be read?
-
I'm also trying to use both the compiler in one sconscript file. I just couldn't figure out how to execute the gcc and nvcc in one sconsript.
Import('env')
env = env.Clone()
env['CC'] = ['gcc']
env['CXX'] = ['g++-6']
env['CPPPATH'] = []
env['CCFLAGS'] = []
env['LIBPATH'] = []
env['LIBS'] = []
ldflags = []
env['CCFLAGS'] += ['-std=c++11']
import os
src_files = []
for root, dirs, files in os.walk("./src", topdown=False):
for dir in dirs:
src_files += Glob("%s/*.cpp" % os.path.join(root, dir))
obj_dir = 'build/%s/%s' % (build_dir, second_build_dir)
objs = []
for src_file in src_files:
target_file = str(src_file).replace('src', obj_dir, 1)
target_file = target_file.replace('cpp', 'o')
objs += env.Object(target_file, src_file)
# build targets
post_fix = 'st' if env['single_thread'] else 'mt'
for main_cpp in Glob('./target/*cpp'):
name = main_cpp.name[:-4]
main_obj = './%s/target/%s.o' % (obj_dir, name)
main_bin = './build/%s/%s_%s' % (build_dir, name, post_fix)
env.Object(main_obj, main_cpp)
env.Program(main_bin, objs + [main_obj])
Comments
Post a Comment