#!/usr/bin/python3

import os,sys,subprocess,math
from complib2 import *

import shutil

libname = 'amsculib2.linux64' #prefix static library name to generate
targetname = 'test' #create this executable when compiling tests
commonincdir = "../../linux64/include"
commonlibdir = "../../linux64/lib"
localbindir = "./bin_linux64"
cc = 'nvcc' #compiler
srcexts = ['.c','.cpp','.cu']
mainsrc = ['main.c','main.cpp','main.cu'] #ignore these files when compiling the static library

kwargs = dict()
include = "-I./include -I{}".format(commonincdir)
kwargs['include'] = include
#-dc flag: relocatable device code - needed for device functions to link in different "execution units"
kwargs['flags'] = "-dc"
kwargs['libdir'] = "-L{} -L{}".format(localbindir,commonlibdir)
kwargs['libflags'] = "-l{}".format(libname)
kwargs['linkerflags'] = ""
kwargs['recurse'] = True

#Pull required binary dynamic libraries to the bin folder
#shutil.copy('{}/libamsimg.dll.a'.format(commonlibdir),localbindir);
#shutil.copy('{}/libamsimg.dll'.format(commonlibdir),localbindir);
#shutil.copy('../../lib_winx64/glew32.dll','./bin_winx64');

#Designate source files for main test program
fsrc = ['./src/main.cu']
fobj = replaceexts(fsrc,'.o')

#Compile test programs
gs_compile_list(cc,fsrc,**kwargs)
gs_link_list(cc,list_to_sss(fobj),'{}/{}'.format(localbindir,targetname),**kwargs)
