[fuchsia] Dbg symbols cipd package doesn't contain tmp dir (flutter/engine#18433)
Fixes: fxb/41743
This commit is contained in:
@@ -21,27 +21,33 @@ def IsLinux():
|
||||
return platform.system() == 'Linux'
|
||||
|
||||
|
||||
# out_dir here is of the format "/b/s/w/ir/k/recipe_cleanup/tmpIbWDdp"
|
||||
# we need to palce the cipd definition in this directory.
|
||||
def GetPackagingDir(out_dir):
|
||||
return os.path.abspath(os.path.join(out_dir, os.pardir))
|
||||
return os.path.abspath(out_dir)
|
||||
|
||||
|
||||
def CreateCIPDDefinition(target_arch, out_dir):
|
||||
def CreateCIPDDefinition(target_arch, out_dir, symbol_dirs):
|
||||
dir_name = os.path.basename(os.path.normpath(out_dir))
|
||||
return """
|
||||
pkg_def = """
|
||||
package: flutter/fuchsia-debug-symbols-%s
|
||||
description: Flutter and Dart runner debug symbols for Fuchsia. Target architecture %s.
|
||||
install_mode: copy
|
||||
data:
|
||||
- dir: %s
|
||||
""" % (target_arch, target_arch, dir_name)
|
||||
""" % (target_arch, target_arch)
|
||||
for symbol_dir in symbol_dirs:
|
||||
symbol_dir_name = os.path.basename(os.path.normpath(symbol_dir))
|
||||
data = '\n - dir: %s' % (symbol_dir_name)
|
||||
pkg_def = pkg_def + data
|
||||
return pkg_def
|
||||
|
||||
|
||||
# CIPD CLI needs the definition and data directory to be relative to each other.
|
||||
def WriteCIPDDefinition(target_arch, out_dir):
|
||||
def WriteCIPDDefinition(target_arch, out_dir, symbol_dirs):
|
||||
_packaging_dir = GetPackagingDir(out_dir)
|
||||
yaml_file = os.path.join(_packaging_dir, 'debug_symbols.cipd.yaml')
|
||||
with open(yaml_file, 'w') as f:
|
||||
cipd_def = CreateCIPDDefinition(target_arch, out_dir)
|
||||
cipd_def = CreateCIPDDefinition(target_arch, out_dir, symbol_dirs)
|
||||
f.write(cipd_def)
|
||||
return yaml_file
|
||||
|
||||
@@ -68,20 +74,28 @@ def ProcessCIPDPackage(upload, cipd_yaml, engine_version, out_dir, target_arch):
|
||||
try:
|
||||
subprocess.check_call(command, cwd=_packaging_dir)
|
||||
break
|
||||
except subprocess.CalledProcessError:
|
||||
print('Failed %s times' % tries + 1)
|
||||
except subprocess.CalledProcessError as error:
|
||||
print('Failed %s times.\nError was: %s' % (tries + 1, error))
|
||||
if tries == num_tries - 1:
|
||||
raise
|
||||
|
||||
# Recursively hardlinks contents from one directory to another,
|
||||
# skipping over collisions.
|
||||
def HardlinkContents(dirA, dirB):
|
||||
internal_symbol_dirs = []
|
||||
for src_dir, _, filenames in os.walk(dirA):
|
||||
for filename in filenames:
|
||||
# if a file contains 'dbg_success' in its name, it is a stamp file.
|
||||
# An example of this would be
|
||||
# '._dart_jit_runner_dbg_symbols_unstripped_dbg_success' these
|
||||
# are generated by GN and have to be ignored.
|
||||
if 'dbg_success' in filename:
|
||||
continue
|
||||
src = os.path.join(src_dir, filename)
|
||||
dest_dir = os.path.join(dirB, os.path.relpath(src_dir, dirA))
|
||||
try:
|
||||
os.makedirs(dest_dir)
|
||||
internal_symbol_dirs.append(dest_dir)
|
||||
except:
|
||||
pass
|
||||
dest = os.path.join(dest_dir, filename)
|
||||
@@ -92,6 +106,7 @@ def HardlinkContents(dirA, dirB):
|
||||
print('%s already exists in destination; skipping linking' % name)
|
||||
continue
|
||||
os.link(src, dest)
|
||||
return internal_symbol_dirs
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
@@ -130,11 +145,15 @@ def main():
|
||||
shutil.rmtree(out_dir)
|
||||
os.makedirs(out_dir)
|
||||
|
||||
internal_symbol_dirs = []
|
||||
for symbol_dir in symbol_dirs:
|
||||
HardlinkContents(symbol_dir, out_dir)
|
||||
internal_symbol_dirs += HardlinkContents(symbol_dir, out_dir)
|
||||
|
||||
# make these unique
|
||||
internal_symbol_dirs = list(set(internal_symbol_dirs))
|
||||
|
||||
arch = args.target_arch
|
||||
cipd_def = WriteCIPDDefinition(arch, out_dir)
|
||||
cipd_def = WriteCIPDDefinition(arch, out_dir, internal_symbol_dirs)
|
||||
ProcessCIPDPackage(args.upload, cipd_def, args.engine_version, out_dir, arch)
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user