Auto merge of #24753 - servo:mainstream-brew, r=jdm

Use an already-installed Homebrew at /usr/local

This requires https://github.com/servo/taskcluster-config/pull/4 to be deployed.

Having the standard location helps `pkg-config` (CC https://github.com/servo/servo/pull/24688), and allows installing pre-compiled pakcages (which is much faster than compiling from source).
This commit is contained in:
bors-servo 2019-11-17 17:49:14 -05:00 committed by GitHub
commit dfa78986a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 35 deletions

View file

@ -89,7 +89,8 @@ def main(task_for):
elif task_for == "try-windows-ami": elif task_for == "try-windows-ami":
CONFIG.git_sha_is_current_head() CONFIG.git_sha_is_current_head()
windows_unit(os.environ["NEW_AMI_WORKER_TYPE"], cached=False) CONFIG.windows_worker_type = os.environ["NEW_AMI_WORKER_TYPE"]
windows_unit(cached=False)
# https://tools.taskcluster.net/hooks/project-servo/daily # https://tools.taskcluster.net/hooks/project-servo/daily
elif task_for == "daily": elif task_for == "daily":
@ -457,9 +458,9 @@ def uwp_nightly():
) )
def windows_unit(worker_type=None, cached=True): def windows_unit(cached=True):
task = ( task = (
windows_build_task("Dev build + unit tests", worker_type=worker_type) windows_build_task("Dev build + unit tests")
.with_treeherder("Windows x64", "Unit") .with_treeherder("Windows x64", "Unit")
.with_script( .with_script(
# Not necessary as this would be done at the start of `build`, # Not necessary as this would be done at the start of `build`,
@ -594,7 +595,7 @@ def update_wpt():
"etc/taskcluster/macos/Brewfile-gstreamer", "etc/taskcluster/macos/Brewfile-gstreamer",
]) ])
# Pushing the new changes to the git remote requires a full repo clone. # Pushing the new changes to the git remote requires a full repo clone.
.with_repo(shallow=False) .with_repo(shallow=False, alternate_object_dir="/var/cache/servo.git/objects")
.with_curl_artifact_script(build_task, "target.tar.gz") .with_curl_artifact_script(build_task, "target.tar.gz")
.with_script(""" .with_script("""
export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig/" export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig/"
@ -630,19 +631,26 @@ def macos_wpt():
def macos_run_task(name): def macos_run_task(name):
task = macos_task(name).with_python2() task = macos_task(name).with_python2()
return with_homebrew(task, ["etc/taskcluster/macos/Brewfile-gstreamer"]) return with_homebrew(task, ["etc/taskcluster/macos/Brewfile-gstreamer"])
wpt_chunks("macOS x64", macos_run_task, build_task, repo_dir="repo", wpt_chunks(
total_chunks=6, processes=4) "macOS x64",
macos_run_task,
build_task,
repo_dir="repo",
repo_kwargs=dict(alternate_object_dir="/var/cache/servo.git/objects"),
total_chunks=6,
processes=4,
)
def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes, def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes,
repo_dir, chunks="all"): repo_dir, chunks="all", repo_kwargs={}):
if chunks == "all": if chunks == "all":
chunks = [n + 1 for n in range(total_chunks)] chunks = [n + 1 for n in range(total_chunks)]
for this_chunk in chunks: for this_chunk in chunks:
task = ( task = (
make_chunk_task("WPT chunk %s / %s" % (this_chunk, total_chunks)) make_chunk_task("WPT chunk %s / %s" % (this_chunk, total_chunks))
.with_treeherder(platform, "WPT-%s" % this_chunk) .with_treeherder(platform, "WPT-%s" % this_chunk)
.with_repo() .with_repo(**repo_kwargs)
.with_curl_artifact_script(build_task, "target.tar.gz") .with_curl_artifact_script(build_task, "target.tar.gz")
.with_script("tar -xzf target.tar.gz") .with_script("tar -xzf target.tar.gz")
.with_index_and_artifacts_expire_in(log_artifacts_expire_in) .with_index_and_artifacts_expire_in(log_artifacts_expire_in)
@ -757,12 +765,10 @@ def linux_task(name):
) )
def windows_task(name, worker_type=None): def windows_task(name):
if worker_type is None:
worker_type = "win2016"
return ( return (
decisionlib.WindowsGenericWorkerTask(name) decisionlib.WindowsGenericWorkerTask(name)
.with_worker_type(worker_type) .with_worker_type(CONFIG.windows_worker_type)
.with_treeherder_required() .with_treeherder_required()
) )
@ -771,7 +777,7 @@ def macos_task(name):
return ( return (
decisionlib.MacOsGenericWorkerTask(name) decisionlib.MacOsGenericWorkerTask(name)
.with_provisioner_id("proj-servo") .with_provisioner_id("proj-servo")
.with_worker_type("macos") .with_worker_type(CONFIG.macos_worker_type)
.with_treeherder_required() .with_treeherder_required()
) )
@ -814,7 +820,7 @@ def android_build_task(name):
) )
def windows_build_task(name, package=True, arch="x86_64", worker_type=None): def windows_build_task(name, package=True, arch="x86_64"):
hashes = { hashes = {
"devel": { "devel": {
"x86_64": "c136cbfb0330041d52fe6ec4e3e468563176333c857f6ed71191ebc37fc9d605", "x86_64": "c136cbfb0330041d52fe6ec4e3e468563176333c857f6ed71191ebc37fc9d605",
@ -828,7 +834,7 @@ def windows_build_task(name, package=True, arch="x86_64", worker_type=None):
} }
version = "1.16.0" version = "1.16.0"
task = ( task = (
windows_task(name, worker_type=worker_type) windows_task(name)
.with_max_run_time_minutes(90) .with_max_run_time_minutes(90)
.with_env( .with_env(
**build_env, **build_env,
@ -876,26 +882,19 @@ def windows_build_task(name, package=True, arch="x86_64", worker_type=None):
def with_homebrew(task, brewfiles): def with_homebrew(task, brewfiles):
task = task.with_script(""" for brewfile in brewfiles:
mkdir -p "$HOME/homebrew" task.with_script("time brew bundle install --verbose --no-upgrade --file=" + brewfile)
export PATH="$HOME/homebrew/bin:$PATH" return task
which brew || curl -L https://github.com/Homebrew/brew/tarball/master \
| tar xz --strip 1 -C "$HOME/homebrew"
""")
for brewfile in brewfiles:
task = task.with_script("""
time brew bundle install --no-upgrade --file={brewfile}
""".format(brewfile=brewfile))
return task
def macos_build_task(name): def macos_build_task(name):
build_task = ( build_task = (
macos_task(name) macos_task(name)
# Allow long runtime in case the cache expired for all those Homebrew dependencies # Stray processes eating CPU can slow things down:
.with_max_run_time_minutes(60 * 4) # https://github.com/servo/servo/issues/24735
.with_max_run_time_minutes(60 * 2)
.with_env(**build_env, **unix_build_env, **macos_build_env) .with_env(**build_env, **unix_build_env, **macos_build_env)
.with_repo() .with_repo(alternate_object_dir="/var/cache/servo.git/objects")
.with_python2() .with_python2()
.with_rustup() .with_rustup()
# Since macOS workers are long-lived and ~/.rustup kept across tasks: # Since macOS workers are long-lived and ~/.rustup kept across tasks:
@ -917,6 +916,7 @@ def macos_build_task(name):
export OPENSSL_INCLUDE_DIR="$(brew --prefix openssl)/include" export OPENSSL_INCLUDE_DIR="$(brew --prefix openssl)/include"
export OPENSSL_LIB_DIR="$(brew --prefix openssl)/lib" export OPENSSL_LIB_DIR="$(brew --prefix openssl)/lib"
export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig/" export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig/"
export PKG_CONFIG_PATH="$(brew --prefix zlib)/lib/pkgconfig/:$PKG_CONFIG_PATH"
""") """)
.with_directory_mount( .with_directory_mount(
@ -999,6 +999,8 @@ CONFIG.index_prefix = "project.servo"
CONFIG.default_provisioner_id = "proj-servo" CONFIG.default_provisioner_id = "proj-servo"
CONFIG.docker_image_build_worker_type = "docker" CONFIG.docker_image_build_worker_type = "docker"
CONFIG.windows_worker_type = "win2016"
CONFIG.macos_worker_type = "macos"
if __name__ == "__main__": # pragma: no cover if __name__ == "__main__": # pragma: no cover
main(task_for=os.environ["TASK_FOR"]) main(task_for=os.environ["TASK_FOR"])

View file

@ -475,9 +475,9 @@ class WindowsGenericWorkerTask(GenericWorkerTask):
type .git\\info\\sparse-checkout type .git\\info\\sparse-checkout
""" """
git += """ git += """
git fetch {depth} %GIT_URL% %GIT_REF% git fetch --no-tags {depth} %GIT_URL% %GIT_REF%
git reset --hard %GIT_SHA% git reset --hard %GIT_SHA%
""".format(depth="--depth 100" if shallow else "") """.format(depth="--depth 30" if shallow else "")
return self \ return self \
.with_git() \ .with_git() \
.with_script(git) \ .with_script(git) \
@ -579,7 +579,7 @@ class UnixTaskMixin(Task):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.curl_scripts_count = 0 self.curl_scripts_count = 0
def with_repo(self, shallow=True): def with_repo(self, shallow=True, alternate_object_dir=None):
""" """
Make a shallow clone the git repository at the start of the task. Make a shallow clone the git repository at the start of the task.
This uses `CONFIG.git_url`, `CONFIG.git_ref`, and `CONFIG.git_sha` This uses `CONFIG.git_url`, `CONFIG.git_ref`, and `CONFIG.git_sha`
@ -592,14 +592,25 @@ class UnixTaskMixin(Task):
`git` and `ca-certificate` need to be installed in the Docker image. `git` and `ca-certificate` need to be installed in the Docker image.
""" """
# Not using $GIT_ALTERNATE_OBJECT_DIRECTORIES since it causes
# "object not found - no match for id" errors when Cargo fetches git dependencies
if alternate_object_dir:
self.with_env(ALTERNATE_OBJDIR=alternate_object_dir)
return self \ return self \
.with_env(**git_env()) \ .with_env(**git_env()) \
.with_early_script(""" .with_early_script("""
git init repo git init repo
cd repo cd repo
git fetch {depth} "$GIT_URL" "$GIT_REF" {alternate}
git reset --hard "$GIT_SHA" time git fetch --no-tags {depth} "$GIT_URL" "$GIT_REF"
""".format(depth="--depth 100" if shallow else "")) time git reset --hard "$GIT_SHA"
""".format(
depth="--depth 30" if shallow else "",
alternate=(
"""echo "$ALTERNATE_OBJDIR" > .git/objects/info/alternates"""
if alternate_object_dir else ""
)
))
def with_curl_script(self, url, file_path): def with_curl_script(self, url, file_path):
self.curl_scripts_count += 1 self.curl_scripts_count += 1

View file

@ -5,6 +5,7 @@ brew "openssl"
brew "pkg-config" brew "pkg-config"
brew "llvm" brew "llvm"
brew "yasm" brew "yasm"
brew "zlib"
# For sccache # For sccache
brew "openssl@1.1" brew "openssl@1.1"

View file

@ -627,6 +627,9 @@ class MachCommands(CommandBase):
'-C', env["GSTREAMER_DIR"], '-C', env["GSTREAMER_DIR"],
]) ])
# https://internals.rust-lang.org/t/exploring-crate-graph-build-times-with-cargo-build-ztimings/10975
opts += ["-Ztimings=info"]
if very_verbose: if very_verbose:
print (["Calling", "cargo", "build"] + opts) print (["Calling", "cargo", "build"] + opts)
for key in env: for key in env: