1 | #!/usr/bin/env xonsh |
2 |
|
3 | import os |
4 |
|
5 | SCRIPT_SOURCE_DIR = os.path.realpath(os.path.dirname(__file__)) |
6 | cd @(SCRIPT_SOURCE_DIR) |
7 | ARGS = "".join($ARGS).lower() |
8 |
|
9 | if not $(which idf.py): |
10 | if os.path.exists(f"{os.path.expanduser('~')}/esp/esp-idf/export.sh"): |
11 | print("Running esp-idf/export.sh") |
12 | source-bash $HOME/esp/esp-idf/export.sh |
13 | $PATH=$PATH |
14 | else: |
15 | print("idf.py not found") |
16 | os.exit(1) |
17 | else: |
18 | print("idf.py already on path") |
19 |
|
20 | mkdir -p @(SCRIPT_SOURCE_DIR)/build |
21 |
|
22 | if "b" in ARGS: |
23 |
|
24 | cd @(SCRIPT_SOURCE_DIR)/build |
25 |
|
26 | if "d" in ARGS: |
27 | print("building in DEV_MODE") |
28 | cmake .. -G Ninja -DDEV_MODE=1 |
29 | else: |
30 | print("building") |
31 | cmake .. -G Ninja |
32 |
|
33 | ninja |
34 |
|
35 | cd @(SCRIPT_SOURCE_DIR) |
36 |
|
37 | if "f" in ARGS: |
38 | idf.py flash -p /dev/ttyUSB0 |
39 |
|
40 | if "m" in ARGS: |
41 | idf.py monitor -p /dev/ttyUSB0 |
42 |
|