Commit 4d13c9a2 authored by Chong Gu's avatar Chong Gu Committed by Commit Bot

[Fuchsia] Fix --fuchsia-out-dir flag not propagating

Move processing the flag to target specification args.
Remove the argument from being processed by the emulator target classes.

Bug: 1131989
Change-Id: I6962d2de51d89c6cac8e3e07a6947c6c39b706c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2444799
Commit-Queue: Chong Gu <chonggu@google.com>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarRakib Hasan <rmhasan@google.com>
Auto-Submit: Chong Gu <chonggu@google.com>
Cr-Commit-Position: refs/heads/master@{#815930}
parent 8082f0b5
......@@ -20,10 +20,19 @@ def GetTargetType():
class AemuTarget(qemu_target.QemuTarget):
EMULATOR_NAME = 'aemu'
def __init__(self, out_dir, target_cpu, system_log_file, cpu_cores,
require_kvm, ram_size_mb, enable_graphics, hardware_gpu):
super(AemuTarget, self).__init__(out_dir, target_cpu, system_log_file,
cpu_cores, require_kvm, ram_size_mb)
def __init__(self,
out_dir,
target_cpu,
system_log_file,
cpu_cores,
require_kvm,
ram_size_mb,
enable_graphics,
hardware_gpu,
fuchsia_out_dir=None):
super(AemuTarget,
self).__init__(out_dir, target_cpu, system_log_file, cpu_cores,
require_kvm, ram_size_mb, fuchsia_out_dir)
# TODO(crbug.com/1000907): Enable AEMU for arm64.
if platform.machine() == 'aarch64':
......
......@@ -43,6 +43,11 @@ def _AddTargetSpecificationArgs(arg_parser):
'subclass of Target that will be used. Only '
'needed if device specific operations such as '
'paving is required.')
device_args.add_argument('--fuchsia-out-dir',
help='Path to a Fuchsia build output directory. '
'Setting the GN arg '
'"default_fuchsia_build_dir_for_installation" '
'will cause it to be passed here.')
def _GetTargetClass(args):
......@@ -107,11 +112,6 @@ def AddCommonArgs(arg_parser):
common_args.add_argument('--verbose', '-v', default=False,
action='store_true',
help='Enable debug-level logging.')
common_args.add_argument('--fuchsia-out-dir',
nargs='+',
help='Path to a Fuchsia build output directory. '
'If more than one outdir is supplied, the last one '
'in the sequence will be used.')
def ConfigureLogging(args):
......@@ -150,10 +150,12 @@ def GetDeploymentTargetForArgs(additional_args=None):
known_args, _ = target_arg_parser.parse_known_args()
target_args = vars(known_args)
# target_cpu is needed to determine target type, so we need to add
# it here to the args used to initialize the Target.
# target_cpu is needed to determine target type, and fuchsia_out_dir
# is needed for devices with Fuchsia built from source code.
target_args.update({'target_cpu': module_args.target_cpu})
target_args.update({'fuchsia_out_dir': module_args.fuchsia_out_dir})
if additional_args:
target_args.update(additional_args)
return target_class(**target_args)
......@@ -38,21 +38,16 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('--package', action='append', required=True,
help='Paths to packages to install.')
parser.add_argument('--fuchsia-out-dir', nargs='+',
parser.add_argument('--fuchsia-out-dir',
required=True,
help='Path to a Fuchsia build output directory. '
'If more than one outdir is supplied, the last one '
'in the sequence will be used.')
'Setting the GN arg '
'"default_fuchsia_build_dir_for_installation" '
'will cause it to be passed here.')
args = parser.parse_args()
assert args.package
if not args.fuchsia_out_dir or len(args.fuchsia_out_dir) == 0:
sys.stderr.write('No Fuchsia build output directory was specified.\n' +
'To resolve this, Use the commandline argument ' +
'--fuchsia-out-dir\nor set the GN arg ' +
'"default_fuchsia_build_dir_for_installation".\n')
return 1
fuchsia_out_dir = os.path.expanduser(args.fuchsia_out_dir.pop())
fuchsia_out_dir = os.path.expanduser(args.fuchsia_out_dir)
repo = amber_repo.ExternalAmberRepo(
os.path.join(fuchsia_out_dir, 'amber-files'))
print('Installing packages and symbols in Amber repo %s...' % repo.GetPath())
......
......@@ -89,8 +89,6 @@ class DeviceTarget(target.Target):
self._host = host
self._port = port
self._fuchsia_out_dir = None
if fuchsia_out_dir:
self._fuchsia_out_dir = os.path.expanduser(fuchsia_out_dir)
self._node_name = node_name
self._os_check = os_check
self._amber_repo = None
......@@ -98,7 +96,7 @@ class DeviceTarget(target.Target):
if self._host and self._node_name:
raise Exception('Only one of "--host" or "--name" can be specified.')
if self._fuchsia_out_dir:
if fuchsia_out_dir:
if ssh_config:
raise Exception('Only one of "--fuchsia-out-dir" or "--ssh_config" can '
'be specified.')
......
......@@ -16,12 +16,15 @@ import tempfile
class EmuTarget(target.Target):
def __init__(self, out_dir, target_cpu, system_log_file):
def __init__(self, out_dir, target_cpu, system_log_file, fuchsia_out_dir):
"""out_dir: The directory which will contain the files that are
generated to support the emulator deployment.
target_cpu: The emulated target CPU architecture.
Can be 'x64' or 'arm64'."""
# fuchsia_out_dir is unused by emulator targets.
del fuchsia_out_dir
super(EmuTarget, self).__init__(out_dir, target_cpu)
self._emu_process = None
self._system_log_file = system_log_file
......
......@@ -40,9 +40,16 @@ def GetTargetType():
class QemuTarget(emu_target.EmuTarget):
EMULATOR_NAME = 'qemu'
def __init__(self, out_dir, target_cpu, system_log_file, cpu_cores,
require_kvm, ram_size_mb):
super(QemuTarget, self).__init__(out_dir, target_cpu, system_log_file)
def __init__(self,
out_dir,
target_cpu,
system_log_file,
cpu_cores,
require_kvm,
ram_size_mb,
fuchsia_out_dir=None):
super(QemuTarget, self).__init__(out_dir, target_cpu, system_log_file,
fuchsia_out_dir)
self._cpu_cores=cpu_cores
self._require_kvm=require_kvm
self._ram_size_mb=ram_size_mb
......
......@@ -4,5 +4,8 @@ robertma@chromium.org
tkent@chromium.org
wangxianzhu@chromium.org
# For Fuchsia related files
per-file *fuchsia.py=file://build/fuchsia/OWNERS
# TEAM: blink-infra@chromium.org
# COMPONENT: Blink>Infra
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