• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/env python
2
3import os
4import shutil
5import stat
6import subprocess
7
8target_list = [
9    "asan",
10    # "cfi",  #no expection
11    # "fuzz", #undefined symbol, not build
12    "scudo",
13    "ubsan",
14    # "shadowcallstack", # __aarch64__
15    # "trace-pc-guard", # build_error
16]
17
18def check_out_dir():
19    if os.path.exists("output") and os.path.isdir("output"):
20        # print("Directory 'out' exist.")
21        shutil.rmtree("output")
22    else:
23        os.mkdir("output")
24        shutil.copy("runtest.sh",os.path.join(os.getcwd(),"output"))
25
26def copy_output(tar):
27    print("Start copying output executable...")
28    tar_out = os.path.join(tar, "exe")
29    copy_tar_path = os.path.join("output", tar)
30    ret = os.path.exists(tar_out) and os.path.isdir(tar_out)
31    if not ret:
32        print(tar_out + " not exists")
33    else:
34        shutil.move(tar_out,copy_tar_path)
35
36def start_build():
37    check_out_dir()
38    for target in target_list:
39        tar_dir = os.path.join(os.getcwd(), target)
40        build_file = os.path.join(tar_dir, "build.py")
41        # build_file = 'build.py'
42        if os.path.exists(build_file) and os.path.isfile(build_file):
43            if os.access(build_file, os.X_OK):
44                # print("[Permission Check]" + build_file + " X_OK")
45                p = subprocess.Popen(build_file, cwd=tar_dir).wait()
46                # if p == 0:
47                copy_output(target)
48            else:
49                print(build_file + " permission denied.")
50                break
51        else:
52            print(build_file + " not found.")
53            break
54
55if __name__ == "__main__":
56    start_build()
57