1
- using System . Collections ;
2
- using UnityEngine ;
1
+ using System ;
2
+ using System . IO ;
3
3
using UnityEditor ;
4
4
using UnityEditor . Callbacks ;
5
- using System . IO ;
6
- using System ;
5
+ using UnityEngine ;
7
6
8
- public class AutoCopySymbolsPostprocessor
7
+ namespace Unity . Editor
9
8
{
10
- [ PostProcessBuild ( ) ]
11
- public static void OnPostprocessBuild ( BuildTarget target , string pathToBuiltProject )
12
- {
13
- if ( target == BuildTarget . Android )
14
- PostProcessAndroidBuild ( pathToBuiltProject ) ;
15
- }
16
-
17
- public static void PostProcessAndroidBuild ( string pathToBuiltProject )
18
- {
19
- CopyAndroidSymbols ( pathToBuiltProject , PlayerSettings . Android . targetArchitectures ) ;
20
- }
21
-
22
- public static void CopyAndroidSymbols ( string pathToBuiltProject , AndroidArchitecture targetDevice )
9
+ public class AutoCopySymbolsPostprocessor
23
10
{
24
- var startTime = DateTime . Now ;
25
- Debug . Log ( nameof ( CopyAndroidSymbols ) + " Start " ) ;
26
- string buildName = Path . GetFileNameWithoutExtension ( pathToBuiltProject ) ;
27
- string symbolsDir = buildName + "_Symbols/" ;
28
- var abi_v7a = "armeabi-v7a/" ;
29
- var abi_v8a = "arm64-v8a/" ;
30
-
31
- CreateDir ( symbolsDir ) ;
32
-
33
- if ( ( PlayerSettings . Android . targetArchitectures & AndroidArchitecture . ARM64 ) > 0 )
11
+ [ PostProcessBuild ( ) ]
12
+ public static void OnPostprocessBuild ( BuildTarget target , string pathToBuiltProject )
34
13
{
35
- var dir = CopySymbols ( symbolsDir , abi_v8a ) ;
36
- GenerateAllSymbols ( dir ) ;
14
+ if ( target == BuildTarget . Android )
15
+ PostProcessAndroidBuild ( pathToBuiltProject ) ;
37
16
}
38
17
39
- if ( ( PlayerSettings . Android . targetArchitectures & AndroidArchitecture . ARMv7 ) > 0 )
18
+ public static void PostProcessAndroidBuild ( string pathToBuiltProject )
40
19
{
41
- var dir = CopySymbols ( symbolsDir , abi_v7a ) ;
42
- GenerateAllSymbols ( dir ) ;
20
+ CopyAndroidSymbols ( pathToBuiltProject , PlayerSettings . Android . targetArchitectures ) ;
43
21
}
44
22
23
+ public static void CopyAndroidSymbols ( string pathToBuiltProject , AndroidArchitecture targetDevice )
24
+ {
25
+ var startTime = DateTime . Now ;
26
+ Debug . Log ( nameof ( CopyAndroidSymbols ) + " Start " ) ;
27
+ string buildName = Path . GetFileNameWithoutExtension ( pathToBuiltProject ) ;
28
+ string symbolsDir = buildName + "_Symbols/" ;
29
+ var abi_v7a = "armeabi-v7a/" ;
30
+ var abi_v8a = "arm64-v8a/" ;
31
+
32
+ CreateDir ( symbolsDir ) ;
33
+
34
+ if ( ( PlayerSettings . Android . targetArchitectures & AndroidArchitecture . ARM64 ) > 0 )
35
+ {
36
+ var dir = CopySymbols ( symbolsDir , abi_v8a ) ;
37
+ GenerateAllSymbols ( dir ) ;
38
+ }
39
+
40
+ if ( ( PlayerSettings . Android . targetArchitectures & AndroidArchitecture . ARMv7 ) > 0 )
41
+ {
42
+ var dir = CopySymbols ( symbolsDir , abi_v7a ) ;
43
+ GenerateAllSymbols ( dir ) ;
44
+ }
45
+
45
46
#if UNITY_2018_1_OR_NEWER
46
47
47
48
#else
@@ -51,100 +52,100 @@ public static void CopyAndroidSymbols(string pathToBuiltProject, AndroidArchitec
51
52
GenerateAllSymbols ( dir ) ;
52
53
}
53
54
#endif
54
- Debug . Log ( nameof ( CopyAndroidSymbols ) + " End ==>" + ( DateTime . Now - startTime ) . TotalSeconds ) ;
55
- }
55
+ Debug . Log ( nameof ( CopyAndroidSymbols ) + " End ==>" + ( DateTime . Now - startTime ) . TotalSeconds ) ;
56
+ }
56
57
57
- const string LibPath = "/../Temp/StagingArea/libs/" ;
58
+ const string LibPath = "/../Temp/StagingArea/libs/" ;
58
59
59
- private static string CopySymbols ( string symbolsDir , string abi )
60
- {
61
- //const string abi = "arm64-v8a/";
62
- string sourceDir = Application . dataPath + LibPath + abi ;
63
- string abiDir = symbolsDir + abi ;
64
- CreateDir ( abiDir ) ;
65
- MoveAllFiles ( sourceDir , abiDir ) ;
66
- // "".Print("CopySymbols", symbolsDir, abi);
67
- return abiDir ;
68
- }
60
+ private static string CopySymbols ( string symbolsDir , string abi )
61
+ {
62
+ //const string abi = "arm64-v8a/";
63
+ string sourceDir = Application . dataPath + LibPath + abi ;
64
+ string abiDir = symbolsDir + abi ;
65
+ CreateDir ( abiDir ) ;
66
+ MoveAllFiles ( sourceDir , abiDir ) ;
67
+ // "".Print("CopySymbols", symbolsDir, abi);
68
+ return abiDir ;
69
+ }
69
70
70
- public static void CreateDir ( string path )
71
- {
72
- if ( Directory . Exists ( path ) )
73
- Directory . Delete ( path , true ) ;
71
+ public static void CreateDir ( string path )
72
+ {
73
+ if ( Directory . Exists ( path ) )
74
+ Directory . Delete ( path , true ) ;
74
75
75
- Directory . CreateDirectory ( path ) ;
76
- }
76
+ Directory . CreateDirectory ( path ) ;
77
+ }
77
78
78
- public static void MoveAllFiles ( string src , string dst )
79
- {
80
- DirectoryInfo srcinfo = new DirectoryInfo ( src ) ;
81
- if ( srcinfo . Exists )
79
+ public static void MoveAllFiles ( string src , string dst )
82
80
{
83
- dst = dst . Replace ( "\\ " , "/" ) ;
84
- FileInfo [ ] files = srcinfo . GetFiles ( "*.*" ) ;
85
- for ( int i = 0 ; i < files . Length ; i ++ )
81
+ DirectoryInfo srcinfo = new DirectoryInfo ( src ) ;
82
+ if ( srcinfo . Exists )
86
83
{
87
- if ( File . Exists ( dst + "/" + files [ i ] . Name ) )
84
+ dst = dst . Replace ( "\\ " , "/" ) ;
85
+ FileInfo [ ] files = srcinfo . GetFiles ( "*.*" ) ;
86
+ for ( int i = 0 ; i < files . Length ; i ++ )
88
87
{
89
- File . Delete ( dst + "/" + files [ i ] . Name ) ;
90
- }
88
+ if ( File . Exists ( dst + "/" + files [ i ] . Name ) )
89
+ {
90
+ File . Delete ( dst + "/" + files [ i ] . Name ) ;
91
+ }
91
92
92
- File . Copy ( files [ i ] . FullName , dst + "/" + files [ i ] . Name ) ;
93
+ File . Copy ( files [ i ] . FullName , dst + "/" + files [ i ] . Name ) ;
94
+ }
93
95
}
94
96
}
95
- }
96
97
97
- public static void GenerateAllSymbols ( string symbolsdir )
98
- {
99
- DirectoryInfo srcinfo = new DirectoryInfo ( symbolsdir ) ;
100
- if ( srcinfo . Exists )
98
+ public static void GenerateAllSymbols ( string symbolsdir )
101
99
{
102
- string cmd = Application . dataPath ;
103
- string soPath = Application . dataPath ;
104
- string jdk = EditorPrefs . GetString ( "JdkPath" ) ;
105
- if ( Application . platform == RuntimePlatform . OSXEditor )
106
- {
107
- // cmd += "/../BuglySymbol/buglySymbolAndroid.jar";
108
- cmd += "/../BuglySymbol/buglyqq-upload-symbol.jar" ;
109
- jdk += "/bin/java" ;
110
- soPath += "/../" + symbolsdir ;
111
- }
112
- else if ( Application . platform == RuntimePlatform . WindowsEditor )
100
+ DirectoryInfo srcinfo = new DirectoryInfo ( symbolsdir ) ;
101
+ if ( srcinfo . Exists )
113
102
{
114
- // cmd += "/../BuglySymbol/buglySymbolAndroid.jar";
115
- cmd += "/../BuglySymbol/buglyqq-upload-symbol.jar" ;
116
- cmd = cmd . Replace ( "/" , "\\ " ) ;
117
- jdk = jdk . Replace ( "/" , "\\ " ) + "\\ bin\\ java.exe" ;
118
- soPath += "/../" + symbolsdir ;
119
- soPath = soPath . Replace ( "/" , "\\ " ) ;
120
- }
103
+ string cmd = Application . dataPath ;
104
+ string soPath = Application . dataPath ;
105
+ string jdk = EditorPrefs . GetString ( "JdkPath" ) ;
106
+ if ( Application . platform == RuntimePlatform . OSXEditor )
107
+ {
108
+ // cmd += "/../BuglySymbol/buglySymbolAndroid.jar";
109
+ cmd += "/../BuglySymbol/buglyqq-upload-symbol.jar" ;
110
+ jdk += "/bin/java" ;
111
+ soPath += "/../" + symbolsdir ;
112
+ }
113
+ else if ( Application . platform == RuntimePlatform . WindowsEditor )
114
+ {
115
+ // cmd += "/../BuglySymbol/buglySymbolAndroid.jar";
116
+ cmd += "/../BuglySymbol/buglyqq-upload-symbol.jar" ;
117
+ cmd = cmd . Replace ( "/" , "\\ " ) ;
118
+ jdk = jdk . Replace ( "/" , "\\ " ) + "\\ bin\\ java.exe" ;
119
+ soPath += "/../" + symbolsdir ;
120
+ soPath = soPath . Replace ( "/" , "\\ " ) ;
121
+ }
121
122
122
- // var appID = "ef9301f8fb";
123
- // var appKey = "ea81cbea-41b4-49d0-a40a-0dcad0cf4c6b";
124
- // var channelTag = GameConfig.Instance().TryGetString("CHANNEL_TAG", "com.bc.avenger");
125
- // var buglyChannelAsset = Resources.Load<com.bugly.sdk.BuglyChannelAsset>("bugly_config");
126
- // var buglyCfg = buglyChannelAsset.GetBuglyChannelCfg(channelTag);
127
- // if (buglyCfg == null)
128
- // {
129
- // Debug.LogError("can not find bugly channel data:" + channelTag);
130
- // }
131
- //
132
- // bool q1DebugValue = GameConfig.Instance().TryGetBool("ENABLE_Q1_DEBUG_MODE", false);
133
- // if (buglyCfg != null)
134
- // {
135
- // if (q1DebugValue)
136
- // {
137
- // appID = buglyCfg.debugAppID;
138
- // appKey = buglyCfg.debugAppKey;
139
- // }
140
- // else
141
- // {
142
- // appID = buglyCfg.appID;
143
- // appKey = buglyCfg.appKey;
144
- // }
145
- // }
146
- //
147
- // Debug.Log("bugly symbolsdir:" + symbolsdir);
123
+ // var appID = "ef9301f8fb";
124
+ // var appKey = "ea81cbea-41b4-49d0-a40a-0dcad0cf4c6b";
125
+ // var channelTag = GameConfig.Instance().TryGetString("CHANNEL_TAG", "com.bc.avenger");
126
+ // var buglyChannelAsset = Resources.Load<com.bugly.sdk.BuglyChannelAsset>("bugly_config");
127
+ // var buglyCfg = buglyChannelAsset.GetBuglyChannelCfg(channelTag);
128
+ // if (buglyCfg == null)
129
+ // {
130
+ // Debug.LogError("can not find bugly channel data:" + channelTag);
131
+ // }
132
+ //
133
+ // bool q1DebugValue = GameConfig.Instance().TryGetBool("ENABLE_Q1_DEBUG_MODE", false);
134
+ // if (buglyCfg != null)
135
+ // {
136
+ // if (q1DebugValue)
137
+ // {
138
+ // appID = buglyCfg.debugAppID;
139
+ // appKey = buglyCfg.debugAppKey;
140
+ // }
141
+ // else
142
+ // {
143
+ // appID = buglyCfg.appID;
144
+ // appKey = buglyCfg.appKey;
145
+ // }
146
+ // }
147
+ //
148
+ // Debug.Log("bugly symbolsdir:" + symbolsdir);
148
149
//
149
150
// #if UPLOAD_SYMBOLS || true
150
151
// // ProcessCommand(jdk, "-jar " + cmd + " -i " + symbolsdir + " -u -id " + appID + " - key " + appKey + " - package " + PlayerSettings.applicationIdentifier + " -version " + PlayerSettings.bundleVersion);
@@ -155,42 +156,43 @@ public static void GenerateAllSymbols(string symbolsdir)
155
156
// #else
156
157
// ProcessCommand(jdk, "-jar " + cmd + " -i " + symbolsdir);
157
158
// #endif
158
- //ProcessCommand(cmd,"-i " + symbolsdir + " -u -id 844a29e21e -key b85577b4-1347-40bb-a880-f8a91446007f -package " + PlayerSettings.applicationIdentifier + " -version " + PlayerSettings.bundleVersion);
159
+ //ProcessCommand(cmd,"-i " + symbolsdir + " -u -id 844a29e21e -key b85577b4-1347-40bb-a880-f8a91446007f -package " + PlayerSettings.applicationIdentifier + " -version " + PlayerSettings.bundleVersion);
160
+ }
159
161
}
160
- }
161
162
162
- public static void ProcessCommand ( string command , string argument )
163
- {
164
- System . Diagnostics . ProcessStartInfo info = new System . Diagnostics . ProcessStartInfo ( command ) ;
165
- info . Arguments = argument ;
166
- info . CreateNoWindow = false ;
167
- info . ErrorDialog = true ;
168
- info . UseShellExecute = true ;
169
-
170
- if ( info . UseShellExecute )
171
- {
172
- info . RedirectStandardOutput = false ;
173
- info . RedirectStandardError = false ;
174
- info . RedirectStandardInput = false ;
175
- }
176
- else
163
+ public static void ProcessCommand ( string command , string argument )
177
164
{
178
- info . RedirectStandardOutput = true ;
179
- info . RedirectStandardError = true ;
180
- info . RedirectStandardInput = true ;
181
- info . StandardOutputEncoding = System . Text . UTF8Encoding . UTF8 ;
182
- info . StandardErrorEncoding = System . Text . UTF8Encoding . UTF8 ;
183
- }
165
+ System . Diagnostics . ProcessStartInfo info = new System . Diagnostics . ProcessStartInfo ( command ) ;
166
+ info . Arguments = argument ;
167
+ info . CreateNoWindow = false ;
168
+ info . ErrorDialog = true ;
169
+ info . UseShellExecute = true ;
184
170
185
- System . Diagnostics . Process process = System . Diagnostics . Process . Start ( info ) ;
171
+ if ( info . UseShellExecute )
172
+ {
173
+ info . RedirectStandardOutput = false ;
174
+ info . RedirectStandardError = false ;
175
+ info . RedirectStandardInput = false ;
176
+ }
177
+ else
178
+ {
179
+ info . RedirectStandardOutput = true ;
180
+ info . RedirectStandardError = true ;
181
+ info . RedirectStandardInput = true ;
182
+ info . StandardOutputEncoding = System . Text . UTF8Encoding . UTF8 ;
183
+ info . StandardErrorEncoding = System . Text . UTF8Encoding . UTF8 ;
184
+ }
186
185
187
- if ( ! info . UseShellExecute )
188
- {
189
- Debug . Log ( process . StandardOutput ) ;
190
- Debug . Log ( process . StandardError ) ;
191
- }
186
+ System . Diagnostics . Process process = System . Diagnostics . Process . Start ( info ) ;
192
187
193
- process . WaitForExit ( ) ;
194
- process . Close ( ) ;
188
+ if ( ! info . UseShellExecute )
189
+ {
190
+ Debug . Log ( process . StandardOutput ) ;
191
+ Debug . Log ( process . StandardError ) ;
192
+ }
193
+
194
+ process . WaitForExit ( ) ;
195
+ process . Close ( ) ;
196
+ }
195
197
}
196
198
}
0 commit comments