[Fuchsia] Add Mac build support.
This adds support to build Chromium for Fuchsia on macOS. Currently, this configuration is to be treated as best-effort. CQ_INCLUDE_TRYBOTS=luci.chromium.try:fuchsia_arm64_cast_audio;luci.chromium.try:fuchsia_x64_cast_audio Bug: 707030 Test: Locally, builds on mac. Change-Id: I9e4bde1b7ff658f51586856ae80598c93a2b2e33 Reviewed-on: https://chromium-review.googlesource.com/1185020 Reviewed-by: John Budorick <jbudorick@chromium.org> Reviewed-by: Kevin Marshall <kmarshall@chromium.org> Reviewed-by: Wez <wez@chromium.org> Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#587546} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: bbc67a1bd5cc611039aef8c6a2f9fa7151a07735
This commit is contained in:
Родитель
1bad69d0ba
Коммит
ed29828362
|
@ -121,7 +121,7 @@ action("blobstore_extended_qcow2") {
|
|||
]
|
||||
|
||||
args = [
|
||||
rebase_path("//third_party/qemu/bin/qemu-img", root_build_dir),
|
||||
rebase_path("${qemu_root}/bin/qemu-img", root_build_dir),
|
||||
"convert",
|
||||
"-f",
|
||||
"raw",
|
||||
|
|
|
@ -17,3 +17,6 @@ if (current_cpu == "arm64") {
|
|||
} else {
|
||||
assert(false, "No libraries available for architecture: $current_cpu")
|
||||
}
|
||||
|
||||
# Compute the qemu path.
|
||||
qemu_root = "//third_party/qemu-${host_os}-${host_cpu}"
|
||||
|
|
|
@ -69,7 +69,7 @@ template("fuchsia_package_runner") {
|
|||
_manifest_path,
|
||||
"//build/fuchsia/",
|
||||
"//build/util/lib/",
|
||||
"//third_party/qemu",
|
||||
"${qemu_root}/",
|
||||
"${fuchsia_sdk}/",
|
||||
]
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ def _MakeQcowDisk(output_dir, disk_path):
|
|||
"""Creates a QEMU copy-on-write version of |disk_path| in the output
|
||||
directory."""
|
||||
|
||||
qimg_path = os.path.join(common.QEMU_ROOT, 'bin', 'qemu-img')
|
||||
qimg_path = os.path.join(common.GetQemuRootForPlatform(), 'bin', 'qemu-img')
|
||||
output_path = os.path.join(output_dir,
|
||||
os.path.basename(disk_path) + '.qcow2')
|
||||
subprocess.check_call([qimg_path, 'create', '-q', '-f', 'qcow2',
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
# found in the LICENSE file.
|
||||
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
DIR_SOURCE_ROOT = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||
QEMU_ROOT = os.path.join(DIR_SOURCE_ROOT, 'third_party', 'qemu')
|
||||
SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, 'third_party', 'fuchsia-sdk', 'sdk')
|
||||
|
||||
def EnsurePathExists(path):
|
||||
|
@ -17,3 +18,24 @@ def EnsurePathExists(path):
|
|||
raise IOError('Missing file: ' + path)
|
||||
|
||||
return path
|
||||
|
||||
def GetHostOsFromPlatform():
|
||||
host_platform = sys.platform
|
||||
if host_platform.startswith('linux'):
|
||||
return 'linux'
|
||||
elif host_platform.startswith('darwin'):
|
||||
return 'mac'
|
||||
raise Exception('Unsupported host platform: %s' % host_platform)
|
||||
|
||||
def GetHostArchFromPlatform():
|
||||
host_arch = platform.machine()
|
||||
if host_arch == 'x86_64':
|
||||
return 'x64'
|
||||
elif host_arch == 'aarch64':
|
||||
return 'arm64'
|
||||
raise Exception('Unsupported host architecture: %s' % host_arch)
|
||||
|
||||
def GetQemuRootForPlatform():
|
||||
return os.path.join(DIR_SOURCE_ROOT, 'third_party',
|
||||
'qemu-' + GetHostOsFromPlatform() + '-' +
|
||||
GetHostArchFromPlatform())
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
61465d3f598a8ad7e6cde3f6505684c63d5361de
|
|
@ -14,7 +14,7 @@ import subprocess
|
|||
import sys
|
||||
import time
|
||||
|
||||
from common import QEMU_ROOT, EnsurePathExists
|
||||
from common import GetQemuRootForPlatform, EnsurePathExists
|
||||
|
||||
|
||||
# Virtual networking configuration data for QEMU.
|
||||
|
@ -57,7 +57,7 @@ class QemuTarget(target.Target):
|
|||
self._qemu_process.kill()
|
||||
|
||||
def Start(self):
|
||||
qemu_path = os.path.join(QEMU_ROOT, 'bin',
|
||||
qemu_path = os.path.join(GetQemuRootForPlatform(), 'bin',
|
||||
'qemu-system-' + self._GetTargetSdkLegacyArch())
|
||||
kernel_args = boot_data.GetKernelArgs(self._output_dir)
|
||||
|
||||
|
@ -100,24 +100,27 @@ class QemuTarget(target.Target):
|
|||
]
|
||||
|
||||
# Configure the machine & CPU to emulate, based on the target architecture.
|
||||
# Enable lightweight virtualization (KVM) if the host and guest OS run on
|
||||
# the same architecture.
|
||||
if self._target_cpu == 'arm64':
|
||||
qemu_command.extend([
|
||||
'-machine','virt',
|
||||
'-cpu', 'cortex-a53',
|
||||
])
|
||||
netdev_type = 'virtio-net-pci'
|
||||
if platform.machine() == 'aarch64':
|
||||
qemu_command.append('-enable-kvm')
|
||||
else:
|
||||
qemu_command.extend([
|
||||
'-machine', 'q35',
|
||||
'-cpu', 'host,migratable=no',
|
||||
])
|
||||
netdev_type = 'e1000'
|
||||
if platform.machine() == 'x86_64':
|
||||
|
||||
# On Linux, enable lightweight virtualization (KVM) if the host and guest
|
||||
# architectures are the same.
|
||||
if sys.platform.startswith('linux'):
|
||||
if self._target_cpu == 'arm64' and platform.machine() == 'aarch64':
|
||||
qemu_command.append('-enable-kvm')
|
||||
elif self._target_cpu == 'x64' and platform.machine() == 'x86_64':
|
||||
qemu_command.extend([
|
||||
'-enable-kvm', '-cpu', 'host,migratable=no',
|
||||
])
|
||||
|
||||
# Configure virtual network. It is used in the tests to connect to
|
||||
# testserver running on the host.
|
||||
|
|
|
@ -10,12 +10,13 @@ import json
|
|||
import logging
|
||||
import multiprocessing
|
||||
import os
|
||||
import select
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import uuid
|
||||
import select
|
||||
|
||||
from symbolizer import FilterStream
|
||||
|
||||
|
@ -40,47 +41,33 @@ def _ReadMergedLines(streams):
|
|||
signals EOF. Absolute output ordering is not guaranteed."""
|
||||
|
||||
assert len(streams) > 0
|
||||
poll = select.poll()
|
||||
streams_by_fd = {}
|
||||
primary_fd = streams[0].fileno()
|
||||
for s in streams:
|
||||
poll.register(s.fileno(), select.POLLIN)
|
||||
streams_by_fd[s.fileno()] = s
|
||||
|
||||
try:
|
||||
while primary_fd != None:
|
||||
events = poll.poll(1)
|
||||
for fileno, event in events:
|
||||
if event & select.POLLIN:
|
||||
yield streams_by_fd[fileno].readline()
|
||||
|
||||
elif event & select.POLLHUP:
|
||||
poll.unregister(fileno)
|
||||
del streams_by_fd[fileno]
|
||||
|
||||
if fileno == primary_fd:
|
||||
primary_fd = None
|
||||
finally:
|
||||
for fd_to_cleanup, _ in streams_by_fd.iteritems():
|
||||
poll.unregister(fd_to_cleanup)
|
||||
while primary_fd != None:
|
||||
rlist, _, _ = select.select(streams_by_fd, [], [], 0.1)
|
||||
for fileno in rlist:
|
||||
line = streams_by_fd[fileno].readline()
|
||||
if line:
|
||||
yield line
|
||||
elif fileno == primary_fd:
|
||||
primary_fd = None
|
||||
else:
|
||||
del streams_by_fd[fileno]
|
||||
|
||||
|
||||
def DrainStreamToStdout(stream, quit_event):
|
||||
"""Outputs the contents of |stream| until |quit_event| is set."""
|
||||
|
||||
poll = select.poll()
|
||||
poll.register(stream.fileno(), select.POLLIN)
|
||||
try:
|
||||
while not quit_event.is_set():
|
||||
events = poll.poll(1)
|
||||
for fileno, event in events:
|
||||
if event & select.POLLIN:
|
||||
print stream.readline().rstrip()
|
||||
elif event & select.POLLHUP:
|
||||
break
|
||||
|
||||
finally:
|
||||
poll.unregister(stream.fileno())
|
||||
while not quit_event.is_set():
|
||||
rlist, _, _ = select.select([ stream ], [], [], 0.1)
|
||||
if rlist:
|
||||
line = rlist[0].readline()
|
||||
if not line:
|
||||
return
|
||||
print line.rstrip()
|
||||
|
||||
|
||||
def RunPackage(output_dir, target, package_path, package_name, package_deps,
|
||||
|
|
|
@ -13,7 +13,7 @@ import sys
|
|||
import tarfile
|
||||
import tempfile
|
||||
|
||||
SDK_HASH_FILE = os.path.join(os.path.dirname(__file__), 'sdk.sha1')
|
||||
from common import GetHostOsFromPlatform, GetHostArchFromPlatform
|
||||
|
||||
REPOSITORY_ROOT = os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__), '..', '..'))
|
||||
|
@ -24,6 +24,16 @@ import find_depot_tools
|
|||
SDK_SUBDIRS = ["arch", "pkg", "qemu", "sysroot", "target",
|
||||
"toolchain_libs", "tools"]
|
||||
|
||||
def GetSdkHashForPlatform():
|
||||
if sys.platform.startswith('darwin'):
|
||||
return os.path.join(os.path.dirname(__file__), 'mac.sdk.sha1')
|
||||
else:
|
||||
return os.path.join(os.path.dirname(__file__), 'sdk.sha1')
|
||||
|
||||
def GetBucketForPlatform():
|
||||
return 'gs://fuchsia/sdk/{platform}-amd64/'.format(
|
||||
platform = GetHostOsFromPlatform())
|
||||
|
||||
|
||||
def EnsureDirExists(path):
|
||||
if not os.path.exists(path):
|
||||
|
@ -63,11 +73,12 @@ def main():
|
|||
# there.
|
||||
Cleanup(os.path.join(REPOSITORY_ROOT, 'third_party', 'fuchsia-sdk'))
|
||||
|
||||
with open(SDK_HASH_FILE, 'r') as f:
|
||||
hash_file = GetSdkHashForPlatform()
|
||||
with open(hash_file, 'r') as f:
|
||||
sdk_hash = f.read().strip()
|
||||
|
||||
if not sdk_hash:
|
||||
print >>sys.stderr, 'No SHA1 found in %s' % SDK_HASH_FILE
|
||||
print >>sys.stderr, 'No SHA1 found in %s' % hash_file
|
||||
return 1
|
||||
|
||||
output_dir = os.path.join(REPOSITORY_ROOT, 'third_party', 'fuchsia-sdk',
|
||||
|
@ -89,9 +100,8 @@ def main():
|
|||
os.close(fd)
|
||||
|
||||
try:
|
||||
bucket = 'gs://fuchsia/sdk/linux-amd64/'
|
||||
cmd = [os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py'),
|
||||
'cp', bucket + sdk_hash, tmp]
|
||||
'cp', GetBucketForPlatform() + sdk_hash, tmp]
|
||||
subprocess.check_call(cmd)
|
||||
with open(tmp, 'rb') as f:
|
||||
EnsureDirExists(output_dir)
|
||||
|
|
|
@ -9,14 +9,17 @@ import("//build/config/fuchsia/config.gni")
|
|||
# the different target architectures.
|
||||
template("fuchsia_clang_toolchain") {
|
||||
clang_toolchain(target_name) {
|
||||
assert(host_os == "linux")
|
||||
assert(host_os == "linux" || host_os == "mac")
|
||||
assert(defined(invoker.toolchain_args),
|
||||
"toolchain_args must be defined for fuchsia_clang_toolchain()")
|
||||
|
||||
# We want to build and strip binaries, but retain the unstripped binaries
|
||||
# in runtime_deps to make them available for isolates.
|
||||
strip = rebase_path("//third_party/eu-strip/bin/eu-strip", root_build_dir)
|
||||
use_unstripped_as_runtime_outputs = true
|
||||
# TODO(https://crbug.com/877080): Switch to llvm-strip.
|
||||
if (host_os == "linux") {
|
||||
strip = rebase_path("//third_party/eu-strip/bin/eu-strip", root_build_dir)
|
||||
use_unstripped_as_runtime_outputs = true
|
||||
}
|
||||
|
||||
toolchain_args = invoker.toolchain_args
|
||||
toolchain_args.current_os = "fuchsia"
|
||||
|
|
Загрузка…
Ссылка в новой задаче