forked from kylemcdonald/ofxFaceTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-projects.py
57 lines (45 loc) · 1.96 KB
/
update-projects.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
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
#!/bin/python
import glob, re, shutil, fileinput, os
def toUpper(pattern):
return pattern.group(1).upper()
def replaceInFile(filename, pattern, replacement):
for line in fileinput.FileInput(filename, inplace=1):
print re.sub(pattern, replacement, line),
sourceProjectName = "EmptyExample"
sourceModelPath = "libs/FaceTracker/model/"
# windows code::blocks
sourceCbp = "example-empty/EmptyExample.cbp"
sourceWorkspace = "example-empty/EmptyExample.workspace"
# xcode osx
sourceXcconfig = "example-empty/Project.xcconfig"
sourcePlist = "example-empty/openFrameworks-Info.plist"
sourcePbxproj = "example-empty/EmptyExample.xcodeproj/project.pbxproj"
examples = glob.glob("example*")
for example in examples:
if example != "example-empty":
sansExample = re.sub("^example", "", example)
upper = re.sub("-([a-z])", toUpper, sansExample)
targetProjectName = upper + "Example"
# windows code::blocks
targetCbp = "{0}/{1}.cbp".format(example, targetProjectName)
targetWorkspace = "{0}/{1}.workspace".format(example, targetProjectName)
shutil.copy(sourceCbp, targetCbp)
shutil.copy(sourceWorkspace, targetWorkspace)
replaceInFile(targetCbp, sourceProjectName, targetProjectName)
replaceInFile(targetWorkspace, sourceProjectName, targetProjectName)
# xcode osx
targetXcodeproj = "{0}/{1}.xcodeproj".format(example, targetProjectName)
targetPbxproj = "{0}/project.pbxproj".format(targetXcodeproj)
shutil.copy(sourceXcconfig, example)
shutil.copy(sourcePlist, example)
if not os.path.exists(targetXcodeproj):
os.mkdir(targetXcodeproj)
shutil.copy(sourcePbxproj, targetPbxproj)
replaceInFile(targetPbxproj, sourceProjectName, targetProjectName)
print "Updated " + targetProjectName + " project."
# model data
targetModelPath = example + "/bin/data/model/"
try: shutil.rmtree(targetModelPath)
except: pass
shutil.copytree(sourceModelPath, targetModelPath)
print "Copied model data into " + targetModelPath