fuchsia: Fix some packaging when run isn't from Crashpad source root

- Use gn --root rather than setting the cwd when running GN so it can
find //.gn.

- Use source-relative path for assets when building the target path, see
for example the failure in:
https://build.chromium.org/p/client.crashpad/builders/crashpad_fuchsia_x64_rel/builds/77/steps/run%20tests/logs/stdio

Bug: crashpad:196
Change-Id: If95636fcb826c22d9d9543cad02f815780621414
Reviewed-on: https://chromium-review.googlesource.com/923436
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Scott Graham 2018-02-16 13:49:30 -08:00 committed by Commit Bot
parent 4b78956158
commit 8ee14eef08

View File

@ -70,10 +70,11 @@ def _BinaryDirTargetOS(binary_dir):
if gn_path:
# Look for a GN “target_os”.
popen = subprocess.Popen(
[gn_path, 'args', binary_dir, '--list=target_os', '--short'],
shell=IS_WINDOWS_HOST, stdout=subprocess.PIPE, stderr=open(os.devnull),
cwd=CRASHPAD_DIR)
popen = subprocess.Popen([gn_path, '--root=' + CRASHPAD_DIR,
'args', binary_dir,
'--list=target_os', '--short'],
shell=IS_WINDOWS_HOST,
stdout=subprocess.PIPE, stderr=open(os.devnull))
value = popen.communicate()[0]
if popen.returncode == 0:
match = re.match('target_os = "(.*)"$', value.decode('utf-8'))
@ -310,13 +311,13 @@ def _GetFuchsiaSDKRoot():
def _GenerateFuchsiaRuntimeDepsFiles(binary_dir, tests):
"""Ensures a <binary_dir>/<test>.runtime_deps file exists for each test."""
targets_file = os.path.abspath(os.path.join(binary_dir, 'targets.txt'))
targets_file = os.path.join(binary_dir, 'targets.txt')
with open(targets_file, 'wb') as f:
f.write('//:' + '\n//:'.join(tests) + '\n')
gn_path = _FindGNFromBinaryDir(binary_dir)
subprocess.check_call(
[gn_path, 'gen', binary_dir, '--runtime-deps-list-file=' + targets_file],
cwd=CRASHPAD_DIR)
[gn_path, '--root=' + CRASHPAD_DIR, 'gen', binary_dir,
'--runtime-deps-list-file=' + targets_file])
def _HandleOutputFromFuchsiaLogListener(process, done_message):
@ -373,7 +374,8 @@ def _RunOnFuchsiaTarget(binary_dir, test, device_name, extra_command_line):
staging_root = test_root + '/pkg'
# Make a staging directory tree on the target.
directories_to_create = [tmp_root, '%s/bin' % staging_root,
directories_to_create = [tmp_root,
'%s/bin' % staging_root,
'%s/assets' % staging_root]
netruncmd(['mkdir', '-p'] + directories_to_create)
@ -396,7 +398,8 @@ def _RunOnFuchsiaTarget(binary_dir, test, device_name, extra_command_line):
target_path = os.path.join(
staging_root, 'bin', local_path[len(binary_dir)+1:])
else:
target_path = os.path.join(staging_root, 'assets', local_path)
relative_path = os.path.relpath(local_path, CRASHPAD_DIR)
target_path = os.path.join(staging_root, 'assets', relative_path)
netcp_path = os.path.join(sdk_root, 'tools', 'netcp')
subprocess.check_call([netcp_path, local_path,
device_name + ':' + target_path],