106106_SUPPORTED_PLATFORMS = (_ANDROID , _IOS , _DESKTOP )
107107
108108# Values for iOS SDK flag (where the iOS app will run)
109- _IOS_SDK_DEVICE = "device "
110- _IOS_SDK_SIMULATOR = "simulator "
109+ _IOS_SDK_DEVICE = "real "
110+ _IOS_SDK_SIMULATOR = "virtual "
111111_SUPPORTED_IOS_SDK = (_IOS_SDK_DEVICE , _IOS_SDK_SIMULATOR )
112112
113113FLAGS = flags .FLAGS
120120 "output_directory" , "~" ,
121121 "Build output will be placed in this directory." )
122122
123+ flags .DEFINE_string (
124+ "artifact_name" , "" ,
125+ "artifacts will be created and placed in output_directory."
126+ " testapps artifact is testapps-$artifact_name;"
127+ " build log artifact is build-results-$artifact_name.log." )
128+
123129flags .DEFINE_string (
124130 "repo_dir" , os .getcwd (),
125131 "Firebase C++ SDK Git repository. Current directory by default." )
141147
142148flags .DEFINE_list (
143149 "ios_sdk" , _IOS_SDK_DEVICE ,
144- "(iOS only) Build for device (ipa), simulator (app), or both. "
145- " Building for both will produce both an .app and an .ipa." )
150+ "(iOS only) Build for real device (. ipa), virtual device / simulator (. app), "
151+ "or both. Building for both will produce both an .app and an .ipa." )
146152
147153flags .DEFINE_bool (
148154 "update_pod_repo" , True ,
@@ -186,7 +192,7 @@ def main(argv):
186192 testapps = FLAGS .testapps
187193
188194 sdk_dir = _fix_path (FLAGS .packaged_sdk or FLAGS .repo_dir )
189- output_dir = _fix_path (FLAGS .output_directory )
195+ root_output_dir = _fix_path (FLAGS .output_directory )
190196 repo_dir = _fix_path (FLAGS .repo_dir )
191197
192198 update_pod_repo = FLAGS .update_pod_repo
@@ -196,9 +202,9 @@ def main(argv):
196202 timestamp = ""
197203
198204 if FLAGS .short_output_paths :
199- output_dir = os .path .join (output_dir , "ta" )
205+ output_dir = os .path .join (root_output_dir , "ta" )
200206 else :
201- output_dir = os .path .join (output_dir , "testapps" + timestamp )
207+ output_dir = os .path .join (root_output_dir , "testapps" + timestamp )
202208
203209 ios_framework_dir = os .path .join (sdk_dir , "xcframeworks" )
204210 ios_framework_exist = os .path .isdir (ios_framework_dir )
@@ -248,8 +254,10 @@ def main(argv):
248254 cmake_flags = cmake_flags ,
249255 short_output_paths = FLAGS .short_output_paths )
250256 logging .info ("END building for %s" , testapp )
257+
258+ _collect_integration_tests (testapps , root_output_dir , FLAGS .artifact_name )
251259
252- _summarize_results (testapps , platforms , failures , output_dir )
260+ _summarize_results (testapps , platforms , failures , root_output_dir , FLAGS . artifact_name )
253261 return 1 if failures else 0
254262
255263
@@ -321,8 +329,43 @@ def _build(
321329 return failures
322330
323331
324- def _summarize_results (testapps , platforms , failures , output_dir ):
332+ def _collect_integration_tests (testapps , output_dir , artifact_name ):
333+ testapps_artifact_dir = "testapps-" + artifact_name
334+ android_testapp_extension = ".apk"
335+ ios_testapp_extension = ".ipa"
336+ ios_simualtor_testapp_extension = ".app"
337+ desktop_testapp_name = "integration_test"
338+ if platform .system () == "Windows" :
339+ desktop_testapp_name += ".exe"
340+
341+ testapp_paths = []
342+ for file_dir , directories , file_names in os .walk (output_dir ):
343+ for directory in directories :
344+ if directory .endswith (ios_simualtor_testapp_extension ):
345+ testapp_paths .append (os .path .join (file_dir , directory ))
346+ for file_name in file_names :
347+ if ((file_name == desktop_testapp_name and "ios_build" not in file_dir )
348+ or file_name .endswith (android_testapp_extension )
349+ or file_name .endswith (ios_testapp_extension )):
350+ testapp_paths .append (os .path .join (file_dir , file_name ))
351+
352+ artifact_path = os .path .join (output_dir , testapps_artifact_dir )
353+ for testapp in testapps :
354+ os .makedirs (os .path .join (artifact_path , testapp ))
355+ for path in testapp_paths :
356+ for testapp in testapps :
357+ if testapp in path :
358+ if os .path .isfile (path ):
359+ shutil .copy (path , os .path .join (artifact_path , testapp ))
360+ else :
361+ dir_util .copy_tree (path , os .path .join (artifact_path , testapp , "integration_test.app" ))
362+ break
363+
364+
365+ def _summarize_results (testapps , platforms , failures , output_dir , artifact_name ):
325366 """Logs a readable summary of the results of the build."""
367+ file_name = "build-results-" + artifact_name + ".log"
368+
326369 summary = []
327370 summary .append ("BUILD SUMMARY:" )
328371 summary .append ("TRIED TO BUILD: " + "," .join (testapps ))
@@ -337,7 +380,7 @@ def _summarize_results(testapps, platforms, failures, output_dir):
337380 summary = "\n " .join (summary )
338381
339382 logging .info (summary )
340- test_validation .write_summary (output_dir , summary )
383+ test_validation .write_summary (output_dir , summary , file_name = file_name )
341384
342385
343386def _build_desktop (sdk_dir , cmake_flags ):
0 commit comments