From f2515870d023515257783caee2deb967a6b071a1 Mon Sep 17 00:00:00 2001 From: cobalt-github-releaser-bot <95661244+cobalt-github-releaser-bot@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:47:29 -0800 Subject: [PATCH] Cherry pick PR #1901: Place app_launcher files in folder in out dir (#2380) Refer to the original PR: https://github.com/youtube/cobalt/pull/1901 Compared to using app_launcher.zip, not archiving the files shaves time off test setup by skipping unarchiving steps. The platforms that use the files directly don't run integration tests and can skip the ~30k files the they add. b/294129333 Co-authored-by: Oscar Vestlie --- starboard/tools/BUILD.gn | 26 +++++++++++++- starboard/tools/app_launcher_packager.py | 44 +++++++++++++++--------- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/starboard/tools/BUILD.gn b/starboard/tools/BUILD.gn index 27dca14c1e38..6e1cc2fc2fce 100644 --- a/starboard/tools/BUILD.gn +++ b/starboard/tools/BUILD.gn @@ -12,7 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -action("build_app_launcher_zip") { +group("build_app_launcher_zip") { + deps = [ + ":package_app_launcher_directory", + ":package_app_launcher_zip", + ] +} + +# TODO(b/294130306): Get rid of app_launcher.zip. +action("package_app_launcher_zip") { script = "//starboard/tools/app_launcher_packager.py" file_list = exec_script(script, [ "-l" ], "trim string") @@ -20,7 +28,23 @@ action("build_app_launcher_zip") { outputs = [ "$root_out_dir/app_launcher.zip" ] args = [ + # TODO(b/294130306): Control this flag with a GN variable. + "--include_integration_tests", "-z", rebase_path(outputs[0], root_build_dir), ] } + +# Platforms that has windows based toolchains (ps4/5, xb1, switch) expect the +# app launcher files to be in a folder in the test archive as opposed to in a +# zip file. +copy("package_app_launcher_directory") { + script = "//starboard/tools/app_launcher_packager.py" + + app_launcher_dir = "$root_out_dir/app_launcher" + + file_list = exec_script(script, [ "-l" ], "trim string") + sources = string_split(file_list) + outputs = + [ "$app_launcher_dir/{{source_root_relative_dir}}/{{source_file_part}}" ] +} diff --git a/starboard/tools/app_launcher_packager.py b/starboard/tools/app_launcher_packager.py index 33300bf89cb3..0ef646586ef8 100644 --- a/starboard/tools/app_launcher_packager.py +++ b/starboard/tools/app_launcher_packager.py @@ -43,7 +43,7 @@ ('starboard/tools/testing', 'sharding_configuration.json') ] -_INCLUDE_BLACK_BOX_TESTS_PATTERNS = [ +_INCLUDE_INTEGRATION_TESTS_PATTERNS = [ # Black box and web platform tests have non-py assets, so everything # is picked up. ('cobalt/black_box_tests', '*'), @@ -103,7 +103,8 @@ def _FindFilesRecursive( # pylint: disable=missing-docstring def CopyAppLauncherTools(repo_root, dest_root, additional_glob_patterns=None, - include_black_box_tests=True): + include_black_box_tests=False, + include_integration_tests=False): """Copies app launcher related files to the destination root. Args: @@ -112,12 +113,16 @@ def CopyAppLauncherTools(repo_root, additional_glob_patterns: Some platforms may need to include certain dependencies beyond the default include file patterns. The results here will be merged in with _INCLUDE_FILE_PATTERNS. - include_black_box_tests: If True then the resources for the black box tests - are included. + include_integration_tests: If True then the resources for the integration + tests are included. + include_black_box_tests: Same as above. Kept for compatibility reasons. """ + # TODO(b/294129333): Remove include_black_box_tests when DS is gone. + include_integration_tests = ( + include_integration_tests or include_black_box_tests) dest_root = _PrepareDestination(dest_root) copy_list = _GetSourceFilesList(repo_root, additional_glob_patterns, - include_black_box_tests) + include_integration_tests) _CopyFiles(repo_root, dest_root, copy_list) @@ -138,13 +143,13 @@ def _PrepareDestination(dest_root): # pylint: disable=missing-docstring def _GetSourceFilesList( # pylint: disable=missing-docstring repo_root, additional_glob_patterns=None, - include_black_box_tests=True): + include_integration_tests=False): # Find all glob files from specified search directories. include_glob_patterns = _INCLUDE_FILE_PATTERNS if additional_glob_patterns: include_glob_patterns += additional_glob_patterns - if include_black_box_tests: - include_glob_patterns += _INCLUDE_BLACK_BOX_TESTS_PATTERNS + if include_integration_tests: + include_glob_patterns += _INCLUDE_INTEGRATION_TESTS_PATTERNS copy_list = [] for d, glob_pattern in include_glob_patterns: flist = _FindFilesRecursive(os.path.join(repo_root, d), glob_pattern) @@ -219,6 +224,10 @@ def main(command_args): '--return_list', action='store_true', help='Return the application resources instead of printing them.') + parser.add_argument( + '--include_integration_tests', + action='store_true', + help='Includes integration test files.') parser.add_argument( '-v', '--verbose', @@ -230,17 +239,25 @@ def main(command_args): log_level.InitializeLogging(args) if args.destination_root: - CopyAppLauncherTools(REPOSITORY_ROOT, args.destination_root) + CopyAppLauncherTools( + REPOSITORY_ROOT, + args.destination_root, + include_integration_tests=args.include_integration_tests) elif args.zip_file: try: temp_dir = tempfile.mkdtemp(prefix='cobalt_app_launcher_') - CopyAppLauncherTools(REPOSITORY_ROOT, temp_dir) + CopyAppLauncherTools( + REPOSITORY_ROOT, + temp_dir, + include_integration_tests=args.include_integration_tests) MakeZipArchive(temp_dir, args.zip_file) finally: shutil.rmtree(temp_dir) elif args.list: src_files = [] - for src_file in _GetSourceFilesList(REPOSITORY_ROOT): + for src_file in _GetSourceFilesList( + REPOSITORY_ROOT, + include_integration_tests=args.include_integration_tests): # Skip paths with '$' since they won't get through the Ninja generator. if '$' in src_file: continue @@ -255,10 +272,5 @@ def main(command_args): return 0 -def DoMain(argv): - """Script main function.""" - return main(argv) - - if __name__ == '__main__': sys.exit(main(sys.argv[1:]))