mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-07 07:02:53 +03:00
add freebsd support
Summary: Add some basic support for FreeBSD to getdeps. Reviewed By: ahornby Differential Revision: D33989129 fbshipit-source-id: 42ff5f160b7e19c12196bb2e52a726f7815487bd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6926f90e05
commit
5cd35796ba
@@ -773,7 +773,10 @@ class FixupDeps(ProjectCmdBase):
|
||||
dep_munger = create_dyn_dep_munger(
|
||||
loader.build_opts, install_dirs, args.strip
|
||||
)
|
||||
dep_munger.process_deps(args.destdir, args.final_install_prefix)
|
||||
if dep_munger is None:
|
||||
print(f"dynamic dependency fixups not supported on {sys.platform}")
|
||||
else:
|
||||
dep_munger.process_deps(args.destdir, args.final_install_prefix)
|
||||
|
||||
def setup_project_cmd_parser(self, parser):
|
||||
parser.add_argument("destdir", help="Where to copy the fixed up executables")
|
||||
|
@@ -100,10 +100,23 @@ class BuilderBase(object):
|
||||
|
||||
@property
|
||||
def num_jobs(self) -> int:
|
||||
# 1.5 GiB is a lot to assume, but it's typical of Facebook-style C++.
|
||||
# Some manifests are even heavier and should override.
|
||||
# This is a hack, but we don't have a "defaults manifest" that we can
|
||||
# customize per platform.
|
||||
# TODO: Introduce some sort of defaults config that can select by
|
||||
# platform, just like manifest contexts.
|
||||
if sys.platform.startswith("freebsd"):
|
||||
# clang on FreeBSD is quite memory-efficient.
|
||||
default_job_weight = 512
|
||||
else:
|
||||
# 1.5 GiB is a lot to assume, but it's typical of Facebook-style C++.
|
||||
# Some manifests are even heavier and should override.
|
||||
default_job_weight = 1536
|
||||
return self.build_opts.get_num_jobs(
|
||||
int(self.manifest.get("build", "job_weight_mib", 1536, ctx=self.ctx))
|
||||
int(
|
||||
self.manifest.get(
|
||||
"build", "job_weight_mib", default_job_weight, ctx=self.ctx
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def run_tests(
|
||||
|
@@ -161,6 +161,9 @@ class BuildOptions(object):
|
||||
def is_linux(self):
|
||||
return self.host_type.is_linux()
|
||||
|
||||
def is_freebsd(self):
|
||||
return self.host_type.is_freebsd()
|
||||
|
||||
def get_num_jobs(self, job_weight):
|
||||
"""Given an estimated job_weight in MiB, compute a reasonable concurrency limit."""
|
||||
if self.specified_num_jobs:
|
||||
|
@@ -12,6 +12,7 @@ import stat
|
||||
import subprocess
|
||||
import sys
|
||||
from struct import unpack
|
||||
from typing import Optional
|
||||
|
||||
from .envfuncs import path_search
|
||||
|
||||
@@ -419,10 +420,13 @@ class MachDeps(DepBase):
|
||||
)
|
||||
|
||||
|
||||
def create_dyn_dep_munger(buildopts, install_dirs, strip=False):
|
||||
def create_dyn_dep_munger(buildopts, install_dirs, strip=False) -> Optional[DepBase]:
|
||||
if buildopts.is_linux():
|
||||
return ElfDeps(buildopts, install_dirs, strip)
|
||||
if buildopts.is_darwin():
|
||||
return MachDeps(buildopts, install_dirs, strip)
|
||||
if buildopts.is_windows():
|
||||
return WinDeps(buildopts, install_dirs, strip)
|
||||
if buildopts.is_freebsd():
|
||||
return ElfDeps(buildopts, install_dirs, strip)
|
||||
return None
|
||||
|
@@ -130,6 +130,32 @@ def _get_available_ram_windows() -> int:
|
||||
return (ms.ullAvailPhys + ms.ullTotalPhys) // (2 * 1024 * 1024)
|
||||
|
||||
|
||||
def _get_available_ram_freebsd() -> int:
|
||||
import ctypes.util
|
||||
|
||||
libc = ctypes.CDLL(ctypes.util.find_library("libc"), use_errno=True)
|
||||
sysctlbyname = libc.sysctlbyname
|
||||
sysctlbyname.restype = ctypes.c_int
|
||||
sysctlbyname.argtypes = [
|
||||
ctypes.c_char_p,
|
||||
ctypes.c_void_p,
|
||||
ctypes.POINTER(ctypes.c_size_t),
|
||||
ctypes.c_void_p,
|
||||
ctypes.c_size_t,
|
||||
]
|
||||
# hw.usermem is pretty close to what we want.
|
||||
memsize = ctypes.c_int64()
|
||||
memsizesize = ctypes.c_size_t(8)
|
||||
res = sysctlbyname(
|
||||
b"hw.usermem", ctypes.byref(memsize), ctypes.byref(memsizesize), None, 0
|
||||
)
|
||||
if res != 0:
|
||||
raise NotImplementedError(
|
||||
f"failed to retrieve hw.memsize sysctl: {ctypes.get_errno()}"
|
||||
)
|
||||
return memsize.value // (1024 * 1024)
|
||||
|
||||
|
||||
def get_available_ram() -> int:
|
||||
"""
|
||||
Returns a platform-appropriate available RAM metric in MiB.
|
||||
@@ -140,6 +166,8 @@ def get_available_ram() -> int:
|
||||
return _get_available_ram_macos()
|
||||
elif sys.platform == "win32":
|
||||
return _get_available_ram_windows()
|
||||
elif sys.platform.startswith("freebsd"):
|
||||
return _get_available_ram_freebsd()
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
f"platform {sys.platform} does not have an implementation of get_available_ram"
|
||||
@@ -158,6 +186,8 @@ class HostType(object):
|
||||
elif is_windows():
|
||||
ostype = "windows"
|
||||
distrovers = str(sys.getwindowsversion().major)
|
||||
elif sys.platform.startswith("freebsd"):
|
||||
ostype = "freebsd"
|
||||
else:
|
||||
ostype = sys.platform
|
||||
|
||||
@@ -185,6 +215,9 @@ class HostType(object):
|
||||
def is_linux(self):
|
||||
return self.ostype == "linux"
|
||||
|
||||
def is_freebsd(self):
|
||||
return self.ostype == "freebsd"
|
||||
|
||||
def as_tuple_string(self):
|
||||
return "%s-%s-%s" % (
|
||||
self.ostype,
|
||||
|
@@ -22,7 +22,7 @@ sha256 = 15a49e2ab81c1822d75b1b1a92f7863f58e31f6d6aac1c4103eef2b071be3112
|
||||
url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-macos-universal.tar.gz
|
||||
sha256 = 0100663380a3bd977b001183cd487412db7aad9de6859927bde97e1e6e44e645
|
||||
|
||||
[download.os=linux]
|
||||
[download.any(os=linux,os=freebsd)]
|
||||
url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz
|
||||
sha256 = aecf6ecb975179eb3bb6a4a50cae192d41e92b9372b02300f9e8f1d5f559544e
|
||||
|
||||
@@ -38,9 +38,9 @@ subdir = cmake-3.20.2-macos-universal
|
||||
CMake.app/Contents/bin = bin
|
||||
CMake.app/Contents/share = share
|
||||
|
||||
[build.os=linux]
|
||||
[build.any(os=linux,os=freebsd)]
|
||||
builder = cmakebootstrap
|
||||
subdir = cmake-3.20.2
|
||||
|
||||
[make.install_args.os=linux]
|
||||
[make.install_args.any(os=linux,os=freebsd)]
|
||||
install
|
||||
|
@@ -11,3 +11,6 @@ sha256 = beda37e94f9746874436c8090c045fd80ae6f8a51f7c668c932a2b110a4fc277
|
||||
[build]
|
||||
builder = cmake
|
||||
subdir = cpptoml-0.1.2
|
||||
|
||||
[cmake.defines.os=freebsd]
|
||||
ENABLE_LIBCXX=NO
|
||||
|
@@ -54,6 +54,9 @@ fbcode/folly = folly
|
||||
BUILD_SHARED_LIBS=OFF
|
||||
BOOST_LINK_STATIC=ON
|
||||
|
||||
[cmake.defines.os=freebsd]
|
||||
LIBDWARF_FOUND=NO
|
||||
|
||||
[cmake.defines.test=on]
|
||||
BUILD_TESTS=ON
|
||||
|
||||
|
@@ -14,3 +14,8 @@ gflags
|
||||
|
||||
[cmake.defines]
|
||||
BUILD_SHARED_LIBS=ON
|
||||
BUILD_TESTING=NO
|
||||
|
||||
[cmake.defines.os=freebsd]
|
||||
HAVE_TR1_UNORDERED_MAP=OFF
|
||||
HAVE_TR1_UNORDERED_SET=OFF
|
||||
|
@@ -17,7 +17,7 @@ url = https://www.openssl.org/source/openssl-1.1.1l.tar.gz
|
||||
sha256 = 0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
|
||||
|
||||
# We use the system openssl on linux
|
||||
[build.not(os=linux)]
|
||||
[build.not(any(os=linux, os=freebsd))]
|
||||
builder = openssl
|
||||
subdir = openssl-1.1.1l
|
||||
|
||||
|
Reference in New Issue
Block a user