diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index 2f90dd295189bd585c7a92405a3a48be53808f53..dc21ad653fc4c4125ff0bbd58df399eff86aa4cc 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -6,6 +6,7 @@ assert(is_fuchsia) import("//build/fuchsia/sdk.gni") import("$flutter_root/shell/gpu/gpu.gni") +import("$flutter_root/tools/fuchsia/clang.gni") import("$flutter_root/tools/fuchsia/package_dir.gni") shell_gpu_configuration("fuchsia_gpu_configuration") { @@ -193,7 +194,9 @@ template("jit_runner") { }, ] - fuchsia_sdk_lib = "//fuchsia/sdk/$host_os/arch/$host_cpu/lib" + fuchsia_sdk_base = "//fuchsia/sdk/$host_os/arch/$host_cpu" + fuchsia_sdk_lib = "$fuchsia_sdk_base/lib" + sysroot_lib = "$fuchsia_sdk_base/sysroot/lib" libraries = [ { @@ -220,6 +223,27 @@ template("jit_runner") { name = "libvulkan.so" path = rebase_path("$fuchsia_sdk_lib") }, + { + name = "libzircon.so" + path = rebase_path("$sysroot_lib") + }, + { + name = "libc.so" + path = rebase_path("$sysroot_lib") + }, + + # Note, we use the md5 hashes here because of gn limitations of json parsing. + # This is a hack, and we can migrate to a better way soon. + { + name = "libc++.so.2" + path = rebase_path( + "$clang_base/${clang_manifest_json.md5_33bfe15b05ada4ed326fbc33adb39b95}") + }, + { + name = "libc++abi.so.1" + path = rebase_path( + "$clang_base/${clang_manifest_json.md5_916c01a85e3353f124776599819ecb1c}") + }, ] meta = [ diff --git a/tools/fuchsia/clang.gni b/tools/fuchsia/clang.gni new file mode 100644 index 0000000000000000000000000000000000000000..0e40aa0b584f0795c0d899349080da3918ae354a --- /dev/null +++ b/tools/fuchsia/clang.gni @@ -0,0 +1,33 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +declare_args() { + # The default clang toolchain provided by the prebuilt. This variable is + # additionally consumed by the Go toolchain. + clang_base = rebase_path("//fuchsia/toolchain/$host_os/lib") +} + +if (current_cpu == "arm64") { + clang_cpu = "aarch64" +} else if (current_cpu == "x64") { + clang_cpu = "x86_64" +} else { + assert(false, "CPU not supported") +} + +if (is_fuchsia) { + clang_target = "${clang_cpu}-fuchsia" +} else if (is_linux) { + clang_target = "${clang_cpu}-linux-gnu" +} else if (is_mac) { + clang_target = "${clang_cpu}-apple-darwin" +} else { + assert(false, "OS not supported") +} + +clang_manifest = rebase_path("$clang_base/${clang_target}.manifest") +clang_manifest_json = + exec_script("$flutter_root/tools/fuchsia/parse_manifest.py", + [ "--input=${clang_manifest}" ], + "json") diff --git a/tools/fuchsia/copy_path.py b/tools/fuchsia/copy_path.py index da529334151f15403db5e26c9eb5a13aeab49238..306895af86be25048722dd87fcfc13429229df54 100755 --- a/tools/fuchsia/copy_path.py +++ b/tools/fuchsia/copy_path.py @@ -3,7 +3,7 @@ # Copyright 2013 The Flutter Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -""" Gather all the fuchsia artifacts to a destination directory. +""" Copies paths, creates if they do not exist. """ import argparse @@ -41,7 +41,7 @@ def CopyPath(src, dst): except OSError as exc: if exc.errno == errno.ENOTDIR: if not SameFile(src, dst): - shutil.copy(src, dst) + shutil.copyfile(src, dst) else: raise diff --git a/tools/fuchsia/parse_manifest.py b/tools/fuchsia/parse_manifest.py new file mode 100755 index 0000000000000000000000000000000000000000..d5ec555b6fe32f3c267c68ff05602956c7422854 --- /dev/null +++ b/tools/fuchsia/parse_manifest.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +""" Parses manifest file and dumps it to json. +""" + +import argparse +import json +import os +import sys +import hashlib + + +def main(): + parser = argparse.ArgumentParser() + + parser.add_argument( + '--input', dest='file_path', action='store', required=True) + + args = parser.parse_args() + + files = open(args.file_path, 'r') + lines = files.read().split() + + output = {} + + for line in lines: + key, val = line.strip().split('=') + md5 = hashlib.md5(key.encode()).hexdigest() + hash_key = 'md5_%s' % md5 + output[hash_key] = os.path.dirname(val) + + print(json.dumps(output)) + + return 0 + + +if __name__ == '__main__': + sys.exit(main())