-
Notifications
You must be signed in to change notification settings - Fork 153
/
fixpaths.py
30 lines (25 loc) · 1.25 KB
/
fixpaths.py
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
#!/usr/bin/python
#
# This tool is used to change include paths from absolute to relative
#
import sys, os
DRYRUN = 0
paths = { "/Users/cnoviello/STM32Toolchain/mastering-stm32/%s/include": ""../include"",
"/Users/cnoviello/STM32Toolchain/mastering-stm32/%s/system/include/stm32f4xx": ""../system/include/stm32f4xx"",
"/Users/cnoviello/STM32Toolchain/mastering-stm32/%s/system/include": ""../system/include"",
"/Users/cnoviello/STM32Toolchain/mastering-stm32/%s/system/include/cmsis/device": ""../system/include/cmsis/device"",
"/Users/cnoviello/STM32Toolchain/mastering-stm32/%s/system/include/cmsis": ""../system/include/cmsis""
}
print "Retrieving projects list...."
projectDirs = [d for d in os.listdir(os.getcwd()) if d.startswith("nucleo-")]
for projectDir in projectDirs:
print "Fixing %s..." % projectDir
cproject = open(os.path.join(os.getcwd(), projectDir, ".cproject"), "r+")
cprojectData = cproject.read()
for path in sorted(paths, reverse=True):
cprojectData = cprojectData.replace((path % projectDir), paths[path])
cproject.close()
if not DRYRUN:
cproject = open(os.path.join(os.getcwd(), projectDir, ".cproject"), "w+")
cproject.write(cprojectData)
cproject.close()