Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CMake/EdenConfigChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fb_find_or_fetch(FBThrift)
include_directories(${FBTHRIFT_INCLUDE_DIR})

# The Python CLI uses fb303's thrift-python modules, which, like thrift-python,
# getdeps only builds on Linux.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# getdeps builds on Linux and macOS.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR APPLE)
set(FB303_THRIFT_PYTHON ON)
endif()
fb_find_or_fetch(fb303)
Expand Down Expand Up @@ -145,9 +145,9 @@ if (NOT BLAKE3_FOUND)
endif()
include_directories(${BLAKE3_INCLUDE_DIR})

# The Python CLI uses thrift-python, which getdeps only builds on Linux, and
# the thrift-python modules that fb303 builds with FB303_THRIFT_PYTHON.
if (ENABLE_THRIFT_PYTHON AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
# The Python CLI uses thrift-python and the thrift-python modules that fb303
# builds with FB303_THRIFT_PYTHON. getdeps provides them on Linux and macOS.
if (ENABLE_THRIFT_PYTHON AND (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR APPLE))
include(FBThriftPythonLibrary)
if (ENABLE_THRIFT_PYTHON STREQUAL "AUTO")
fb_find_thrift_python_runtime(QUIET)
Expand Down
24 changes: 15 additions & 9 deletions build/fbcode_builder/CMake/FBThriftPythonLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro(fb_find_thrift_python_runtime)
if(
NOT _FB_THRIFT_PYTHON_RUNTIME_FOUND OR
NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift/python" OR
NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs" OR
(NOT APPLE AND NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs") OR
NOT EXISTS "${FOLLY_PYTHON_SITE_PACKAGES}/folly"
)
# Ensure Python3 is found so we can use ${Python3_EXECUTABLE}
Expand Down Expand Up @@ -121,7 +121,7 @@ macro(fb_find_thrift_python_runtime)
"fbthrift-python was found at ${THRIFT_PYTHON_SITE_PACKAGES}, but "
"its thrift/python runtime package is missing.")
unset(THRIFT_PYTHON_SITE_PACKAGES)
elseif(NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs")
elseif(NOT APPLE AND NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs")
message(WARNING
"fbthrift-python was found at ${THRIFT_PYTHON_SITE_PACKAGES}, but "
"thrift.libs is missing. Install an auditwheel-repaired "
Expand Down Expand Up @@ -370,7 +370,7 @@ function(add_fb_thrift_python_executable TARGET)
if(
THRIFT_PYTHON_SITE_PACKAGES AND
EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift/python" AND
EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs"
(APPLE OR EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs")
)
# The bundled thrift/ hides the wheel's namespace package, so link all of
# its subpackages: thrift.python imports thrift.py3, for example.
Expand All @@ -390,17 +390,23 @@ function(add_fb_thrift_python_executable TARGET)
)
endif()
endforeach()
set(thrift_libs_link_commands)
if(EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs")
list(APPEND thrift_libs_link_commands
COMMAND ${CMAKE_COMMAND}
"-DFB_REMOVE_PATH=${target_dir}/thrift.libs"
-P "${_FB_THRIFT_PYTHON_REMOVE_PATH_SCRIPT}"
COMMAND ${CMAKE_COMMAND} -E create_symlink
"${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs"
"${target_dir}/thrift.libs"
)
endif()
add_custom_command(
TARGET ${TARGET}.GEN_PY_EXE POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${target_dir}/thrift"
COMMAND ${CMAKE_COMMAND} -E touch "${target_dir}/thrift/__init__.py"
${link_commands}
COMMAND ${CMAKE_COMMAND}
"-DFB_REMOVE_PATH=${target_dir}/thrift.libs"
-P "${_FB_THRIFT_PYTHON_REMOVE_PATH_SCRIPT}"
COMMAND ${CMAKE_COMMAND} -E create_symlink
"${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs"
"${target_dir}/thrift.libs"
${thrift_libs_link_commands}
COMMENT "Symlinking thrift-python and its native dependencies into ${TARGET}"
)
else()
Expand Down
31 changes: 23 additions & 8 deletions build/fbcode_builder/CMake/RustStaticLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ endfunction()
# `${TARGET}` CMake library target.
#
# ```cmake
# rust_cxx_bridge(<TARGET> <CXX_BRIDGE_FILE> [CRATE <CRATE_NAME>] [LIBS <LIBNAMES>])
# rust_cxx_bridge(<TARGET> <CXX_BRIDGE_FILE> [CRATE <CRATE_NAME>]
# [CARGO_DIRECTORY <DIRECTORY>] [LIBS <LIBNAMES>])
# ```
#
# Parameters:
Expand All @@ -406,19 +407,24 @@ endfunction()
# - CRATE_NAME:
# Name of the crate. This parameter is optional. If unspecified, it will
# fallback to `${TARGET}`.
# - CARGO_DIRECTORY:
# Directory where Cargo resolves the cxx dependency. Defaults to the current
# source directory.
# - LIBS <lib1> [<lib2> ...]:
# A list of libraries that this library depends on.
#
function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE)
fb_cmake_parse_args(ARG "" "CRATE" "LIBS" "${ARGN}")
fb_cmake_parse_args(ARG "" "CRATE;CARGO_DIRECTORY" "LIBS" "${ARGN}")

if(DEFINED ARG_CRATE)
set(crate_name "${ARG_CRATE}")
else()
set(crate_name "${TARGET}")
endif()

_rust_cxxbridge(cxxbridge cxxbridge_target)
_rust_cxxbridge(
cxxbridge cxxbridge_target "${ARG_CARGO_DIRECTORY}"
)

add_library(${crate_name} STATIC)
target_include_directories(
Expand Down Expand Up @@ -482,22 +488,27 @@ endfunction()
# source directory depends on.
#
# ```cmake
# rust_cxx_header(<TARGET> [LIBS <LIBNAMES>])
# rust_cxx_header(<TARGET> [CARGO_DIRECTORY <DIRECTORY>] [LIBS <LIBNAMES>])
# ```
#
# Parameters:
# - TARGET:
# Name of the interface library target to create, which puts the header on
# the include path. An internal custom target, `${TARGET}.header`, generates
# it.
# - CARGO_DIRECTORY:
# Directory where Cargo resolves the cxx dependency. Defaults to the current
# source directory.
# - LIBS <lib1> [<lib2> ...]:
# A list of libraries that this library depends on, such as the Rust static
# library that contains the cxx runtime.
#
function(rust_cxx_header TARGET)
fb_cmake_parse_args(ARG "" "" "LIBS" "${ARGN}")
fb_cmake_parse_args(ARG "" "CARGO_DIRECTORY" "LIBS" "${ARGN}")

_rust_cxxbridge(cxxbridge cxxbridge_target)
_rust_cxxbridge(
cxxbridge cxxbridge_target "${ARG_CARGO_DIRECTORY}"
)
add_custom_target(
${TARGET}.header
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/rust/cxx.h"
Expand All @@ -513,17 +524,21 @@ endfunction()
# commands running it depend on, which runs `cargo install cxxbridge-cmd` when
# no installed cxxbridge has that version. Also adds the rule that generates
# `rust/cxx.h` in the current binary directory.
function(_rust_cxxbridge CXXBRIDGE_VAR DEPENDS_VAR)
function(_rust_cxxbridge CXXBRIDGE_VAR DEPENDS_VAR CARGO_DIRECTORY)
if(USE_CARGO_VENDOR)
set(extra_cargo_env "CARGO_HOME=${RUST_CARGO_HOME}")
endif()

if(NOT CARGO_DIRECTORY)
set(CARGO_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

execute_process(
COMMAND
"${CMAKE_COMMAND}" -E env
${extra_cargo_env}
"${CARGO_COMMAND}" tree -i cxx --depth=0
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY "${CARGO_DIRECTORY}"
RESULT_VARIABLE cxx_version_result
OUTPUT_VARIABLE cxx_version_output
)
Expand Down
3 changes: 3 additions & 0 deletions build/fbcode_builder/manifests/cpptoml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ subdir = cpptoml-0.1.2

[cmake.defines.os=freebsd]
ENABLE_LIBCXX=NO

[cmake.defines.os=darwin]
ENABLE_LIBCXX=NO
6 changes: 2 additions & 4 deletions build/fbcode_builder/manifests/eden
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ rust-shed
[dependencies.fbsource=on]
rust

[dependencies.os=darwin]
osxfuse

[dependencies.not(os=windows)]
# TODO: teach getdeps to compile curl on Windows.
# Enabling curl on Windows requires us to find a way to compile libcurl with
# msvc.
libcurl
# Added so that OSS doesn't see system "python" which is python 2 on darwin and some linux

# Avoid finding a system "python" that may still be Python 2.
python

[dependencies.test=on]
Expand Down
1 change: 1 addition & 0 deletions build/fbcode_builder/manifests/edencommon
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repo_url = https://github.com/facebookexperimental/edencommon.git

[build]
builder = cmake
patchfile = edencommon_pipe_darwin.patch

[dependencies]
boost
Expand Down
3 changes: 3 additions & 0 deletions build/fbcode_builder/manifests/fb303
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ BUILD_TESTS=OFF
[cmake.defines.os=linux]
FB303_THRIFT_PYTHON=ON

[cmake.defines.os=darwin]
FB303_THRIFT_PYTHON=ON

[shipit.pathmap]
fbcode/fb303/github = .
fbcode/fb303/public_autocargo = fb303
Expand Down
26 changes: 20 additions & 6 deletions build/fbcode_builder/manifests/fbthrift-python
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ fbthrift = thrift/lib/rust
[build]
builder = cmake
job_weight_mib = 3072
patchfile = fbthrift_python_darwin.patch

[build.not(os=linux)]
[build.os=darwin]
builder = cmake

[build.os=windows]
builder = nop

[cmake.defines]
Expand All @@ -34,25 +38,35 @@ THRIFT_TESTS=OFF
[cmake.defines.os=linux]
THRIFT_PYTHON=ON

[cmake.defines.os=darwin]
THRIFT_PYTHON=ON

[dependencies]
benchmark
fizz-python
fmt-python
folly-python
googletest
libsodium
wangle-python
zstd-python
mvfst-python
xxhash
# Thrift also depends on openssl but since the latter requires a platform-
# specific configuration we rely on the folly manifest to provide this
# dependency to avoid duplication.

[dependencies.os=linux]
fizz-python
fmt-python
wangle-python
zstd-python
mvfst-python
libaio-python
libevent-python

[dependencies.os=darwin]
fizz
fmt
wangle
zstd
mvfst

[shipit.pathmap]
xplat/thrift/public_tld = .
xplat/thrift = thrift
Expand Down
29 changes: 22 additions & 7 deletions build/fbcode_builder/manifests/folly-python
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ repo_url = https://github.com/facebook/folly.git
[build]
builder = cmake
job_weight_mib = 1024
patchfile = folly_python_darwin.patch

[build.not(os=linux)]
[build.os=darwin]
builder = cmake

[build.os=windows]
builder = nop

[dependencies]
Expand All @@ -20,15 +24,9 @@ gflags
# copy of glog.
glog = shared_libs
googletest
boost-python
libdwarf-python
libevent-python
libsodium
fast_float
fmt-python
lz4-python
snappy
zstd-python
# no openssl or zlib in the linux case, why?
# these are usually installed on the system
# and are the easiest system deps to pull in.
Expand All @@ -41,6 +39,12 @@ zstd-python
# to build our own.
[dependencies.os=darwin]
openssl
boost
libdwarf
libevent
fmt
lz4
zstd

# Windows has neither openssl nor zlib, so we get
# to provide both
Expand All @@ -49,6 +53,12 @@ openssl
zlib

[dependencies.os=linux]
boost-python
libdwarf-python
libevent-python
fmt-python
lz4-python
zstd-python
libaio-python
libiberty-python
libunwind
Expand All @@ -70,6 +80,11 @@ fbcode/folly = folly
PYTHON_EXTENSIONS=ON
BUILD_SHARED_LIBS=ON

[cmake.defines.os=darwin]
PYTHON_EXTENSIONS=ON
BUILD_SHARED_LIBS=ON
CMAKE_CXX_FLAGS=-DGLOG_USE_GLOG_EXPORT

[cmake.defines.not(os=windows)]
BOOST_LINK_STATIC=ON

Expand Down
22 changes: 22 additions & 0 deletions build/fbcode_builder/patches/edencommon_pipe_darwin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/eden/common/utils/Pipe.cpp b/eden/common/utils/Pipe.cpp
index 1724dbd1..67e188b2 100644
--- a/eden/common/utils/Pipe.cpp
+++ b/eden/common/utils/Pipe.cpp
@@ -43,7 +43,7 @@ Pipe::Pipe(bool nonBlocking) {
#else
int fds[2];
int res;
-#if FOLLY_HAVE_PIPE2
+#if FOLLY_HAVE_PIPE2 && !defined(__APPLE__)
res = pipe2(fds, (nonBlocking ? O_NONBLOCK : 0) | O_CLOEXEC);
#else
res = pipe(fds);
@@ -58,7 +58,7 @@ Pipe::Pipe(bool nonBlocking) {
read = FileDescriptor(fds[0], FileDescriptor::FDType::Pipe);
write = FileDescriptor(fds[1], FileDescriptor::FDType::Pipe);

-#if !FOLLY_HAVE_PIPE2
+#if !FOLLY_HAVE_PIPE2 || defined(__APPLE__)
read.setCloExec();
write.setCloExec();
if (nonBlocking) {
Loading