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 15asan_flags = [ "-DCMAKE_CXX_FLAGS=-fsanitize=address" ] 16 17build_args=[] 18build_args.extend(linux_args) 19build_args.extend(asan_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 # os.chdir("build") 32 build_cmd = "cmake " + (" ".join(build_args))+ " .." 33 print(build_cmd) 34 res1 = subprocess.Popen(build_cmd,cwd='build',shell=True).wait() 35 # print(res1) 36 res2 = subprocess.Popen('make',cwd='build',shell=True).wait() 37 # print(res2) 38 rm_build() 39 40if __name__ == '__main__': 41 build_linux() 42