-
Notifications
You must be signed in to change notification settings - Fork 0
/
ABS.py
193 lines (132 loc) · 6.82 KB
/
ABS.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
from Utility.HeaderBase import *
from SystemBase import *
from APM import *
from UBS import *
from UBSHelper import *
from ABSHelper import *
from ConfigParser import *
## Combine UBS + APM
class AgoraBuildSystem(BaseSystem):
__instance = None
__initialized = False
def __new__(cls, *args, **kwargs):
if not cls.__instance:
cls.__instance = super().__new__(cls, *args, **kwargs)
cls.__instance.__initialized = False
return cls.__instance
def __init__(self) -> None:
if not self.__initialized:
super().__init__()
self.__initialized = True
def Get():
return AgoraBuildSystem()
def Init(self):
PrintStageLog("AgoraBuildSystem Init")
PyUnrealBuildSystem.Get().Init()
AgoraPluginManager.Get().Init()
def Start(self):
AgoraBuildSystem.Get().Init()
args = self.ParseCMDArgs()
if args.agorasdktype != "RTC":
ConfigParser.Get().Init(args.agorasdktype)
self.CreateTask(args)
def ParseCMDArgs(self):
ArgParser = argparse.ArgumentParser(description="Parse Package Args")
bIncludeConflictArgs = False
PyUnrealBuildSystem.Get().AddArgsToParser(ArgParser,bIncludeConflictArgs)
AgoraPluginManager.Get().AddArgsToParser(ArgParser,bIncludeConflictArgs)
bUseSubParser = False
if bUseSubParser:
Subparsers = ArgParser.add_subparsers(help='commands')
UBSArgParser = Subparsers.add_parser(name='UBS', help='unreal build system')
PyUnrealBuildSystem.Get().AddArgsToParser(UBSArgParser)
APMArgParser = Subparsers.add_parser(name='APM', help='agora plugin manager')
AgoraPluginManager.Get().AddArgsToParser(APMArgParser)
self.AddArgsToParser(ArgParser)
Args = ArgParser.parse_args()
PrintLog(Args)
return Args
def AddArgsToParser(self,ArgParser,bIncludeConflictArgs = True):
ArgParser.add_argument("-BuildUEProject",action = "store_true")
ArgParser.add_argument("-AddPostXcodeBuild",action = "store_true") ## after packaging, updated Xcode project and use 'xcodebuild' to build again
#ArgParser.add_argument("-NeedCopySDKWhenBuilding",action = "store_true")
ArgParser.add_argument("-MacTrust",action = "store_true")
ArgParser.add_argument("-Password",default="")
## Related to resources file dir: Ex. xcode project files (used for ios / mac post packaging actions)
ArgParser.add_argument("-ResourceTagName",default="admin@MAGIT04038")
ArgParser.add_argument("-TestUEPlugin",action = "store_true")
ArgParser.add_argument("-TestPluginPath",default = "/Users/admin/Documents/PluginWorkDir/PluginArchive/4.3.1/AgoraPlugin.zip")
ArgParser.add_argument("-TestAgoraPlugin",action = "store_true") ## Test Agora Plugin
ArgParser.add_argument("-QuerySDK",action = "store_true") ## Query Agora SDK to find the tested plugin file
ArgParser.add_argument("-TestBlackList",default = "")
ArgParser.add_argument("-GenPlugin",action = "store_true")
ArgParser.add_argument("-SkipCopySDKToProject",action = "store_true")
ArgParser.add_argument("-SkipClean",action = "store_true")
ArgParser.add_argument("-AppToIPA",action="store_true")
ArgParser.add_argument("-AppPath",default="")
if bIncludeConflictArgs:
pass
def CreateTask(self,Args):
ABSHelper.Get().Init(Args)
if Args.GenPlugin == True:
AgoraPluginManager.Get().StartGenPlugin(Args)
if Args.BuildUEProject == True:
if Args.SkipCopySDKToProject != True:
self.CopySDKToUEProject(Args)
if Args.SkipClean != True:
Args.Clean = True
PyUnrealBuildSystem.Get().CreateTask(Args)
Args.Clean = False
Args.BuildCookRun = True
PyUnrealBuildSystem.Get().CreateTask(Args)
Args.BuildCookRun = False
if Args.TestUEPlugin == True:
PyUnrealBuildSystem.Get().BuildPlugin(Args,Args.TestPluginPath)
if Args.TestAgoraPlugin == True:
PyUnrealBuildSystem.Get().CreateTask(Args)
btest_use_agora_sdk_info = Args.QuerySDK
if btest_use_agora_sdk_info:
sdkinfo = AgoraSDKInfo(Args.agorasdk,Args.sdkisaudioonly)
path_plugin_zipfile = AgoraPluginManager.Get().GetPath_QueryPluginZipFile(sdkinfo,False,True)
if path_plugin_zipfile.exists():
self.TestAgoraPlugin(Args,path_plugin_zipfile)
else:
PrintErr("[TestPlugin] not found agora sdk")
else:
self.TestAgoraPlugin(Args,Args.TestPluginPath)
if Args.AppToIPA == True:
UnrealProjectManager.ConvertMacAppToIPA(Args.AppPath)
if Args.GenUEMarketplacePlugin == True:
self.GenUEMarketplacePlugin(Args)
def CopySDKToUEProject(self,Args):
bdo_macratrust = Args.MacTrust
sdkinfo = AgoraSDKInfo(Args.agorasdk, Args.sdkisaudioonly, Args.agorasdktype)
dst_project_path = Path(Args.uprojectpath).parent
dst_plugin_path = dst_project_path.joinpath("Plugins")
dst_plugin_path.mkdir(parents= True, exist_ok= True)
AgoraPluginManager.Get().QueryAndCopySDKToDstPath(sdkinfo,dst_plugin_path)
if bdo_macratrust and self.GetHostPlatform() == "Mac":
AgoraPluginManager.Get().DoMacRATrustTask(dst_project_path,Args.Password)
def TestAgoraPlugin(self,Args,path_plugin_zipfile):
path_working_dir = Path(path_plugin_zipfile).parent
path_unzip = path_working_dir / Path(PyUnrealBuildSystem.Get().GetName_TestPluginUnzipDir())
## Clean First
if path_unzip.exists():
FileUtility.DeleteDir(path_unzip)
## Prepare :
## Unzip the plugin to get uplugin file path
OneZipCommand =ZipCommand()
OneZipCommand.UnZipFile(path_plugin_zipfile,path_unzip)
name_plugin,path_uplugin_file = UBSHelper.Get().GetInfo_PluginNameAndUPluginFilePath(path_unzip)
path_plugin = Path(path_uplugin_file).parent
### Agora Modfication
AgoraPluginManager.Get().RemoveSymbolicLink(path_plugin / Path("Source/ThirdParty/AgoraPluginLibrary") / Path("Mac") / Path("Release"))
## Start Testing
PyUnrealBuildSystem.Get().BuildPluginInner(Args,path_uplugin_file)
### [After Build] Clean Environment
if path_unzip.exists():
FileUtility.DeleteDir(path_unzip)
def GenUEMarketplacePlugin(self,Args):
AgoraPluginManager.Get().GenUEMarketplacePlugins(Args)
if __name__ == '__main__':
AgoraBuildSystem.Get().Start()