Commit 9638e4f4 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

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: I7c0eaef08765f8119bec9a67d381014d07ba4606
Reviewed-on: https://chromium-review.googlesource.com/985474Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarJames Robinson <jamesr@chromium.org>
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549641}
parent 24b33eb7
......@@ -74,8 +74,10 @@ def _GetStrippedPath(bin_path):
"""Finds the stripped version of the binary |bin_path| in the build
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:
raise Exception('File "%s" is not in an .unstripped directory.' % bin_path)
return bin_path
return os.path.normpath(os.path.join(bin_path,
os.path.pardir,
......@@ -104,20 +106,21 @@ def BuildManifest(root_dir, out_dir, app_name, app_filename,
next_path = next_path.strip()
if os.path.isdir(next_path):
for root, _, files in os.walk(next_path):
for next_file in files:
if next_file.startswith('.'):
for current_file in files:
if current_file.startswith('.'):
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:
expanded_files.add(os.path.abspath(next_path))
# Format and write out the manifest contents.
app_found = False
for next_file in expanded_files:
if _IsBinary(next_file):
next_file = _GetStrippedPath(next_file)
for current_file in expanded_files:
if _IsBinary(current_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])
if in_package_path == app_filename:
in_package_path = 'bin/app'
......@@ -127,7 +130,14 @@ def BuildManifest(root_dir, out_dir, app_name, app_filename,
# environments with differing parent directory structures,
# e.g. builder bots and swarming clients.
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:
raise Exception('Could not locate executable inside runtime_deps.')
......
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/fuchsia/config.gni")
import("//build/config/sysroot.gni")
# Creates a Fuchsia .far package file.
#
......@@ -34,7 +35,7 @@ template("package") {
_bundle_target = "${pkg.package_name}__bundle"
# Generates a manifest file based on the GN runtime deps
# suitable for "far" tool consumption.
# suitable for "pm" tool consumption.
action(_write_manifest_target) {
forward_variables_from(invoker,
[
......@@ -47,6 +48,7 @@ template("package") {
inputs = [
_runtime_deps_file,
"//build/config/fuchsia/sandbox_policy",
]
outputs = [
......@@ -55,6 +57,11 @@ template("package") {
data_deps = pkg.deps
# Include the SDK's core dynamic libraries in the package.
data = [
"${sysroot}/dist/",
]
args = [
rebase_path("//"),
rebase_path(root_out_dir),
......
{
"features": [ "persistent-storage",
"shell",
"system-temp" ]
"features": [ "persistent-storage", "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