Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reland: [fuchsia] Remove pm use in build_fuchsia_artifacts #55932

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
5 changes: 2 additions & 3 deletions ci/builders/linux_fuchsia.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,13 @@
"parameters": [
"--engine-version",
"${REVISION}",
"--skip-build",
"--upload"
],
"script": "flutter/tools/fuchsia/build_fuchsia_artifacts.py",
"language": "python3"
},
{
"name": "Upload to CIPD for arch: arm64",
"name": "Upload debug symbols to CIPD for arch: arm64",
"parameters": [
"--engine-version",
"${REVISION}",
Expand All @@ -255,7 +254,7 @@
"language": "python3"
},
{
"name": "Upload to CIPD for arch: x64",
"name": "Upload debug symbols to CIPD for arch: x64",
"parameters": [
"--engine-version",
"${REVISION}",
Expand Down
6 changes: 0 additions & 6 deletions shell/platform/fuchsia/dart_runner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ template("aot_runner_package") {
"//flutter/shell/platform/fuchsia/runtime/dart/profiler_symbols:dart_aot_runner",
"target_gen_dir") + "/dart_aot_runner.dartprofilersymbols")

inputs = [
vmservice_snapshot,
observatory_archive_file,
dart_profiler_symbols,
]

resources += [
{
path = vmservice_snapshot
Expand Down
116 changes: 23 additions & 93 deletions tools/fuchsia/build_fuchsia_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,29 @@
import sys
import tempfile

from gather_flutter_runner_artifacts import CreateMetaPackage, CopyPath
from gen_package import CreateFarPackage

_script_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), '..'))
_src_root_dir = os.path.join(_script_dir, '..', '..', '..')
_out_dir = os.path.join(_src_root_dir, 'out', 'ci')
_bucket_directory = os.path.join(_out_dir, 'fuchsia_bucket')


def EnsureParentExists(path):
dir_name, _ = os.path.split(path)
if not os.path.exists(dir_name):
os.makedirs(dir_name)


def CopyPath(src, dst):
try:
EnsureParentExists(dst)
shutil.copytree(src, dst)
except OSError as exc:
if exc.errno == errno.ENOTDIR:
shutil.copy(src, dst)
else:
raise


def IsLinux():
return platform.system() == 'Linux'

Expand All @@ -48,40 +62,6 @@ def GetFuchsiaSDKPath():
return os.path.join(_src_root_dir, 'fuchsia', 'sdk', host_os)


def GetHostArchFromPlatform():
host_arch = platform.machine()
# platform.machine() returns AMD64 on 64-bit Windows.
if host_arch in ['x86_64', 'AMD64']:
return 'x64'
elif host_arch == 'aarch64':
return 'arm64'
raise Exception('Unsupported host architecture: %s' % host_arch)


def GetPMBinPath():
return os.path.join(GetFuchsiaSDKPath(), 'tools', GetHostArchFromPlatform(), 'pm')


def RunExecutable(command):
subprocess.check_call(command, cwd=_src_root_dir)


def RunGN(variant_dir, flags):
print('Running gn for variant "%s" with flags: %s' % (variant_dir, ','.join(flags)))
RunExecutable([
os.path.join('flutter', 'tools', 'gn'),
] + flags)

assert os.path.exists(os.path.join(_out_dir, variant_dir))


def BuildNinjaTargets(variant_dir, targets):
assert os.path.exists(os.path.join(_out_dir, variant_dir))

print('Running autoninja for targets: %s' % targets)
RunExecutable(['autoninja', '-C', os.path.join(_out_dir, variant_dir)] + targets)


def RemoveDirectoryIfExists(path):
if not os.path.exists(path):
return
Expand Down Expand Up @@ -148,22 +128,18 @@ def CopyZirconFFILibIfExists(source, destination):

def CopyToBucketWithMode(source, destination, aot, product, runner_type, api_level):
mode = 'aot' if aot else 'jit'
product_suff = '_product' if product else ''
runner_name = '%s_%s%s_runner' % (runner_type, mode, product_suff)
far_dir_name = '%s_far' % runner_name
source_root = os.path.join(_out_dir, source)
far_base = os.path.join(source_root, far_dir_name)
CreateMetaPackage(far_base, runner_name)
pm_bin = GetPMBinPath()
key_path = os.path.join(_script_dir, 'development.key')

destination = os.path.join(_bucket_directory, destination, mode)
CreateFarPackage(pm_bin, far_base, key_path, destination, api_level)

far_file = '%s_%s%s_runner-0.far' % (runner_type, mode, '_product' if product else '')
CopyPath('%s/%s' % (source_root, far_file), '%s/%s' % (destination, far_file))

patched_sdk_dirname = '%s_runner_patched_sdk' % runner_type
patched_sdk_dir = os.path.join(source_root, patched_sdk_dirname)
dest_sdk_path = os.path.join(destination, patched_sdk_dirname)
if not os.path.exists(dest_sdk_path):
CopyPath(patched_sdk_dir, dest_sdk_path)

CopyGenSnapshotIfExists(source_root, destination)
CopyFlutterTesterBinIfExists(source_root, destination)
CopyZirconFFILibIfExists(source_root, destination)
Expand Down Expand Up @@ -259,7 +235,7 @@ def RunCIPDCommandWithRetries(command):
subprocess.check_call(command, cwd=_bucket_directory)
break
except subprocess.CalledProcessError:
print('Failed %s times' % tries + 1)
print('Failed %s times' % str(tries + 1))
if tries == num_tries - 1:
raise

Expand Down Expand Up @@ -298,39 +274,6 @@ def ProcessCIPDPackage(upload, engine_version):
])


