|
6 | 6 | import sys |
7 | 7 |
|
8 | 8 | REPLACE_LIST = [ |
9 | | - ["from", "to"] |
| 9 | + ["from", "to"] |
10 | 10 | ] |
11 | 11 |
|
12 | 12 | STDK_REF_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
17 | 17 |
|
18 | 18 |
|
19 | 19 | def print_usage(): |
20 | | - print("") |
21 | | - print("Usage: python setup.py [BSP_NAME]") |
22 | | - print("--------------------------------------------------") |
23 | | - for dir in os.listdir(os.path.join(STDK_REF_PATH, "bsp")): |
24 | | - if (os.path.isdir(os.path.join(STDK_REF_PATH, "bsp", dir)) |
25 | | - and os.path.isdir(os.path.join(STDK_REF_PATH, "tools", dir))): |
26 | | - print(" ex) python setup.py " + dir) |
27 | | - print("") |
| 20 | + print("") |
| 21 | + print("Usage: python setup.py [BSP_NAME]") |
| 22 | + print("--------------------------------------------------") |
| 23 | + for dir in os.listdir(os.path.join(STDK_REF_PATH, "tools")): |
| 24 | + dirpath = os.path.join(STDK_REF_PATH, "tools", dir) |
| 25 | + if (os.path.exists(os.path.join(dirpath, "setup_"+ dir + ".py")) or |
| 26 | + os.path.exists(os.path.join(dirpath, "setup_"+ dir + ".sh"))): |
| 27 | + print(" ex) python setup.py " + dir) |
| 28 | + print("") |
28 | 29 |
|
29 | 30 |
|
30 | 31 | def find_setup_script(bsp_name): |
31 | | - if os.path.exists(os.path.join("tools", bsp_name, "setup_" + bsp_name + ".py")): |
32 | | - return "python " + os.path.join("tools", bsp_name, "setup_" + bsp_name + ".py") |
33 | | - if "SHELL" in os.environ: |
34 | | - if os.path.exists(os.path.join("tools", bsp_name, "setup_" + bsp_name + ".sh")): |
35 | | - return os.path.join("tools", bsp_name, "setup_" + bsp_name + ".sh") |
36 | | - print("Fail to find setup script") |
37 | | - print_usage() |
38 | | - exit(1) |
| 32 | + if os.path.exists(os.path.join("tools", bsp_name, "setup_" + bsp_name + ".py")): |
| 33 | + return "python " + os.path.join("tools", bsp_name, "setup_" + bsp_name + ".py") |
| 34 | + if "SHELL" in os.environ: |
| 35 | + if os.path.exists(os.path.join("tools", bsp_name, "setup_" + bsp_name + ".sh")): |
| 36 | + return os.path.join("tools", bsp_name, "setup_" + bsp_name + ".sh") |
| 37 | + print("Fail to find setup script") |
| 38 | + print_usage() |
| 39 | + exit(1) |
39 | 40 |
|
40 | 41 | def update_submodule(path): |
41 | | - cwd = os.getcwd() |
42 | | - try: |
43 | | - print("Update submodule " + path) |
44 | | - os.system("git submodule sync " + path) |
45 | | - os.system("git submodule init " + path) |
46 | | - os.system("git submodule update " + path) |
47 | | - os.chdir(path) |
48 | | - os.system("git reset --hard HEAD") |
49 | | - except: |
50 | | - print("Failed to update submodule " + path) |
51 | | - os.chdir(cwd) |
| 42 | + cwd = os.getcwd() |
| 43 | + try: |
| 44 | + print("Update submodule " + path) |
| 45 | + os.system("git submodule sync " + path) |
| 46 | + os.system("git submodule init " + path) |
| 47 | + os.system("git submodule update " + path) |
| 48 | + os.chdir(path) |
| 49 | + os.system("git reset --hard HEAD") |
| 50 | + except: |
| 51 | + print("Failed to update submodule " + path) |
| 52 | + os.chdir(cwd) |
52 | 53 |
|
53 | 54 | update_submodule(STDK_CORE_PATH) |
54 | 55 |
|
55 | 56 | if len(sys.argv) == 1: |
56 | | - print_usage() |
57 | | - exit(1) |
| 57 | + print_usage() |
| 58 | + exit(1) |
58 | 59 |
|
59 | 60 | BSP_NAME = sys.argv[1] |
60 | 61 | EXTRA_ARGS = sys.argv[2:] |
61 | 62 |
|
62 | 63 | for item in REPLACE_LIST: |
63 | | - if BSP_NAME == item[0]: |
64 | | - BSP_NAME = item[1] |
| 64 | + if BSP_NAME == item[0]: |
| 65 | + BSP_NAME = item[1] |
65 | 66 |
|
66 | 67 | setup_script = find_setup_script(BSP_NAME) |
67 | 68 |
|
68 | 69 | BSP_PATH = os.path.join(STDK_REF_PATH, "bsp", BSP_NAME) |
69 | 70 | if BSP_PATH and os.path.isdir(BSP_PATH): |
70 | | - update_submodule(BSP_PATH) |
| 71 | + update_submodule(BSP_PATH) |
71 | 72 |
|
72 | 73 | setup_cmd = setup_script + " " + BSP_NAME |
73 | 74 | for args in EXTRA_ARGS: |
74 | | - setup_cmd = setup_cmd + " " + args |
| 75 | + setup_cmd = setup_cmd + " " + args |
75 | 76 | ret_val = os.system(setup_cmd) |
76 | 77 | if ret_val: |
77 | | - print_usage() |
78 | | - exit(1) |
| 78 | + print_usage() |
| 79 | + exit(1) |
79 | 80 | else: |
80 | | - print("") |
81 | | - print("======================================================================") |
82 | | - print("") |
83 | | - print("To use SmartThings Device SDK build script, run following command:") |
84 | | - print("") |
85 | | - print(" python build.py " + BSP_NAME + " [APP_NAME]") |
86 | | - print("") |
| 81 | + print("") |
| 82 | + print("======================================================================") |
| 83 | + print("") |
| 84 | + print("To use SmartThings Device SDK build script, run following command:") |
| 85 | + print("") |
| 86 | + print(" python build.py " + BSP_NAME + " [APP_NAME]") |
| 87 | + print("") |
0 commit comments