-
Notifications
You must be signed in to change notification settings - Fork 4
/
createdsym.py
executable file
·93 lines (79 loc) · 2.25 KB
/
createdsym.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
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import time
import shutil
import commands
from stat import *
def dsymFilePath():
dsymPath = os.environ["BUILT_PRODUCTS_DIR"] + "/" + os.environ["PRODUCT_NAME"] + ".app.dSYM"
print 'dsymPath: ' + dsymPath
return dsymPath
def workDir():
currentDir = os.path.expanduser("~/Downloads/symbolicatetool") #os.path.dirname(os.path.realpath(__file__))
print "workDir: " + currentDir
return currentDir
def createDSymFile():
execName = os.environ["EXECUTABLE_NAME"]
execPath = os.environ["BUILT_PRODUCTS_DIR"] + "/" + os.environ["PRODUCT_NAME"] + ".app" + "/" + execName
outPath = os.environ["BUILT_PRODUCTS_DIR"] + "/" + os.environ["PRODUCT_NAME"] + ".dSYM"
cmdStr = "xcrun dsymutil " + execPath + " -o " + outPath + " 2> /dev/null"
print "dsymutil cmdStr: " + cmdStr
s, ret = commands.getstatusoutput(cmdStr)
print "cmdStr ret: " + str(s)
return outPath
def deleteDSymFile():
destDir = workDir() + "/build"
if not os.path.exists(destDir):
print "no destDir: " + destDir
return
files = []
for f in os.listdir(destDir):
if f.endswith(".dSYM"):
path = destDir + "/" + f
files.append(path)
print "files: ", files
for f in files:
if not os.path.exists(f):
continue
shutil.rmtree(f)
def copyDSymFile():
isGen = False
srcPath = dsymFilePath()
if not os.path.exists(srcPath):
isGen = True
srcPath = createDSymFile()
if not os.path.exists(srcPath):
print "source dSYM not found: " + srcPath
return
else:
print "source dSYM found: " + srcPath
destDir = workDir() + "/build"
execName = os.environ["EXECUTABLE_NAME"]
destPath = destDir + "/" + execName + ".app" + ".dSYM"
print "destPath: " + destPath
if os.path.exists(destPath):
print "destPath alread exists"
else:
shutil.copytree(srcPath, destPath)
if isGen:
shutil.rmtree(srcPath)
def canRun():
if os.environ["EFFECTIVE_PLATFORM_NAME"] == "-iphonesimulator":
print "is iphonesimulator build, just return"
return False
return True
if __name__ == '__main__':
print "createdsym.py main start"
if canRun():
print "can run"
try:
deleteDSymFile()
copyDSymFile()
except Exception, err:
print "warning: unhandled exception:"
print Exception, err
else:
print "cannot run"
print "createdsym.py main end"