-
Notifications
You must be signed in to change notification settings - Fork 398
Expand file tree
/
Copy pathupdate_makefile_targets.py
More file actions
executable file
·36 lines (34 loc) · 1.34 KB
/
update_makefile_targets.py
File metadata and controls
executable file
·36 lines (34 loc) · 1.34 KB
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
#!/usr/bin/env python3
import glob
for makefile in glob.glob('src*/makefile'):
print('Processing', makefile)
download_target = 'download: '
check_target = 'check: '
clean_target = 'clean: '
download_line = None
check_line = None
clean_line = None
with open(makefile, 'r+') as f:
lines = f.readlines()
for i in range(len(lines)):
if not lines[i].strip().startswith('#') and 'curl' in lines[i].lower() and ':' in lines[i-1]:
download_target += lines[i-1].partition(':')[0] + ' '
if lines[i].lower().startswith('check-') and ':' in lines[i]:
check_target += lines[i].partition(':')[0] + ' '
if lines[i].lower().startswith('clean-') and ':' in lines[i]:
clean_target += lines[i].partition(':')[0] + ' '
if 'check:' in lines[i]:
check_line = i
if 'clean:' in lines[i]:
clean_line = i
if 'download:' in lines[i]:
download_line = i
if download_line:
lines[download_line] = download_target.rstrip() + '\n'
if check_line:
lines[check_line] = check_target.rstrip() + '\n'
if clean_line:
lines[clean_line] = clean_target.rstrip() + '\n'
f.seek(0)
f.writelines(lines)
f.truncate()