37
37
38
38
import argparse
39
39
import json
40
- import os
41
- import re
42
- import subprocess
43
- import sys
44
-
45
- from integration_testing import config_reader
40
+ import platform
46
41
47
42
48
43
DEFAULT_WORKFLOW = "desktop"
49
44
EXPANDED_KEY = "expanded"
50
45
MINIMAL_KEY = "minimal"
51
46
47
+ _WINDOWS = "Windows"
48
+ _MACOS = "macOS"
49
+ _LINUX = "Linux"
50
+
52
51
PARAMETERS = {
53
52
"integration_tests" : {
54
53
"matrix" : {
55
- "unity_version" : ["2019.4.32f1 " ],
54
+ "unity_version" : ["2019" ],
56
55
"android_device" : ["android_target" , "emulator_target" ],
57
56
"ios_device" : ["ios_target" , "simulator_target" ],
58
57
62
61
},
63
62
64
63
EXPANDED_KEY : {
65
- "unity_version" : ["2020.3.22f1 " , "2019.4.32f1 " , "2018.4.36f1 " , "2017.4.40f1" , "2017.4.10f1 " ],
64
+ "unity_version" : ["2020" , "2019" , "2018" , "2017" ],
66
65
"android_device" : ["android_target" , "android_latest" , "emulator_target" , "emulator_latest" , "emulator_32bit" ],
67
66
"ios_device" : ["ios_min" , "ios_target" , "ios_latest" , "simulator_min" , "simulator_target" , "simulator_latest" ],
68
67
}
78
77
# Plese use Unity LTS versions: https://unity3d.com/unity/qa/lts-releases
79
78
# To list avaliable packages, install u3d, and use cmd "u3d available -u $unity_version -p"
80
79
# The packages below is valid only if Unity Hub is not installed.
81
- UNITY_PACKAGES = {
82
- "2020.3.22f1" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-il2cpp" ], "macOS" : None , "Linux" : ["linux-il2cpp" ]},
83
- "2019.4.32f1" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["windows-il2cpp" ], "macOS" : None , "Linux" : ["linux-il2cpp" ]},
84
- "2018.4.36f1" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-il2cpp" ], "macOS" : None , "Linux" : None },
85
- "2017.4.40f1" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : None , "macOS" : None , "Linux" : None },
86
- "2017.4.10f1" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows" ], "macOS" : None , "Linux" : None } # For Linux Special
80
+ # TODO(@sunmou): Add Android Setting. e.g. NDK_VERSION
81
+ UNITY_SETTINGS = {
82
+ "2020" : {
83
+ _WINDOWS : {
84
+ "version" : "2020.3.22f1" ,
85
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : None , "macOS" : ["Mac-mono" ], "Linux" : ["Linux-mono" ]}
86
+ },
87
+ _MACOS : {
88
+ "version" : "2020.3.22f1" ,
89
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-mono" ], "macOS" : None , "Linux" : ["Linux-mono" ]}
90
+ },
91
+ _LINUX : {
92
+ "version" : "2020.3.22f1" ,
93
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-mono" ], "macOS" : ["Mac-mono" ], "Linux" : None }
94
+ }
95
+ },
96
+ "2019" : {
97
+ _WINDOWS : {
98
+ "version" : "2019.4.32f1" ,
99
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : None , "macOS" : ["Mac-mono" ], "Linux" : ["Linux-mono" ]}
100
+ },
101
+ _MACOS : {
102
+ "version" : "2019.4.32f1" ,
103
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-mono" ], "macOS" : None , "Linux" : ["Linux-mono" ]}
104
+ },
105
+ _LINUX : {
106
+ "version" : "2019.4.32f1" ,
107
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-mono" ], "macOS" : ["Mac-mono" ], "Linux" : None }
108
+ }
109
+ },
110
+ "2018" : {
111
+ _WINDOWS : {
112
+ "version" : "2018.4.36f1" ,
113
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-il2cpp" ], "macOS" : ["Mac-mono" ], "Linux" : ["Linux" ]}
114
+ },
115
+ _MACOS : {
116
+ "version" : "2018.4.36f1" ,
117
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-mono" ], "macOS" : ["Mac-il2cpp" ], "Linux" : ["Linux" ]}
118
+ },
119
+ _LINUX : {
120
+ "version" : "2018.4.36f1" ,
121
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows-mono" ], "macOS" : ["Mac-mono" ], "Linux" : None }
122
+ }
123
+ },
124
+ "2017" : {
125
+ _WINDOWS : {
126
+ "version" : "2017.4.40f1" ,
127
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : None , "macOS" : ["Mac" ], "Linux" : ["Linux" ]}
128
+ },
129
+ _MACOS : {
130
+ "version" : "2017.4.40f1" ,
131
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows" ], "macOS" : None , "Linux" : ["Linux" ]}
132
+ },
133
+ _LINUX : {
134
+ "version" : "2017.4.10f1" ,
135
+ "packages" : {"Default" : ["Unity" ], "Android" : ["Android" ], "iOS" : ["Ios" ], "Windows" : ["Windows" ], "macOS" : ["Mac" ], "Linux" : None }
136
+ }
137
+ }
87
138
}
88
139
89
140
TEST_DEVICES = {
103
154
}
104
155
105
156
157
+ def get_os ():
158
+ """Current Operation System"""
159
+ if platform .system () == 'Windows' :
160
+ return _WINDOWS
161
+ elif platform .system () == 'Darwin' :
162
+ return _MACOS
163
+ elif platform .system () == 'Linux' :
164
+ return _LINUX
165
+
166
+
167
+ def get_unity_path (version ):
168
+ """Returns the path to this version of Unity, as generated by U3D."""
169
+ # These are the path formats assumed by U3D, as documented here:
170
+ # https://github.com/DragonBox/u3d
171
+ unity_full_version = UNITY_SETTINGS [version ][get_os ()]["version" ]
172
+ if platform .system () == "Windows" :
173
+ return "/c/Program Files/Unity_%s" % unity_full_version
174
+ elif platform .system () == "Darwin" :
175
+ return "/Applications/Unity_%s" % unity_full_version
176
+ elif platform .system () == 'Linux' :
177
+ return "/opt/unity-editor-%s" % unity_full_version
178
+
179
+
106
180
def get_value (workflow , test_matrix , parm_key , config_parms_only = False ):
107
181
""" Fetch value from configuration
108
182
@@ -168,6 +242,17 @@ def filter_values_on_diff(parm_key, value, auto_diff):
168
242
169
243
def main ():
170
244
args = parse_cmdline_args ()
245
+ if args .unity_version :
246
+ if args .parm_key == "unity_path" :
247
+ print (get_unity_path (args .unity_version ))
248
+ else :
249
+ print (UNITY_SETTINGS [args .unity_version ][get_os ()].get (args .parm_key ))
250
+ return
251
+
252
+ if args .device :
253
+ print (TEST_DEVICES .get (args .parm_key ).get ("type" ))
254
+ return
255
+
171
256
if args .override :
172
257
# If it is matrix parm, convert CSV string into a list
173
258
if not args .config :
@@ -176,10 +261,6 @@ def main():
176
261
print_value (args .override )
177
262
return
178
263
179
- if args .device :
180
- print (TEST_DEVICES .get (args .parm_key ).get ("type" ))
181
- return
182
-
183
264
if args .expanded :
184
265
test_matrix = EXPANDED_KEY
185
266
elif args .minimal :
@@ -203,8 +284,9 @@ def parse_cmdline_args():
203
284
parser .add_argument ('-k' , '--parm_key' , required = True , help = 'Print the value of specified key from matrix or config maps.' )
204
285
parser .add_argument ('-a' , '--auto_diff' , metavar = 'BRANCH' , help = 'Compare with specified base branch to automatically set matrix options' )
205
286
parser .add_argument ('-o' , '--override' , help = 'Override existing value with provided value' )
206
- parser .add_argument ('-d' , '--device' , action = 'store_true' , help = 'Get the device type, used with -k $device' )
287
+ parser .add_argument ('-d' , '--device' , type = bool , default = False , help = 'Get the device type, used with -k $device' )
207
288
parser .add_argument ('-t' , '--device_type' , default = ['real' , 'virtual' ], help = 'Test on which type of mobile devices' )
289
+ parser .add_argument ('-u' , '--unity_version' , help = 'Get unity setting based on unity major version' )
208
290
args = parser .parse_args ()
209
291
return args
210
292
0 commit comments