Skip to content

Commit

Permalink
Cherry pick PR #1901: Place app_launcher files in folder in out dir (#…
Browse files Browse the repository at this point in the history
…2380)

Refer to the original PR: #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 <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and oxve committed Feb 5, 2024
1 parent ad7add4 commit f251587
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
26 changes: 25 additions & 1 deletion starboard/tools/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,39 @@
# 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")
inputs = string_split(file_list)
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}}" ]
}
44 changes: 28 additions & 16 deletions starboard/tools/app_launcher_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '*'),
Expand Down Expand Up @@ -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:
Expand All @@ -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)


Expand All @@ -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)
Expand Down Expand Up @@ -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',
Expand All @@ -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
Expand All @@ -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:]))

0 comments on commit f251587

Please sign in to comment.