Commit 7e8cc330 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

Reland "[CCA WebUI] Add deploy_swa function in cca.py"

This reverts commit 77826976.

Reason for revert: The failure is not related to the CL.

Original change's description:
> Revert "[CCA WebUI] Add deploy_swa function in cca.py"
>
> This reverts commit 2a4aa8b6.
>
> Reason for revert: Speculative, suspected in breaking cros_browser_sanity_test, see https://ci.chromium.org/p/chrome/builders/ci/chromeos-eve-chrome/10590
>
> Original change's description:
> > [CCA WebUI] Add deploy_swa function in cca.py
> >
> > It can help to boost the development when simply changing JS/CSS/HTML
> > on CCA (SWA).
> >
> > Bug: 1127459
> > Test: cca deploy-swa [BOARD] [DEVICE]
> > Change-Id: I3f494a8d455b4c5632f91942f95b428b03294af9
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2456706
> > Reviewed-by: Shik Chen <shik@chromium.org>
> > Reviewed-by: Inker Kuo <inker@chromium.org>
> > Commit-Queue: Wei Lee <wtlee@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#815087}
>
> TBR=shik@chromium.org,inker@chromium.org,wtlee@chromium.org
>
> Change-Id: I0ec15027ea4000d30ca7f7851dd8a6c806c37e0a
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1127459
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461270
> Reviewed-by: Olga Sharonova <olka@chromium.org>
> Commit-Queue: Olga Sharonova <olka@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#815108}

TBR=shik@chromium.org,olka@chromium.org,inker@chromium.org,wtlee@chromium.org

# Not skipping CQ checks because this is a reland.

Bug: 1127459
Change-Id: I2745f6e90318f0051e4f03c3800a47d93c648295
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463044Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Commit-Queue: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815500}
parent 8cc988f4
......@@ -14,6 +14,7 @@ import shlex
import shutil
import subprocess
import sys
import tempfile
import time
......@@ -28,9 +29,9 @@ def shell_join(cmd):
return ' '.join(shlex.quote(c) for c in cmd)
def run(args):
def run(args, cwd=None):
logging.debug(f'$ {shell_join(args)}')
subprocess.check_call(args)
subprocess.check_call(args, cwd=cwd)
def build_locale_strings():
......@@ -195,6 +196,68 @@ def deploy(args):
run(cmd)
def deploy_swa(args):
cca_root = os.getcwd()
target_dir = os.path.join(get_chromium_root(), f'out_{args.board}/Release')
build_pak_cmd = [
'tools/grit/grit.py',
'-i',
os.path.join(cca_root, 'camera_app_resources.grd'),
'build',
'-o',
os.path.join(target_dir, 'gen/chromeos'),
'-f',
os.path.join(target_dir,
'gen/tools/gritsettings/default_resource_ids'),
'-E',
f'root_gen_dir={os.path.join(target_dir, "gen")}',
]
# Since there is a constraint in grit.py which will replace ${root_gen_dir}
# in .grd file only if the script is executed in the parent directory of
# ${root_gen_dir}, execute the script in Chromium root as a workaround.
run(build_pak_cmd, get_chromium_root())
with tempfile.TemporaryDirectory() as tmp_dir:
pak_util_script = os.path.join(get_chromium_root(),
'tools/grit/pak_util.py')
extract_resources_pak_cmd = [
pak_util_script,
'extract',
os.path.join(target_dir, 'resources.pak'),
'-o',
tmp_dir,
]
run(extract_resources_pak_cmd)
extract_camera_pak_cmd = [
pak_util_script,
'extract',
os.path.join(target_dir,
'gen/chromeos/chromeos_camera_app_resources.pak'),
'-o',
tmp_dir,
]
run(extract_camera_pak_cmd)
create_new_resources_pak_cmd = [
pak_util_script,
'create',
'-i',
tmp_dir,
os.path.join(target_dir, 'resources.pak'),
]
run(create_new_resources_pak_cmd)
deploy_new_resources_pak_cmd = [
'rsync',
'--inplace',
os.path.join(target_dir, 'resources.pak'),
f'{args.device}:/opt/google/chrome/',
]
run(deploy_new_resources_pak_cmd)
def test(args):
assert 'CCAUI' not in args.device, (
'The first argument should be <device> instead of a test name pattern.'
......@@ -257,6 +320,17 @@ def parse_args(args):
deploy_parser.add_argument('device')
deploy_parser.set_defaults(func=deploy)
deploy_swa_parser = subparsers.add_parser(
'deploy-swa',
help='deploy CCA (SWA) to device',
description='''Deploy CCA (SWA) to device.
This script only works if there is no file added/deleted.
And please build Chrome at least once before running the command.'''
)
deploy_swa_parser.add_argument('board')
deploy_swa_parser.add_argument('device')
deploy_swa_parser.set_defaults(func=deploy_swa)
test_parser = subparsers.add_parser('test',
help='run tests',
description='Run CCA tests on device.')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment