-
Notifications
You must be signed in to change notification settings - Fork 276
/
update-projects.py
76 lines (62 loc) · 2.76 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/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"
# windows code::blocks
sourceCbp = "example-empty/EmptyExample.cbp"
sourceWorkspace = "example-empty/EmptyExample.workspace"
# windows vs2010
sourceSln = "example-empty/EmptyExample.sln"
sourceVcxproj = "example-empty/EmptyExample.vcxproj"
sourceVcxprojFilters = "example-empty/EmptyExample.vcxproj.filters"
sourceVcxprojUser = "example-empty/EmptyExample.vcxproj.user"
# xcode osx
sourceXcconfig = "example-empty/Project.xcconfig"
sourcePlist = "example-empty/openFrameworks-Info.plist"
sourceXcodeproj = "example-empty/ofApp.xcodeproj/"
# linux
sourceMakefile = "example-empty/Makefile"
sourceConfigs = "example-empty/config.make"
sourceAddons = "example-empty/addons.make"
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"
#linux
targetDir = "{0}/".format(example, targetProjectName)
emptyDir = "example-empty"
shutil.copy(sourceMakefile, targetDir)
shutil.copy(sourceConfigs, targetDir)
shutil.copy(sourceAddons, targetDir)
# 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)
# windows vs2010
targetSln = "{0}/{1}.sln".format(example, targetProjectName)
targetVcxproj = "{0}/{1}.vcxproj".format(example, targetProjectName)
targetVcxprojFilters = "{0}/{1}.vcxproj.filters".format(example, targetProjectName)
targetVcxprojUser = "{0}/{1}.vcxproj.user".format(example, targetProjectName)
shutil.copy(sourceSln, targetSln)
shutil.copy(sourceVcxproj, targetVcxproj)
shutil.copy(sourceVcxprojFilters, targetVcxprojFilters)
shutil.copy(sourceVcxprojUser, targetVcxprojUser)
replaceInFile(targetSln, sourceProjectName, targetProjectName)
replaceInFile(targetVcxproj, sourceProjectName, targetProjectName)
# xcode osx
targetXcodeproj = "{0}/ofApp.xcodeproj".format(example)
shutil.copy(sourceXcconfig, example)
shutil.copy(sourcePlist, example)
try: shutil.rmtree(targetXcodeproj)
except: pass
shutil.copytree(sourceXcodeproj, targetXcodeproj)
print "Copied into " + targetProjectName + "."