-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwscript
91 lines (84 loc) · 2.96 KB
/
wscript
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python
# encoding: utf-8
from __future__ import print_function
import os.path
import os
import sys
import subprocess
import json
import fnmatch
import shutil
sys.path.insert(0, 'ardupilot/Tools/ardupilotwaf/')
sys.path.insert(0, '.')
import waflib.extras.compat15
import ardupilotwaf
import boards
from waflib.Configure import conf
from waflib import Context, Logs, Task, Utils
def copy_local_hwdef():
# find all folders containing hwdef.dat in current directory
hwdef_folders = []
dirname, dirlist, filenames = next(os.walk('.'))
for dir in dirlist:
if os.path.isfile(os.path.join(dirname, dir, 'hwdef.dat')):
hwdef_folders.append(dir)
## copy all the directories to the ardupilot directory
for dir in hwdef_folders:
# ensure dir is not .
if dir == '.':
continue
# check if symlink exists
realpath = os.path.realpath(os.path.join(dirname, dir))
if os.path.islink(os.path.join('ardupilot/libraries/AP_HAL_ChibiOS/hwdef', dir)):
# check if symlink points to correct directory
if os.path.realpath(os.path.join('ardupilot/libraries/AP_HAL_ChibiOS/hwdef', dir)) == realpath:
continue
else:
os.remove(os.path.join('ardupilot/libraries/AP_HAL_ChibiOS/hwdef', dir))
elif os.path.isdir(os.path.join('ardupilot/libraries/AP_HAL_ChibiOS/hwdef', dir)):
shutil.rmtree(os.path.join('ardupilot/libraries/AP_HAL_ChibiOS/hwdef', dir))
# create symlink to directory
os.symlink(realpath, os.path.join('ardupilot/libraries/AP_HAL_ChibiOS/hwdef', dir))
# create symlinks to files inside bootloader
dirname, dirlist, filenames = next(os.walk('bootloaders'))
for file in filenames:
realpath = os.path.realpath(os.path.join(dirname, file))
# remove file if it exists
if os.path.isfile(os.path.join('ardupilot/Tools/bootloaders', file)):
os.remove(os.path.join('ardupilot/Tools/bootloaders', file))
# copy file
shutil.copy(realpath, os.path.join('ardupilot/Tools/bootloaders', file))
def options(opt):
opt.parser.set_defaults(top='ardupilot')
copy_local_hwdef()
os.chdir('ardupilot')
try:
opt.recurse('ardupilot/')
except Exception as e:
os.chdir('..')
raise e
os.chdir('..')
def configure(cfg):
copy_local_hwdef()
os.chdir('ardupilot')
try:
cfg.recurse('ardupilot/')
except Exception as e:
os.chdir('..')
raise e
os.chdir('..')
cfg.load('wscript_git')
def build(bld):
copy_local_hwdef()
bld.env = bld.env_of_name(bld.env.BOARD)
bld.bldnode = bld.bldnode.make_node(bld.env.BOARD)
os.chdir('ardupilot')
bld.recurse('ardupilot/')
os.chdir('..')
# remove AP_Periph from build
bld.recurse('AP_Periph/')
bld.recurse('AP_Bootloader/')
def list_boards(ctx):
os.chdir('ardupilot')
print(*boards.get_boards_names())
os.chdir('..')