Commit 54c93b85 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

Reland "Fuchsia: remove "shell" capability and add dynamic libraries to packages."

Removing the "shell" capability allows packaged apps to load dynamic libraries
from the package. In addition, it prevents the app from using any
system-provided libraries, in favor of the package supplying all of its
data and dynamic library dependencies.

This CL includes the system libraries from the SDK's "dist" directory in
packages built using the package() GN template.


Bug: 823927
Change-Id: Ibc22913658f73d992e563e829a377be66f61f805
Reviewed-on: https://chromium-review.googlesource.com/1025046Reviewed-by: default avatarScott Graham <scottmg@chromium.org>
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552950}
parent 4572fe08
...@@ -74,8 +74,10 @@ def _GetStrippedPath(bin_path): ...@@ -74,8 +74,10 @@ def _GetStrippedPath(bin_path):
"""Finds the stripped version of the binary |bin_path| in the build """Finds the stripped version of the binary |bin_path| in the build
output directory.""" output directory."""
# Skip the resolution step for binaries that don't have stripped counterparts,
# like system libraries or other libraries built outside the Chromium build.
if not '.unstripped' in bin_path: if not '.unstripped' in bin_path:
raise Exception('File "%s" is not in an .unstripped directory.' % bin_path) return bin_path
return os.path.normpath(os.path.join(bin_path, return os.path.normpath(os.path.join(bin_path,
os.path.pardir, os.path.pardir,
...@@ -104,20 +106,21 @@ def BuildManifest(root_dir, out_dir, app_name, app_filename, ...@@ -104,20 +106,21 @@ def BuildManifest(root_dir, out_dir, app_name, app_filename,
next_path = next_path.strip() next_path = next_path.strip()
if os.path.isdir(next_path): if os.path.isdir(next_path):
for root, _, files in os.walk(next_path): for root, _, files in os.walk(next_path):
for next_file in files: for current_file in files:
if next_file.startswith('.'): if current_file.startswith('.'):
continue continue
expanded_files.add(os.path.abspath(os.path.join(root, next_file))) expanded_files.add(os.path.abspath(
os.path.join(root, current_file)))
else: else:
expanded_files.add(os.path.abspath(next_path)) expanded_files.add(os.path.abspath(next_path))
# Format and write out the manifest contents. # Format and write out the manifest contents.
app_found = False app_found = False
for next_file in expanded_files: for current_file in expanded_files:
if _IsBinary(next_file): if _IsBinary(current_file):
next_file = _GetStrippedPath(next_file) current_file = _GetStrippedPath(current_file)
in_package_path = MakePackagePath(os.path.join(out_dir, next_file), in_package_path = MakePackagePath(os.path.join(out_dir, current_file),
[root_dir, out_dir]) [root_dir, out_dir])
if in_package_path == app_filename: if in_package_path == app_filename:
in_package_path = 'bin/app' in_package_path = 'bin/app'
...@@ -127,7 +130,14 @@ def BuildManifest(root_dir, out_dir, app_name, app_filename, ...@@ -127,7 +130,14 @@ def BuildManifest(root_dir, out_dir, app_name, app_filename,
# environments with differing parent directory structures, # environments with differing parent directory structures,
# e.g. builder bots and swarming clients. # e.g. builder bots and swarming clients.
output.write('%s=%s\n' % (in_package_path, output.write('%s=%s\n' % (in_package_path,
os.path.relpath(next_file, out_dir))) os.path.relpath(current_file, out_dir)))
# Use libc.so's dynamic linker by aliasing libc.so to ld.so.1.
# Fuchsia always looks for the linker implementation in ld.so.1.
if os.path.basename(in_package_path) == 'libc.so':
output.write('%s=%s\n' % (os.path.dirname(in_package_path) + '/ld.so.1',
os.path.relpath(current_file, out_dir)))
if not app_found: if not app_found:
raise Exception('Could not locate executable inside runtime_deps.') raise Exception('Could not locate executable inside runtime_deps.')
......
...@@ -8,3 +8,12 @@ declare_args() { ...@@ -8,3 +8,12 @@ declare_args() {
# Path to Fuchsia SDK. # Path to Fuchsia SDK.
fuchsia_sdk = "//third_party/fuchsia-sdk/sdk" fuchsia_sdk = "//third_party/fuchsia-sdk/sdk"
} }
# Compute the arch-specific path to packages' dynamic library dependencies.
if (current_cpu == "arm64") {
dist_libroot = fuchsia_sdk + "/arch/arm64/dist"
} else if (current_cpu == "x64") {
dist_libroot = fuchsia_sdk + "/arch/x64/dist"
} else {
dist_libroot = ""
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/fuchsia/config.gni") import("//build/config/fuchsia/config.gni")
import("//build/config/sysroot.gni")
# Creates a Fuchsia .far package file. # Creates a Fuchsia .far package file.
# #
...@@ -34,7 +35,7 @@ template("package") { ...@@ -34,7 +35,7 @@ template("package") {
_bundle_target = "${pkg.package_name}__bundle" _bundle_target = "${pkg.package_name}__bundle"
# Generates a manifest file based on the GN runtime deps # Generates a manifest file based on the GN runtime deps
# suitable for "far" tool consumption. # suitable for "pm" tool consumption.
action(_write_manifest_target) { action(_write_manifest_target) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
...@@ -47,6 +48,7 @@ template("package") { ...@@ -47,6 +48,7 @@ template("package") {
inputs = [ inputs = [
_runtime_deps_file, _runtime_deps_file,
"//build/config/fuchsia/sandbox_policy",
] ]
outputs = [ outputs = [
...@@ -55,6 +57,11 @@ template("package") { ...@@ -55,6 +57,11 @@ template("package") {
data_deps = pkg.deps data_deps = pkg.deps
# Include the SDK's core dynamic libraries in the package.
data = [
dist_libroot,
]
args = [ args = [
rebase_path("//"), rebase_path("//"),
rebase_path(root_out_dir), rebase_path(root_out_dir),
......
{ {
"features": [ "persistent-storage", "features": [ "persistent-storage", "system-temp" ]
"shell",
"system-temp" ]
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment