You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.2 KiB
Python

#!/usr/bin/python3
import os,sys,math
import subprocess
import shutil
from shutil import copytree
from amsbuildlib4 import *
libname = "amscimglib4.msvc64" #static library name to generate
binname = "tests.exe" #create this executable when compiling main.c or main.cpp
commondir = "../../winx64" #common directory to pul libraries and includes from
depdir = "./dependencies/winx64" #local pre-compiled dependency libraries and their includes
installdir = "../../winx64" #directory to install to when finished
builddir = "./build_msvc64"
doinstall = False #copies the build_output to the install dir when finished
cc = "cl" #compiler
cflags = "/MT /O2 /DEXPORT_TEMPLATEDLL"
libraries = "lib{}.lib".format(libname)
libdirs = "/LIBPATH:{} /LIBPATH:{}/lib /LIBPATH:{}/lib".format(builddir,commondir,depdir)
linkerflags = "/LD /link /IMPLIB:lib{}.lib".format(libname)
srcexts = [".c",".cpp"]
binsrc = ["main.c","main.cpp"] #ignore these files when compiling the static library
#keyword list to control the compilers/linkers
kwargs = dict()
include = "-I./include -I{}/include -I{}/include".format(commondir, depdir)
kwargs["include"] = include
kwargs["flags"] = cflags
kwargs["libdir"] = libdirs
kwargs["libflags"] = libraries
kwargs["linkerflags"] = linkerflags
kwargs["recurse"] = True
kwargs["objstore"] = "{}/objstore".format(builddir)
kwargs["searchincdirs"] = "./include"
kwargs["objext"] = ".obj"
#Find all source files, except the main project files
srcfiles = flist('./src',exts = srcexts, recurse=True)
srcfiles = except_contains(srcfiles,binsrc)
#compile all the source files in the list
#gs_compile_list(cc,files,**kwargs)
msvc_incremental_compile_list(cc,srcfiles,**kwargs)
#archive all the source files into a static library
objlist = flist(kwargs['objstore'],exts='.obj',recurse=True)
#msvc_lib_list(objlist,'{}/lib{}.lib'.format(builddir,libname))
msvc_link_list(list_to_sss(fobj),'{}/lib{}.dll'.format(builddir,libname),**kwargs)
if(doinstall):
#Copy a binary to the common bin folder
#Push any libraries to the common lib folder
shutil.copy('{}/lib/lib{}.lib'.format(builddir,libname),commondir)
#Copy include files to the common include folder
copytree('./include/',commondir+'/include/',dirs_exist_ok=True)