#!/usr/bin/python3 import os,sys,subprocess,math from complib2 import * import shutil from distutils.dir_util import copy_tree as copy_tree #this version does overwrites libname = 'amsclil1.mingw64' #prefix static library name to generate targetname = 'tests.exe' #create this executable when compiling tests commonincdir = "../../winx64/include" commonlibdir = "../../winx64/lib" localbindir = "./bin_winx64" cc = 'x86_64-w64-mingw32-gcc' #compiler srcexts = ['.c','.cpp'] mainsrc = ['main.c'] #ignore these files when compiling the static library kwargs = dict() include = "-I./include -I{}".format(commonincdir) kwargs['include'] = include kwargs['flags'] = "-fPIC -O3" kwargs['libdir'] = "-L{} -L{}".format(localbindir,commonlibdir) kwargs['libflags'] = "-l{}".format(libname) kwargs['linkerflags'] = "-static -static-libgcc -Wl,-rpath=." kwargs['recurse'] = True #find all source files, except the main project files files = flist('./src',exts = srcexts, recurse=True) files = except_contains(files,mainsrc) objfiles = replaceexts(files,'.o') objfiles_sss = list_to_sss(objfiles) #compile all the source files in the list gs_compile_list(cc,files,**kwargs) #archive all the source files into a static library ar_list(objfiles,'{}/lib{}.a'.format(localbindir,libname)) #Push any libraries to the common lib folder shutil.copy('{}/lib{}.a'.format(localbindir,libname),commonlibdir) #Copy include files to the common include folder copy_tree('./include/',commonincdir+'/')