Skip to content

Commit fe889c2

Browse files
committed
[修改]1. 修改符号表的生成
1 parent 42221a6 commit fe889c2

File tree

1 file changed

+145
-143
lines changed

1 file changed

+145
-143
lines changed
Lines changed: 145 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
1-
using System.Collections;
2-
using UnityEngine;
1+
using System;
2+
using System.IO;
33
using UnityEditor;
44
using UnityEditor.Callbacks;
5-
using System.IO;
6-
using System;
5+
using UnityEngine;
76

8-
public class AutoCopySymbolsPostprocessor
7+
namespace Unity.Editor
98
{
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
2310
{
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)
3413
{
35-
var dir = CopySymbols(symbolsDir, abi_v8a);
36-
GenerateAllSymbols(dir);
14+
if (target == BuildTarget.Android)
15+
PostProcessAndroidBuild(pathToBuiltProject);
3716
}
3817

39-
if ((PlayerSettings.Android.targetArchitectures & AndroidArchitecture.ARMv7) > 0)
18+
public static void PostProcessAndroidBuild(string pathToBuiltProject)
4019
{
41-
var dir = CopySymbols(symbolsDir, abi_v7a);
42-
GenerateAllSymbols(dir);
20+
CopyAndroidSymbols(pathToBuiltProject, PlayerSettings.Android.targetArchitectures);
4321
}
4422

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+
4546
#if UNITY_2018_1_OR_NEWER
4647

4748
#else
@@ -51,100 +52,100 @@ public static void CopyAndroidSymbols(string pathToBuiltProject, AndroidArchitec
5152
GenerateAllSymbols(dir);
5253
}
5354
#endif
54-
Debug.Log(nameof(CopyAndroidSymbols) + " End ==>" + (DateTime.Now - startTime).TotalSeconds);
55-
}
55+
Debug.Log(nameof(CopyAndroidSymbols) + " End ==>" + (DateTime.Now - startTime).TotalSeconds);
56+
}
5657

57-
const string LibPath = "/../Temp/StagingArea/libs/";
58+
const string LibPath = "/../Temp/StagingArea/libs/";
5859

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+
}
6970

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);
7475

75-
Directory.CreateDirectory(path);
76-
}
76+
Directory.CreateDirectory(path);
77+
}
7778

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)
8280
{
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)
8683
{
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++)
8887
{
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+
}
9192

92-
File.Copy(files[i].FullName, dst + "/" + files[i].Name);
93+
File.Copy(files[i].FullName, dst + "/" + files[i].Name);
94+
}
9395
}
9496
}
95-
}
9697

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)
10199
{
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)
113102
{
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+
}
121122

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);
148149
//
149150
// #if UPLOAD_SYMBOLS || true
150151
// // 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)
155156
// #else
156157
// ProcessCommand(jdk, "-jar " + cmd + " -i " + symbolsdir);
157158
// #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+
}
159161
}
160-
}
161162

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)
177164
{
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;
184170

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+
}
186185

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);
192187

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+
}
195197
}
196198
}

0 commit comments

Comments
 (0)