少年修仙传客户端基础资源
liuxue
2021-08-12 6149631752ee76f85e8eca17454ddaf27fc13dbc
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System.Diagnostics;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;
 
public class UpLoadBuglySo
{
    private static string[] soFolders = {"arm64-v8a", "armeabi-v7a","unity"};
    private static string soCmdAnroid =
        "java -jar buglyqq-upload-symbol.jar -inputSymbol #SOPATH# -appid #ID# -appkey #KEY# -bundleid #BUNDLEID# -version #VERSION# -platform Android";
 
    private static string soCmdIOS =
        "java -jar buglyqq-upload-symbol.jar -inputSymbol ./IOS/UnityFramework.framework.dSYM -appid #ID# -appkey #KEY# -bundleid #BUNDLEID# -version #VERSION# -platform IOS";
 
    /// <summary>
    /// 打完包后调用此方法 自动上传符号表文件
    /// </summary>
    [MenuItem("Tools/自动上传符号表/Android", priority = 2049)]
    public static void UploadAndroidBuglyso(){
        DeleteSo();
        CopyBuglySo();
        if (EditCommand(out string arg)) {
            Debug.Log("EditCommand: " + arg);
            RunCmd(arg, BuglyToolPath());
        }
    }
    [MenuItem("Tools/自动上传符号表/IOS", priority = 2049)]
    public static void UploadIOSBuglyso()
    {
        if (EditCommandIOS(out string arg))
        {
            Debug.Log("EditCommand: " + arg);
            RunCmd(arg, BuglyToolPath());
        }
    }
    private static void CopyBuglySo(){
        FileTool.CopyFolder(DeBugSOPath(), BuglyToolPath() + "/Android/");
        FileTool.OpenFolder(BuglyToolPath());
    }
 
 
    private static void DeleteSo(){
        foreach (var folder in soFolders) {
            FileTool.DeleteFolder(BuglyToolPath() + "/Android/");
        }
    } 
    private static bool EditCommand(out string arg){
        bool exists = false;        
        var versionInfo = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex, "_", VersionConfig.Get().buildTime);
        StringBuilder sb = new StringBuilder();
        foreach (var folder in soFolders) 
        {
            exists = true;
            sb.Append(soCmdAnroid).Append(" & ");
            if(folder == "unity")
            {
                sb.Replace("#SOPATH#", "libunity.sym.so");
            }
            else
            {
                string soPath = BuglyToolPath() + "/Android/" + folder ;
                if (FileTool.CheckFolder(soPath))
                {
                    soPath = soPath + "/libil2cpp.sym.so";
                    sb.Replace("#SOPATH#", soPath);
                }
                else
                {
                    exists = false;
                    break;
                }
            }
            sb.Replace("#ID#", ExceptionCatcher.AppIDAndroid);  //这里注意一下要改成自己的id
            sb.Replace("#KEY#", ExceptionCatcher.AppKeyAndroid); //自己的key
            sb.Replace("#BUNDLEID#", VersionConfig.Get().appId);
            sb.Replace("#VERSION#", versionInfo);            
        }
 
        sb.Append("exit").Replace("/", @"\");
        arg = sb.ToString();
        return exists;
    }
    private static bool EditCommandIOS(out string arg)
    {
        bool exists = true;
        var versionInfo = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex, "_", VersionConfig.Get().buildTime);
        StringBuilder sb = new StringBuilder();
        sb.Append(soCmdIOS).Append(" & ");
        sb.Replace("#ID#", ExceptionCatcher.AppIDIOS);  //这里注意一下要改成自己的id
        sb.Replace("#KEY#", ExceptionCatcher.AppKeyIOS); //自己的key
        sb.Replace("#BUNDLEID#", VersionConfig.Get().appId);
        sb.Replace("#VERSION#", versionInfo);
        sb.Append("exit").Replace("/", @"\");
        arg = sb.ToString();
        return exists;
    }
    public static string DeBugSOPath(){
        return Path.GetFullPath(Application.dataPath + "/../Temp/StagingArea/symbols");
    }
 
    public static string BuglyToolPath(){
        return Path.GetFullPath(Application.dataPath + "/../buglytools");
    }
    public static void RunCmd(string arg, string workingDirectory,string exe ="cmd.exe"){
            
        ProcessStartInfo info = new ProcessStartInfo(exe);
        info.Arguments = "/c " + arg;
        info.WorkingDirectory = workingDirectory;
        info.CreateNoWindow = false;
        info.ErrorDialog = true; 
        info.UseShellExecute = true;
 
        if (info.UseShellExecute) {
            info.RedirectStandardOutput = false;
            info.RedirectStandardError = false;
            info.RedirectStandardInput = false;
        }
        else {
            info.RedirectStandardOutput = true;
            info.RedirectStandardError = true;
            info.RedirectStandardInput = true;
            info.StandardOutputEncoding = System.Text.UTF8Encoding.UTF8;
            info.StandardErrorEncoding = System.Text.UTF8Encoding.UTF8;
        }
        Debug.Log("RunCmd: "+info.Arguments);
 
        Process process = Process.Start(info);
 
        if (!info.UseShellExecute) {
            Debug.Log(process.StandardOutput);
            Debug.Log(process.StandardError);
        }
 
        process.WaitForExit();
        process.Close();
    }
}