1#!/usr/bin/python 2 3import os 4import subprocess 5import sys 6import shutil 7 8pre_dir = os.path.abspath(os.path.dirname(os.getcwd())) 9config_dir = os.path.join(os.path.dirname(pre_dir),'script') 10sys.path.append(config_dir) 11 12from config_args import linux_args 13 14# Add asan compile options 15scudo_flags = [ "-DCMAKE_CXX_FLAGS=-fsanitize=scudo" ] 16 17build_args=[] 18build_args.extend(linux_args) 19build_args.extend(scudo_flags) 20 21def rm_build(): 22 if os.path.exists("build") and os.path.isdir("build"): 23 shutil.rmtree("build") 24 while True: 25 if not os.path.exists("build"): 26 break 27 28def build_linux(): 29 rm_build() 30 os.mkdir("build") 31 build_cmd = "cmake " + (" ".join(build_args))+ " .." 32 print(build_cmd) 33 res1 = subprocess.Popen(build_cmd,cwd='build',shell=True).wait() 34 # print(res1) 35 res2 = subprocess.Popen('make',cwd='build',shell=True).wait() 36 # print(res2) 37 rm_build() 38 39if __name__ == '__main__': 40 build_linux() 41