#!/usr/bin/python3

import os,sys,subprocess,math
from complib2 import *
from complib3 import gs_incremental_compile, gs_incremental_compile_list

import shutil
from shutil import copytree

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

kwargs = dict()
include = "-I./include -I{}".format(commonincdir)
kwargs['include'] = include
kwargs['flags'] = "-dc"
kwargs['libdir'] = "-L{} -L{}".format(localbindir,commonlibdir)
kwargs['libflags'] = "-llib{} -llibamsculib2.msvc64".format(libname)
kwargs['linkerflags'] = ""
kwargs['recurse'] = True
kwargs['objstore'] = "./objstore"
kwargs['searchincdirs'] = ['./include']

#-lamsmathlib3.linux64 -lamsstring3.linux64 -lamsmatrix_cpp.linux64 -llapack -lblas -lgfortran -lamsmathutilthread.linux64 -lamsmathutil2.linux64

#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)
