piosetup.py 683 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import argparse
import os

parser = argparse.ArgumentParser(
    description='''\
Utility for building Arduino IDE based projects with PlatformIO''')
parser.add_argument('-p', '--project-dir', required=True)
parser.add_argument('-d', '--pio-dir', default='.pio')
parser.add_argument('-b', '--board', default='uno')
args = vars(parser.parse_args())

args['project_dir'] = os.path.abspath(args['project_dir'])

SETUP_SCRIPT =\
"""\
mkdir -p {pio_dir}
rm -rf {pio_dir}/src
platformio init --project-dir {pio_dir} --board {board}
cp -rf {project_dir}/* {pio_dir}/src/
cd {pio_dir} && platformio run -t upload
""".format(**args)

print(args)
print(SETUP_SCRIPT)

os.system(SETUP_SCRIPT)