def BuildTarget(
runtime_mode, arch, optimized, enable_lto, enable_legacy, asan, dart_version_git_info,
prebuilt_dart_sdk, build_targets
):
unopt = "_unopt" if not optimized else ""
out_dir = 'fuchsia_%s%s_%s' % (runtime_mode, unopt, arch)
flags = [
'--fuchsia',
'--fuchsia-cpu',
arch,
'--runtime-mode',
runtime_mode,
]

if not optimized:
flags.append('--unoptimized')
if not enable_lto:
flags.append('--no-lto')
if not enable_legacy:
flags.append('--no-fuchsia-legacy')
if asan:
flags.append('--asan')
if not dart_version_git_info:
flags.append('--no-dart-version-git-info')
if not prebuilt_dart_sdk:
flags.append('--no-prebuilt-dart-sdk')

RunGN(out_dir, flags)
BuildNinjaTargets(out_dir, build_targets)

return


def main():
parser = argparse.ArgumentParser()

Expand Down Expand Up @@ -381,13 +324,6 @@ def main():
help='If set, disables legacy code for the build.'
)

parser.add_argument(
'--skip-build',
action='store_true',
default=False,
help='If set, skips building and just creates packages.'
)

parser.add_argument(
'--targets',
default='',
Expand Down Expand Up @@ -447,12 +383,6 @@ def main():
runtime_mode = runtime_modes[i]
product = product_modes[i]
if build_mode == 'all' or runtime_mode == build_mode:
if not args.skip_build:
BuildTarget(
runtime_mode, arch, optimized, enable_lto, enable_legacy, args.asan,
not args.no_dart_version_git_info, not args.no_prebuilt_dart_sdk,
args.targets.split(",") if args.targets else ['flutter']
)
CopyBuildToBucket(runtime_mode, arch, optimized, product)

# This is a hack. The recipe for building and uploading Fuchsia to CIPD
Expand Down
68 changes: 0 additions & 68 deletions tools/fuchsia/copy_path.py

This file was deleted.

1 change: 0 additions & 1 deletion tools/fuchsia/development.key

This file was deleted.

Loading