Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit bdc7136

Browse files
authored
[fuchsia] Add sysroot and clang libs to package (#10082)
* [fuchsia] Add sysroot deps * bundle in clang stuff too * fix host_os
1 parent 72f747a commit bdc7136

File tree

4 files changed

+101
-3
lines changed

4 files changed

+101
-3
lines changed

shell/platform/fuchsia/flutter/BUILD.gn

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ assert(is_fuchsia)
66

77
import("//build/fuchsia/sdk.gni")
88
import("$flutter_root/shell/gpu/gpu.gni")
9+
import("$flutter_root/tools/fuchsia/clang.gni")
910
import("$flutter_root/tools/fuchsia/package_dir.gni")
1011

1112
shell_gpu_configuration("fuchsia_gpu_configuration") {
@@ -193,7 +194,9 @@ template("jit_runner") {
193194
},
194195
]
195196

196-
fuchsia_sdk_lib = "//fuchsia/sdk/$host_os/arch/$host_cpu/lib"
197+
fuchsia_sdk_base = "//fuchsia/sdk/$host_os/arch/$host_cpu"
198+
fuchsia_sdk_lib = "$fuchsia_sdk_base/lib"
199+
sysroot_lib = "$fuchsia_sdk_base/sysroot/lib"
197200

198201
libraries = [
199202
{
@@ -220,6 +223,27 @@ template("jit_runner") {
220223
name = "libvulkan.so"
221224
path = rebase_path("$fuchsia_sdk_lib")
222225
},
226+
{
227+
name = "libzircon.so"
228+
path = rebase_path("$sysroot_lib")
229+
},
230+
{
231+
name = "libc.so"
232+
path = rebase_path("$sysroot_lib")
233+
},
234+
235+
# Note, we use the md5 hashes here because of gn limitations of json parsing.
236+
# This is a hack, and we can migrate to a better way soon.
237+
{
238+
name = "libc++.so.2"
239+
path = rebase_path(
240+
"$clang_base/${clang_manifest_json.md5_33bfe15b05ada4ed326fbc33adb39b95}")
241+
},
242+
{
243+
name = "libc++abi.so.1"
244+
path = rebase_path(
245+
"$clang_base/${clang_manifest_json.md5_916c01a85e3353f124776599819ecb1c}")
246+
},
223247
]
224248

225249
meta = [

tools/fuchsia/clang.gni

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
declare_args() {
6+
# The default clang toolchain provided by the prebuilt. This variable is
7+
# additionally consumed by the Go toolchain.
8+
clang_base = rebase_path("//fuchsia/toolchain/$host_os/lib")
9+
}
10+
11+
if (current_cpu == "arm64") {
12+
clang_cpu = "aarch64"
13+
} else if (current_cpu == "x64") {
14+
clang_cpu = "x86_64"
15+
} else {
16+
assert(false, "CPU not supported")
17+
}
18+
19+
if (is_fuchsia) {
20+
clang_target = "${clang_cpu}-fuchsia"
21+
} else if (is_linux) {
22+
clang_target = "${clang_cpu}-linux-gnu"
23+
} else if (is_mac) {
24+
clang_target = "${clang_cpu}-apple-darwin"
25+
} else {
26+
assert(false, "OS not supported")
27+
}
28+
29+
clang_manifest = rebase_path("$clang_base/${clang_target}.manifest")
30+
clang_manifest_json =
31+
exec_script("$flutter_root/tools/fuchsia/parse_manifest.py",
32+
[ "--input=${clang_manifest}" ],
33+
"json")

tools/fuchsia/copy_path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2013 The Flutter Authors. All rights reserved.
44
# Use of this source code is governed by a BSD-style license that can be
55
# found in the LICENSE file.
6-
""" Gather all the fuchsia artifacts to a destination directory.
6+
""" Copies paths, creates if they do not exist.
77
"""
88

99
import argparse
@@ -41,7 +41,7 @@ def CopyPath(src, dst):
4141
except OSError as exc:
4242
if exc.errno == errno.ENOTDIR:
4343
if not SameFile(src, dst):
44-
shutil.copy(src, dst)
44+
shutil.copyfile(src, dst)
4545
else:
4646
raise
4747

tools/fuchsia/parse_manifest.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2013 The Flutter Authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
""" Parses manifest file and dumps it to json.
7+
"""
8+
9+
import argparse
10+
import json
11+
import os
12+
import sys
13+
import hashlib
14+
15+
16+
def main():
17+
parser = argparse.ArgumentParser()
18+
19+
parser.add_argument(
20+
'--input', dest='file_path', action='store', required=True)
21+
22+
args = parser.parse_args()
23+
24+
files = open(args.file_path, 'r')
25+
lines = files.read().split()
26+
27+
output = {}
28+
29+
for line in lines:
30+
key, val = line.strip().split('=')
31+
md5 = hashlib.md5(key.encode()).hexdigest()
32+
hash_key = 'md5_%s' % md5
33+
output[hash_key] = os.path.dirname(val)
34+
35+
print(json.dumps(output))
36+
37+
return 0
38+
39+
40+
if __name__ == '__main__':
41+
sys.exit(main())

0 commit comments

Comments
 (0)