-
Notifications
You must be signed in to change notification settings - Fork 39
/
CreatePackage.py
81 lines (67 loc) · 2.76 KB
/
CreatePackage.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
76
77
78
79
80
81
import os
import sys
import re
import platform
import zipfile
import codecs
def PrintInfo (message):
print ('INFO: ' + message)
def PrintError (message):
print ('ERROR: ' + message)
def GetVersionFromCMakeLists (cMakeListsPath):
file = codecs.open (cMakeListsPath, 'r', 'utf-8')
content = file.read ()
file.close ()
match1 = re.search (r'set \(VSE_VERSION_1 ([0-9]+)\)', content)
match2 = re.search (r'set \(VSE_VERSION_2 ([0-9]+)\)', content)
match3 = re.search (r'set \(VSE_VERSION_3 ([0-9]+)\)', content)
return ".".join ([match1.group (1), match2.group (1), match3.group (1)])
def FindPDB (buildDir, moduleName, buildType):
pdbPath = os.path.join (buildDir, moduleName + '.dir', buildType, moduleName + '.pdb')
if os.path.exists (pdbPath):
return pdbPath
pdbPath = os.path.join (buildDir, buildType, moduleName + '.pdb')
if os.path.exists (pdbPath):
return pdbPath
pdbPath = os.path.join (buildDir, buildType, moduleName + 'Debug.pdb')
if os.path.exists (pdbPath):
return pdbPath
return None
def Main (argv):
currentDir = os.path.dirname (os.path.abspath (__file__))
os.chdir (currentDir)
if len (argv) != 4:
print ('usage: CreatePackage.py <devKitDir> <packageName> <buildType>')
return 1
devKitDir = argv[1]
packageName = argv[2]
buildType = argv[3]
cMakeListsPath = os.path.abspath ('CMakeLists.txt')
version = GetVersionFromCMakeLists (cMakeListsPath)
buildDir = os.path.abspath ('Build')
packagePath = os.path.join (buildDir, 'Package')
if not os.path.exists (packagePath):
os.makedirs (packagePath)
zipPath = os.path.abspath (os.path.join (packagePath, 'VisualScriptEngine_V' + version + '_' + packageName + '_' + buildType + '_x64.zip'))
requiredFolders = [
os.path.abspath (os.path.join (devKitDir, 'include')),
os.path.abspath (os.path.join (devKitDir, 'lib')),
os.path.abspath (os.path.join (devKitDir, 'source')),
os.path.abspath (os.path.join (devKitDir, 'localization'))
]
zip = zipfile.ZipFile (zipPath, mode = 'w', compression = zipfile.ZIP_DEFLATED)
for folder in requiredFolders:
for file in os.listdir (folder):
zip.write (os.path.join (folder, file), os.path.join (os.path.basename (folder), file))
if platform.system () == 'Windows':
if buildType in ['Debug', 'RelWithDebInfo']:
libPath = os.path.abspath (os.path.join (devKitDir, 'lib'))
for moduleName in ['NodeEngine', 'NodeUIEngine', 'BuiltInNodes', 'WindowsAppSupport']:
pdbPath = FindPDB (buildDir, moduleName, buildType)
zip.write (pdbPath, os.path.join (os.path.basename (libPath), moduleName + '.pdb'))
outputPath = os.path.abspath (os.path.join (buildDir, buildType))
for testFile in ['WindowsReferenceApp.exe']:
zip.write (os.path.join (outputPath, testFile), os.path.join ('testapp', testFile))
zip.close ()
return 0
sys.exit (Main (sys.argv))