1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-08 18:02:05 +03:00

getdeps: Add support for brew packages and define package dependencies

Summary:
In order to speed up build times on a mac, add homebrew support to
getdeps.

Homebrew packages can be declared in a manifest using the `homebrew` header.

Futher, ahornby has added manifest entries for homebrew packages which are
included in this diff and also included a change to use the correct version of
openssl. Without this openssl change, homebrew cmake configure finds an old
openssl 1.0.2 install.

This diff provides a 2x speed up for building folly:

Timings for clean getdeps folly build on mid-2018 2.9Ghz i9 6 core intel macbook pro with 32GB RAM:

With new homebrew system deps:
```
rm -rf /Users/ahornby/.scratch/UsersZahornbyZfbsource/fbcode_builder_getdeps/
time ./opensource/fbcode_builder/getdeps.py build --allow-system-packages folly
real	17m39.329s
user	76m10.317s
sys	5m50.163s
```

Without:
```
rm -rf /Users/ahornby/.scratch/UsersZahornbyZfbsource/fbcode_builder_getdeps/
time ./opensource/fbcode_builder/getdeps.py build folly
real	32m10.344s
user	105m53.448s
sys	15m57.858s
```

Reviewed By: ahornby

Differential Revision: D33842632

fbshipit-source-id: ac785d4a8dcfa31b77292bddd9e747022ac36e3b
This commit is contained in:
Harvey Hunt
2022-02-04 04:27:13 -08:00
committed by Facebook GitHub Bot
parent 1cd8738897
commit a75c04f38c
31 changed files with 179 additions and 44 deletions

View File

@@ -14,7 +14,7 @@ from typing import Optional, Mapping
from .copytree import containing_repo_type
from .envfuncs import Env, add_path_entry
from .fetcher import get_fbsource_repo_data
from .fetcher import get_fbsource_repo_data, homebrew_package_prefix
from .manifest import ContextGenerator
from .platform import HostType, is_windows, get_available_ram
@@ -206,6 +206,12 @@ class BuildOptions(object):
sdkroot = subprocess.check_output(["xcrun", "--show-sdk-path"])
env["SDKROOT"] = sdkroot.decode().strip()
# MacOS includes a version of bison so homebrew won't automatically add
# its own version to PATH. Find where the homebrew bison is and prepend
# it to PATH.
if self.is_darwin() and self.host_type.get_package_manager() == "homebrew":
add_homebrew_package_to_path(env, "bison")
if self.fbsource_dir:
env["YARN_YARN_OFFLINE_MIRROR"] = os.path.join(
self.fbsource_dir, "xplat/third-party/yarn/offline-mirror"
@@ -300,6 +306,14 @@ class BuildOptions(object):
if os.path.isfile(cert_file):
env["SSL_CERT_FILE"] = cert_file
# Try extra hard to find openssl, needed with homebrew on macOS
if (
self.is_darwin()
and "OPENSSL_DIR" not in env
and "OPENSSL_ROOT_DIR" in os.environ
):
env["OPENSSL_ROOT_DIR"] = os.environ["OPENSSL_ROOT_DIR"]
return env
@@ -491,3 +505,9 @@ def setup_build_options(args, host_type=None):
install_dir=args.install_prefix,
**build_args
)
def add_homebrew_package_to_path(env, package):
prefix = homebrew_package_prefix(package)
if prefix and os.path.exists(os.path.join(prefix, "bin")):
add_path_entry(env, "PATH", os.path.join(prefix, "bin"), append=False)