├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── TagIt.yml │ └── getdeps_linux.yml ├── CHANGELOG.md ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── LICENSE-examples ├── README.md ├── build ├── README.md ├── build_fbzmq.sh ├── deps │ └── github_hashes │ │ └── facebook │ │ ├── fbthrift-rev.txt │ │ ├── folly-rev.txt │ │ └── wangle-rev.txt └── fbcode_builder │ ├── .gitignore │ ├── CMake │ ├── FBBuildOptions.cmake │ ├── FBCMakeParseArgs.cmake │ ├── FBCompilerSettings.cmake │ ├── FBCompilerSettingsMSVC.cmake │ ├── FBCompilerSettingsUnix.cmake │ ├── FBPythonBinary.cmake │ ├── FBPythonTestAddTests.cmake │ ├── FBThriftCppLibrary.cmake │ ├── FBThriftLibrary.cmake │ ├── FBThriftPyLibrary.cmake │ ├── FindDoubleConversion.cmake │ ├── FindGMock.cmake │ ├── FindGflags.cmake │ ├── FindGlog.cmake │ ├── FindLibEvent.cmake │ ├── FindLibUnwind.cmake │ ├── FindPCRE.cmake │ ├── FindRe2.cmake │ ├── FindSodium.cmake │ ├── FindZstd.cmake │ ├── RustStaticLibrary.cmake │ ├── fb_py_test_main.py │ ├── fb_py_win_main.c │ └── make_fbpy_archive.py │ ├── LICENSE │ ├── README.md │ ├── getdeps.py │ ├── getdeps │ ├── __init__.py │ ├── builder.py │ ├── buildopts.py │ ├── cache.py │ ├── cargo.py │ ├── copytree.py │ ├── dyndeps.py │ ├── envfuncs.py │ ├── errors.py │ ├── expr.py │ ├── fetcher.py │ ├── load.py │ ├── manifest.py │ ├── platform.py │ ├── py_wheel_builder.py │ ├── runcmd.py │ ├── subcmd.py │ └── test │ │ ├── expr_test.py │ │ ├── fixtures │ │ └── duplicate │ │ │ ├── foo │ │ │ └── subdir │ │ │ └── foo │ │ ├── manifest_test.py │ │ ├── platform_test.py │ │ └── scratch_test.py │ ├── manifests │ ├── CLI11 │ ├── OpenNSA │ ├── airstore │ ├── autoconf │ ├── automake │ ├── bison │ ├── boost │ ├── bz2 │ ├── cmake │ ├── cpptoml │ ├── delos_core │ ├── double-conversion │ ├── eden │ ├── eden_scm │ ├── edencommon │ ├── exprtk │ ├── f4d │ ├── fatal │ ├── fb303 │ ├── fb303-source │ ├── fboss │ ├── fbthrift │ ├── fbthrift-source │ ├── fbzmq │ ├── fizz │ ├── fmt │ ├── folly │ ├── gflags │ ├── git-lfs │ ├── glog │ ├── gnu-bash │ ├── gnu-coreutils │ ├── gnu-grep │ ├── gnu-sed │ ├── googletest │ ├── googletest_1_8 │ ├── gperf │ ├── iproute2 │ ├── jq │ ├── katran │ ├── libbpf │ ├── libbpf_0_2_0_beta │ ├── libcurl │ ├── libelf │ ├── libevent │ ├── libffi │ ├── libgit2 │ ├── libicu │ ├── libmnl │ ├── libnl │ ├── libsai │ ├── libsodium │ ├── libtool │ ├── libusb │ ├── libyaml │ ├── libzmq │ ├── lz4 │ ├── lzo │ ├── mononoke │ ├── mvfst │ ├── ncurses │ ├── nghttp2 │ ├── ninja │ ├── nlohmann-json │ ├── nmap │ ├── openr │ ├── openssl │ ├── osxfuse │ ├── patchelf │ ├── pcre │ ├── perl │ ├── pexpect │ ├── protobuf │ ├── proxygen │ ├── python │ ├── python-click │ ├── python-dulwich │ ├── python-filelock │ ├── python-ptyprocess │ ├── python-six │ ├── python-toml │ ├── range-v3 │ ├── re2 │ ├── rocksdb │ ├── rust-shed │ ├── snappy │ ├── sqlite3 │ ├── sqlite3-bin │ ├── tcl │ ├── tree │ ├── wangle │ ├── watchman │ ├── xz │ ├── yaml-cpp │ ├── zlib │ └── zstd │ └── patches │ └── zlib_dont_build_more_than_needed.patch └── fbzmq ├── .clang-format ├── CMakeLists.txt ├── async ├── AsyncSignalHandler.cpp ├── AsyncSignalHandler.h ├── Runnable.h ├── StopEventLoopSignalHandler.h ├── ZmqEventLoop.cpp ├── ZmqEventLoop.h ├── ZmqThrottle.cpp ├── ZmqThrottle.h ├── ZmqTimeout.cpp ├── ZmqTimeout.h └── tests │ ├── AsyncSignalHandlerTest.cpp │ ├── ZmqEventLoopTest.cpp │ ├── ZmqThrottleTest.cpp │ └── ZmqTimeoutTest.cpp ├── cmake └── fbzmq-config.cmake.in ├── examples ├── client │ ├── ZmqClient.cpp │ ├── ZmqClient.h │ └── ZmqClientMain.cpp ├── common │ ├── Constants.cpp │ └── Constants.h ├── if │ └── Example.thrift └── server │ ├── ZmqServer.cpp │ ├── ZmqServer.h │ └── ZmqServerMain.cpp ├── py └── setup.py ├── service ├── if │ └── Monitor.thrift ├── logging │ ├── LogSample.cpp │ ├── LogSample.h │ └── tests │ │ └── LogSampleTest.cpp ├── monitor │ ├── SystemMetrics.cpp │ ├── SystemMetrics.h │ ├── ZmqMonitor.h │ ├── ZmqMonitorClient.cpp │ ├── ZmqMonitorClient.h │ ├── ZmqMonitorSample.cpp │ └── tests │ │ ├── ZmqMonitorClientTest.cpp │ │ └── ZmqMonitorTest.cpp └── stats │ ├── ExportType.h │ ├── ExportedStat.cpp │ ├── ExportedStat.h │ ├── ThreadData.cpp │ ├── ThreadData.h │ └── tests │ └── ThreadDataTest.cpp └── zmq ├── Common.cpp ├── Common.h ├── Context.cpp ├── Context.h ├── Message.cpp ├── Message.h ├── README.md ├── Socket.cpp ├── Socket.h ├── SocketMonitor.cpp ├── SocketMonitor.h ├── Zmq.h └── tests ├── CommonTest.cpp ├── ContextTest.cpp ├── MessageTest.cpp ├── SocketMonitorTest.cpp ├── SocketTest.cpp ├── SystemMetricsTest.cpp └── Test.thrift /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Please use this template for reporting suspected bugs or requests for help.* 2 | 3 | # Issue Description 4 | 5 | 6 | # Environment 7 | 8 | * tag or commit hash on which this occured 9 | * OS version: 10 | ... 11 | 12 | 13 | # Minimal test code / Steps to reproduce the issue 14 | 15 | 16 | 17 | # What's the actual result? 18 | 19 | 20 | 21 | # What's the expected result? 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Pull Request Template 2 | 3 | Title: [] 4 | 5 | Description: 6 | - Explain in detail what was broken! 7 | - How did you fix it 8 | 9 | 10 | Test Plan: 11 | - Explain in detail how you tested it 12 | 13 | # Pull Request Guideline 14 | 15 | - Before sending a pull request make sure each commit solves one clear, minimal, 16 | plausible problem. Further each commit should have the above format. 17 | - Please avoid sending a pull request with recursive merge nodes, as they 18 | are impossible to fix once merged. Please rebase your branch on 19 | facebook/openr master instead of merging it. 20 | - If you are a new contributor please have a look at our contributing guidelines: 21 | [CONTRIBUTING](https://github.com/facebook/fbzmq/CONTRIBUTING.md) 22 | -------------------------------------------------------------------------------- /.github/workflows/TagIt.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | # Only match TagIt tags, which always start with this prefix 5 | - 'v20*' 6 | 7 | name: TagIt 8 | 9 | jobs: 10 | build: 11 | name: Release 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v2 16 | - name: Archive project 17 | id: archive_project 18 | run: | 19 | FILE_NAME=${GITHUB_REPOSITORY#*/}-${GITHUB_REF##*/} 20 | git archive ${{ github.ref }} -o ${FILE_NAME}.zip 21 | git archive ${{ github.ref }} -o ${FILE_NAME}.tar.gz 22 | echo "::set-output name=file_name::${FILE_NAME}" 23 | - name: Compute digests 24 | id: compute_digests 25 | run: | 26 | echo "::set-output name=tgz_256::$(openssl dgst -sha256 ${{ steps.archive_project.outputs.file_name }}.tar.gz)" 27 | echo "::set-output name=tgz_512::$(openssl dgst -sha512 ${{ steps.archive_project.outputs.file_name }}.tar.gz)" 28 | echo "::set-output name=zip_256::$(openssl dgst -sha256 ${{ steps.archive_project.outputs.file_name }}.zip)" 29 | echo "::set-output name=zip_512::$(openssl dgst -sha512 ${{ steps.archive_project.outputs.file_name }}.zip)" 30 | - name: Create Release 31 | id: create_release 32 | uses: actions/create-release@v1 33 | env: 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | with: 36 | tag_name: ${{ github.ref }} 37 | release_name: ${{ github.ref }} 38 | body: | 39 | Automated release from TagIt 40 |
41 | File Hashes 42 |
    43 |
  • ${{ steps.compute_digests.outputs.zip_256 }}
  • 44 |
  • ${{ steps.compute_digests.outputs.zip_512 }}
  • 45 |
  • ${{ steps.compute_digests.outputs.tgz_256 }}
  • 46 |
  • ${{ steps.compute_digests.outputs.tgz_512 }}
  • 47 |
48 |
49 | draft: false 50 | prerelease: false 51 | - name: Upload zip 52 | uses: actions/upload-release-asset@v1 53 | env: 54 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 55 | with: 56 | upload_url: ${{ steps.create_release.outputs.upload_url }} 57 | asset_path: ./${{ steps.archive_project.outputs.file_name }}.zip 58 | asset_name: ${{ steps.archive_project.outputs.file_name }}.zip 59 | asset_content_type: application/zip 60 | - name: Upload tar.gz 61 | uses: actions/upload-release-asset@v1 62 | env: 63 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 64 | with: 65 | upload_url: ${{ steps.create_release.outputs.upload_url }} 66 | asset_path: ./${{ steps.archive_project.outputs.file_name }}.tar.gz 67 | asset_name: ${{ steps.archive_project.outputs.file_name }}.tar.gz 68 | asset_content_type: application/gzip 69 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2014-present, Facebook, Inc. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | # 7 | 8 | cmake_minimum_required(VERSION 3.2) 9 | 10 | if (NOT DEFINED PACKAGE_VERSION) 11 | set(PACKAGE_VERSION 1.0.0) 12 | endif() 13 | 14 | if (NOT DEFINED SO_VERSION) 15 | set(SO_VERSION 1) 16 | endif() 17 | 18 | project(fbzmq) 19 | 20 | if (UNIX AND (APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")) 21 | add_definitions(-DIS_BSD) 22 | endif() 23 | 24 | set(INCLUDE_INSTALL_DIR include CACHE STRING 25 | "The subdirectory where header files should be installed") 26 | set(LIB_INSTALL_DIR lib CACHE STRING 27 | "The subdirectory where libraries should be installed") 28 | 29 | if (NOT DEFINED CPACK_GENERATOR) 30 | set(CPACK_GENERATOR "RPM") 31 | endif() 32 | include(CPack) 33 | 34 | set(CMAKE_CXX_STANDARD 17) 35 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 36 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror ${CMAKE_CXX_FLAGS}") 37 | set(CMAKE_CXX_FLAGS "-Wno-noexcept-type ${CMAKE_CXX_FLAGS}") 38 | set(CMAKE_CXX_FLAGS "-Wno-deprecated-declarations ${CMAKE_CXX_FLAGS}") 39 | 40 | include_directories(${CMAKE_SOURCE_DIR}) 41 | include_directories(${CMAKE_BINARY_DIR}) 42 | 43 | set( 44 | CMAKE_MODULE_PATH 45 | "${CMAKE_SOURCE_DIR}/build/fbcode_builder/CMake" 46 | ${CMAKE_MODULE_PATH} 47 | ) 48 | include(FBThriftCppLibrary) 49 | 50 | # External third-party libraries 51 | find_library(DOUBLECONV double-conversion) 52 | find_package(Gflags REQUIRED) 53 | find_package(Glog REQUIRED) 54 | find_library(PTHREAD pthread) 55 | find_library(ZMQ zmq) 56 | find_package(Threads REQUIRED) 57 | 58 | set(REQ_BOOST_COMPONENTS ${REQ_BOOST_COMPONENTS} system thread context filesystem program_options regex) 59 | find_package(Boost 1.65.0 MODULE 60 | COMPONENTS 61 | ${REQ_BOOST_COMPONENTS} 62 | REQUIRED 63 | ) 64 | 65 | find_path(ZMQ_INCLUDE_DIR zmq.h) 66 | 67 | include_directories(${Boost_INCLUDE_DIRS} ${ZMQ_INCLUDE_DIR}) 68 | 69 | 70 | # Facebook specific libraries 71 | find_package(folly CONFIG REQUIRED) 72 | find_library(ZSTD zstd) 73 | find_package(fizz CONFIG REQUIRED) 74 | find_package(fmt CONFIG REQUIRED) 75 | find_package(wangle CONFIG REQUIRED) 76 | find_package(FBThrift CONFIG REQUIRED) 77 | 78 | # Include Thrift 79 | include_directories(${FBTHRIFT_INCLUDE_DIR}) 80 | 81 | add_subdirectory(fbzmq) 82 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to make participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies within all project spaces, and it also applies when 49 | an individual is representing the project or its community in public spaces. 50 | Examples of representing a project or community include using an official 51 | project e-mail address, posting via an official social media account, or acting 52 | as an appointed representative at an online or offline event. Representation of 53 | a project may be further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at . All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | 78 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to fbzmq 2 | We want to make contributing to this project as easy and as transparent as possible. 3 | 4 | ## Code of Conduct 5 | The code of conduct is described in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md) 6 | 7 | ## Our Development Process 8 | This library is actively being used by several projects on Facebook. We 9 | don't expect any major changes in APIs exposed by libraries, however bug 10 | fixes, performance improvements and code maintenance is likely to happen on 11 | a regular basis. New APIs or functionalities might be added as per future needs. 12 | 13 | ## Pull Requests 14 | We actively welcome your pull requests. 15 | 16 | 1. Fork the repo and create your branch from `master`. 17 | 2. If you've added code that should be tested, add tests. 18 | 3. If you've changed APIs, update the documentation. 19 | 4. Ensure the test suite passes. 20 | 5. Make sure your code lints. 21 | 6. If you haven't already, complete the Contributor License Agreement ("CLA"). 22 | 23 | ## Contributor License Agreement ("CLA") 24 | In order to accept your pull request, we need you to submit a CLA. You only need 25 | to do this once to work on any of Facebook's open-source projects. 26 | 27 | Complete your CLA here: [CLA - Agreement](https://code.facebook.com/cla) 28 | 29 | 30 | ## Issues 31 | We use GitHub issues to track public bugs. Please ensure your description is 32 | clear and has sufficient instructions to be able to reproduce the issue. 33 | 34 | Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe 35 | disclosure of security bugs. In those cases, please go through the process 36 | outlined on that page and do not file a public issue. 37 | 38 | ## Coding Style 39 | Please try to follow the existing coding style within `fbzmq` code. For C++ 40 | code, our style is 41 | * 2 spaces for indentation rather than tabs 42 | * 80 character line length 43 | * Use clang-format for formatting code 44 | 45 | ## License 46 | By contributing to fbzmq, you agree that your contributions will be licensed 47 | under the LICENSE file in the root directory of this source tree. 48 | 49 | 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014-present, Facebook, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE-examples: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 2 | 3 | The examples provided by Facebook are for non-commercial testing and evaluation 4 | purposes only. Facebook reserves all rights not expressly granted. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 9 | FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 10 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 11 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | -------------------------------------------------------------------------------- /build/README.md: -------------------------------------------------------------------------------- 1 | # Building using `fbcode_builder` 2 | 3 | Continuous integration builds are powered by `fbcode_builder`, a tiny tool 4 | shared by several Facebook projects. Its files are in `./fbcode_builder` 5 | (on Github) or in `fbcode/opensource/fbcode_builder` (inside Facebook's 6 | repo). 7 | 8 | Start with the READMEs in the `fbcode_builder` directory. 9 | 10 | `./fbcode_builder_config.py` contains the project-specific configuration. 11 | -------------------------------------------------------------------------------- /build/deps/github_hashes/facebook/fbthrift-rev.txt: -------------------------------------------------------------------------------- 1 | Subproject commit 20fb382803335240e61b3bf1f2e78c3fafe29e0a 2 | -------------------------------------------------------------------------------- /build/deps/github_hashes/facebook/folly-rev.txt: -------------------------------------------------------------------------------- 1 | Subproject commit 6695e49418b39e3104495422de3db7937a32d323 2 | -------------------------------------------------------------------------------- /build/deps/github_hashes/facebook/wangle-rev.txt: -------------------------------------------------------------------------------- 1 | Subproject commit b61de7afca81db28aaf94677c191b398cf66716c 2 | -------------------------------------------------------------------------------- /build/fbcode_builder/.gitignore: -------------------------------------------------------------------------------- 1 | # Facebook-internal CI builds don't have write permission outside of the 2 | # source tree, so we install all projects into this directory. 3 | /facebook_ci 4 | __pycache__/ 5 | *.pyc 6 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBBuildOptions.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | function (fb_activate_static_library_option) 4 | option(USE_STATIC_DEPS_ON_UNIX 5 | "If enabled, use static dependencies on unix systems. This is generally discouraged." 6 | OFF 7 | ) 8 | # Mark USE_STATIC_DEPS_ON_UNIX as an "advanced" option, since enabling it 9 | # is generally discouraged. 10 | mark_as_advanced(USE_STATIC_DEPS_ON_UNIX) 11 | 12 | if(UNIX AND USE_STATIC_DEPS_ON_UNIX) 13 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE) 14 | endif() 15 | endfunction() 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBCompilerSettings.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This file applies common compiler settings that are shared across 4 | # a number of Facebook opensource projects. 5 | # Please use caution and your best judgement before making changes 6 | # to these shared compiler settings in order to avoid accidentally 7 | # breaking a build in another project! 8 | 9 | if (WIN32) 10 | include(FBCompilerSettingsMSVC) 11 | else() 12 | include(FBCompilerSettingsUnix) 13 | endif() 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBCompilerSettingsMSVC.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This file applies common compiler settings that are shared across 4 | # a number of Facebook opensource projects. 5 | # Please use caution and your best judgement before making changes 6 | # to these shared compiler settings in order to avoid accidentally 7 | # breaking a build in another project! 8 | 9 | add_compile_options( 10 | /wd4250 # 'class1' : inherits 'class2::member' via dominance 11 | ) 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBCompilerSettingsUnix.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This file applies common compiler settings that are shared across 4 | # a number of Facebook opensource projects. 5 | # Please use caution and your best judgement before making changes 6 | # to these shared compiler settings in order to avoid accidentally 7 | # breaking a build in another project! 8 | 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wno-deprecated -Wno-deprecated-declarations") 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBPythonTestAddTests.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # Add a command to be emitted to the CTest file 4 | set(ctest_script) 5 | function(add_command CMD) 6 | set(escaped_args "") 7 | foreach(arg ${ARGN}) 8 | # Escape all arguments using "Bracket Argument" syntax 9 | # We could skip this for argument that don't contain any special 10 | # characters if we wanted to make the output slightly more human-friendly. 11 | set(escaped_args "${escaped_args} [==[${arg}]==]") 12 | endforeach() 13 | set(ctest_script "${ctest_script}${CMD}(${escaped_args})\n" PARENT_SCOPE) 14 | endfunction() 15 | 16 | if(NOT EXISTS "${TEST_EXECUTABLE}") 17 | message(FATAL_ERROR "Test executable does not exist: ${TEST_EXECUTABLE}") 18 | endif() 19 | execute_process( 20 | COMMAND ${CMAKE_COMMAND} -E env ${TEST_ENV} "${TEST_INTERPRETER}" "${TEST_EXECUTABLE}" --list-tests 21 | WORKING_DIRECTORY "${TEST_WORKING_DIR}" 22 | OUTPUT_VARIABLE output 23 | RESULT_VARIABLE result 24 | ) 25 | if(NOT "${result}" EQUAL 0) 26 | string(REPLACE "\n" "\n " output "${output}") 27 | message( 28 | FATAL_ERROR 29 | "Error running test executable: ${TEST_EXECUTABLE}\n" 30 | "Output:\n" 31 | " ${output}\n" 32 | ) 33 | endif() 34 | 35 | # Parse output 36 | string(REPLACE "\n" ";" tests_list "${output}") 37 | foreach(test_name ${tests_list}) 38 | add_command( 39 | add_test 40 | "${TEST_PREFIX}${test_name}" 41 | ${CMAKE_COMMAND} -E env ${TEST_ENV} 42 | "${TEST_INTERPRETER}" "${TEST_EXECUTABLE}" "${test_name}" 43 | ) 44 | add_command( 45 | set_tests_properties 46 | "${TEST_PREFIX}${test_name}" 47 | PROPERTIES 48 | WORKING_DIRECTORY "${TEST_WORKING_DIR}" 49 | ${TEST_PROPERTIES} 50 | ) 51 | endforeach() 52 | 53 | # Set a list of discovered tests in the parent scope, in case users 54 | # want access to this list as a CMake variable 55 | if(TEST_LIST) 56 | add_command(set ${TEST_LIST} ${tests_list}) 57 | endif() 58 | 59 | file(WRITE "${CTEST_FILE}" "${ctest_script}") 60 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBThriftLibrary.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | include(FBCMakeParseArgs) 4 | include(FBThriftPyLibrary) 5 | include(FBThriftCppLibrary) 6 | 7 | # 8 | # add_fbthrift_library() 9 | # 10 | # This is a convenience function that generates thrift libraries for multiple 11 | # languages. 12 | # 13 | # For example: 14 | # add_fbthrift_library( 15 | # foo foo.thrift 16 | # LANGUAGES cpp py 17 | # SERVICES Foo 18 | # DEPENDS bar) 19 | # 20 | # will be expanded into two separate calls: 21 | # 22 | # add_fbthrift_cpp_library(foo_cpp foo.thrift SERVICES Foo DEPENDS bar_cpp) 23 | # add_fbthrift_py_library(foo_py foo.thrift SERVICES Foo DEPENDS bar_py) 24 | # 25 | function(add_fbthrift_library LIB_NAME THRIFT_FILE) 26 | # Parse the arguments 27 | set(one_value_args PY_NAMESPACE INCLUDE_DIR THRIFT_INCLUDE_DIR) 28 | set(multi_value_args SERVICES DEPENDS LANGUAGES CPP_OPTIONS PY_OPTIONS) 29 | fb_cmake_parse_args( 30 | ARG "" "${one_value_args}" "${multi_value_args}" "${ARGN}" 31 | ) 32 | 33 | if(NOT DEFINED ARG_INCLUDE_DIR) 34 | set(ARG_INCLUDE_DIR "include") 35 | endif() 36 | if(NOT DEFINED ARG_THRIFT_INCLUDE_DIR) 37 | set(ARG_THRIFT_INCLUDE_DIR "${ARG_INCLUDE_DIR}/thrift-files") 38 | endif() 39 | 40 | # CMake 3.12+ adds list(TRANSFORM) which would be nice to use here, but for 41 | # now we still want to support older versions of CMake. 42 | set(CPP_DEPENDS) 43 | set(PY_DEPENDS) 44 | foreach(dep IN LISTS ARG_DEPENDS) 45 | list(APPEND CPP_DEPENDS "${dep}_cpp") 46 | list(APPEND PY_DEPENDS "${dep}_py") 47 | endforeach() 48 | 49 | foreach(lang IN LISTS ARG_LANGUAGES) 50 | if ("${lang}" STREQUAL "cpp") 51 | add_fbthrift_cpp_library( 52 | "${LIB_NAME}_cpp" "${THRIFT_FILE}" 53 | SERVICES ${ARG_SERVICES} 54 | DEPENDS ${CPP_DEPENDS} 55 | OPTIONS ${ARG_CPP_OPTIONS} 56 | INCLUDE_DIR "${ARG_INCLUDE_DIR}" 57 | THRIFT_INCLUDE_DIR "${ARG_THRIFT_INCLUDE_DIR}" 58 | ) 59 | elseif ("${lang}" STREQUAL "py" OR "${lang}" STREQUAL "python") 60 | if (DEFINED ARG_PY_NAMESPACE) 61 | set(namespace_args NAMESPACE "${ARG_PY_NAMESPACE}") 62 | endif() 63 | add_fbthrift_py_library( 64 | "${LIB_NAME}_py" "${THRIFT_FILE}" 65 | SERVICES ${ARG_SERVICES} 66 | ${namespace_args} 67 | DEPENDS ${PY_DEPENDS} 68 | OPTIONS ${ARG_PY_OPTIONS} 69 | THRIFT_INCLUDE_DIR "${ARG_THRIFT_INCLUDE_DIR}" 70 | ) 71 | else() 72 | message( 73 | FATAL_ERROR "unknown language for thrift library ${LIB_NAME}: ${lang}" 74 | ) 75 | endif() 76 | endforeach() 77 | endfunction() 78 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindDoubleConversion.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | # Finds libdouble-conversion. 4 | # 5 | # This module defines: 6 | # DOUBLE_CONVERSION_INCLUDE_DIR 7 | # DOUBLE_CONVERSION_LIBRARY 8 | # 9 | 10 | find_path(DOUBLE_CONVERSION_INCLUDE_DIR double-conversion/double-conversion.h) 11 | find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion) 12 | 13 | include(FindPackageHandleStandardArgs) 14 | find_package_handle_standard_args( 15 | DoubleConversion 16 | DEFAULT_MSG 17 | DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR) 18 | 19 | mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY) 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindGMock.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # Find libgmock 3 | # 4 | # LIBGMOCK_DEFINES - List of defines when using libgmock. 5 | # LIBGMOCK_INCLUDE_DIR - where to find gmock/gmock.h, etc. 6 | # LIBGMOCK_LIBRARIES - List of libraries when using libgmock. 7 | # LIBGMOCK_FOUND - True if libgmock found. 8 | 9 | IF (LIBGMOCK_INCLUDE_DIR) 10 | # Already in cache, be silent 11 | SET(LIBGMOCK_FIND_QUIETLY TRUE) 12 | ENDIF () 13 | 14 | find_package(GTest CONFIG QUIET) 15 | if (TARGET GTest::gmock) 16 | get_target_property(LIBGMOCK_DEFINES GTest::gtest INTERFACE_COMPILE_DEFINITIONS) 17 | if (NOT ${LIBGMOCK_DEFINES}) 18 | # Explicitly set to empty string if not found to avoid it being 19 | # set to NOTFOUND and breaking compilation 20 | set(LIBGMOCK_DEFINES "") 21 | endif() 22 | get_target_property(LIBGMOCK_INCLUDE_DIR GTest::gtest INTERFACE_INCLUDE_DIRECTORIES) 23 | set(LIBGMOCK_LIBRARIES GTest::gmock_main GTest::gmock GTest::gtest) 24 | set(LIBGMOCK_FOUND ON) 25 | message(STATUS "Found gmock via config, defines=${LIBGMOCK_DEFINES}, include=${LIBGMOCK_INCLUDE_DIR}, libs=${LIBGMOCK_LIBRARIES}") 26 | else() 27 | 28 | FIND_PATH(LIBGMOCK_INCLUDE_DIR gmock/gmock.h) 29 | 30 | FIND_LIBRARY(LIBGMOCK_MAIN_LIBRARY_DEBUG NAMES gmock_maind) 31 | FIND_LIBRARY(LIBGMOCK_MAIN_LIBRARY_RELEASE NAMES gmock_main) 32 | FIND_LIBRARY(LIBGMOCK_LIBRARY_DEBUG NAMES gmockd) 33 | FIND_LIBRARY(LIBGMOCK_LIBRARY_RELEASE NAMES gmock) 34 | FIND_LIBRARY(LIBGTEST_LIBRARY_DEBUG NAMES gtestd) 35 | FIND_LIBRARY(LIBGTEST_LIBRARY_RELEASE NAMES gtest) 36 | 37 | find_package(Threads REQUIRED) 38 | INCLUDE(SelectLibraryConfigurations) 39 | SELECT_LIBRARY_CONFIGURATIONS(LIBGMOCK_MAIN) 40 | SELECT_LIBRARY_CONFIGURATIONS(LIBGMOCK) 41 | SELECT_LIBRARY_CONFIGURATIONS(LIBGTEST) 42 | 43 | set(LIBGMOCK_LIBRARIES 44 | ${LIBGMOCK_MAIN_LIBRARY} 45 | ${LIBGMOCK_LIBRARY} 46 | ${LIBGTEST_LIBRARY} 47 | Threads::Threads 48 | ) 49 | 50 | if(CMAKE_SYSTEM_NAME STREQUAL "Windows") 51 | # The GTEST_LINKED_AS_SHARED_LIBRARY macro must be set properly on Windows. 52 | # 53 | # There isn't currently an easy way to determine if a library was compiled as 54 | # a shared library on Windows, so just assume we've been built against a 55 | # shared build of gmock for now. 56 | SET(LIBGMOCK_DEFINES "GTEST_LINKED_AS_SHARED_LIBRARY=1" CACHE STRING "") 57 | endif() 58 | 59 | # handle the QUIETLY and REQUIRED arguments and set LIBGMOCK_FOUND to TRUE if 60 | # all listed variables are TRUE 61 | INCLUDE(FindPackageHandleStandardArgs) 62 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 63 | GMock 64 | DEFAULT_MSG 65 | LIBGMOCK_MAIN_LIBRARY 66 | LIBGMOCK_LIBRARY 67 | LIBGTEST_LIBRARY 68 | LIBGMOCK_LIBRARIES 69 | LIBGMOCK_INCLUDE_DIR 70 | ) 71 | 72 | MARK_AS_ADVANCED( 73 | LIBGMOCK_DEFINES 74 | LIBGMOCK_MAIN_LIBRARY 75 | LIBGMOCK_LIBRARY 76 | LIBGTEST_LIBRARY 77 | LIBGMOCK_LIBRARIES 78 | LIBGMOCK_INCLUDE_DIR 79 | ) 80 | endif() 81 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindGlog.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # - Try to find Glog 3 | # Once done, this will define 4 | # 5 | # GLOG_FOUND - system has Glog 6 | # GLOG_INCLUDE_DIRS - the Glog include directories 7 | # GLOG_LIBRARIES - link these to use Glog 8 | 9 | include(FindPackageHandleStandardArgs) 10 | include(SelectLibraryConfigurations) 11 | 12 | find_library(GLOG_LIBRARY_RELEASE glog 13 | PATHS ${GLOG_LIBRARYDIR}) 14 | find_library(GLOG_LIBRARY_DEBUG glogd 15 | PATHS ${GLOG_LIBRARYDIR}) 16 | 17 | find_path(GLOG_INCLUDE_DIR glog/logging.h 18 | PATHS ${GLOG_INCLUDEDIR}) 19 | 20 | select_library_configurations(GLOG) 21 | 22 | find_package_handle_standard_args(Glog DEFAULT_MSG 23 | GLOG_LIBRARY 24 | GLOG_INCLUDE_DIR) 25 | 26 | mark_as_advanced( 27 | GLOG_LIBRARY 28 | GLOG_INCLUDE_DIR) 29 | 30 | set(GLOG_LIBRARIES ${GLOG_LIBRARY}) 31 | set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) 32 | 33 | if (NOT TARGET glog::glog) 34 | add_library(glog::glog UNKNOWN IMPORTED) 35 | set_target_properties(glog::glog PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}") 36 | set_target_properties(glog::glog PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${GLOG_LIBRARIES}") 37 | endif() 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindLibEvent.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # - Find LibEvent (a cross event library) 3 | # This module defines 4 | # LIBEVENT_INCLUDE_DIR, where to find LibEvent headers 5 | # LIBEVENT_LIB, LibEvent libraries 6 | # LibEvent_FOUND, If false, do not try to use libevent 7 | 8 | set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}") 9 | foreach(prefix ${LibEvent_EXTRA_PREFIXES}) 10 | list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include") 11 | list(APPEND LibEvent_LIB_PATHS "${prefix}/lib") 12 | endforeach() 13 | 14 | find_package(Libevent CONFIG QUIET) 15 | if (TARGET event) 16 | # Re-export the config under our own names 17 | 18 | # Somewhat gross, but some vcpkg installed libevents have a relative 19 | # `include` path exported into LIBEVENT_INCLUDE_DIRS, which triggers 20 | # a cmake error because it resolves to the `include` dir within the 21 | # folly repo, which is not something cmake allows to be in the 22 | # INTERFACE_INCLUDE_DIRECTORIES. Thankfully on such a system the 23 | # actual include directory is already part of the global include 24 | # directories, so we can just skip it. 25 | if (NOT "${LIBEVENT_INCLUDE_DIRS}" STREQUAL "include") 26 | set(LIBEVENT_INCLUDE_DIR ${LIBEVENT_INCLUDE_DIRS}) 27 | else() 28 | set(LIBEVENT_INCLUDE_DIR) 29 | endif() 30 | 31 | # Unfortunately, with a bare target name `event`, downstream consumers 32 | # of the package that depends on `Libevent` located via CONFIG end 33 | # up exporting just a bare `event` in their libraries. This is problematic 34 | # because this in interpreted as just `-levent` with no library path. 35 | # When libevent is not installed in the default installation prefix 36 | # this results in linker errors. 37 | # To resolve this, we ask cmake to lookup the full path to the library 38 | # and use that instead. 39 | cmake_policy(PUSH) 40 | if(POLICY CMP0026) 41 | # Allow reading the LOCATION property 42 | cmake_policy(SET CMP0026 OLD) 43 | endif() 44 | get_target_property(LIBEVENT_LIB event LOCATION) 45 | cmake_policy(POP) 46 | 47 | set(LibEvent_FOUND ${Libevent_FOUND}) 48 | if (NOT LibEvent_FIND_QUIETLY) 49 | message(STATUS "Found libevent from package config include=${LIBEVENT_INCLUDE_DIRS} lib=${LIBEVENT_LIB}") 50 | endif() 51 | else() 52 | find_path(LIBEVENT_INCLUDE_DIR event.h PATHS ${LibEvent_INCLUDE_PATHS}) 53 | find_library(LIBEVENT_LIB NAMES event PATHS ${LibEvent_LIB_PATHS}) 54 | 55 | if (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR) 56 | set(LibEvent_FOUND TRUE) 57 | set(LIBEVENT_LIB ${LIBEVENT_LIB}) 58 | else () 59 | set(LibEvent_FOUND FALSE) 60 | endif () 61 | 62 | if (LibEvent_FOUND) 63 | if (NOT LibEvent_FIND_QUIETLY) 64 | message(STATUS "Found libevent: ${LIBEVENT_LIB}") 65 | endif () 66 | else () 67 | if (LibEvent_FIND_REQUIRED) 68 | message(FATAL_ERROR "Could NOT find libevent.") 69 | endif () 70 | message(STATUS "libevent NOT found.") 71 | endif () 72 | 73 | mark_as_advanced( 74 | LIBEVENT_LIB 75 | LIBEVENT_INCLUDE_DIR 76 | ) 77 | endif() 78 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindLibUnwind.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | find_path(LIBUNWIND_INCLUDE_DIR NAMES libunwind.h) 16 | mark_as_advanced(LIBUNWIND_INCLUDE_DIR) 17 | 18 | find_library(LIBUNWIND_LIBRARY NAMES unwind) 19 | mark_as_advanced(LIBUNWIND_LIBRARY) 20 | 21 | include(FindPackageHandleStandardArgs) 22 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 23 | LIBUNWIND 24 | REQUIRED_VARS LIBUNWIND_LIBRARY LIBUNWIND_INCLUDE_DIR) 25 | 26 | if(LIBUNWIND_FOUND) 27 | set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARY}) 28 | set(LIBUNWIND_INCLUDE_DIRS ${LIBUNWIND_INCLUDE_DIR}) 29 | endif() 30 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindPCRE.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | include(FindPackageHandleStandardArgs) 3 | find_path(PCRE_INCLUDE_DIR NAMES pcre.h) 4 | find_library(PCRE_LIBRARY NAMES pcre) 5 | find_package_handle_standard_args( 6 | PCRE 7 | DEFAULT_MSG 8 | PCRE_LIBRARY 9 | PCRE_INCLUDE_DIR 10 | ) 11 | mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARY) 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindRe2.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This software may be used and distributed according to the terms of the 4 | # GNU General Public License version 2. 5 | 6 | find_library(RE2_LIBRARY re2) 7 | mark_as_advanced(RE2_LIBRARY) 8 | 9 | find_path(RE2_INCLUDE_DIR NAMES re2/re2.h) 10 | mark_as_advanced(RE2_INCLUDE_DIR) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 14 | RE2 15 | REQUIRED_VARS RE2_LIBRARY RE2_INCLUDE_DIR) 16 | 17 | if(RE2_FOUND) 18 | set(RE2_LIBRARY ${RE2_LIBRARY}) 19 | set(RE2_INCLUDE_DIR, ${RE2_INCLUDE_DIR}) 20 | endif() 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindZstd.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # 16 | # - Try to find Facebook zstd library 17 | # This will define 18 | # ZSTD_FOUND 19 | # ZSTD_INCLUDE_DIR 20 | # ZSTD_LIBRARY 21 | # 22 | 23 | find_path(ZSTD_INCLUDE_DIR NAMES zstd.h) 24 | 25 | find_library(ZSTD_LIBRARY_DEBUG NAMES zstdd zstd_staticd) 26 | find_library(ZSTD_LIBRARY_RELEASE NAMES zstd zstd_static) 27 | 28 | include(SelectLibraryConfigurations) 29 | SELECT_LIBRARY_CONFIGURATIONS(ZSTD) 30 | 31 | include(FindPackageHandleStandardArgs) 32 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 33 | ZSTD DEFAULT_MSG 34 | ZSTD_LIBRARY ZSTD_INCLUDE_DIR 35 | ) 36 | 37 | if (ZSTD_FOUND) 38 | message(STATUS "Found Zstd: ${ZSTD_LIBRARY}") 39 | endif() 40 | 41 | mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY) 42 | -------------------------------------------------------------------------------- /build/fbcode_builder/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Facebook, Inc. and its affiliates. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/fbcode_builder/README.md: -------------------------------------------------------------------------------- 1 | # Easy builds for Facebook projects 2 | 3 | This directory contains tools designed to simplify continuous-integration 4 | (and other builds) of Facebook open source projects. In particular, this helps 5 | manage builds for cross-project dependencies. 6 | 7 | The main entry point is the `getdeps.py` script. This script has several 8 | subcommands, but the most notable is the `build` command. This will download 9 | and build all dependencies for a project, and then build the project itself. 10 | 11 | ## Deployment 12 | 13 | This directory is copied literally into a number of different Facebook open 14 | source repositories. Any change made to code in this directory will be 15 | automatically be replicated by our open source tooling into all GitHub hosted 16 | repositories that use `fbcode_builder`. Typically this directory is copied 17 | into the open source repositories as `build/fbcode_builder/`. 18 | 19 | 20 | # Project Configuration Files 21 | 22 | The `manifests` subdirectory contains configuration files for many different 23 | projects, describing how to build each project. These files also list 24 | dependencies between projects, enabling `getdeps.py` to build all dependencies 25 | for a project before building the project itself. 26 | 27 | 28 | # Shared CMake utilities 29 | 30 | Since this directory is copied into many Facebook open source repositories, 31 | it is also used to help share some CMake utility files across projects. The 32 | `CMake/` subdirectory contains a number of `.cmake` files that are shared by 33 | the CMake-based build systems across several different projects. 34 | 35 | 36 | # Older Build Scripts 37 | 38 | This directory also still contains a handful of older build scripts that 39 | pre-date the current `getdeps.py` build system. Most of the other `.py` files 40 | in this top directory, apart from `getdeps.py` itself, are from this older 41 | build system. This older system is only used by a few remaining projects, and 42 | new projects should generally use the newer `getdeps.py` script, by adding a 43 | new configuration file in the `manifests/` subdirectory. 44 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookarchive/fbzmq/93cdb764f59baea218c28da6454371e7caac2728/build/fbcode_builder/getdeps/__init__.py -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/cache.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | class ArtifactCache(object): 8 | """The ArtifactCache is a small abstraction that allows caching 9 | named things in some external storage mechanism. 10 | The primary use case is for storing the build products on CI 11 | systems to accelerate the build""" 12 | 13 | def download_to_file(self, name, dest_file_name) -> bool: 14 | """If `name` exists in the cache, download it and place it 15 | in the specified `dest_file_name` location on the filesystem. 16 | If a transient issue was encountered a TransientFailure shall 17 | be raised. 18 | If `name` doesn't exist in the cache `False` shall be returned. 19 | If `dest_file_name` was successfully updated `True` shall be 20 | returned. 21 | All other conditions shall raise an appropriate exception.""" 22 | return False 23 | 24 | def upload_from_file(self, name, source_file_name) -> None: 25 | """Causes `name` to be populated in the cache by uploading 26 | the contents of `source_file_name` to the storage system. 27 | If a transient issue was encountered a TransientFailure shall 28 | be raised. 29 | If the upload failed for some other reason, an appropriate 30 | exception shall be raised.""" 31 | pass 32 | 33 | 34 | def create_cache() -> None: 35 | """This function is monkey patchable to provide an actual 36 | implementation""" 37 | return None 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/copytree.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | import os 7 | import shutil 8 | import subprocess 9 | 10 | from .platform import is_windows 11 | 12 | 13 | PREFETCHED_DIRS = set() 14 | 15 | 16 | def containing_repo_type(path): 17 | while True: 18 | if os.path.exists(os.path.join(path, ".git")): 19 | return ("git", path) 20 | if os.path.exists(os.path.join(path, ".hg")): 21 | return ("hg", path) 22 | 23 | parent = os.path.dirname(path) 24 | if parent == path: 25 | return None, None 26 | path = parent 27 | 28 | 29 | def find_eden_root(dirpath): 30 | """If the specified directory is inside an EdenFS checkout, returns 31 | the canonical absolute path to the root of that checkout. 32 | 33 | Returns None if the specified directory is not in an EdenFS checkout. 34 | """ 35 | if is_windows(): 36 | repo_type, repo_root = containing_repo_type(dirpath) 37 | if repo_root is not None: 38 | if os.path.exists(os.path.join(repo_root, ".eden", "config")): 39 | return os.path.realpath(repo_root) 40 | return None 41 | 42 | try: 43 | return os.readlink(os.path.join(dirpath, ".eden", "root")) 44 | except OSError: 45 | return None 46 | 47 | 48 | def prefetch_dir_if_eden(dirpath) -> None: 49 | """After an amend/rebase, Eden may need to fetch a large number 50 | of trees from the servers. The simplistic single threaded walk 51 | performed by copytree makes this more expensive than is desirable 52 | so we help accelerate things by performing a prefetch on the 53 | source directory""" 54 | global PREFETCHED_DIRS 55 | if dirpath in PREFETCHED_DIRS: 56 | return 57 | root = find_eden_root(dirpath) 58 | if root is None: 59 | return 60 | # pyre-fixme[6]: For 1st param expected `bytes` but got `str`. 61 | # pyre-fixme[6]: For 2nd param expected `bytes` but got `str`. 62 | glob = f"{os.path.relpath(dirpath, root).replace(os.sep, '/')}/**" 63 | print(f"Prefetching {glob}") 64 | subprocess.call( 65 | ["edenfsctl", "prefetch", "--repo", root, "--silent", glob, "--background"] 66 | ) 67 | PREFETCHED_DIRS.add(dirpath) 68 | 69 | 70 | # pyre-fixme[9]: ignore has type `bool`; used as `None`. 71 | def copytree(src_dir, dest_dir, ignore: bool = None): 72 | """Recursively copy the src_dir to the dest_dir, filtering 73 | out entries using the ignore lambda. The behavior of the 74 | ignore lambda must match that described by `shutil.copytree`. 75 | This `copytree` function knows how to prefetch data when 76 | running in an eden repo. 77 | TODO: I'd like to either extend this or add a variant that 78 | uses watchman to mirror src_dir into dest_dir. 79 | """ 80 | prefetch_dir_if_eden(src_dir) 81 | # pyre-fixme[6]: For 3rd param expected 82 | # `Union[typing.Callable[[Union[PathLike[str], str], List[str]], Iterable[str]], 83 | # typing.Callable[[str, List[str]], Iterable[str]], None]` but got `bool`. 84 | return shutil.copytree(src_dir, dest_dir, ignore=ignore) 85 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/errors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | class TransientFailure(Exception): 8 | """Raising this error causes getdeps to return with an error code 9 | that Sandcastle will consider to be a retryable transient 10 | infrastructure error""" 11 | 12 | pass 13 | 14 | 15 | class ManifestNotFound(Exception): 16 | def __init__(self, manifest_name) -> None: 17 | super(Exception, self).__init__("Unable to find manifest '%s'" % manifest_name) 18 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/subcmd.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | class SubCmd(object): 8 | NAME = None 9 | HELP = None 10 | 11 | def run(self, args) -> int: 12 | """perform the command""" 13 | return 0 14 | 15 | def setup_parser(self, parser) -> None: 16 | # Subclasses should override setup_parser() if they have any 17 | # command line options or arguments. 18 | pass 19 | 20 | 21 | CmdTable = [] 22 | 23 | 24 | def add_subcommands(parser, common_args, cmd_table=CmdTable) -> None: 25 | """Register parsers for the defined commands with the provided parser""" 26 | for cls in cmd_table: 27 | command = cls() 28 | command_parser = parser.add_parser( 29 | command.NAME, help=command.HELP, parents=[common_args] 30 | ) 31 | command.setup_parser(command_parser) 32 | command_parser.set_defaults(func=command.run) 33 | 34 | 35 | def cmd(name, help=None, cmd_table=CmdTable): 36 | """ 37 | @cmd() is a decorator that can be used to help define Subcmd instances 38 | 39 | Example usage: 40 | 41 | @subcmd('list', 'Show the result list') 42 | class ListCmd(Subcmd): 43 | def run(self, args): 44 | # Perform the command actions here... 45 | pass 46 | """ 47 | 48 | def wrapper(cls): 49 | class SubclassedCmd(cls): 50 | NAME = name 51 | HELP = help 52 | 53 | cmd_table.append(SubclassedCmd) 54 | return SubclassedCmd 55 | 56 | return wrapper 57 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/expr_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | import unittest 8 | 9 | from ..expr import parse_expr 10 | 11 | 12 | class ExprTest(unittest.TestCase): 13 | def test_equal(self) -> None: 14 | valid_variables = {"foo", "some_var", "another_var"} 15 | e = parse_expr("foo=bar", valid_variables) 16 | self.assertTrue(e.eval({"foo": "bar"})) 17 | self.assertFalse(e.eval({"foo": "not-bar"})) 18 | self.assertFalse(e.eval({"not-foo": "bar"})) 19 | 20 | def test_not_equal(self) -> None: 21 | valid_variables = {"foo"} 22 | e = parse_expr("not(foo=bar)", valid_variables) 23 | self.assertFalse(e.eval({"foo": "bar"})) 24 | self.assertTrue(e.eval({"foo": "not-bar"})) 25 | 26 | def test_bad_not(self) -> None: 27 | valid_variables = {"foo"} 28 | with self.assertRaises(Exception): 29 | parse_expr("foo=not(bar)", valid_variables) 30 | 31 | def test_bad_variable(self) -> None: 32 | valid_variables = {"bar"} 33 | with self.assertRaises(Exception): 34 | parse_expr("foo=bar", valid_variables) 35 | 36 | def test_all(self) -> None: 37 | valid_variables = {"foo", "baz"} 38 | e = parse_expr("all(foo = bar, baz = qux)", valid_variables) 39 | self.assertTrue(e.eval({"foo": "bar", "baz": "qux"})) 40 | self.assertFalse(e.eval({"foo": "bar", "baz": "nope"})) 41 | self.assertFalse(e.eval({"foo": "nope", "baz": "nope"})) 42 | 43 | def test_any(self) -> None: 44 | valid_variables = {"foo", "baz"} 45 | e = parse_expr("any(foo = bar, baz = qux)", valid_variables) 46 | self.assertTrue(e.eval({"foo": "bar", "baz": "qux"})) 47 | self.assertTrue(e.eval({"foo": "bar", "baz": "nope"})) 48 | self.assertFalse(e.eval({"foo": "nope", "baz": "nope"})) 49 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/fixtures/duplicate/foo: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = foo 3 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/fixtures/duplicate/subdir/foo: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = foo 3 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/platform_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | import unittest 8 | 9 | from ..platform import HostType 10 | 11 | 12 | class PlatformTest(unittest.TestCase): 13 | def test_create(self) -> None: 14 | p = HostType() 15 | self.assertNotEqual(p.ostype, None, msg="probed and returned something") 16 | 17 | tuple_string = p.as_tuple_string() 18 | round_trip = HostType.from_tuple_string(tuple_string) 19 | self.assertEqual(round_trip, p) 20 | 21 | def test_rendering_of_none(self) -> None: 22 | p = HostType(ostype="foo") 23 | self.assertEqual(p.as_tuple_string(), "foo-none-none") 24 | 25 | def test_is_methods(self) -> None: 26 | p = HostType(ostype="windows") 27 | self.assertTrue(p.is_windows()) 28 | self.assertFalse(p.is_darwin()) 29 | self.assertFalse(p.is_linux()) 30 | 31 | p = HostType(ostype="darwin") 32 | self.assertFalse(p.is_windows()) 33 | self.assertTrue(p.is_darwin()) 34 | self.assertFalse(p.is_linux()) 35 | 36 | p = HostType(ostype="linux") 37 | self.assertFalse(p.is_windows()) 38 | self.assertFalse(p.is_darwin()) 39 | self.assertTrue(p.is_linux()) 40 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/scratch_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | import unittest 8 | 9 | from ..buildopts import find_existing_win32_subst_for_path 10 | 11 | 12 | class Win32SubstTest(unittest.TestCase): 13 | def test_no_existing_subst(self) -> None: 14 | self.assertIsNone( 15 | find_existing_win32_subst_for_path( 16 | r"C:\users\alice\appdata\local\temp\fbcode_builder_getdeps", 17 | subst_mapping={}, 18 | ) 19 | ) 20 | self.assertIsNone( 21 | find_existing_win32_subst_for_path( 22 | r"C:\users\alice\appdata\local\temp\fbcode_builder_getdeps", 23 | subst_mapping={"X:\\": r"C:\users\alice\appdata\local\temp\other"}, 24 | ) 25 | ) 26 | 27 | def test_exact_match_returns_drive_path(self) -> None: 28 | self.assertEqual( 29 | find_existing_win32_subst_for_path( 30 | r"C:\temp\fbcode_builder_getdeps", 31 | subst_mapping={"X:\\": r"C:\temp\fbcode_builder_getdeps"}, 32 | ), 33 | "X:\\", 34 | ) 35 | self.assertEqual( 36 | find_existing_win32_subst_for_path( 37 | r"C:/temp/fbcode_builder_getdeps", 38 | subst_mapping={"X:\\": r"C:/temp/fbcode_builder_getdeps"}, 39 | ), 40 | "X:\\", 41 | ) 42 | 43 | def test_multiple_exact_matches_returns_arbitrary_drive_path(self) -> None: 44 | self.assertIn( 45 | find_existing_win32_subst_for_path( 46 | r"C:\temp\fbcode_builder_getdeps", 47 | subst_mapping={ 48 | "X:\\": r"C:\temp\fbcode_builder_getdeps", 49 | "Y:\\": r"C:\temp\fbcode_builder_getdeps", 50 | "Z:\\": r"C:\temp\fbcode_builder_getdeps", 51 | }, 52 | ), 53 | ("X:\\", "Y:\\", "Z:\\"), 54 | ) 55 | 56 | def test_drive_letter_is_case_insensitive(self) -> None: 57 | self.assertEqual( 58 | find_existing_win32_subst_for_path( 59 | r"C:\temp\fbcode_builder_getdeps", 60 | subst_mapping={"X:\\": r"c:\temp\fbcode_builder_getdeps"}, 61 | ), 62 | "X:\\", 63 | ) 64 | 65 | def test_path_components_are_case_insensitive(self) -> None: 66 | self.assertEqual( 67 | find_existing_win32_subst_for_path( 68 | r"C:\TEMP\FBCODE_builder_getdeps", 69 | subst_mapping={"X:\\": r"C:\temp\fbcode_builder_getdeps"}, 70 | ), 71 | "X:\\", 72 | ) 73 | self.assertEqual( 74 | find_existing_win32_subst_for_path( 75 | r"C:\temp\fbcode_builder_getdeps", 76 | subst_mapping={"X:\\": r"C:\TEMP\FBCODE_builder_getdeps"}, 77 | ), 78 | "X:\\", 79 | ) 80 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/CLI11: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = CLI11 3 | 4 | [download] 5 | url = https://github.com/CLIUtils/CLI11/archive/v2.0.0.tar.gz 6 | sha256 = 2c672f17bf56e8e6223a3bfb74055a946fa7b1ff376510371902adb9cb0ab6a3 7 | 8 | [build] 9 | builder = cmake 10 | subdir = CLI11-2.0.0 11 | 12 | [cmake.defines] 13 | CLI11_BUILD_TESTS = OFF 14 | CLI11_BUILD_EXAMPLES = OFF 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/OpenNSA: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = OpenNSA 3 | 4 | [download] 5 | url = https://docs.broadcom.com/docs-and-downloads/csg/opennsa-6.5.22.tgz 6 | sha256 = 74bfbdaebb6bfe9ebb0deac3aff624385cdcf5aa416ba63706c36538b3c3c46c 7 | 8 | [build] 9 | builder = nop 10 | subdir = opennsa-6.5.22 11 | 12 | [install.files] 13 | lib/x86-64 = lib 14 | include = include 15 | src/gpl-modules/systems/bde/linux/include = include/systems/bde/linux 16 | src/gpl-modules/include/ibde.h = include/ibde.h 17 | src/gpl-modules = src/gpl-modules 18 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/airstore: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = airstore 3 | fbsource_path = fbcode/fair_infra/data/airstore/ 4 | shipit_project = AIRStore 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/fairinternal/AIRStore.git 9 | 10 | [build.os=linux] 11 | builder = cmake 12 | 13 | [build.not(os=linux)] 14 | # We only support Linux 15 | builder = nop 16 | 17 | [dependencies] 18 | boost 19 | fizz 20 | fmt 21 | folly 22 | googletest 23 | libsodium 24 | libevent 25 | double-conversion 26 | proxygen 27 | wangle 28 | zstd 29 | zlib 30 | xz 31 | 32 | [shipit.pathmap] 33 | fbcode/fair_infra/data/airstore = . 34 | 35 | [shipit.strip] 36 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/autoconf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = autoconf 3 | 4 | [debs] 5 | autoconf 6 | 7 | [homebrew] 8 | autoconf 9 | 10 | [rpms] 11 | autoconf 12 | 13 | [download] 14 | url = http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz 15 | sha256 = 954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969 16 | 17 | [build] 18 | builder = autoconf 19 | subdir = autoconf-2.69 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/automake: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = automake 3 | 4 | [homebrew] 5 | automake 6 | 7 | [debs] 8 | automake 9 | 10 | [rpms] 11 | automake 12 | 13 | [download] 14 | url = http://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz 15 | sha256 = 608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8 16 | 17 | [build] 18 | builder = autoconf 19 | subdir = automake-1.16.1 20 | 21 | [dependencies] 22 | autoconf 23 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/bison: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = bison 3 | 4 | [debs] 5 | bison 6 | 7 | [homebrew] 8 | bison 9 | 10 | [rpms] 11 | bison 12 | 13 | [download.not(os=windows)] 14 | url = https://mirrors.kernel.org/gnu/bison/bison-3.3.tar.gz 15 | sha256 = fdeafb7fffade05604a61e66b8c040af4b2b5cbb1021dcfe498ed657ac970efd 16 | 17 | [download.os=windows] 18 | url = https://github.com/lexxmark/winflexbison/releases/download/v2.5.17/winflexbison-2.5.17.zip 19 | sha256 = 3dc27a16c21b717bcc5de8590b564d4392a0b8577170c058729d067d95ded825 20 | 21 | [build.not(os=windows)] 22 | builder = autoconf 23 | subdir = bison-3.3 24 | 25 | [build.os=windows] 26 | builder = nop 27 | 28 | [install.files.os=windows] 29 | data = bin/data 30 | win_bison.exe = bin/bison.exe 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/boost: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = boost 3 | 4 | [download.not(os=windows)] 5 | url = https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.gz 6 | sha256 = 94ced8b72956591c4775ae2207a9763d3600b30d9d7446562c552f0a14a63be7 7 | 8 | [download.os=windows] 9 | url = https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.zip 10 | sha256 = f22143b5528e081123c3c5ed437e92f648fe69748e95fa6e2bd41484e2986cc3 11 | 12 | [preinstalled.env] 13 | # Here we list the acceptable versions that cmake needs a hint to find 14 | BOOST_ROOT_1_69_0 15 | BOOST_ROOT_1_78_0 16 | 17 | [debs] 18 | libboost-all-dev 19 | 20 | [homebrew] 21 | boost 22 | # Boost cmake detection on homebrew adds this as requirement: https://github.com/Homebrew/homebrew-core/issues/67427#issuecomment-754187345 23 | icu4c 24 | 25 | [rpms.all(distro=centos_stream,distro_vers=8)] 26 | boost169 27 | boost169-math 28 | boost169-test 29 | boost169-fiber 30 | boost169-graph 31 | boost169-log 32 | boost169-openmpi 33 | boost169-timer 34 | boost169-chrono 35 | boost169-locale 36 | boost169-thread 37 | boost169-atomic 38 | boost169-random 39 | boost169-static 40 | boost169-contract 41 | boost169-date-time 42 | boost169-iostreams 43 | boost169-container 44 | boost169-coroutine 45 | boost169-filesystem 46 | boost169-system 47 | boost169-stacktrace 48 | boost169-regex 49 | boost169-devel 50 | boost169-context 51 | boost169-python3-devel 52 | boost169-type_erasure 53 | boost169-wave 54 | boost169-python3 55 | boost169-serialization 56 | boost169-program-options 57 | 58 | [rpms.not(all(distro=centos_stream,distro_vers=8))] 59 | boost-devel 60 | boost-static 61 | 62 | [build] 63 | builder = boost 64 | job_weight_mib = 512 65 | 66 | [b2.args] 67 | --with-atomic 68 | --with-chrono 69 | --with-container 70 | --with-context 71 | --with-contract 72 | --with-coroutine 73 | --with-date_time 74 | --with-exception 75 | --with-fiber 76 | --with-filesystem 77 | --with-graph 78 | --with-graph_parallel 79 | --with-iostreams 80 | --with-locale 81 | --with-log 82 | --with-math 83 | --with-mpi 84 | --with-program_options 85 | --with-python 86 | --with-random 87 | --with-regex 88 | --with-serialization 89 | --with-stacktrace 90 | --with-system 91 | --with-test 92 | --with-thread 93 | --with-timer 94 | --with-type_erasure 95 | --with-wave 96 | 97 | [bootstrap.args.os=darwin] 98 | # Not really gcc, but CI puts a broken clang in the PATH, and saying gcc 99 | # here selects the correct one from Xcode. 100 | --with-toolset=gcc 101 | 102 | [b2.args.os=linux] 103 | # RHEL hardened gcc is not compatible with PCH 104 | # https://bugzilla.redhat.com/show_bug.cgi?id=1806545 105 | pch=off 106 | 107 | [b2.args.os=darwin] 108 | toolset=clang 109 | 110 | [b2.args.all(os=windows,fb=on)] 111 | toolset=msvc-14.2 112 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/bz2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = bz2 3 | 4 | [debs] 5 | libbz2-dev 6 | 7 | [homebrew] 8 | bzip2 9 | 10 | [rpms] 11 | bzip2-devel 12 | 13 | [download] 14 | url = https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz 15 | sha256 = ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269 16 | 17 | [build.not(os=windows)] 18 | builder = make 19 | subdir = bzip2-1.0.8 20 | 21 | [make.build_args.os=linux] 22 | # python bz2 support on linux needs dynamic library 23 | -f 24 | Makefile-libbz2_so 25 | 26 | [make.install_args] 27 | install 28 | 29 | [build.os=windows] 30 | builder = nop 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/cmake: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = cmake 3 | 4 | [homebrew] 5 | cmake 6 | 7 | # 18.04 cmake is too old 8 | [debs.not(all(distro=ubuntu,distro_vers="18.04"))] 9 | cmake 10 | 11 | [rpms] 12 | cmake 13 | 14 | [dependencies] 15 | ninja 16 | 17 | [download.os=windows] 18 | url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-windows-x86_64.zip 19 | sha256 = 15a49e2ab81c1822d75b1b1a92f7863f58e31f6d6aac1c4103eef2b071be3112 20 | 21 | [download.os=darwin] 22 | url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-macos-universal.tar.gz 23 | sha256 = 0100663380a3bd977b001183cd487412db7aad9de6859927bde97e1e6e44e645 24 | 25 | [download.any(os=linux,os=freebsd)] 26 | url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz 27 | sha256 = aecf6ecb975179eb3bb6a4a50cae192d41e92b9372b02300f9e8f1d5f559544e 28 | 29 | [build.os=windows] 30 | builder = nop 31 | subdir = cmake-3.20.2-windows-x86_64 32 | 33 | [build.os=darwin] 34 | builder = nop 35 | subdir = cmake-3.20.2-macos-universal 36 | 37 | [install.files.os=darwin] 38 | CMake.app/Contents/bin = bin 39 | CMake.app/Contents/share = share 40 | 41 | [build.any(os=linux,os=freebsd)] 42 | builder = cmakebootstrap 43 | subdir = cmake-3.20.2 44 | 45 | [make.install_args.any(os=linux,os=freebsd)] 46 | install 47 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/cpptoml: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = cpptoml 3 | 4 | [homebrew] 5 | cpptoml 6 | 7 | [download] 8 | url = https://github.com/chadaustin/cpptoml/archive/refs/tags/v0.1.2.tar.gz 9 | sha256 = beda37e94f9746874436c8090c045fd80ae6f8a51f7c668c932a2b110a4fc277 10 | 11 | [build] 12 | builder = cmake 13 | subdir = cpptoml-0.1.2 14 | 15 | [cmake.defines.os=freebsd] 16 | ENABLE_LIBCXX=NO 17 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/delos_core: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = delos_core 3 | fbsource_path = fbcode/delos_core 4 | shipit_project = delos_core 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookincubator/delos_core.git 9 | 10 | [build.os=linux] 11 | builder = cmake 12 | 13 | [build.not(os=linux)] 14 | builder = nop 15 | 16 | [dependencies] 17 | glog 18 | googletest 19 | folly 20 | fbthrift 21 | fb303 22 | re2 23 | 24 | [shipit.pathmap] 25 | fbcode/delos_core = . 26 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/double-conversion: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = double-conversion 3 | 4 | [download] 5 | url = https://github.com/google/double-conversion/archive/v3.1.4.tar.gz 6 | sha256 = 95004b65e43fefc6100f337a25da27bb99b9ef8d4071a36a33b5e83eb1f82021 7 | 8 | [homebrew] 9 | double-conversion 10 | 11 | [rpms] 12 | double-conversion 13 | double-conversion-devel 14 | 15 | [build] 16 | builder = cmake 17 | subdir = double-conversion-3.1.4 18 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/eden: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = eden 3 | fbsource_path = fbcode/eden 4 | shipit_project = eden 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexperimental/eden.git 9 | 10 | [github.actions] 11 | run_tests = off 12 | 13 | [build] 14 | builder = cmake 15 | 16 | [dependencies] 17 | googletest 18 | folly 19 | fbthrift 20 | fb303 21 | cpptoml 22 | rocksdb 23 | re2 24 | libgit2 25 | pexpect 26 | python-toml 27 | python-filelock 28 | edencommon 29 | 30 | [dependencies.fbsource=on] 31 | rust 32 | 33 | # macOS ships with sqlite3, and some of the core system 34 | # frameworks require that that version be linked rather 35 | # than the one we might build for ourselves here, so we 36 | # skip building it on macos. 37 | [dependencies.not(os=darwin)] 38 | sqlite3 39 | 40 | [dependencies.os=darwin] 41 | osxfuse 42 | 43 | [dependencies.not(os=windows)] 44 | # TODO: teach getdeps to compile curl on Windows. 45 | # Enabling curl on Windows requires us to find a way to compile libcurl with 46 | # msvc. 47 | libcurl 48 | # Added so that OSS doesn't see system "python" which is python 2 on darwin and some linux 49 | python 50 | 51 | [dependencies.all(fb=off)] 52 | # Outside Meta hg is not installed, or if it is, its not the one we want to test with 53 | eden_scm 54 | 55 | [shipit.pathmap.fb=on] 56 | # for internal builds that use getdeps 57 | fbcode/fb303 = fb303 58 | fbcode/common/rust/fbwhoami = common/rust/fbwhoami 59 | fbcode/common/rust/shed = common/rust/shed 60 | fbcode/thrift/lib/rust = thrift/lib/rust 61 | 62 | [shipit.pathmap] 63 | # Map hostcaps for now as eden C++ includes its .h. Rust-shed should install it 64 | fbcode/common/rust/shed/hostcaps = common/rust/shed/hostcaps 65 | fbcode/configerator/structs/scm/hg = configerator/structs/scm/hg 66 | fbcode/eden/oss = . 67 | fbcode/eden = eden 68 | fbcode/tools/lfs = tools/lfs 69 | 70 | [shipit.pathmap.fb=off] 71 | fbcode/eden/fs/public_autocargo = eden/fs 72 | fbcode/eden/scm/public_autocargo = eden/scm 73 | fbcode/common/rust/shed/hostcaps/public_cargo = common/rust/shed/hostcaps 74 | fbcode/configerator/structs/scm/hg/public_autocargo = configerator/structs/scm/hg 75 | 76 | [shipit.strip] 77 | ^fbcode/eden/fs/eden-config\.h$ 78 | ^fbcode/eden/fs/py/eden/config\.py$ 79 | ^fbcode/eden/hg-server/.*$ 80 | ^fbcode/eden/mononoke/(?!lfs_protocol) 81 | ^fbcode/eden/scm/build/.*$ 82 | ^fbcode/eden/scm/lib/third-party/rust/.*/Cargo.toml$ 83 | ^fbcode/eden/.*/\.cargo/.*$ 84 | /Cargo\.lock$ 85 | \.pyc$ 86 | 87 | [shipit.strip.fb=off] 88 | ^fbcode/common/rust/shed(?!/public_autocargo).*/Cargo\.toml$ 89 | ^fbcode/configerator/structs/scm/hg(?!/public_autocargo).*/Cargo\.toml$ 90 | ^fbcode/eden/fs(?!/public_autocargo).*/Cargo\.toml$ 91 | ^fbcode/eden/scm(?!/public_autocargo|/edenscmnative).*/Cargo\.toml$ 92 | ^.*/facebook/.*$ 93 | ^.*/fb/.*$ 94 | 95 | [cmake.defines.all(fb=on,os=windows)] 96 | ENABLE_GIT=OFF 97 | INSTALL_PYTHON_LIB=ON 98 | 99 | [cmake.defines.all(not(fb=on),os=windows)] 100 | ENABLE_GIT=OFF 101 | 102 | [cmake.defines.fbsource=on] 103 | USE_CARGO_VENDOR=ON 104 | 105 | [cmake.defines.fb=on] 106 | IS_FB_BUILD=ON 107 | 108 | [depends.environment] 109 | EDEN_VERSION_OVERRIDE 110 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/eden_scm: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = eden_scm 3 | fbsource_path = fbcode/eden 4 | shipit_project = eden 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexperimental/eden.git 9 | 10 | [build.not(os=windows)] 11 | builder = make 12 | subdir = eden/scm 13 | 14 | [build.os=windows] 15 | # For now the biggest blocker is missing "make" on windows, but there are bound 16 | # to be more 17 | builder = nop 18 | 19 | [make.build_args] 20 | getdepsbuild 21 | 22 | [make.install_args] 23 | install-getdeps 24 | 25 | [make.test_args] 26 | test-getdeps 27 | 28 | [shipit.pathmap] 29 | fbcode/configerator/structs/scm/hg = configerator/structs/scm/hg 30 | fbcode/configerator/structs/scm/hg/public_autocargo = configerator/structs/scm/hg 31 | fbcode/eden/oss = . 32 | fbcode/eden = eden 33 | fbcode/eden/fs/public_autocargo = eden/fs 34 | fbcode/eden/mononoke/public_autocargo = eden/mononoke 35 | fbcode/eden/scm/public_autocargo = eden/scm 36 | fbcode/tools/lfs = tools/lfs 37 | 38 | [shipit.strip] 39 | ^fbcode/configerator/structs/scm/hg(?!/public_autocargo).*/Cargo\.toml$ 40 | ^fbcode/eden/fs/eden-config\.h$ 41 | ^fbcode/eden/fs/py/eden/config\.py$ 42 | ^fbcode/eden/hg-server/.*$ 43 | ^fbcode/eden/fs(?!/public_autocargo).*/Cargo\.toml$ 44 | ^fbcode/eden/mononoke(?!/public_autocargo).*/Cargo\.toml$ 45 | ^fbcode/eden/scm(?!/public_autocargo|/edenscmnative/bindings).*/Cargo\.toml$ 46 | ^fbcode/eden/scm/build/.*$ 47 | ^fbcode/eden/.*/\.cargo/.*$ 48 | ^.*/facebook/.*$ 49 | ^.*/fb/.*$ 50 | /Cargo\.lock$ 51 | \.pyc$ 52 | 53 | [dependencies] 54 | fb303 55 | fbthrift 56 | rust-shed 57 | 58 | [dependencies.not(os=windows)] 59 | python 60 | 61 | # We use the system openssl on linux 62 | [dependencies.not(os=linux)] 63 | openssl 64 | 65 | [dependencies.fbsource=on] 66 | rust 67 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/edencommon: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = edencommon 3 | fbsource_path = fbcode/eden/common 4 | shipit_project = edencommon 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexperimental/edencommon.git 9 | 10 | [build] 11 | builder = cmake 12 | 13 | [dependencies] 14 | folly 15 | gflags 16 | glog 17 | 18 | [cmake.defines.test=on] 19 | BUILD_TESTS=ON 20 | 21 | [cmake.defines.test=off] 22 | BUILD_TESTS=OFF 23 | 24 | [shipit.pathmap] 25 | fbcode/eden/common = eden/common 26 | fbcode/eden/common/oss = . 27 | 28 | [shipit.strip] 29 | @README.facebook@ 30 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/exprtk: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = exprtk 3 | 4 | [download] 5 | url = https://github.com/ArashPartow/exprtk/archive/refs/tags/0.0.1.tar.gz 6 | sha256 = fb72791c88ae3b3426e14fdad630027715682584daf56b973569718c56e33f28 7 | 8 | [build.not(os=windows)] 9 | builder = nop 10 | subdir = exprtk-0.0.1 11 | 12 | [install.files] 13 | exprtk.hpp = exprtk.hpp 14 | 15 | [dependencies] 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/f4d: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = f4d 3 | fbsource_path = fbcode/f4d 4 | shipit_project = f4d 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexternal/f4d.git 9 | rev = master 10 | 11 | [build.os=windows] 12 | builder = nop 13 | 14 | [build.not(os=windows)] 15 | builder = cmake 16 | 17 | [dependencies] 18 | double-conversion 19 | folly 20 | glog 21 | googletest 22 | boost 23 | protobuf 24 | lzo 25 | libicu 26 | re2 27 | 28 | [shipit.pathmap] 29 | fbcode/f4d/public_tld = . 30 | fbcode/f4d = f4d 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fatal: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fatal 3 | fbsource_path = fbcode/fatal 4 | shipit_project = fatal 5 | 6 | [git] 7 | repo_url = https://github.com/facebook/fatal.git 8 | 9 | [shipit.pathmap] 10 | fbcode/fatal = . 11 | fbcode/fatal/public_tld = . 12 | 13 | [build] 14 | builder = nop 15 | subdir = . 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fb303: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fb303 3 | fbsource_path = fbcode/fb303 4 | shipit_project = fb303 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fb303.git 9 | 10 | [cargo] 11 | cargo_config_file = source/fb303/thrift/.cargo/config 12 | 13 | [crate.pathmap] 14 | fb303_core = fb303/thrift 15 | 16 | [build] 17 | builder = cmake 18 | 19 | [dependencies] 20 | folly 21 | gflags 22 | glog 23 | fbthrift 24 | 25 | [cmake.defines.test=on] 26 | BUILD_TESTS=ON 27 | 28 | [cmake.defines.test=off] 29 | BUILD_TESTS=OFF 30 | 31 | [shipit.pathmap] 32 | fbcode/fb303/github = . 33 | fbcode/fb303/public_autocargo = fb303 34 | fbcode/fb303 = fb303 35 | 36 | [shipit.strip] 37 | ^fbcode/fb303/(?!public_autocargo).+/Cargo\.toml$ 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fb303-source: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fb303-source 3 | fbsource_path = fbcode/fb303 4 | shipit_project = fb303 5 | shipit_fbcode_builder = false 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fb303.git 9 | 10 | [build] 11 | builder = nop 12 | 13 | [shipit.pathmap] 14 | fbcode/fb303/github = . 15 | fbcode/fb303/public_autocargo = fb303 16 | fbcode/fb303 = fb303 17 | 18 | [shipit.strip] 19 | ^fbcode/fb303/(?!public_autocargo).+/Cargo\.toml$ 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fboss: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fboss 3 | fbsource_path = fbcode/fboss 4 | shipit_project = fboss 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fboss.git 9 | 10 | [build.os=linux] 11 | builder = cmake 12 | # fboss files take a lot of RAM to compile. 13 | job_weight_mib = 3072 14 | 15 | [build.not(os=linux)] 16 | builder = nop 17 | 18 | [dependencies] 19 | folly 20 | fb303 21 | wangle 22 | fizz 23 | fmt 24 | libsodium 25 | googletest 26 | zstd 27 | fbthrift 28 | iproute2 29 | libmnl 30 | libusb 31 | libcurl 32 | libnl 33 | libsai 34 | OpenNSA 35 | re2 36 | python 37 | yaml-cpp 38 | libyaml 39 | CLI11 40 | exprtk 41 | nlohmann-json 42 | 43 | [shipit.pathmap] 44 | fbcode/fboss/github = . 45 | fbcode/fboss/common = common 46 | fbcode/fboss = fboss 47 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fbthrift: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fbthrift 3 | fbsource_path = fbcode/thrift 4 | shipit_project = fbthrift 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fbthrift.git 9 | 10 | [cargo] 11 | cargo_config_file = source/thrift/lib/rust/.cargo/config 12 | 13 | [crate.pathmap] 14 | fbthrift = thrift/lib/rust 15 | 16 | [build] 17 | builder = cmake 18 | job_weight_mib = 2048 19 | 20 | [dependencies] 21 | bison 22 | folly 23 | wangle 24 | fizz 25 | fmt 26 | googletest 27 | libsodium 28 | python-six 29 | zstd 30 | 31 | [dependencies.os=linux] 32 | # python doesn't build on Windows yet and this causes python3 shebangs to 33 | # expand to a non-portable path on macOS 34 | python 35 | 36 | [shipit.pathmap] 37 | fbcode/thrift/public_tld = . 38 | fbcode/thrift = thrift 39 | 40 | [shipit.strip] 41 | ^fbcode/thrift/thrift-config\.h$ 42 | ^fbcode/thrift/perf/canary.py$ 43 | ^fbcode/thrift/perf/loadtest.py$ 44 | ^fbcode/thrift/.castle/.* 45 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fbthrift-source: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fbthrift-source 3 | fbsource_path = fbcode/thrift 4 | shipit_project = fbthrift 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fbthrift.git 9 | 10 | [build] 11 | builder = nop 12 | 13 | [shipit.pathmap] 14 | fbcode/thrift/public_tld = . 15 | fbcode/thrift = thrift 16 | 17 | [shipit.strip] 18 | ^fbcode/thrift/thrift-config\.h$ 19 | ^fbcode/thrift/perf/canary.py$ 20 | ^fbcode/thrift/perf/loadtest.py$ 21 | ^fbcode/thrift/.castle/.* 22 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fbzmq: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fbzmq 3 | fbsource_path = facebook/fbzmq 4 | shipit_project = fbzmq 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fbzmq.git 9 | 10 | [build.os=linux] 11 | builder = cmake 12 | 13 | [build.not(os=linux)] 14 | # boost.fiber is required and that is not available on macos. 15 | # libzmq doesn't currently build on windows. 16 | builder = nop 17 | 18 | [dependencies] 19 | boost 20 | folly 21 | fbthrift 22 | googletest 23 | libzmq 24 | 25 | [shipit.pathmap] 26 | fbcode/fbzmq = fbzmq 27 | fbcode/fbzmq/public_tld = . 28 | 29 | [shipit.strip] 30 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fizz: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fizz 3 | fbsource_path = fbcode/fizz 4 | shipit_project = fizz 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookincubator/fizz.git 9 | 10 | [build] 11 | builder = cmake 12 | subdir = fizz 13 | 14 | [cmake.defines] 15 | BUILD_EXAMPLES = OFF 16 | 17 | [cmake.defines.test=on] 18 | BUILD_TESTS = ON 19 | 20 | [cmake.defines.all(os=windows, test=on)] 21 | BUILD_TESTS = OFF 22 | 23 | [cmake.defines.test=off] 24 | BUILD_TESTS = OFF 25 | 26 | [dependencies] 27 | folly 28 | libsodium 29 | zlib 30 | zstd 31 | 32 | [dependencies.all(test=on, not(os=windows))] 33 | googletest 34 | 35 | [shipit.pathmap] 36 | fbcode/fizz/public_tld = . 37 | fbcode/fizz = fizz 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fmt: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fmt 3 | 4 | [download] 5 | url = https://github.com/fmtlib/fmt/archive/refs/tags/8.0.1.tar.gz 6 | sha256 = b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01 7 | 8 | [build] 9 | builder = cmake 10 | subdir = fmt-8.0.1 11 | 12 | [cmake.defines] 13 | FMT_TEST = OFF 14 | FMT_DOC = OFF 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/folly: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = folly 3 | fbsource_path = fbcode/folly 4 | shipit_project = folly 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/folly.git 9 | 10 | [build] 11 | builder = cmake 12 | job_weight_mib = 1024 13 | 14 | [dependencies] 15 | gflags 16 | glog 17 | googletest 18 | boost 19 | libevent 20 | libsodium 21 | double-conversion 22 | fmt 23 | lz4 24 | snappy 25 | zstd 26 | # no openssl or zlib in the linux case, why? 27 | # these are usually installed on the system 28 | # and are the easiest system deps to pull in. 29 | # In the future we want to be able to express 30 | # that a system dep is sufficient in the manifest 31 | # for eg: openssl and zlib, but for now we don't 32 | # have it. 33 | 34 | # macOS doesn't expose the openssl api so we need 35 | # to build our own. 36 | [dependencies.os=darwin] 37 | openssl 38 | 39 | # Windows has neither openssl nor zlib, so we get 40 | # to provide both 41 | [dependencies.os=windows] 42 | openssl 43 | zlib 44 | 45 | # xz depends on autoconf which does not build on 46 | # Windows 47 | [dependencies.not(os=windows)] 48 | xz 49 | 50 | [shipit.pathmap] 51 | fbcode/folly/public_tld = . 52 | fbcode/folly = folly 53 | 54 | [shipit.strip] 55 | ^fbcode/folly/folly-config\.h$ 56 | ^fbcode/folly/public_tld/build/facebook_.* 57 | 58 | [cmake.defines] 59 | BUILD_SHARED_LIBS=OFF 60 | BOOST_LINK_STATIC=ON 61 | 62 | [cmake.defines.os=freebsd] 63 | LIBDWARF_FOUND=NO 64 | 65 | [cmake.defines.test=on] 66 | BUILD_TESTS=ON 67 | 68 | [cmake.defines.test=off] 69 | BUILD_TESTS=OFF 70 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gflags: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gflags 3 | 4 | [download] 5 | url = https://github.com/gflags/gflags/archive/v2.2.2.tar.gz 6 | sha256 = 34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf 7 | 8 | [build] 9 | builder = cmake 10 | subdir = gflags-2.2.2 11 | 12 | [cmake.defines] 13 | BUILD_SHARED_LIBS = ON 14 | BUILD_STATIC_LIBS = ON 15 | #BUILD_gflags_nothreads_LIB = OFF 16 | BUILD_gflags_LIB = ON 17 | 18 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/git-lfs: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = git-lfs 3 | 4 | [download.os=linux] 5 | url = https://github.com/git-lfs/git-lfs/releases/download/v2.9.1/git-lfs-linux-amd64-v2.9.1.tar.gz 6 | sha256 = 2a8e60cf51ec45aa0f4332aa0521d60ec75c76e485d13ebaeea915b9d70ea466 7 | 8 | [build] 9 | builder = nop 10 | 11 | [install.files] 12 | git-lfs = bin/git-lfs 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/glog: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = glog 3 | 4 | [download] 5 | url = https://github.com/google/glog/archive/v0.5.0.tar.gz 6 | sha256 = eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5 7 | 8 | [build] 9 | builder = cmake 10 | subdir = glog-0.5.0 11 | 12 | [dependencies] 13 | gflags 14 | 15 | [cmake.defines] 16 | BUILD_SHARED_LIBS=ON 17 | BUILD_TESTING=NO 18 | WITH_PKGCONFIG=ON 19 | 20 | [cmake.defines.os=freebsd] 21 | HAVE_TR1_UNORDERED_MAP=OFF 22 | HAVE_TR1_UNORDERED_SET=OFF 23 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gnu-bash: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gnu-bash 3 | 4 | [download.os=darwin] 5 | url = https://ftp.gnu.org/gnu/bash/bash-5.1-rc1.tar.gz 6 | sha256 = 0b2684eb1990329d499c96decfe2459f3e150deb915b0a9d03cf1be692b1d6d3 7 | 8 | [build.os=darwin] 9 | # The buildin FreeBSD bash on OSX is both outdated and incompatible with the 10 | # modern GNU bash, so for the sake of being cross-platform friendly this 11 | # manifest provides GNU bash. 12 | # NOTE: This is the 5.1-rc1 version, which is almost the same as what Homebrew 13 | # uses (Homebrew installs 5.0 with the 18 patches that in fact make the 5.1-rc1 14 | # version). 15 | builder = autoconf 16 | subdir = bash-5.1-rc1 17 | build_in_src_dir = true 18 | 19 | [build.not(os=darwin)] 20 | builder = nop 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gnu-coreutils: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gnu-coreutils 3 | 4 | [download.os=darwin] 5 | url = https://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.gz 6 | sha256 = d5ab07435a74058ab69a2007e838be4f6a90b5635d812c2e26671e3972fca1b8 7 | 8 | [build.os=darwin] 9 | # The buildin FreeBSD version incompatible with the GNU one, so for the sake of 10 | # being cross-platform friendly this manifest provides the GNU version. 11 | builder = autoconf 12 | subdir = coreutils-8.32 13 | 14 | [build.not(os=darwin)] 15 | builder = nop 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gnu-grep: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gnu-grep 3 | 4 | [download.os=darwin] 5 | url = https://ftp.gnu.org/gnu/grep/grep-3.5.tar.gz 6 | sha256 = 9897220992a8fd38a80b70731462defa95f7ff2709b235fb54864ddd011141dd 7 | 8 | [build.os=darwin] 9 | # The buildin FreeBSD version incompatible with the GNU one, so for the sake of 10 | # being cross-platform friendly this manifest provides the GNU version. 11 | builder = autoconf 12 | subdir = grep-3.5 13 | 14 | [build.not(os=darwin)] 15 | builder = nop 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gnu-sed: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gnu-sed 3 | 4 | [download.os=darwin] 5 | url = https://ftp.gnu.org/gnu/sed/sed-4.8.tar.gz 6 | sha256 = 53cf3e14c71f3a149f29d13a0da64120b3c1d3334fba39c4af3e520be053982a 7 | 8 | [build.os=darwin] 9 | # The buildin FreeBSD version incompatible with the GNU one, so for the sake of 10 | # being cross-platform friendly this manifest provides the GNU version. 11 | builder = autoconf 12 | subdir = sed-4.8 13 | 14 | [build.not(os=darwin)] 15 | builder = nop 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/googletest: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = googletest 3 | 4 | [download] 5 | url = https://github.com/google/googletest/archive/release-1.11.0.tar.gz 6 | sha256 = b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5 7 | 8 | [build] 9 | builder = cmake 10 | subdir = googletest-release-1.11.0 11 | 12 | [cmake.defines] 13 | # Everything else defaults to the shared runtime, so tell gtest that 14 | # it should not use its choice of the static runtime 15 | gtest_force_shared_crt=ON 16 | 17 | [cmake.defines.os=windows] 18 | BUILD_SHARED_LIBS=ON 19 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/googletest_1_8: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = googletest_1_8 3 | 4 | [download] 5 | url = https://github.com/google/googletest/archive/release-1.8.0.tar.gz 6 | sha256 = 58a6f4277ca2bc8565222b3bbd58a177609e9c488e8a72649359ba51450db7d8 7 | 8 | [build] 9 | builder = cmake 10 | subdir = googletest-release-1.8.0 11 | 12 | [cmake.defines] 13 | # Everything else defaults to the shared runtime, so tell gtest that 14 | # it should not use its choice of the static runtime 15 | gtest_force_shared_crt=ON 16 | 17 | [cmake.defines.os=windows] 18 | BUILD_SHARED_LIBS=ON 19 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gperf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gperf 3 | 4 | [download] 5 | url = http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz 6 | sha256 = 588546b945bba4b70b6a3a616e80b4ab466e3f33024a352fc2198112cdbb3ae2 7 | 8 | [build.not(os=windows)] 9 | builder = autoconf 10 | subdir = gperf-3.1 11 | 12 | [build.os=windows] 13 | builder = nop 14 | 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/iproute2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = iproute2 3 | 4 | [download] 5 | url = https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/iproute2-4.12.0.tar.gz 6 | sha256 = 46612a1e2d01bb31932557bccdb1b8618cae9a439dfffc08ef35ed8e197f14ce 7 | 8 | [build.os=linux] 9 | builder = iproute2 10 | subdir = iproute2-4.12.0 11 | 12 | [build.not(os=linux)] 13 | builder = nop 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/jq: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = jq 3 | 4 | [rpms] 5 | jq 6 | 7 | [debs] 8 | jq 9 | 10 | [download.not(os=windows)] 11 | url = https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz 12 | sha256 = c4d2bfec6436341113419debf479d833692cc5cdab7eb0326b5a4d4fbe9f493c 13 | 14 | [build.not(os=windows)] 15 | builder = autoconf 16 | subdir = jq-1.5 17 | 18 | [build.os=windows] 19 | builder = nop 20 | 21 | [autoconf.args] 22 | # This argument turns off some developers tool and it is recommended in jq's 23 | # README 24 | --disable-maintainer-mode 25 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/katran: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = katran 3 | fbsource_path = fbcode/katran 4 | shipit_project = katran 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookincubator/katran.git 9 | 10 | [build.not(os=linux)] 11 | builder = nop 12 | 13 | [build.os=linux] 14 | builder = cmake 15 | subdir = . 16 | 17 | [cmake.defines.test=on] 18 | BUILD_TESTS=ON 19 | 20 | [cmake.defines.test=off] 21 | BUILD_TESTS=OFF 22 | 23 | [dependencies] 24 | folly 25 | fizz 26 | libbpf 27 | libmnl 28 | zlib 29 | googletest 30 | 31 | 32 | [shipit.pathmap] 33 | fbcode/katran/public_root = . 34 | fbcode/katran = katran 35 | 36 | [shipit.strip] 37 | ^fbcode/katran/facebook 38 | ^fbcode/katran/OSS_SYNC 39 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libbpf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libbpf 3 | 4 | [download] 5 | url = https://github.com/libbpf/libbpf/archive/refs/tags/v0.7.0.tar.gz 6 | sha256 = 5083588ce5a3a620e395ee1e596af77b4ec5771ffc71cff2af49dfee38c06361 7 | 8 | # BPF only builds on linux, so make it a NOP on other platforms 9 | [build.not(os=linux)] 10 | builder = nop 11 | 12 | [build.os=linux] 13 | builder = make 14 | subdir = libbpf-0.7.0/src 15 | 16 | [make.build_args] 17 | BUILD_STATIC_ONLY=y 18 | 19 | # libbpf-0.3 requires uapi headers >= 5.8 20 | [make.install_args] 21 | install 22 | install_uapi_headers 23 | BUILD_STATIC_ONLY=y 24 | 25 | [dependencies] 26 | libelf 27 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libbpf_0_2_0_beta: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libbpf_0_2_0_beta 3 | 4 | [download] 5 | url = https://github.com/libbpf/libbpf/archive/b6dd2f2.tar.gz 6 | sha256 = 8db9dca90f5c445ef2362e3c6a00f3d6c4bf36e8782f8e27704109c78e541497 7 | 8 | # BPF only builds on linux, so make it a NOP on other platforms 9 | [build.not(os=linux)] 10 | builder = nop 11 | 12 | [build.os=linux] 13 | builder = make 14 | subdir = libbpf-b6dd2f2b7df4d3bd35d64aaf521d9ad18d766f53/src 15 | 16 | [make.build_args] 17 | BUILD_STATIC_ONLY=y 18 | 19 | # libbpf now requires uapi headers >= 5.8 20 | [make.install_args] 21 | install 22 | install_uapi_headers 23 | BUILD_STATIC_ONLY=y 24 | 25 | [dependencies] 26 | libelf 27 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libcurl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libcurl 3 | 4 | [rpms] 5 | libcurl-devel 6 | libcurl 7 | 8 | [debs] 9 | libcurl4-openssl-dev 10 | 11 | [download] 12 | url = https://curl.haxx.se/download/curl-7.65.1.tar.gz 13 | sha256 = 821aeb78421375f70e55381c9ad2474bf279fc454b791b7e95fc83562951c690 14 | 15 | [dependencies] 16 | nghttp2 17 | 18 | # We use system OpenSSL on Linux (see folly's manifest for details) 19 | [dependencies.not(os=linux)] 20 | openssl 21 | 22 | [build.not(os=windows)] 23 | builder = autoconf 24 | subdir = curl-7.65.1 25 | 26 | [autoconf.args] 27 | # fboss (which added the libcurl dep) doesn't need ldap so it is disabled here. 28 | # if someone in the future wants to add ldap for something else, it won't hurt 29 | # fboss. However, that would require adding an ldap manifest. 30 | # 31 | # For the same reason, we disable libssh2 and libidn2 which aren't really used 32 | # but would require adding manifests if we don't disable them. 33 | --disable-ldap 34 | --without-libssh2 35 | --without-libidn2 36 | 37 | [build.os=windows] 38 | builder = cmake 39 | subdir = curl-7.65.1 40 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libelf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libelf 3 | 4 | [rpms] 5 | elfutils-libelf-devel-static 6 | 7 | [debs] 8 | libelf-dev 9 | 10 | [download] 11 | url = https://ftp.osuosl.org/pub/blfs/conglomeration/libelf/libelf-0.8.13.tar.gz 12 | sha256 = 591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d 13 | 14 | # libelf only makes sense on linux, so make it a NOP on other platforms 15 | [build.not(os=linux)] 16 | builder = nop 17 | 18 | [build.os=linux] 19 | builder = autoconf 20 | subdir = libelf-0.8.13 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libevent: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libevent 3 | 4 | [debs] 5 | libevent-dev 6 | 7 | [homebrew] 8 | libevent 9 | 10 | [rpms] 11 | libevent-devel 12 | 13 | # Note that the CMakeLists.txt file is present only in 14 | # git repo and not in the release tarball, so take care 15 | # to use the github generated source tarball rather than 16 | # the explicitly uploaded source tarball 17 | [download] 18 | url = https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz 19 | sha256 = 92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb 20 | 21 | [build] 22 | builder = cmake 23 | subdir = libevent-2.1.12-stable 24 | 25 | [cmake.defines] 26 | EVENT__DISABLE_TESTS = ON 27 | EVENT__DISABLE_BENCHMARK = ON 28 | EVENT__DISABLE_SAMPLES = ON 29 | EVENT__DISABLE_REGRESS = ON 30 | 31 | [cmake.defines.shared_libs=on] 32 | EVENT__BUILD_SHARED_LIBRARIES = ON 33 | 34 | [cmake.defines.os=windows] 35 | EVENT__LIBRARY_TYPE = STATIC 36 | 37 | [dependencies.not(any(os=linux, os=freebsd))] 38 | openssl 39 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libffi: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libffi 3 | 4 | [debs] 5 | libffi-dev 6 | 7 | [homebrew] 8 | libffi 9 | 10 | [rpms] 11 | libffi-devel 12 | libffi 13 | 14 | [download] 15 | url = https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz 16 | sha256 = 540fb721619a6aba3bdeef7d940d8e9e0e6d2c193595bc243241b77ff9e93620 17 | 18 | [build] 19 | builder = autoconf 20 | subdir = libffi-3.4.2 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libgit2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libgit2 3 | 4 | [homebrew] 5 | libgit2 6 | 7 | [rpms] 8 | libgit2-devel 9 | 10 | # Ubuntu 18.04 libgit2 has clash with libcurl4-openssl-dev as it depends on 11 | # libcurl4-gnutls-dev. Should be ok from 20.04 again 12 | # There is a description at https://github.com/r-hub/sysreqsdb/issues/77 13 | # [debs] 14 | # libgit2-dev 15 | 16 | [download] 17 | url = https://github.com/libgit2/libgit2/archive/v0.28.1.tar.gz 18 | sha256 = 0ca11048795b0d6338f2e57717370208c2c97ad66c6d5eac0c97a8827d13936b 19 | 20 | [build] 21 | builder = cmake 22 | subdir = libgit2-0.28.1 23 | 24 | [cmake.defines] 25 | # Could turn this on if we also wanted to add a manifest for libssh2 26 | USE_SSH = OFF 27 | BUILD_CLAR = OFF 28 | # Have to build shared to work around annoying problems with cmake 29 | # mis-parsing the frameworks required to link this on macos :-/ 30 | BUILD_SHARED_LIBS = ON 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libicu: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libicu 3 | 4 | [rpms] 5 | libicu-devel 6 | 7 | [debs] 8 | libicu-dev 9 | 10 | [download] 11 | url = https://github.com/unicode-org/icu/releases/download/release-68-2/icu4c-68_2-src.tgz 12 | sha256 = c79193dee3907a2199b8296a93b52c5cb74332c26f3d167269487680d479d625 13 | 14 | [build.not(os=windows)] 15 | builder = autoconf 16 | subdir = icu/source 17 | 18 | [build.os=windows] 19 | builder = nop 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libmnl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libmnl 3 | 4 | [rpms] 5 | libmnl-devel 6 | 7 | # all centos 8 distros are missing this, 8 | # but its in fedora so may be back in a later version 9 | [rpms.not(all(any(distro=centos_stream,distro=centos),distro_vers=8))] 10 | libmnl-static 11 | 12 | [debs] 13 | libmnl-dev 14 | 15 | [download] 16 | url = http://www.netfilter.org/pub/libmnl/libmnl-1.0.4.tar.bz2 17 | sha256 = 171f89699f286a5854b72b91d06e8f8e3683064c5901fb09d954a9ab6f551f81 18 | 19 | [build.os=linux] 20 | builder = autoconf 21 | subdir = libmnl-1.0.4 22 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libnl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libnl 3 | 4 | [rpms] 5 | libnl3-devel 6 | libnl3 7 | 8 | [debs] 9 | libnl-3-dev 10 | libnl-route-3-dev 11 | 12 | [download] 13 | url = https://www.infradead.org/~tgr/libnl/files/libnl-3.2.25.tar.gz 14 | sha256 = 8beb7590674957b931de6b7f81c530b85dc7c1ad8fbda015398bc1e8d1ce8ec5 15 | 16 | [build.os=linux] 17 | builder = autoconf 18 | subdir = libnl-3.2.25 19 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libsai: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libsai 3 | 4 | [download] 5 | url = https://github.com/opencomputeproject/SAI/archive/v1.7.1.tar.gz 6 | sha256 = e18eb1a2a6e5dd286d97e13569d8b78cc1f8229030beed0db4775b9a50ab6a83 7 | 8 | [build] 9 | builder = nop 10 | subdir = SAI-1.7.1 11 | 12 | [install.files] 13 | inc = include 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libsodium: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libsodium 3 | 4 | [debs] 5 | libsodium-dev 6 | 7 | [homebrew] 8 | libsodium 9 | 10 | [rpms] 11 | libsodium-devel 12 | libsodium-static 13 | 14 | [download.not(os=windows)] 15 | url = https://github.com/jedisct1/libsodium/releases/download/1.0.17/libsodium-1.0.17.tar.gz 16 | sha256 = 0cc3dae33e642cc187b5ceb467e0ad0e1b51dcba577de1190e9ffa17766ac2b1 17 | 18 | [build.not(os=windows)] 19 | builder = autoconf 20 | subdir = libsodium-1.0.17 21 | 22 | [download.os=windows] 23 | url = https://download.libsodium.org/libsodium/releases/libsodium-1.0.17-msvc.zip 24 | sha256 = f0f32ad8ebd76eee99bb039f843f583f2babca5288a8c26a7261db9694c11467 25 | 26 | [build.os=windows] 27 | builder = nop 28 | 29 | [install.files.os=windows] 30 | x64/Release/v141/dynamic/libsodium.dll = bin/libsodium.dll 31 | x64/Release/v141/dynamic/libsodium.lib = lib/libsodium.lib 32 | x64/Release/v141/dynamic/libsodium.exp = lib/libsodium.exp 33 | x64/Release/v141/dynamic/libsodium.pdb = lib/libsodium.pdb 34 | include = include 35 | 36 | [autoconf.args] 37 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libtool: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libtool 3 | 4 | [homebrew] 5 | libtool 6 | 7 | [rpms] 8 | libtool 9 | 10 | [debs] 11 | libtool 12 | 13 | [download] 14 | url = http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz 15 | sha256 = e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3 16 | 17 | [build] 18 | builder = autoconf 19 | subdir = libtool-2.4.6 20 | 21 | [dependencies] 22 | automake 23 | 24 | [autoconf.args] 25 | --enable-ltdl-install 26 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libusb: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libusb 3 | 4 | [debs] 5 | libusb-1.0-0-dev 6 | 7 | [homebrew] 8 | libusb 9 | 10 | [rpms] 11 | libusb-devel 12 | libusb 13 | 14 | [download] 15 | url = https://github.com/libusb/libusb/releases/download/v1.0.22/libusb-1.0.22.tar.bz2 16 | sha256 = 75aeb9d59a4fdb800d329a545c2e6799f732362193b465ea198f2aa275518157 17 | 18 | [build.os=linux] 19 | builder = autoconf 20 | subdir = libusb-1.0.22 21 | 22 | [autoconf.args] 23 | # fboss (which added the libusb dep) doesn't need udev so it is disabled here. 24 | # if someone in the future wants to add udev for something else, it won't hurt 25 | # fboss. 26 | --disable-udev 27 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libyaml: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libyaml 3 | 4 | [download] 5 | url = http://pyyaml.org/download/libyaml/yaml-0.1.7.tar.gz 6 | sha256 = 8088e457264a98ba451a90b8661fcb4f9d6f478f7265d48322a196cec2480729 7 | 8 | [build.os=linux] 9 | builder = autoconf 10 | subdir = yaml-0.1.7 11 | 12 | [build.not(os=linux)] 13 | builder = nop 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libzmq: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libzmq 3 | 4 | [debs] 5 | libzmq3-dev 6 | 7 | [homebrew] 8 | zeromq 9 | 10 | [rpms] 11 | zeromq-devel 12 | zeromq 13 | 14 | [download] 15 | url = https://github.com/zeromq/libzmq/releases/download/v4.3.1/zeromq-4.3.1.tar.gz 16 | sha256 = bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb 17 | 18 | 19 | [build] 20 | builder = autoconf 21 | subdir = zeromq-4.3.1 22 | 23 | [autoconf.args] 24 | 25 | [dependencies] 26 | autoconf 27 | libtool 28 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/lz4: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = lz4 3 | 4 | [homebrew] 5 | lz4 6 | 7 | [rpms] 8 | lz4-devel 9 | # centos (not centos_stream that is Meta internal) 8 is missing this 10 | [rpms.not(all(distro=centos,distro_vers=8))] 11 | lz4-static 12 | 13 | [debs] 14 | liblz4-dev 15 | 16 | [download] 17 | url = https://github.com/lz4/lz4/archive/v1.8.3.tar.gz 18 | sha256 = 33af5936ac06536805f9745e0b6d61da606a1f8b4cc5c04dd3cbaca3b9b4fc43 19 | 20 | [build] 21 | builder = cmake 22 | subdir = lz4-1.8.3/contrib/cmake_unofficial 23 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/lzo: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = lzo 3 | 4 | [debs] 5 | liblzo2-dev 6 | 7 | [homebrew] 8 | lzo 9 | 10 | [rpms] 11 | lzo-devel 12 | 13 | [download] 14 | url = http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz 15 | sha256 = c0f892943208266f9b6543b3ae308fab6284c5c90e627931446fb49b4221a072 16 | 17 | [build.not(os=windows)] 18 | builder = autoconf 19 | subdir = lzo-2.10 20 | 21 | [build.os=windows] 22 | builder = nop 23 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/mononoke: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = mononoke 3 | fbsource_path = fbcode/eden 4 | shipit_project = eden 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexperimental/eden.git 9 | 10 | [build.not(os=windows)] 11 | builder = cargo 12 | 13 | [build.os=windows] 14 | # building Mononoke on windows is not supported 15 | builder = nop 16 | 17 | [cargo] 18 | build_doc = true 19 | workspace_dir = eden/mononoke 20 | 21 | [shipit.pathmap] 22 | fbcode/configerator/structs/scm/hg = configerator/structs/scm/hg 23 | fbcode/configerator/structs/scm/hg/public_autocargo = configerator/structs/scm/hg 24 | fbcode/configerator/structs/scm/mononoke/public_autocargo = configerator/structs/scm/mononoke 25 | fbcode/configerator/structs/scm/mononoke = configerator/structs/scm/mononoke 26 | fbcode/eden/oss = . 27 | fbcode/eden = eden 28 | fbcode/eden/fs/public_autocargo = eden/fs 29 | fbcode/eden/mononoke/public_autocargo = eden/mononoke 30 | fbcode/eden/scm/public_autocargo = eden/scm 31 | fbcode/tools/lfs = tools/lfs 32 | tools/rust/ossconfigs = . 33 | 34 | [shipit.strip] 35 | ^fbcode/configerator/structs/scm/hg(?!/public_autocargo).*/Cargo\.toml$ 36 | ^fbcode/configerator/structs/scm/mononoke(?!/public_autocargo).*/Cargo\.toml$ 37 | ^fbcode/eden/fs(?!/public_autocargo).*/Cargo\.toml$ 38 | ^fbcode/eden/scm/lib/third-party/rust/.*/Cargo\.toml$ 39 | ^fbcode/eden/mononoke(?!/public_autocargo).*/Cargo\.toml$ 40 | # strip other scm code unrelated to mononoke to prevent triggering unnecessary checks 41 | ^fbcode/eden/(?!mononoke|/scm/lib/xdiff.*)/.*$ 42 | ^.*/facebook/.*$ 43 | ^.*/fb/.*$ 44 | 45 | [dependencies] 46 | fb303 47 | fbthrift 48 | rust-shed 49 | 50 | [dependencies.fb=on] 51 | rust 52 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/mvfst: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = mvfst 3 | fbsource_path = fbcode/quic 4 | shipit_project = mvfst 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookincubator/mvfst.git 9 | 10 | [build] 11 | builder = cmake 12 | subdir = . 13 | 14 | [cmake.defines.test=on] 15 | BUILD_TESTS = ON 16 | 17 | [cmake.defines.all(os=windows, test=on)] 18 | BUILD_TESTS = OFF 19 | 20 | [cmake.defines.test=off] 21 | BUILD_TESTS = OFF 22 | 23 | [dependencies] 24 | folly 25 | fizz 26 | 27 | [dependencies.all(test=on, not(os=windows))] 28 | googletest 29 | 30 | [shipit.pathmap] 31 | fbcode/quic/public_root = . 32 | fbcode/quic = quic 33 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/ncurses: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = ncurses 3 | 4 | [debs] 5 | libncurses-dev 6 | 7 | [homebrew] 8 | ncurses 9 | 10 | [rpms] 11 | ncurses-devel 12 | 13 | [download] 14 | url = https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz 15 | sha256 = 97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059 16 | 17 | [build.not(os=windows)] 18 | builder = autoconf 19 | subdir = ncurses-6.3 20 | 21 | [autoconf.args] 22 | --without-cxx-binding 23 | --without-ada 24 | 25 | [autoconf.args.os=linux] 26 | --enable-shared 27 | --with-shared 28 | 29 | [build.os=windows] 30 | builder = nop 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/nghttp2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = nghttp2 3 | 4 | [rpms] 5 | libnghttp2-devel 6 | libnghttp2 7 | 8 | [debs] 9 | libnghttp2-dev 10 | 11 | [download] 12 | url = https://github.com/nghttp2/nghttp2/releases/download/v1.39.2/nghttp2-1.39.2.tar.gz 13 | sha256 = fc820a305e2f410fade1a3260f09229f15c0494fc089b0100312cd64a33a38c0 14 | 15 | [build] 16 | builder = autoconf 17 | subdir = nghttp2-1.39.2 18 | 19 | [autoconf.args] 20 | --enable-lib-only 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/ninja: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = ninja 3 | 4 | [debs] 5 | ninja-build 6 | 7 | [homebrew] 8 | ninja 9 | 10 | [rpms] 11 | ninja-build 12 | 13 | [download.os=windows] 14 | url = https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip 15 | sha256 = bbde850d247d2737c5764c927d1071cbb1f1957dcabda4a130fa8547c12c695f 16 | 17 | [build.os=windows] 18 | builder = nop 19 | 20 | [install.files.os=windows] 21 | ninja.exe = bin/ninja.exe 22 | 23 | [download.not(os=windows)] 24 | url = https://github.com/ninja-build/ninja/archive/v1.10.2.tar.gz 25 | sha256 = ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed 26 | 27 | [build.not(os=windows)] 28 | builder = ninja_bootstrap 29 | subdir = ninja-1.10.2 30 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/nlohmann-json: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = nlohmann-json 3 | 4 | [download] 5 | url = https://github.com/nlohmann/json/archive/refs/tags/v3.10.5.tar.gz 6 | sha256 = 5daca6ca216495edf89d167f808d1d03c4a4d929cef7da5e10f135ae1540c7e4 7 | 8 | [dependencies] 9 | 10 | [build] 11 | builder = cmake 12 | subdir = json-3.10.5 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/nmap: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = nmap 3 | 4 | [rpms] 5 | nmap 6 | 7 | [debs] 8 | nmap 9 | 10 | [download.not(os=windows)] 11 | url = https://api.github.com/repos/nmap/nmap/tarball/ef8213a36c2e89233c806753a57b5cd473605408 12 | sha256 = eda39e5a8ef4964fac7db16abf91cc11ff568eac0fa2d680b0bfa33b0ed71f4a 13 | 14 | [build.not(os=windows)] 15 | builder = autoconf 16 | subdir = nmap-nmap-ef8213a 17 | build_in_src_dir = true 18 | 19 | [build.os=windows] 20 | builder = nop 21 | 22 | [autoconf.args] 23 | # Without this option the build was filing to find some third party libraries 24 | # that we don't need 25 | enable_rdma=no 26 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/openr: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = openr 3 | fbsource_path = facebook/openr 4 | shipit_project = openr 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/openr.git 9 | 10 | [build.os=linux] 11 | builder = cmake 12 | 13 | [build.not(os=linux)] 14 | # boost.fiber is required and that is not available on macos. 15 | builder = nop 16 | 17 | [dependencies] 18 | boost 19 | fb303 20 | fbthrift 21 | folly 22 | googletest 23 | re2 24 | range-v3 25 | 26 | [cmake.defines.test=on] 27 | BUILD_TESTS=ON 28 | ADD_ROOT_TESTS=OFF 29 | 30 | [cmake.defines.test=off] 31 | BUILD_TESTS=OFF 32 | 33 | 34 | [shipit.pathmap] 35 | fbcode/openr = openr 36 | fbcode/openr/public_tld = . 37 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/openssl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = openssl 3 | 4 | [debs] 5 | libssl-dev 6 | 7 | [homebrew] 8 | openssl@1.1 9 | # on homebrew need the matching curl and ca- 10 | 11 | [rpms] 12 | openssl 13 | openssl-devel 14 | openssl-libs 15 | 16 | [download] 17 | url = https://www.openssl.org/source/openssl-1.1.1l.tar.gz 18 | sha256 = 0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1 19 | 20 | # We use the system openssl on linux 21 | [build.not(any(os=linux, os=freebsd))] 22 | builder = openssl 23 | subdir = openssl-1.1.1l 24 | 25 | [dependencies.os=windows] 26 | perl 27 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/osxfuse: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = osxfuse 3 | 4 | [download] 5 | url = https://github.com/osxfuse/osxfuse/archive/osxfuse-3.8.3.tar.gz 6 | sha256 = 93bab6731bdfe8dc1ef069483437270ce7fe5a370f933d40d8d0ef09ba846c0c 7 | 8 | [build] 9 | builder = nop 10 | 11 | [install.files] 12 | osxfuse-osxfuse-3.8.3/common = include 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/patchelf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = patchelf 3 | 4 | [rpms] 5 | patchelf 6 | 7 | [debs] 8 | patchelf 9 | 10 | [download] 11 | url = https://github.com/NixOS/patchelf/archive/0.10.tar.gz 12 | sha256 = b3cb6bdedcef5607ce34a350cf0b182eb979f8f7bc31eae55a93a70a3f020d13 13 | 14 | [build] 15 | builder = autoconf 16 | subdir = patchelf-0.10 17 | 18 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/pcre: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = pcre 3 | 4 | [homebrew] 5 | pcre 6 | 7 | [rpms] 8 | pcre-devel 9 | pcre-static 10 | 11 | [debs] 12 | libpcre3-dev 13 | 14 | [download] 15 | url = https://versaweb.dl.sourceforge.net/project/pcre/pcre/8.43/pcre-8.43.tar.gz 16 | sha256 = 0b8e7465dc5e98c757cc3650a20a7843ee4c3edf50aaf60bb33fd879690d2c73 17 | 18 | [build] 19 | builder = cmake 20 | subdir = pcre-8.43 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/perl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = perl 3 | 4 | [download.os=windows] 5 | url = http://strawberryperl.com/download/5.28.1.1/strawberry-perl-5.28.1.1-64bit-portable.zip 6 | sha256 = 935c95ba096fa11c4e1b5188732e3832d330a2a79e9882ab7ba8460ddbca810d 7 | 8 | [build.os=windows] 9 | builder = nop 10 | subdir = perl 11 | 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/pexpect: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = pexpect 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl 6 | sha256 = 2094eefdfcf37a1fdbfb9aa090862c1a4878e5c7e0e7e7088bdb511c558e5cd1 7 | 8 | [build] 9 | builder = python-wheel 10 | 11 | [dependencies] 12 | python-ptyprocess 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/protobuf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = protobuf 3 | 4 | [rpms] 5 | protobuf-devel 6 | 7 | [debs] 8 | libprotobuf-dev 9 | 10 | [git] 11 | repo_url = https://github.com/protocolbuffers/protobuf.git 12 | rev = master 13 | 14 | [build.not(os=windows)] 15 | builder = autoconf 16 | 17 | [build.os=windows] 18 | builder = nop 19 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/proxygen: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = proxygen 3 | fbsource_path = fbcode/proxygen 4 | shipit_project = proxygen 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/proxygen.git 9 | 10 | [build.os=windows] 11 | builder = nop 12 | 13 | [build] 14 | builder = cmake 15 | subdir = . 16 | 17 | [cmake.defines] 18 | BUILD_QUIC = ON 19 | 20 | [cmake.defines.test=on] 21 | BUILD_TESTS = ON 22 | 23 | [cmake.defines.test=off] 24 | BUILD_TESTS = OFF 25 | 26 | [dependencies] 27 | zlib 28 | gperf 29 | folly 30 | fizz 31 | wangle 32 | mvfst 33 | 34 | [dependencies.test=on] 35 | googletest 36 | 37 | [shipit.pathmap] 38 | fbcode/proxygen/public_tld = . 39 | fbcode/proxygen = proxygen 40 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python 3 | 4 | [homebrew] 5 | python@3.8 6 | 7 | [rpms] 8 | python3 9 | python3-devel 10 | 11 | # eden_scm needs dataclasses which arrive in 3.7, and the bionic python is 3.6 12 | [debs.not(all(distro=ubuntu,distro_vers="18.04"))] 13 | python3-all-dev 14 | 15 | [download] 16 | url = https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz 17 | sha256 = 903b92d76354366b1d9c4434d0c81643345cef87c1600adfa36095d7b00eede4 18 | 19 | [build] 20 | builder = autoconf 21 | subdir = Python-3.8.13 22 | 23 | [autoconf.args] 24 | --enable-shared 25 | --with-ensurepip=install 26 | 27 | # python's pkg-config libffi detection is broken 28 | # See https://bugs.python.org/issue34823 for clearest description 29 | # and pending PR https://github.com/python/cpython/pull/20451 30 | # The documented workaround requires an environment variable derived from 31 | # pkg-config to be passed into its configure step 32 | [autoconf.envcmd.LDFLAGS] 33 | pkg-config 34 | --libs-only-L 35 | libffi 36 | 37 | [dependencies] 38 | libffi 39 | # eden tests expect the python bz2 support 40 | bz2 41 | # eden tests expect the python curses support 42 | ncurses 43 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-click: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-click 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl 6 | sha256 = dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-dulwich: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-dulwich 3 | 4 | # The below links point to custom github forks of project dulwich, because the 5 | # 0.18.6 version didn't have an official rollout of wheel packages. 6 | 7 | [download.os=linux] 8 | url = https://github.com/lukaspiatkowski/dulwich/releases/download/dulwich-0.18.6-wheel/dulwich-0.18.6-cp36-cp36m-linux_x86_64.whl 9 | sha256 = e96f545f3d003e67236785473caaba2c368e531ea85fd508a3bd016ebac3a6d8 10 | 11 | [download.os=darwin] 12 | url = https://github.com/lukaspiatkowski/dulwich/releases/download/dulwich-0.18.6-wheel/dulwich-0.18.6-cp37-cp37m-macosx_10_14_x86_64.whl 13 | sha256 = 8373652056284ad40ea5220b659b3489b0a91f25536322345a3e4b5d29069308 14 | 15 | [build.not(os=windows)] 16 | builder = python-wheel 17 | 18 | [build.os=windows] 19 | builder = nop 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-filelock: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-filelock 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/31/24/ee722b92f23b9ebd87783e893a75352c048bbbc1f67dce0d63b58b46cb48/filelock-3.3.2-py3-none-any.whl 6 | sha256 = bb2a1c717df74c48a2d00ed625e5a66f8572a3a30baacb7657add1d7bac4097b 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-ptyprocess: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-ptyprocess 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl 6 | sha256 = d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-six: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-six 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl 6 | sha256 = 3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-toml: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-toml 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl 6 | sha256 = 235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/range-v3: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = range-v3 3 | 4 | [download] 5 | url = https://github.com/ericniebler/range-v3/archive/refs/tags/0.11.0.tar.gz 6 | sha256 = 376376615dbba43d3bef75aa590931431ecb49eb36d07bb726a19f680c75e20c 7 | 8 | 9 | [build] 10 | builder = cmake 11 | subdir = range-v3-0.11.0 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/re2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = re2 3 | 4 | [homebrew] 5 | re2 6 | 7 | [debs] 8 | libre2-dev 9 | 10 | [rpms] 11 | re2 12 | re2-devel 13 | 14 | [download] 15 | url = https://github.com/google/re2/archive/2019-06-01.tar.gz 16 | sha256 = 02b7d73126bd18e9fbfe5d6375a8bb13fadaf8e99e48cbb062e4500fc18e8e2e 17 | 18 | [build] 19 | builder = cmake 20 | subdir = re2-2019-06-01 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/rocksdb: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = rocksdb 3 | 4 | [download] 5 | url = https://github.com/facebook/rocksdb/archive/refs/tags/v7.0.2.tar.gz 6 | sha256 = d808c87074aef7a4ea8e329b1b3de718a95cf2895dbe606036d75e66af10d05a 7 | 8 | [dependencies] 9 | lz4 10 | snappy 11 | 12 | [build] 13 | builder = cmake 14 | subdir = rocksdb-7.0.2 15 | 16 | [cmake.defines] 17 | WITH_SNAPPY=ON 18 | WITH_LZ4=ON 19 | WITH_TESTS=OFF 20 | WITH_BENCHMARK_TOOLS=OFF 21 | # We get relocation errors with the static gflags lib, 22 | # and there's no clear way to make it pick the shared gflags 23 | # so just turn it off. 24 | WITH_GFLAGS=OFF 25 | # mac pro machines don't have some of the newer features that 26 | # rocksdb enables by default; ask it to disable their use even 27 | # when building on new hardware 28 | PORTABLE = ON 29 | # Disable the use of -Werror 30 | FAIL_ON_WARNINGS = OFF 31 | 32 | [cmake.defines.os=windows] 33 | ROCKSDB_INSTALL_ON_WINDOWS=ON 34 | # RocksDB hard codes the paths to the snappy libs to something 35 | # that doesn't exist; ignoring the usual cmake rules. As a result, 36 | # we can't build it with snappy without either patching rocksdb or 37 | # without introducing more complex logic to the build system to 38 | # connect the snappy build outputs to rocksdb's custom logic here. 39 | # Let's just turn it off on windows. 40 | WITH_SNAPPY=OFF 41 | WITH_LZ4=OFF 42 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/rust-shed: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = rust-shed 3 | fbsource_path = fbcode/common/rust/shed 4 | shipit_project = rust-shed 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexperimental/rust-shed.git 9 | 10 | [build] 11 | builder = cargo 12 | 13 | [cargo] 14 | build_doc = true 15 | workspace_dir = 16 | 17 | [shipit.pathmap] 18 | fbcode/common/rust/shed = shed 19 | fbcode/common/rust/shed/public_autocargo = shed 20 | fbcode/common/rust/shed/public_tld = . 21 | tools/rust/ossconfigs = . 22 | 23 | [shipit.strip] 24 | ^fbcode/common/rust/shed/(?!public_autocargo|public_tld).+/Cargo\.toml$ 25 | 26 | [dependencies] 27 | fbthrift 28 | fb303 29 | 30 | # We use the system openssl on linux 31 | [dependencies.not(os=linux)] 32 | openssl 33 | 34 | [dependencies.fbsource=on] 35 | rust 36 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/snappy: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = snappy 3 | 4 | [debs] 5 | libsnappy-dev 6 | 7 | [download] 8 | url = https://github.com/google/snappy/archive/1.1.7.tar.gz 9 | sha256 = 3dfa02e873ff51a11ee02b9ca391807f0c8ea0529a4924afa645fbf97163f9d4 10 | 11 | [build] 12 | builder = cmake 13 | subdir = snappy-1.1.7 14 | 15 | [cmake.defines] 16 | SNAPPY_BUILD_TESTS = OFF 17 | 18 | # Avoid problems like `relocation R_X86_64_PC32 against symbol` on ELF systems 19 | # when linking rocksdb, which builds PIC even when building a static lib 20 | [cmake.defines.os=linux] 21 | BUILD_SHARED_LIBS = ON 22 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/sqlite3: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = sqlite3 3 | 4 | [debs] 5 | libsqlite3-dev 6 | 7 | [homebrew] 8 | sqlite 9 | 10 | [rpms] 11 | sqlite-devel 12 | sqlite-libs 13 | 14 | [download] 15 | url = https://sqlite.org/2019/sqlite-amalgamation-3280000.zip 16 | sha256 = d02fc4e95cfef672b45052e221617a050b7f2e20103661cda88387349a9b1327 17 | 18 | [dependencies] 19 | cmake 20 | ninja 21 | 22 | [build] 23 | builder = sqlite 24 | subdir = sqlite-amalgamation-3280000 25 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/sqlite3-bin: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = sqlite3-bin 3 | 4 | [rpms] 5 | sqlite 6 | 7 | [debs] 8 | sqlite3 9 | 10 | [download.os=linux] 11 | url = https://github.com/sqlite/sqlite/archive/version-3.33.0.tar.gz 12 | sha256 = 48e5f989eefe9af0ac758096f82ead0f3c7b58118ac17cc5810495bd5084a331 13 | 14 | [build.os=linux] 15 | builder = autoconf 16 | subdir = sqlite-version-3.33.0 17 | 18 | [build.not(os=linux)] 19 | # MacOS comes with sqlite3 preinstalled and don't need Windows here 20 | builder = nop 21 | 22 | [dependencies.os=linux] 23 | tcl 24 | 25 | [autoconf.args] 26 | # This flag disabled tcl as a runtime library used for some functionality, 27 | # but tcl is still a required dependency as it is used by the build files 28 | --disable-tcl 29 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/tcl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = tcl 3 | 4 | [rpms] 5 | tcl 6 | 7 | [debs] 8 | tcl 9 | 10 | [download] 11 | url = https://github.com/tcltk/tcl/archive/core-8-7a3.tar.gz 12 | sha256 = 22d748f0c9652f3ecc195fed3f24a1b6eea8d449003085e6651197951528982e 13 | 14 | [build.os=linux] 15 | builder = autoconf 16 | subdir = tcl-core-8-7a3/unix 17 | 18 | [build.not(os=linux)] 19 | # This is for sqlite3 on Linux for now 20 | builder = nop 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/tree: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = tree 3 | 4 | [debs] 5 | tree 6 | 7 | [homebrew] 8 | tree 9 | 10 | [rpms] 11 | tree 12 | 13 | [download.os=linux] 14 | url = https://salsa.debian.org/debian/tree-packaging/-/archive/debian/1.8.0-1/tree-packaging-debian-1.8.0-1.tar.gz 15 | sha256 = a841eee1d52bfd64a48f54caab9937b9bd92935055c48885c4ab1ae4dab7fae5 16 | 17 | [download.os=darwin] 18 | # The official package of tree source requires users of non-Linux platform to 19 | # comment/uncomment certain lines in the Makefile to build for their platform. 20 | # Besauce getdeps.py doesn't have that functionality we just use this custom 21 | # fork of tree which has proper lines uncommented for a OSX build 22 | url = https://github.com/lukaspiatkowski/tree-command/archive/debian/1.8.0-1-macos.tar.gz 23 | sha256 = 9cbe889553d95cf5a2791dd0743795d46a3c092c5bba691769c0e5c52e11229e 24 | 25 | [build.os=linux] 26 | builder = make 27 | subdir = tree-packaging-debian-1.8.0-1 28 | 29 | [build.os=darwin] 30 | builder = make 31 | subdir = tree-command-debian-1.8.0-1-macos 32 | 33 | [build.os=windows] 34 | builder = nop 35 | 36 | [make.install_args] 37 | install 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/wangle: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = wangle 3 | fbsource_path = fbcode/wangle 4 | shipit_project = wangle 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/wangle.git 9 | 10 | [build] 11 | builder = cmake 12 | subdir = wangle 13 | 14 | [cmake.defines.test=on] 15 | BUILD_TESTS=ON 16 | 17 | [cmake.defines.test=off] 18 | BUILD_TESTS=OFF 19 | 20 | [dependencies] 21 | folly 22 | googletest 23 | fizz 24 | 25 | [shipit.pathmap] 26 | fbcode/wangle/public_tld = . 27 | fbcode/wangle = wangle 28 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/watchman: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = watchman 3 | fbsource_path = fbcode/watchman 4 | shipit_project = watchman 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/watchman.git 9 | 10 | [build] 11 | builder = cmake 12 | 13 | [dependencies] 14 | boost 15 | cpptoml 16 | fb303 17 | fbthrift 18 | folly 19 | pcre 20 | googletest 21 | 22 | [dependencies.fbsource=on] 23 | rust 24 | 25 | [shipit.pathmap] 26 | fbcode/watchman = watchman 27 | fbcode/watchman/oss = . 28 | fbcode/eden/fs = eden/fs 29 | 30 | [shipit.strip] 31 | ^fbcode/eden/fs/(?!.*\.thrift|service/shipit_test_file\.txt) 32 | 33 | [cmake.defines.fb=on] 34 | ENABLE_EDEN_SUPPORT=ON 35 | 36 | # FB macos specific settings 37 | [cmake.defines.all(fb=on,os=darwin)] 38 | # this path is coupled with the FB internal watchman-osx.spec 39 | WATCHMAN_STATE_DIR=/opt/facebook/watchman/var/run/watchman 40 | # tell cmake not to try to create /opt/facebook/... 41 | INSTALL_WATCHMAN_STATE_DIR=OFF 42 | USE_SYS_PYTHON=OFF 43 | 44 | [depends.environment] 45 | WATCHMAN_VERSION_OVERRIDE 46 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/xz: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = xz 3 | 4 | [debs] 5 | liblzma-dev 6 | 7 | [homebrew] 8 | xz 9 | 10 | [rpms] 11 | xz-devel 12 | 13 | [download] 14 | url = https://tukaani.org/xz/xz-5.2.5.tar.gz 15 | sha256 = f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10 16 | 17 | [build] 18 | builder = autoconf 19 | subdir = xz-5.2.5 20 | 21 | [autoconf.args] 22 | --disable-shared 23 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/yaml-cpp: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = yaml-cpp 3 | 4 | [download] 5 | url = https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.2.tar.gz 6 | sha256 = e4d8560e163c3d875fd5d9e5542b5fd5bec810febdcba61481fe5fc4e6b1fd05 7 | 8 | [build.os=linux] 9 | builder = cmake 10 | subdir = yaml-cpp-yaml-cpp-0.6.2 11 | 12 | [build.not(os=linux)] 13 | builder = nop 14 | 15 | [dependencies] 16 | boost 17 | googletest 18 | 19 | [cmake.defines] 20 | YAML_CPP_BUILD_TESTS=OFF 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/zlib: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = zlib 3 | 4 | [debs] 5 | zlib1g-dev 6 | 7 | [homebrew] 8 | zlib 9 | 10 | [rpms] 11 | zlib-devel 12 | zlib-static 13 | 14 | [download] 15 | url = http://zlib.net/zlib-1.2.12.tar.gz 16 | sha256 = 91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9 17 | 18 | [build] 19 | builder = cmake 20 | subdir = zlib-1.2.12 21 | patchfile = zlib_dont_build_more_than_needed.patch 22 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/zstd: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = zstd 3 | 4 | [homebrew] 5 | zstd 6 | 7 | [rpms] 8 | libzstd-devel 9 | libzstd 10 | 11 | [download] 12 | url = https://github.com/facebook/zstd/releases/download/v1.4.5/zstd-1.4.5.tar.gz 13 | sha256 = 98e91c7c6bf162bf90e4e70fdbc41a8188b9fa8de5ad840c401198014406ce9e 14 | 15 | [build] 16 | builder = cmake 17 | subdir = zstd-1.4.5/build/cmake 18 | 19 | # The zstd cmake build explicitly sets the install name 20 | # for the shared library in such a way that cmake discards 21 | # the path to the library from the install_name, rendering 22 | # the library non-resolvable during the build. The short 23 | # term solution for this is just to link static on macos. 24 | [cmake.defines.os=darwin] 25 | ZSTD_BUILD_SHARED = OFF 26 | 27 | [cmake.defines.os=windows] 28 | ZSTD_BUILD_SHARED = OFF 29 | -------------------------------------------------------------------------------- /build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -183,8 +183,7 @@ 4 | set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) 5 | endif(MINGW) 6 | 7 | -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 8 | -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 9 | +add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 10 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 11 | set_target_properties(zlib PROPERTIES SOVERSION 1) 12 | 13 | @@ -201,7 +200,7 @@ 14 | 15 | if(UNIX) 16 | # On unix-like platforms the library is almost always called libz 17 | - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) 18 | + set_target_properties(zlib PROPERTIES OUTPUT_NAME z) 19 | if(NOT APPLE) 20 | set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") 21 | endif() 22 | @@ -211,7 +210,7 @@ 23 | endif() 24 | 25 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) 26 | - install(TARGETS zlib zlibstatic 27 | + install(TARGETS zlib 28 | RUNTIME DESTINATION "${INSTALL_BIN_DIR}" 29 | ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" 30 | LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) 31 | -------------------------------------------------------------------------------- /fbzmq/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AccessModifierOffset: -1 3 | AlignAfterOpenBracket: AlwaysBreak 4 | AlignConsecutiveAssignments: false 5 | AlignConsecutiveDeclarations: false 6 | AlignEscapedNewlinesLeft: true 7 | AlignOperands: false 8 | AlignTrailingComments: false 9 | AllowAllParametersOfDeclarationOnNextLine: true 10 | AllowShortBlocksOnASingleLine: false 11 | AllowShortCaseLabelsOnASingleLine: false 12 | AllowShortFunctionsOnASingleLine: Empty 13 | AllowShortIfStatementsOnASingleLine: false 14 | AllowShortLoopsOnASingleLine: false 15 | AlwaysBreakAfterDefinitionReturnType: true 16 | AlwaysBreakBeforeMultilineStrings: true 17 | AlwaysBreakTemplateDeclarations: true 18 | IndentFunctionDeclarationAfterType: false 19 | BinPackArguments: false 20 | BinPackParameters: false 21 | BraceWrapping: 22 | AfterClass: false 23 | AfterControlStatement: false 24 | AfterEnum: false 25 | AfterFunction: false 26 | AfterNamespace: false 27 | AfterObjCDeclaration: false 28 | AfterStruct: false 29 | AfterUnion: false 30 | BeforeCatch: false 31 | BeforeElse: false 32 | IndentBraces: false 33 | BreakBeforeBinaryOperators: None 34 | BreakBeforeBraces: Attach 35 | BreakBeforeTernaryOperators: true 36 | BreakConstructorInitializersBeforeComma: false 37 | BreakAfterJavaFieldAnnotations: false 38 | BreakStringLiterals: false 39 | ColumnLimit: 80 40 | CommentPragmas: '^ IWYU pragma:' 41 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 42 | ConstructorInitializerIndentWidth: 4 43 | ContinuationIndentWidth: 4 44 | Cpp11BracedListStyle: true 45 | DerivePointerAlignment: false 46 | DisableFormat: false 47 | ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ] 48 | IncludeCategories: 49 | - Regex: '^<.*\.h(pp)?>' 50 | Priority: 1 51 | - Regex: '^<.*' 52 | Priority: 2 53 | - Regex: '.*' 54 | Priority: 3 55 | IndentCaseLabels: false 56 | IndentWidth: 2 57 | IndentWrappedFunctionNames: false 58 | KeepEmptyLinesAtTheStartOfBlocks: false 59 | MacroBlockBegin: '' 60 | MacroBlockEnd: '' 61 | MaxEmptyLinesToKeep: 1 62 | NamespaceIndentation: None 63 | ObjCBlockIndentWidth: 2 64 | ObjCSpaceAfterProperty: false 65 | ObjCSpaceBeforeProtocolList: false 66 | PenaltyBreakBeforeFirstCallParameter: 10 67 | PenaltyBreakComment: 60 68 | PenaltyBreakFirstLessLess: 20 69 | PenaltyBreakString: 1000 70 | PenaltyExcessCharacter: 1000000 71 | PenaltyReturnTypeOnItsOwnLine: 200 72 | PointerAlignment: Left 73 | ReflowComments: true 74 | SortIncludes: true 75 | SpaceAfterCStyleCast: false 76 | SpaceBeforeAssignmentOperators: true 77 | SpaceBeforeParens: ControlStatements 78 | SpaceInEmptyParentheses: false 79 | SpacesBeforeTrailingComments: 1 80 | SpacesInAngles: false 81 | SpacesInContainerLiterals: false 82 | SpacesInCStyleCastParentheses: false 83 | SpacesInParentheses: false 84 | SpacesInSquareBrackets: false 85 | Standard: Cpp11 86 | TabWidth: 8 87 | UseTab: Never 88 | ... 89 | -------------------------------------------------------------------------------- /fbzmq/async/AsyncSignalHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | 14 | #ifdef IS_BSD 15 | #ifdef __APPLE__ 16 | #define SIG_MAX __DARWIN_NSIG 17 | #else 18 | #define SIG_MAX NSIG 19 | #endif 20 | 21 | #endif 22 | 23 | namespace fbzmq { 24 | 25 | /** 26 | * A handler to receive notification about POSIX signals. 27 | * 28 | * AsyncSignalHandler allows code to process signals from within a 29 | * ZmqEventLoop. 30 | * Standard signal handlers interrupt execution of the main thread, and 31 | * are run while the main thread is paused. As a result, great care must be 32 | * taken to avoid race conditions if the signal handler has to access or modify 33 | * any data used by the main thread. 34 | * 35 | * AsyncSignalHandler solves this problem by running the AsyncSignalHandler 36 | * callback in normal thread of execution, as a ZmqEventLoop callback. 37 | * 38 | * AsyncSignalHandler may only be used in a single thread. It will only 39 | * process signals received by the thread where the AsyncSignalHandler is 40 | * registered. It is the user's responsibility to ensure that signals are 41 | * delivered to the desired thread in multi-threaded programs. 42 | */ 43 | class AsyncSignalHandler { 44 | public: 45 | /** 46 | * Create a new AsyncSignalHandler. 47 | */ 48 | explicit AsyncSignalHandler(ZmqEventLoop* evl); 49 | virtual ~AsyncSignalHandler(); 50 | 51 | /** 52 | * Register to receive callbacks about the specified signal. 53 | * 54 | * Once the handler has been registered for a particular signal, 55 | * signalReceived() will be called each time this thread receives this 56 | * signal. 57 | * 58 | * Throws an exception if an error occurs, or if this handler is already 59 | * registered for this signal. 60 | * 61 | * NOTE: MUST be called before starting any other thread, 62 | * otherwise main thread may miss some signal. Maybe becaues other threads 63 | * created by main() will inherit a copy of the signal mask according to 64 | * pthread_mask(3) 65 | */ 66 | void registerSignalHandler(int sig); 67 | 68 | /** 69 | * Unregister for callbacks about the specified signal. 70 | * 71 | * Throws an exception if an error occurs, or if this signal was not 72 | * registered. 73 | */ 74 | void unregisterSignalHandler(int sig); 75 | 76 | /** 77 | * signalReceived() will called to indicate that the specified signal has 78 | * been received. 79 | * 80 | * signalReceived() will always be invoked from the event loop (i.e., 81 | * after the main POSIX signal handler has returned control to the event loop 82 | * thread). 83 | */ 84 | virtual void signalReceived(int sig) noexcept = 0; 85 | 86 | /** 87 | * get event loop 88 | */ 89 | ZmqEventLoop* getZmqEventLoop(); 90 | 91 | private: 92 | // Forbidden copy constructor and assignment operator 93 | AsyncSignalHandler(AsyncSignalHandler const&); 94 | AsyncSignalHandler& operator=(AsyncSignalHandler const&); 95 | 96 | void setupSignal(int sig, bool isAdding); 97 | 98 | // event loop 99 | ZmqEventLoop* evl_{nullptr}; 100 | 101 | // Local file descriptor for accepting signals 102 | int signalFd_{-1}; 103 | 104 | // registered signals 105 | sigset_t registeredSignals_; 106 | 107 | #ifdef IS_BSD 108 | sig_t signalHandlers_[SIG_MAX]{}; 109 | #endif 110 | }; 111 | 112 | } // namespace fbzmq 113 | -------------------------------------------------------------------------------- /fbzmq/async/Runnable.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | namespace fbzmq { 11 | 12 | class Runnable { 13 | public: 14 | virtual ~Runnable() = default; 15 | 16 | /** 17 | * Start thread execution. Ideally this function blocks and returns only when 18 | * stop is called . 19 | */ 20 | virtual void run() = 0; 21 | 22 | /** 23 | * Implementation of signalling to running thread for stopping. This should 24 | */ 25 | virtual void stop() = 0; 26 | 27 | /** 28 | * Indicates if thread is running or not 29 | */ 30 | virtual bool isRunning() const = 0; 31 | 32 | /** 33 | * Busy-spin or wait until thread is running. 34 | */ 35 | virtual void waitUntilRunning() = 0; 36 | 37 | /** 38 | * Busy-spin or wait until thread is stopped. Useful when you issued a stop 39 | * signal and want to wait before proceeding. 40 | */ 41 | virtual void waitUntilStopped() = 0; 42 | }; 43 | 44 | } // namespace fbzmq 45 | -------------------------------------------------------------------------------- /fbzmq/async/StopEventLoopSignalHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace fbzmq { 13 | 14 | /** 15 | * A commom signal handler which stops the underlying zmq event loop upon signal 16 | * catching for graceful exit. Use AsyncSignalHandler directly if you intend to 17 | * do more. 18 | */ 19 | class StopEventLoopSignalHandler final : public AsyncSignalHandler { 20 | public: 21 | explicit StopEventLoopSignalHandler(ZmqEventLoop* evl) 22 | : AsyncSignalHandler(evl) {} 23 | 24 | private: 25 | void 26 | signalReceived(int sig) noexcept override { 27 | LOG(INFO) << "Received signal: " << sig << ". Stopping event loop ..."; 28 | auto evl = getZmqEventLoop(); 29 | evl->stop(); 30 | } 31 | }; 32 | 33 | } // namespace fbzmq 34 | -------------------------------------------------------------------------------- /fbzmq/async/ZmqThrottle.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | 10 | namespace fbzmq { 11 | 12 | ZmqThrottle::ZmqThrottle( 13 | folly::ScheduledExecutor* evl, 14 | std::chrono::milliseconds timeout, 15 | TimeoutCallback callback) 16 | : ZmqTimeout(evl), timeout_(timeout), callback_(std::move(callback)) { 17 | CHECK(callback_); 18 | } 19 | 20 | void 21 | ZmqThrottle::operator()() noexcept { 22 | // Return immediately as callback is already scheduled. 23 | if (isScheduled()) { 24 | return; 25 | } 26 | 27 | // Special case to handle immediate timeouts 28 | if (timeout_ <= std::chrono::milliseconds(0)) { 29 | callback_(); 30 | return; 31 | } 32 | 33 | scheduleTimeout(timeout_); 34 | } 35 | 36 | void 37 | ZmqThrottle::timeoutExpired() noexcept { 38 | callback_(); 39 | } 40 | 41 | } // namespace fbzmq 42 | -------------------------------------------------------------------------------- /fbzmq/async/ZmqThrottle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | namespace fbzmq { 16 | 17 | /** 18 | * This class provides you capability to rate-limit certain events which might 19 | * happen rapidly in the system and processing of an event is expensive. 20 | * 21 | * For e.g. you want to `saveState()` on every `addKey` and `removeKey` but 22 | * saving state is expensive operation. You can do 23 | * 24 | * auto throttledSaveState = ZmqThrottle(evl, 1_s, [this] () noexcept { 25 | * saveState(); 26 | * }); 27 | * 28 | * And then call `throttledSaveState()` on every `addKey` and `removeKey` but 29 | * internally `saveState()` will be execute at max once per second. 30 | */ 31 | class ZmqThrottle final : private ZmqTimeout { 32 | public: 33 | ZmqThrottle( 34 | folly::ScheduledExecutor* evl, 35 | std::chrono::milliseconds timeout, 36 | TimeoutCallback callback); 37 | 38 | ~ZmqThrottle() override = default; 39 | 40 | /** 41 | * Overload function operator. This method exposes throttled version of 42 | * callback passed in. 43 | */ 44 | void operator()() noexcept; 45 | 46 | /** 47 | * Tells you if this is currently active ? 48 | */ 49 | bool 50 | isActive() const { 51 | return isScheduled(); 52 | } 53 | 54 | /** 55 | * Cancel scheduled throttle 56 | */ 57 | void 58 | cancel() { 59 | cancelTimeout(); 60 | } 61 | 62 | private: 63 | /** 64 | * Overrides ZmqTimeout's timeout callback 65 | */ 66 | void timeoutExpired() noexcept override; 67 | 68 | const std::chrono::milliseconds timeout_{0}; 69 | TimeoutCallback callback_{nullptr}; 70 | }; 71 | 72 | } // namespace fbzmq 73 | -------------------------------------------------------------------------------- /fbzmq/async/ZmqTimeout.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | 10 | namespace fbzmq { 11 | 12 | namespace { 13 | 14 | /** 15 | * Wraps a function object as an ZmqTimeout instance. 16 | */ 17 | struct ZmqTimeoutWrapper : public ZmqTimeout { 18 | public: 19 | ZmqTimeoutWrapper( 20 | folly::ScheduledExecutor* eventLoop, TimeoutCallback callback) 21 | : ZmqTimeout(eventLoop), callback_(std::move(callback)) {} 22 | 23 | void 24 | timeoutExpired() noexcept override { 25 | callback_(); 26 | } 27 | 28 | private: 29 | TimeoutCallback callback_; 30 | }; 31 | 32 | } // anonymous namespace 33 | 34 | ZmqTimeout::ZmqTimeout(folly::ScheduledExecutor* eventLoop) 35 | : eventLoop_(eventLoop) { 36 | token_ = std::make_shared(0); 37 | CHECK(eventLoop); 38 | } 39 | 40 | std::unique_ptr 41 | ZmqTimeout::make( 42 | folly::ScheduledExecutor* eventLoop, TimeoutCallback callback) { 43 | return std::unique_ptr( 44 | new ZmqTimeoutWrapper(eventLoop, std::move(callback))); 45 | } 46 | 47 | ZmqTimeout::~ZmqTimeout() { 48 | if (isScheduled()) { 49 | cancelTimeout(); 50 | } 51 | } 52 | 53 | void 54 | ZmqTimeout::scheduleTimeout( 55 | std::chrono::milliseconds timeoutPeriod, bool isPeriodic) { 56 | // Cancel already scheduled timeout if any 57 | if (isScheduled()) { 58 | cancelTimeout(); 59 | } 60 | 61 | state_ = isPeriodic ? TimeoutState::PERIODIC : TimeoutState::SCHEDULED; 62 | timeoutPeriod_ = timeoutPeriod; 63 | scheduleTimeoutHelper(); 64 | } 65 | 66 | void 67 | ZmqTimeout::cancelTimeout() { 68 | if (state_ == TimeoutState::NONE) { 69 | LOG(WARNING) << "Trying to cancel timeout which is not scheduled."; 70 | return; 71 | } 72 | 73 | state_ = TimeoutState::NONE; 74 | ++(*token_); // Increment token 75 | } 76 | 77 | void 78 | ZmqTimeout::scheduleTimeoutHelper() noexcept { 79 | ++(*token_); // Increment token 80 | eventLoop_->scheduleAt( 81 | // NOTE: copy absolute as well as reference to token. This is to guarantee 82 | // that token is valid memory even if ZmqTimeout is destroyed 83 | [this, tokenAbs = *token_, token = token_]() noexcept { 84 | if (tokenAbs == *token) { 85 | timeoutExpiredHelper(); 86 | } 87 | }, 88 | std::chrono::steady_clock::now() + timeoutPeriod_); 89 | } 90 | 91 | void 92 | ZmqTimeout::timeoutExpiredHelper() noexcept { 93 | if (state_ == TimeoutState::PERIODIC) { 94 | scheduleTimeoutHelper(); 95 | } else { 96 | state_ = TimeoutState::NONE; 97 | } 98 | 99 | // Invoke timeoutExpired callback. 100 | timeoutExpired(); 101 | } 102 | 103 | } // namespace fbzmq 104 | -------------------------------------------------------------------------------- /fbzmq/async/ZmqTimeout.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace fbzmq { 15 | 16 | /** 17 | * ZmqTimeout wraps some basic functionality of scheduling async calls. It is 18 | * very similar to folly::AsyncTimeout but instead of running in EventBase this 19 | * run in ZmqEventLoop. 20 | * 21 | * There are multiple ways you can use this 22 | * 1. Inherit this class and implement the timeoutExpired 23 | * 2. Use `make` function to create and schedule multiple timeouts 24 | * 25 | */ 26 | class ZmqTimeout { 27 | public: 28 | /** 29 | * Construct a ZmqTimeout with eventLoop instance. All callbacks/timeouts will 30 | * be invoked in eventLoop's main loop. Sub-class must implement 31 | * `timeoutExpired`. 32 | */ 33 | explicit ZmqTimeout(folly::ScheduledExecutor* eventLoop); 34 | 35 | /** 36 | * This construct and returns you the ZmqTimeout with specified function as 37 | * a callback. 38 | * 39 | * timeout_ = ZmqTimeout::make(thread_, [] () { 40 | * LOG(INFO) << "Timeout got expired."; 41 | * }); 42 | * 43 | * timeout_->scheduleTimeout(std::chrono::seconds(1)); // or 44 | * timeout_->schedulePeriodic(std::chrono::seconds(1)); 45 | */ 46 | static std::unique_ptr make( 47 | folly::ScheduledExecutor* eventLoop, TimeoutCallback callback); 48 | 49 | /** 50 | * Timeout will be automatically cancelled if it is running. 51 | */ 52 | virtual ~ZmqTimeout(); 53 | 54 | /** 55 | * non-copyable and non-movable 56 | */ 57 | ZmqTimeout(ZmqTimeout const&) = delete; 58 | ZmqTimeout& operator=(ZmqTimeout const&) = delete; 59 | 60 | /** 61 | * This function must be implemented by sub-classes. 62 | */ 63 | virtual void timeoutExpired() noexcept = 0; 64 | 65 | /** 66 | * Schedule timeout which will be invoked after specified duration in the 67 | * eventLoop's loop. 68 | * 69 | * If timeout is already scheduled then it will be re-scheduled with new 70 | * timeout value. 71 | * 72 | * If periodic flag is passed then timeoutExpired will be invoked periodically 73 | * with specified timeout until timeout is cancelled. 74 | */ 75 | void scheduleTimeout( 76 | std::chrono::milliseconds timeoutPeriod, bool isPeriodic = false); 77 | 78 | /** 79 | * Cancel already scheduled timeout, if it is running. 80 | */ 81 | void cancelTimeout(); 82 | 83 | /** 84 | * Is this function currently scheduled. Will always be true if scheduled 85 | * periodically. 86 | */ 87 | bool 88 | isScheduled() const { 89 | return state_ != TimeoutState::NONE; 90 | } 91 | 92 | /** 93 | * Is this timeout scheduled periodically. 94 | */ 95 | bool 96 | isPeriodic() const { 97 | return state_ == TimeoutState::PERIODIC; 98 | } 99 | 100 | private: 101 | /** 102 | * Helper function to attach timeout 103 | */ 104 | void scheduleTimeoutHelper() noexcept; 105 | 106 | /** 107 | * Helper function which calls timeoutExpired. 108 | */ 109 | void timeoutExpiredHelper() noexcept; 110 | 111 | enum class TimeoutState { 112 | NONE = 1, 113 | SCHEDULED = 2, 114 | PERIODIC = 3, 115 | }; 116 | 117 | // ScheduledExecutor instance in which to run/schedule the timeouts 118 | folly::ScheduledExecutor* eventLoop_{nullptr}; 119 | 120 | // Current timeout state 121 | TimeoutState state_{TimeoutState::NONE}; 122 | 123 | // Token associated with the scheduled timeout. 124 | std::shared_ptr token_; 125 | 126 | // Timeout duration associated with periodic timeout 127 | std::chrono::milliseconds timeoutPeriod_{0}; 128 | }; 129 | 130 | } // namespace fbzmq 131 | -------------------------------------------------------------------------------- /fbzmq/async/tests/ZmqTimeoutTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace fbzmq { 17 | 18 | using namespace std::chrono_literals; 19 | 20 | TEST(ZmqTimeoutTest, ZmqEventLoop) { 21 | fbzmq::ZmqEventLoop evl; 22 | 23 | auto start = std::chrono::steady_clock::now(); 24 | size_t count{0}; 25 | folly::Baton<> waitBaton; 26 | 27 | // Schedule first timeout 28 | auto timeout = ZmqTimeout::make(&evl, [&]() noexcept { 29 | auto diff = std::chrono::duration_cast( 30 | std::chrono::steady_clock::now() - start); 31 | LOG(INFO) << "Executing callback after " << diff.count() << "ms."; 32 | 33 | // fetch_add returns previous value 34 | ++count; 35 | if (count >= 4) { 36 | waitBaton.post(); 37 | } 38 | 39 | EXPECT_EQ(1, evl.getNumPendingTimeouts()); 40 | }); 41 | 42 | EXPECT_EQ(0, evl.getNumPendingTimeouts()); 43 | EXPECT_NO_THROW(timeout->cancelTimeout()); 44 | timeout->scheduleTimeout(100ms, true /* periodic */); 45 | EXPECT_TRUE(timeout->isScheduled()); 46 | 47 | // can schedule twice with no issue 48 | timeout->scheduleTimeout(100ms, true /* periodic */); 49 | EXPECT_TRUE(timeout->isScheduled()); 50 | EXPECT_TRUE(timeout->isPeriodic()); 51 | EXPECT_LE(1, evl.getNumPendingTimeouts()); 52 | 53 | // Start event loop 54 | std::thread evlThread([&]() { 55 | LOG(INFO) << "Starting zmq thread."; 56 | evl.run(); 57 | LOG(INFO) << "Stopping zmq thread."; 58 | }); 59 | 60 | // Wait for completion 61 | waitBaton.wait(); 62 | timeout.reset(); 63 | EXPECT_EQ(4, count); 64 | 65 | // Cleanup 66 | evl.stop(); 67 | evlThread.join(); 68 | } 69 | 70 | TEST(ZmqTimeoutTest, FollyEventBase) { 71 | folly::EventBase evb; 72 | 73 | auto start = std::chrono::steady_clock::now(); 74 | size_t count{0}; 75 | folly::Baton<> waitBaton; 76 | 77 | // Schedule first timeout 78 | auto timeout = ZmqTimeout::make(&evb, [&]() noexcept { 79 | auto diff = std::chrono::duration_cast( 80 | std::chrono::steady_clock::now() - start); 81 | LOG(INFO) << "Executing callback after " << diff.count() << "ms."; 82 | 83 | // fetch_add returns previous value 84 | ++count; 85 | if (count >= 4) { 86 | waitBaton.post(); 87 | } 88 | }); 89 | 90 | EXPECT_NO_THROW(timeout->cancelTimeout()); 91 | timeout->scheduleTimeout(100ms, true /* periodic */); 92 | EXPECT_TRUE(timeout->isScheduled()); 93 | 94 | // can schedule twice with no issue 95 | timeout->scheduleTimeout(100ms, true /* periodic */); 96 | EXPECT_TRUE(timeout->isScheduled()); 97 | EXPECT_TRUE(timeout->isPeriodic()); 98 | 99 | // Start event loop 100 | std::thread evbThread([&]() { 101 | LOG(INFO) << "Starting event-base thread."; 102 | evb.loopForever(); 103 | LOG(INFO) << "Stopping event-base thread."; 104 | }); 105 | 106 | // Wait for completion 107 | waitBaton.wait(); 108 | timeout.reset(); 109 | EXPECT_EQ(4, count); 110 | 111 | // Cleanup 112 | evb.terminateLoopSoon(); 113 | evbThread.join(); 114 | } 115 | 116 | } // namespace fbzmq 117 | 118 | int 119 | main(int argc, char* argv[]) { 120 | testing::InitGoogleTest(&argc, argv); 121 | gflags::ParseCommandLineFlags(&argc, &argv, true); 122 | google::InitGoogleLogging(argv[0]); 123 | google::InstallFailureSignalHandler(); 124 | 125 | return RUN_ALL_TESTS(); 126 | } 127 | -------------------------------------------------------------------------------- /fbzmq/cmake/fbzmq-config.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2014-present, Facebook, Inc. 3 | # 4 | # CMake package configuration file for fbzmq 5 | # 6 | # Defines the target "fbzmq::fbzmq" 7 | # Add this to your target_link_libraries() call to depend on fbzmq. 8 | 9 | @PACKAGE_INIT@ 10 | 11 | set_and_check(FBZMQ_CMAKE_DIR "@PACKAGE_CMAKE_INSTALL_DIR@") 12 | 13 | if (NOT TARGET fbzmq::fbzmq) 14 | include("${FBZMQ_CMAKE_DIR}/fbzmq-targets.cmake") 15 | endif() 16 | 17 | if (NOT fbzmq_FIND_QUIETLY) 18 | message(STATUS "Found fbzmq: ${PACKAGE_PREFIX_DIR}") 19 | endif() 20 | -------------------------------------------------------------------------------- /fbzmq/examples/client/ZmqClient.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE-examples file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace fbzmq { 16 | namespace example { 17 | 18 | class ZmqClient { 19 | public: 20 | ZmqClient( 21 | fbzmq::Context& zmqContext, 22 | const std::string& primitiveCmdUrl, 23 | const std::string& stringCmdUrl, 24 | const std::string& thriftCmdUrl, 25 | const std::string& multipleCmdUrl, 26 | const std::string& pubUrl); 27 | 28 | // start making requests of various types (primitive, string, thrift) 29 | void startRequests() noexcept; 30 | 31 | private: 32 | // Initialize ZMQ sockets 33 | void prepare() noexcept; 34 | 35 | // make primitive type request 36 | void makePrimitiveRequest() noexcept; 37 | 38 | // make string type request 39 | void makeStringRequest() noexcept; 40 | 41 | // make multiple request 42 | void makeMultipleRequest() noexcept; 43 | 44 | // make a KEY_SET request 45 | // return true on success, false on failure 46 | bool setKeyValue(const std::string& key, int64_t value) noexcept; 47 | 48 | // make a KEY_GET request 49 | // return true on success, false on failure 50 | bool getKey(const std::string& key, int64_t& value) noexcept; 51 | 52 | // make thrift type request 53 | void makeThriftRequest() noexcept; 54 | 55 | // ZMQ context reference 56 | fbzmq::Context& zmqContext_; 57 | 58 | // ZMQ communication urls 59 | const std::string primitiveCmdUrl_; 60 | const std::string stringCmdUrl_; 61 | const std::string thriftCmdUrl_; 62 | const std::string multipleCmdUrl_; 63 | const std::string pubUrl_; 64 | 65 | // subscriber socket 66 | fbzmq::Socket subSock_; 67 | 68 | // used for serialize/deserialize thrift obj 69 | apache::thrift::CompactSerializer serializer_; 70 | }; 71 | 72 | } // namespace example 73 | } // namespace fbzmq 74 | -------------------------------------------------------------------------------- /fbzmq/examples/client/ZmqClientMain.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE-examples file in the root directory of this source tree. 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | int 15 | main(int argc, char** argv) { 16 | gflags::ParseCommandLineFlags(&argc, &argv, true); 17 | google::InitGoogleLogging(argv[0]); 18 | google::InstallFailureSignalHandler(); 19 | 20 | // Zmq Context 21 | fbzmq::Context ctx; 22 | 23 | // start ZmqClient 24 | fbzmq::example::ZmqClient client( 25 | ctx, 26 | fbzmq::example::Constants::kPrimitiveCmdUrl.str(), 27 | fbzmq::example::Constants::kStringCmdUrl.str(), 28 | fbzmq::example::Constants::kThriftCmdUrl.str(), 29 | fbzmq::example::Constants::kMultipleCmdUrl.str(), 30 | fbzmq::example::Constants::kPubUrl.str()); 31 | 32 | client.startRequests(); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /fbzmq/examples/common/Constants.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE-examples file in the root directory of this source tree. 7 | */ 8 | 9 | #include 10 | 11 | namespace fbzmq { 12 | namespace example { 13 | 14 | constexpr folly::StringPiece Constants::kPrimitiveCmdUrl; 15 | 16 | constexpr folly::StringPiece Constants::kStringCmdUrl; 17 | 18 | constexpr folly::StringPiece Constants::kThriftCmdUrl; 19 | 20 | constexpr folly::StringPiece Constants::kMultipleCmdUrl; 21 | 22 | constexpr folly::StringPiece Constants::kPubUrl; 23 | 24 | constexpr std::chrono::milliseconds Constants::kReadTimeout; 25 | 26 | } // namespace example 27 | } // namespace fbzmq 28 | -------------------------------------------------------------------------------- /fbzmq/examples/common/Constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE-examples file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace fbzmq { 16 | namespace example { 17 | 18 | class Constants { 19 | public: 20 | // the zmq url for request/reply primitive message 21 | static constexpr folly::StringPiece kPrimitiveCmdUrl = 22 | "tcp://127.0.0.1:55555"; 23 | 24 | // the zmq url for request/reply string message 25 | static constexpr folly::StringPiece kStringCmdUrl = "tcp://127.0.0.1:55556"; 26 | 27 | // the zmq url for request/reply thrift message 28 | static constexpr folly::StringPiece kThriftCmdUrl = "tcp://127.0.0.1:55557"; 29 | 30 | // the zmq url for request/reply multiple message 31 | static constexpr folly::StringPiece kMultipleCmdUrl = "tcp://127.0.0.1:55558"; 32 | 33 | // the zmq url for subscribe/publish primitive message 34 | static constexpr folly::StringPiece kPubUrl = "tcp://127.0.0.1:55559"; 35 | 36 | // the default I/O read timeout in milliseconds 37 | static constexpr std::chrono::milliseconds kReadTimeout{500}; 38 | }; 39 | 40 | } // namespace example 41 | } // namespace fbzmq 42 | -------------------------------------------------------------------------------- /fbzmq/examples/if/Example.thrift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE-examples file in the root directory of this source tree. 7 | */ 8 | 9 | namespace cpp2 fbzmq.example.thrift 10 | 11 | enum Command { 12 | KEY_SET = 1, 13 | KEY_GET = 2, 14 | } 15 | 16 | // a request to the server 17 | struct Request { 18 | 1: required Command cmd; 19 | 2: required string key; 20 | // value not used if it's a KEY_GET command 21 | 3: optional i64 value; 22 | } 23 | 24 | // a response back to client 25 | struct Response { 26 | 1: required bool success; 27 | // value not used if it's a KEY_SET command 28 | 2: optional i64 value = 99; 29 | } 30 | 31 | struct StrValue { 32 | 1: string value; 33 | } 34 | -------------------------------------------------------------------------------- /fbzmq/examples/server/ZmqServer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE-examples file in the root directory of this source tree. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace fbzmq { 17 | namespace example { 18 | 19 | class ZmqServer final : public fbzmq::ZmqEventLoop { 20 | public: 21 | ZmqServer( 22 | fbzmq::Context& zmqContext, 23 | const std::string& primitiveCmdUrl, 24 | const std::string& stringCmdUrl, 25 | const std::string& thriftCmdUrl, 26 | const std::string& multipleCmdUrl, 27 | const std::string& pubUrl); 28 | 29 | // disable copying 30 | ZmqServer(const ZmqServer&) = delete; 31 | ZmqServer& operator=(const ZmqServer&) = delete; 32 | 33 | private: 34 | // Initialize ZMQ sockets 35 | void prepare() noexcept; 36 | 37 | // process received primitive type command 38 | void processPrimitiveCommand() noexcept; 39 | 40 | // process received string type command 41 | void processStringCommand() noexcept; 42 | 43 | // process received thrift type command 44 | void processThriftCommand() noexcept; 45 | 46 | // process received multiple command 47 | void processMultipleCommand() noexcept; 48 | 49 | // communication urls 50 | const std::string primitiveCmdUrl_; 51 | const std::string stringCmdUrl_; 52 | const std::string thriftCmdUrl_; 53 | const std::string multipleCmdUrl_; 54 | const std::string pubUrl_; 55 | 56 | // command socket for primitive type message 57 | fbzmq::Socket primitiveCmdSock_; 58 | // command socket for string type message 59 | fbzmq::Socket stringCmdSock_; 60 | // command socket for thrift type message 61 | fbzmq::Socket thriftCmdSock_; 62 | // command socket for multiple message 63 | fbzmq::Socket multipleCmdSock_; 64 | 65 | // publication socket 66 | fbzmq::Socket pubSock_; 67 | 68 | // used for serialize/deserialize thrift obj 69 | apache::thrift::CompactSerializer serializer_; 70 | 71 | // key-value store 72 | std::unordered_map kvStore_; 73 | }; 74 | 75 | } // namespace example 76 | } // namespace fbzmq 77 | -------------------------------------------------------------------------------- /fbzmq/examples/server/ZmqServerMain.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the license found in the 6 | * LICENSE-examples file in the root directory of this source tree. 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | int 16 | main(int argc, char** argv) { 17 | gflags::ParseCommandLineFlags(&argc, &argv, true); 18 | google::InitGoogleLogging(argv[0]); 19 | google::InstallFailureSignalHandler(); 20 | 21 | // start signal handler before any thread 22 | fbzmq::ZmqEventLoop mainEventLoop; 23 | fbzmq::StopEventLoopSignalHandler handler(&mainEventLoop); 24 | handler.registerSignalHandler(SIGINT); 25 | handler.registerSignalHandler(SIGQUIT); 26 | handler.registerSignalHandler(SIGTERM); 27 | 28 | std::vector allThreads{}; 29 | 30 | // Zmq Context 31 | fbzmq::Context ctx; 32 | 33 | // start ZmqServer 34 | fbzmq::example::ZmqServer server( 35 | ctx, 36 | fbzmq::example::Constants::kPrimitiveCmdUrl.str(), 37 | fbzmq::example::Constants::kStringCmdUrl.str(), 38 | fbzmq::example::Constants::kThriftCmdUrl.str(), 39 | fbzmq::example::Constants::kMultipleCmdUrl.str(), 40 | fbzmq::example::Constants::kPubUrl.str()); 41 | std::thread serverThread([&server]() noexcept { 42 | LOG(INFO) << "Starting Server thread ..."; 43 | server.run(); 44 | LOG(INFO) << "Server stopped."; 45 | }); 46 | server.waitUntilRunning(); 47 | allThreads.emplace_back(std::move(serverThread)); 48 | 49 | LOG(INFO) << "Starting main event loop..."; 50 | mainEventLoop.run(); 51 | LOG(INFO) << "Main event loop got stopped"; 52 | 53 | server.stop(); 54 | server.waitUntilStopped(); 55 | 56 | for (auto& t : allThreads) { 57 | t.join(); 58 | } 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /fbzmq/py/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # 4 | # Copyright (c) 2014-present, Facebook, Inc. 5 | # 6 | # This source code is licensed under the MIT license found in the 7 | # LICENSE file in the root directory of this source tree. 8 | # 9 | 10 | from __future__ import absolute_import, division, print_function 11 | 12 | import os 13 | from subprocess import check_call 14 | 15 | from setuptools import find_packages, setup 16 | 17 | 18 | THRIFT_FILES = ["service/if/Monitor.thrift"] 19 | 20 | 21 | def create_package_list(base): 22 | """ 23 | Get all packages under the base directory 24 | """ 25 | 26 | return [base] + ["{}.{}".format(base, pkg) for pkg in find_packages(base)] 27 | 28 | 29 | def generate_thrift_files(): 30 | """ 31 | Get list of all thrift files (absolute path names) and then generate 32 | python definitions for all thrift files. 33 | """ 34 | 35 | current_dir = os.path.dirname(os.path.realpath(__file__)) 36 | root_dir = os.path.dirname(current_dir) 37 | for thrift_file in THRIFT_FILES: 38 | print("> Generating python definition for {}".format(thrift_file)) 39 | check_call( 40 | [ 41 | "thrift1", 42 | "--gen", 43 | "py", 44 | "--out", 45 | current_dir, 46 | os.path.join(root_dir, thrift_file), 47 | ] 48 | ) 49 | 50 | 51 | generate_thrift_files() 52 | setup( 53 | name="py-fbzmq", 54 | version="1.0", 55 | author="Open Routing", 56 | author_email="openr@fb.com", 57 | description="Python bindings for fbzmq thrift definitions", 58 | packages=create_package_list("fbzmq"), 59 | license="MIT", 60 | ) 61 | -------------------------------------------------------------------------------- /fbzmq/service/if/Monitor.thrift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | namespace cpp fbzmq.thrift 9 | namespace cpp2 fbzmq.thrift 10 | namespace go fbzmq.Monitor 11 | namespace php Fbzmq 12 | namespace py fbzmq.Monitor 13 | namespace py3 fbzmq.thrift 14 | 15 | enum MonitorCommand { 16 | // operations on counters in the monitor 17 | SET_COUNTER_VALUES = 1, 18 | GET_COUNTER_VALUES = 2, 19 | DUMP_ALL_COUNTER_NAMES = 3, 20 | DUMP_ALL_COUNTER_DATA = 4, 21 | BUMP_COUNTER = 5, 22 | GET_EVENT_LOGS = 6, 23 | 24 | // operations on logs, which are not saved in the monitor 25 | LOG_EVENT = 11, 26 | } 27 | 28 | // 29 | // cmd parameters for client threads to update their counters 30 | // 31 | 32 | // counter value type for calculating rates 33 | enum CounterValueType { 34 | GAUGE = 1, 35 | COUNTER = 2, 36 | } 37 | 38 | // store a counter or gauge value with timestamp 39 | struct Counter { 40 | 10: double value; 41 | 11: CounterValueType valueType; 42 | // last update timestamp in microseconds 43 | 12: i64 timestamp; 44 | } 45 | typedef map ( 46 | cpp.type = "std::unordered_map", 47 | ) CounterMap 48 | 49 | // parameters for SET_COUNTER_VALUES command 50 | struct CounterSetParams { 51 | // counter name -> Counter struct 52 | 1: CounterMap counters; 53 | } 54 | 55 | // parameters for GET_COUNTER_VALUES command 56 | struct CounterGetParams { 57 | 1: list counterNames; 58 | } 59 | 60 | // parameters for BUMP_COUNTER command 61 | struct CounterBumpParams { 62 | 1: list counterNames; 63 | } 64 | 65 | // parameters for LOG_EVENT 66 | struct EventLog { 67 | // name/id of the event log 68 | 1: string category; 69 | 2: list samples; 70 | } 71 | 72 | // 73 | // Request specification 74 | // 75 | 76 | // a request to the server (tagged union) 77 | struct MonitorRequest { 78 | 1: MonitorCommand cmd; 79 | 2: CounterSetParams counterSetParams; 80 | 3: CounterGetParams counterGetParams; 81 | 4: CounterBumpParams counterBumpParams; 82 | 5: EventLog eventLog; 83 | } 84 | 85 | // 86 | // Responses 87 | // 88 | 89 | struct CounterValuesResponse { 90 | 1: CounterMap counters; 91 | } 92 | 93 | struct EventLogsResponse { 94 | 1: list eventLogs; 95 | } 96 | 97 | struct CounterNamesResponse { 98 | 1: list counterNames; 99 | } 100 | 101 | // 102 | // Publication 103 | // 104 | 105 | enum PubType { 106 | COUNTER_PUB = 1, 107 | EVENT_LOG_PUB = 2, 108 | } 109 | 110 | struct MonitorPub { 111 | 1: PubType pubType; 112 | 2: CounterValuesResponse counterPub; 113 | 3: EventLog eventLogPub; 114 | } 115 | -------------------------------------------------------------------------------- /fbzmq/service/monitor/SystemMetrics.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | #include "SystemMetrics.h" 4 | 5 | #if defined(IS_BSD) && defined(__APPLE__) 6 | #include 7 | #include 8 | #elif defined(IS_BSD) 9 | #include 10 | #include 11 | #include 12 | #endif 13 | 14 | namespace fbzmq { 15 | 16 | /* Return RSS memory the process currently used from /proc/[pid]/status. 17 | / The /proc is a pseudo-filesystem providing an API to kernel data 18 | / structures. 19 | */ 20 | folly::Optional 21 | SystemMetrics::getRSSMemBytes() { 22 | #if !defined(IS_BSD) 23 | folly::Optional rss{folly::none}; 24 | // match the line like: "VmRSS: 9028 kB" 25 | std::regex rssRegex("VmRSS:\\s+(\\d+)\\s+(\\w+)"); 26 | std::smatch rssMatched; 27 | std::string line; 28 | std::ifstream input; 29 | try { 30 | // "/proc/self/" allows a process to look at itself without knowing the PID. 31 | std::ifstream input("/proc/self/status"); 32 | if (input.is_open()) { 33 | while (std::getline(input, line)) { 34 | if (std::regex_search(line, rssMatched, rssRegex) && 35 | rssMatched[2] == "kB") { 36 | rss = std::stoull(rssMatched[1]) * 1024; 37 | break; 38 | } 39 | } 40 | } 41 | } catch (const std::exception& ex) { 42 | LOG(ERROR) 43 | << "Fail to read the \"/proc/self/status\" of current process to get the memory usage: " 44 | << ex.what(); 45 | } 46 | return rss; 47 | #elif !defined(__APPLE__) 48 | struct rusage rusage; 49 | getrusage(RUSAGE_SELF, &rusage); 50 | return (size_t)(rusage.ru_maxrss * 1024); 51 | #else 52 | struct task_basic_info t_info; 53 | mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; 54 | task_info( 55 | current_task(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count); 56 | return t_info.resident_size; 57 | #endif 58 | } 59 | 60 | /* Return CPU% the process used 61 | / This need to be called twice to get the time difference 62 | / and calculate the CPU%. 63 | / 64 | / It will return folly::none when: 65 | / 1. first time query 66 | / 2. get invalid time: 67 | / - previous timestamp > current timestamp 68 | / - preivous total used time > current total used time 69 | */ 70 | folly::Optional 71 | SystemMetrics::getCPUpercentage() { 72 | struct rusage usage; 73 | getrusage(RUSAGE_SELF, &usage); 74 | 75 | ProcCpuTime nowCpuTime(usage); 76 | folly::Optional cpuPct{folly::none}; 77 | 78 | // calculate the CPU% = (process time diff) / (time elapsed) * 100 79 | if (prevCpuTime.timestamp != 0 && // has cached before 80 | nowCpuTime.timestamp > prevCpuTime.timestamp && 81 | nowCpuTime.totalTime > prevCpuTime.totalTime) { 82 | uint64_t timestampDiff = nowCpuTime.timestamp - prevCpuTime.timestamp; 83 | uint64_t procTimeDiff = nowCpuTime.totalTime - prevCpuTime.totalTime; 84 | cpuPct = ((double)procTimeDiff / (double)timestampDiff) * 100; 85 | } 86 | 87 | // update the cache for next CPU% update 88 | prevCpuTime = nowCpuTime; 89 | 90 | return cpuPct; 91 | } 92 | 93 | // get current timestamp 94 | uint64_t 95 | SystemMetrics::getCurrentNanoTime() { 96 | return std::chrono::duration_cast( 97 | std::chrono::steady_clock::now().time_since_epoch()) 98 | .count(); 99 | } 100 | 101 | } // namespace fbzmq 102 | -------------------------------------------------------------------------------- /fbzmq/service/monitor/SystemMetrics.h: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace fbzmq { 14 | 15 | /** 16 | * This class provides the API to get the system usage for monitoring, 17 | * including the CPU, memory usage, etc. 18 | */ 19 | class SystemMetrics { 20 | public: 21 | // get RSS memory the process used 22 | folly::Optional getRSSMemBytes(); 23 | 24 | // get CPU% the process used 25 | folly::Optional getCPUpercentage(); 26 | 27 | private: 28 | /** 29 | / To record CPU used time of current process (in nanoseconds) 30 | */ 31 | typedef struct ProcCpuTime { 32 | uint64_t userTime = 0; /* CPU time used in user mode */ 33 | uint64_t sysTime = 0; /* CPU time used in system mode*/ 34 | uint64_t totalTime = 0; /* total CPU time used */ 35 | uint64_t timestamp = 0; /* timestamp for current record */ 36 | ProcCpuTime(){}; // for initializing the prevCpuTime 37 | ProcCpuTime(struct rusage& usage) 38 | : userTime( 39 | usage.ru_utime.tv_sec * 1.0e9 + usage.ru_utime.tv_usec * 1.0e3), 40 | sysTime( 41 | usage.ru_stime.tv_sec * 1.0e9 + usage.ru_stime.tv_usec * 1.0e3), 42 | totalTime(userTime + sysTime), 43 | timestamp(getCurrentNanoTime()) {} 44 | } ProcCpuTime; 45 | 46 | // cache for CPU used time of previous query 47 | ProcCpuTime prevCpuTime; 48 | 49 | // get current timestamp (in nanoseconds) 50 | uint64_t static getCurrentNanoTime(); 51 | }; 52 | 53 | } // namespace fbzmq 54 | -------------------------------------------------------------------------------- /fbzmq/service/monitor/ZmqMonitorClient.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "ZmqMonitor.h" 16 | 17 | namespace fbzmq { 18 | 19 | /** 20 | * This class abstracts out many client side operations of ZmqMonitor into 21 | * very simple APIs to use. 22 | * 1. Advertise name/counter into local ZmqMonitor 23 | * 2. Access content of ZmqMonitor (name-counters) 24 | * 25 | */ 26 | class ZmqMonitorClient { 27 | public: 28 | /** 29 | * Creates and initializes all necessary sockets for communicating with 30 | * ZmqMonitor. 31 | */ 32 | ZmqMonitorClient( 33 | fbzmq::Context& zmqContext, 34 | std::string const& monitorCmdUrl, 35 | std::string const& socketId = ""); 36 | 37 | // 38 | // Synchronous wrapper calls around ZmqMonitor 39 | // throw zmq exception upon error 40 | // 41 | 42 | /** 43 | * Add name-counter(s) into ZmqMonitor 44 | */ 45 | void setCounter(std::string const& name, thrift::Counter const& counter); 46 | void setCounters(const CounterMap& counters); 47 | 48 | /** 49 | * Get name from ZmqMonitor. 50 | */ 51 | folly::Optional getCounter(std::string const& name); 52 | 53 | /** 54 | * Dump all counter names in ZmqMonitor. 55 | */ 56 | std::vector dumpCounterNames(); 57 | 58 | /** 59 | * Dump ZmqMonitor. 60 | */ 61 | CounterMap dumpCounters(); 62 | 63 | /** 64 | * Bump counter. 65 | */ 66 | void bumpCounter(std::string const& name); 67 | 68 | /** 69 | * Add an event log. 70 | */ 71 | void addEventLog(thrift::EventLog const& eventLog); 72 | 73 | /** 74 | * Get last event logs from ZmqMonitor 75 | */ 76 | folly::Optional> getLastEventLogs(); 77 | 78 | private: 79 | // 80 | // Mutable state 81 | // 82 | 83 | const std::string monitorCmdUrl_; 84 | 85 | // DEALER socket 86 | fbzmq::Socket monitorCmdSock_; 87 | 88 | // Serializer object for thrift-obj <-> string conversion 89 | apache::thrift::CompactSerializer serializer_; 90 | }; 91 | 92 | } // namespace fbzmq 93 | -------------------------------------------------------------------------------- /fbzmq/service/monitor/ZmqMonitorSample.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include "ZmqMonitor.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | using namespace std; 17 | using namespace fbzmq; 18 | 19 | DEFINE_string(ip, "::1", "Controller ip we talk to"); 20 | DEFINE_int32(monitor_router_port, 60008, "The monitor router port we talk to"); 21 | DEFINE_bool(periodic, true, "Whether to do periodic monitoring"); 22 | DEFINE_int32(period, 5, "Period in second"); 23 | 24 | // send DUMP_ALL_COUNTER_DATA request to monitor 25 | // then print reponse values 26 | void 27 | oneShot(Context& context) noexcept { 28 | Socket dealer(context); 29 | 30 | // enable ipv6 on the socket 31 | const int ipv6Enable = 1; 32 | dealer.setSockOpt(ZMQ_IPV6, &ipv6Enable, sizeof(int)).value(); 33 | 34 | // connect to router socket of monitor 35 | std::string routerSockUrl = 36 | folly::sformat("tcp://[{}]:{}", FLAGS_ip, FLAGS_monitor_router_port); 37 | LOG(INFO) << "Connecting to monitor on " << routerSockUrl; 38 | dealer.connect(SocketUrl(routerSockUrl)).value(); 39 | 40 | apache::thrift::CompactSerializer serializer; 41 | thrift::MonitorRequest thriftReq; 42 | *thriftReq.cmd() = thrift::MonitorCommand::DUMP_ALL_COUNTER_DATA; 43 | 44 | // send request 45 | 46 | LOG(INFO) << "Sending DUMP_ALL_COUNTER_DATA request."; 47 | dealer.sendThriftObj(thriftReq, serializer).value(); 48 | 49 | // receive and process response 50 | auto thriftNameValuesRep = 51 | dealer.recvThriftObj(serializer).value(); 52 | LOG(INFO) << "Current monitor Key Value Pairs"; 53 | for (auto const& it : *thriftNameValuesRep.counters()) { 54 | LOG(INFO) << " " << it.first << ": " << *it.second.value(); 55 | } 56 | } 57 | 58 | int 59 | main(int argc, char* argv[]) { 60 | // Parse command line flags 61 | gflags::ParseCommandLineFlags(&argc, &argv, true); 62 | google::InitGoogleLogging(argv[0]); 63 | FLAGS_logtostderr = true; 64 | 65 | // use single IO thread 66 | Context context; 67 | 68 | if (!FLAGS_periodic) { 69 | oneShot(context); 70 | return 0; 71 | } 72 | 73 | while (true) { 74 | oneShot(context); 75 | /* sleep override */ 76 | std::this_thread::sleep_for(std::chrono::seconds(FLAGS_period)); 77 | } 78 | 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /fbzmq/service/stats/ExportType.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | namespace fbzmq { 11 | 12 | enum ExportType { 13 | SUM = 0x01, 14 | AVG = 0x02, 15 | // MIN = 0x04, // Not Available yet 16 | // MAX = 0x08, // Not Available yet 17 | RATE = 0x10, 18 | COUNT = 0x20, 19 | COUNT_RATE = 0x40 20 | }; 21 | } // namespace fbzmq 22 | -------------------------------------------------------------------------------- /fbzmq/service/stats/ExportedStat.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include "ExportedStat.h" 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace fbzmq { 15 | 16 | namespace { 17 | 18 | /** 19 | * Number of buckets to use for folly::BucketedTimeSeries 20 | */ 21 | static const uint64_t kTsBuckets{60}; 22 | 23 | /** 24 | * Statically defined levels for multi level timeseries. 25 | */ 26 | static const std::vector kLevelDurations = { 27 | std::chrono::seconds(60), // One minute 28 | std::chrono::seconds(600), // Ten minutes 29 | std::chrono::seconds(3600), // One hour 30 | std::chrono::seconds(0), // All time 31 | }; 32 | 33 | /** 34 | * Utility function to get the current timestamp in seconds since epoch. 35 | */ 36 | std::chrono::seconds 37 | getTsInSeconds() { 38 | return std::chrono::duration_cast( 39 | std::chrono::steady_clock::now().time_since_epoch()); 40 | } 41 | 42 | } // namespace 43 | 44 | ExportedStat::ExportedStat(std::string const& key) : key_(key) { 45 | multiTs_.reset(new folly::MultiLevelTimeSeries( 46 | kTsBuckets, kLevelDurations.size(), &kLevelDurations[0])); 47 | } 48 | 49 | void 50 | ExportedStat::setExportType(ExportType type) { 51 | exportTypeBits_ |= type; 52 | } 53 | 54 | void 55 | ExportedStat::unsetExportType(ExportType type) { 56 | exportTypeBits_ &= ~type; 57 | } 58 | 59 | /** 60 | * Add new value to this stats. We use current timestamp using steady_clock 61 | */ 62 | void 63 | ExportedStat::addValue(int64_t value) { 64 | multiTs_->addValue(getTsInSeconds(), value); 65 | } 66 | 67 | /** 68 | * API to get the counters for exported stat-types among all the levels. 69 | * Counters are named as "..". e.g. "foo.avg.60" 70 | */ 71 | void 72 | ExportedStat::getCounters(std::unordered_map& counters) { 73 | // Update timeseries 74 | multiTs_->update(getTsInSeconds()); 75 | 76 | for (size_t i = 0; i < kLevelDurations.size(); i++) { 77 | auto const& level = multiTs_->getLevel(i); 78 | auto const interval = level.duration().count(); 79 | 80 | if (exportTypeBits_ & SUM) { 81 | auto key = folly::sformat("{}.sum.{}", key_, interval); 82 | counters[key] = level.sum(); 83 | } 84 | 85 | if (exportTypeBits_ & AVG) { 86 | auto key = folly::sformat("{}.avg.{}", key_, interval); 87 | counters[key] = level.avg(); 88 | } 89 | 90 | if (exportTypeBits_ & RATE) { 91 | auto key = folly::sformat("{}.rate.{}", key_, interval); 92 | counters[key] = level.rate(); 93 | } 94 | 95 | if (exportTypeBits_ & COUNT) { 96 | auto key = folly::sformat("{}.count.{}", key_, interval); 97 | counters[key] = level.count(); 98 | } 99 | 100 | if (exportTypeBits_ & COUNT_RATE) { 101 | auto key = folly::sformat("{}.count_rate.{}", key_, interval); 102 | counters[key] = level.countRate(); 103 | } 104 | } 105 | } 106 | } // namespace fbzmq 107 | -------------------------------------------------------------------------------- /fbzmq/service/stats/ExportedStat.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include "ExportType.h" 19 | 20 | namespace fbzmq { 21 | 22 | /** 23 | * Class which stores the multi-level timeseries data for a certain key and 24 | * wraps up the logic for updating and building-counters. 25 | * 26 | * We are using most common levels (derived from fbcode::ServiceData) which are 27 | * - 1 minute (.60) 28 | * - 10 minutes (.600) 29 | * - 1 hour (.3600) 30 | * - all time (.0) 31 | */ 32 | class ExportedStat : public boost::noncopyable { 33 | public: 34 | explicit ExportedStat(std::string const& key); 35 | 36 | /** 37 | * Set/unset export-type for this statistic. 38 | */ 39 | void setExportType(ExportType type); 40 | void unsetExportType(ExportType type); 41 | 42 | /** 43 | * Add new value to this stats. We use current timestamp using steady_clock 44 | */ 45 | void addValue(int64_t value); 46 | 47 | /** 48 | * API to get the counters for exported stat-types among all the levels. 49 | * Counters are named as "..". e.g. "foo.avg.60" 50 | */ 51 | void getCounters(std::unordered_map& counters); 52 | 53 | private: 54 | // The associated key 55 | std::string key_{""}; 56 | 57 | // MultiLevelTimeSeries associated with this statistics 58 | std::unique_ptr> multiTs_; 59 | 60 | // Masked bitset for export types. #efficiency 61 | uint32_t exportTypeBits_{0}; 62 | }; 63 | } // namespace fbzmq 64 | -------------------------------------------------------------------------------- /fbzmq/service/stats/ThreadData.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include "ThreadData.h" 9 | 10 | namespace fbzmq { 11 | 12 | void 13 | ThreadData::resetAllData() { 14 | counters_.clear(); 15 | stats_.clear(); 16 | } 17 | 18 | void 19 | ThreadData::addStatExportType(std::string const& key, ExportType type) { 20 | auto it = stats_.find(key); 21 | if (it == stats_.end()) { 22 | std::tie(it, std::ignore) = stats_.emplace( 23 | std::piecewise_construct, 24 | std::forward_as_tuple(key), 25 | std::forward_as_tuple(key)); 26 | } 27 | 28 | it->second.setExportType(type); 29 | } 30 | 31 | void 32 | ThreadData::clearStatExportType(std::string const& key, ExportType type) { 33 | auto it = stats_.find(key); 34 | if (it != stats_.end()) { 35 | it->second.unsetExportType(type); 36 | } 37 | } 38 | 39 | void 40 | ThreadData::addStatValue(std::string const& key, int64_t value) { 41 | auto it = stats_.find(key); 42 | if (it == stats_.end()) { 43 | std::tie(it, std::ignore) = stats_.emplace( 44 | std::piecewise_construct, 45 | std::forward_as_tuple(key), 46 | std::forward_as_tuple(key)); 47 | } 48 | 49 | it->second.addValue(value); 50 | } 51 | 52 | void 53 | ThreadData::addStatValue( 54 | const std::string& key, int64_t value, ExportType type) { 55 | auto it = stats_.find(key); 56 | if (it == stats_.end()) { 57 | std::tie(it, std::ignore) = stats_.emplace( 58 | std::piecewise_construct, 59 | std::forward_as_tuple(key), 60 | std::forward_as_tuple(key)); 61 | } 62 | 63 | it->second.setExportType(type); 64 | it->second.addValue(value); 65 | } 66 | 67 | void 68 | ThreadData::setCounter(std::string const& key, int64_t value) { 69 | counters_[key] = value; 70 | } 71 | 72 | void 73 | ThreadData::clearCounter(std::string const& key) { 74 | counters_.erase(key); 75 | } 76 | 77 | int64_t 78 | ThreadData::incrementCounter(std::string const& key, int64_t amount) { 79 | return (counters_[key] += amount); 80 | } 81 | 82 | std::unordered_map 83 | ThreadData::getCounters() { 84 | std::unordered_map counters; 85 | 86 | // Add all the flat counters 87 | counters.insert(counters_.begin(), counters_.end()); 88 | 89 | // Add all stats 90 | for (auto& kv : stats_) { 91 | kv.second.getCounters(counters); 92 | } 93 | 94 | return counters; 95 | } 96 | } // namespace fbzmq 97 | -------------------------------------------------------------------------------- /fbzmq/service/stats/ThreadData.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include "ExportedStat.h" 16 | 17 | namespace fbzmq { 18 | 19 | /** 20 | * Thread storage for storing flat counters, timeseries counters and stats. This 21 | * can be extended to store histograms and string values. 22 | * 23 | * The idea has been borrowed from the fbcode:ServiceData however we have no 24 | * singleton here. The ThreadData is not thread safe and it is assumed to be 25 | * used within a single thread only. 26 | * 27 | * If you want to use within multiple threads then use your own locks :P 28 | */ 29 | class ThreadData : public boost::noncopyable { 30 | public: 31 | ThreadData() = default; 32 | ~ThreadData() = default; 33 | 34 | /** 35 | * Clear all counters and exported stats etc. You must call 36 | * addStatExportType/addStatExports/addHistogram again to 37 | * re-add statistics. 38 | */ 39 | void resetAllData(); 40 | 41 | /** 42 | * Exports the given stat value to the counters, using the given export type. 43 | * In other words, after calling for key = "foo", calls to getCounters() will 44 | * contains several counters of the form. 45 | * 46 | * type SUM: foo.SUM, foo.SUM.60, foo.SUM.600, foo.SUM.3600 47 | * type COUNT: foo.COUNT, foo.COUNT.60, foo.COUNT.600, foo.COUNT.3600 48 | * type AVG: foo.avg, foo.avg.60, foo.avg.600, foo.avg.3600 49 | * so on for other types 50 | */ 51 | void addStatExportType(std::string const& key, ExportType type); 52 | void clearStatExportType(std::string const& key, ExportType type); 53 | 54 | /** 55 | * Adds a value to the historical statistics for a given key. Checkout the 56 | * documentation of `addStatExportType` to see how to make these statistics 57 | * available via calls to getCounters(). 58 | */ 59 | void addStatValue(std::string const& key, int64_t value); 60 | 61 | /** 62 | * Same as above but allows you to specify the export type on the fly. 63 | */ 64 | void addStatValue(std::string const& key, int64_t value, ExportType type); 65 | 66 | /** 67 | * API to set a flat counter. 68 | */ 69 | void setCounter(std::string const& key, int64_t value); 70 | 71 | /** 72 | * Clear/Remove the counter from internal map. 73 | */ 74 | void clearCounter(std::string const& key); 75 | 76 | /** 77 | * Utility function to increment the flat-counter 78 | */ 79 | int64_t incrementCounter(std::string const& key, int64_t amount = 1); 80 | 81 | /** 82 | * Returns all the counters (flat + exportedStats) as a map of key, vals. 83 | */ 84 | std::unordered_map getCounters(); 85 | 86 | private: 87 | // Exported stats 88 | std::unordered_map stats_{}; 89 | 90 | // Simple flat counters. 91 | std::unordered_map counters_{}; 92 | }; 93 | } // namespace fbzmq 94 | -------------------------------------------------------------------------------- /fbzmq/service/stats/tests/ThreadDataTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | TEST(ThreadDataTest, ApiTest) { 17 | fbzmq::ThreadData tData; 18 | 19 | tData.setCounter("counter_key", 0); 20 | tData.addStatExportType("stats_key", fbzmq::AVG); 21 | tData.addStatExportType("stats_key", fbzmq::SUM); 22 | 23 | // counters must have 9 (1 + 4 + 4) keys 24 | auto counters = tData.getCounters(); 25 | EXPECT_EQ(counters.size(), 9); 26 | for (auto const& kv : counters) { 27 | EXPECT_EQ(kv.second, 0); 28 | } 29 | EXPECT_EQ(1, counters.count("counter_key")); 30 | EXPECT_EQ(1, counters.count("stats_key.avg.60")); 31 | EXPECT_EQ(1, counters.count("stats_key.avg.600")); 32 | EXPECT_EQ(1, counters.count("stats_key.avg.3600")); 33 | EXPECT_EQ(1, counters.count("stats_key.avg.0")); 34 | EXPECT_EQ(1, counters.count("stats_key.sum.60")); 35 | EXPECT_EQ(1, counters.count("stats_key.sum.600")); 36 | EXPECT_EQ(1, counters.count("stats_key.sum.3600")); 37 | EXPECT_EQ(1, counters.count("stats_key.sum.0")); 38 | 39 | // Add some values 40 | tData.setCounter("counter_key", 10); 41 | CHECK_EQ(11, tData.incrementCounter("counter_key", 1)); 42 | tData.addStatValue("stats_key", 10); 43 | tData.addStatValue("stats_key", 20); 44 | 45 | // counters must have 9 keys as before and expected values 46 | counters = tData.getCounters(); 47 | EXPECT_EQ(9, counters.size()); 48 | EXPECT_EQ(11, counters["counter_key"]); 49 | EXPECT_EQ(15, counters["stats_key.avg.60"]); 50 | EXPECT_EQ(15, counters["stats_key.avg.600"]); 51 | EXPECT_EQ(15, counters["stats_key.avg.3600"]); 52 | EXPECT_EQ(15, counters["stats_key.avg.0"]); 53 | EXPECT_EQ(30, counters["stats_key.sum.60"]); 54 | EXPECT_EQ(30, counters["stats_key.sum.600"]); 55 | EXPECT_EQ(30, counters["stats_key.sum.3600"]); 56 | EXPECT_EQ(30, counters["stats_key.sum.0"]); 57 | 58 | // Add a new and remove export types 59 | tData.addStatExportType("stats_key", fbzmq::COUNT); 60 | tData.clearStatExportType("stats_key", fbzmq::AVG); 61 | tData.clearCounter("counter_key"); 62 | 63 | // counters should have 8 keys and appropriate values 64 | counters = tData.getCounters(); 65 | EXPECT_EQ(8, counters.size()); 66 | EXPECT_EQ(30, counters["stats_key.sum.60"]); 67 | EXPECT_EQ(30, counters["stats_key.sum.600"]); 68 | EXPECT_EQ(30, counters["stats_key.sum.3600"]); 69 | EXPECT_EQ(30, counters["stats_key.sum.0"]); 70 | EXPECT_EQ(2, counters["stats_key.count.60"]); 71 | EXPECT_EQ(2, counters["stats_key.count.600"]); 72 | EXPECT_EQ(2, counters["stats_key.count.3600"]); 73 | EXPECT_EQ(2, counters["stats_key.count.0"]); 74 | } 75 | 76 | int 77 | main(int argc, char** argv) { 78 | // Basic initialization 79 | testing::InitGoogleTest(&argc, argv); 80 | gflags::ParseCommandLineFlags(&argc, &argv, true); 81 | google::InitGoogleLogging(argv[0]); 82 | 83 | // Run the tests 84 | return RUN_ALL_TESTS(); 85 | } 86 | -------------------------------------------------------------------------------- /fbzmq/zmq/Common.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | #ifdef IS_BSD 10 | #include 11 | #endif 12 | 13 | namespace fbzmq { 14 | 15 | Error::Error() : errNum(zmq_errno()), errString(zmq_strerror(errNum)) {} 16 | 17 | Error::Error(int errNum) : errNum(errNum), errString(zmq_strerror(errNum)) {} 18 | 19 | Error::Error(int errNum, std::string errString) 20 | : errNum(errNum), errString(errString) {} 21 | 22 | std::ostream& 23 | operator<<(std::ostream& out, Error const& err) { 24 | out << err.errString << " (errno=" << err.errNum << ")"; 25 | return out; 26 | } 27 | 28 | folly::Expected 29 | poll(zmq_pollitem_t const* items_, int nitems_, long timeout_ = -1) { 30 | while (true) { 31 | auto rc = zmq_poll(const_cast(items_), nitems_, timeout_); 32 | if (rc >= 0) { 33 | return rc; 34 | } 35 | const auto errNum = zmq_errno(); 36 | if (errNum == EINTR) { 37 | continue; 38 | } 39 | return folly::makeUnexpected(Error(errNum)); 40 | } 41 | } 42 | 43 | folly::Expected 44 | poll( 45 | std::vector const& items, 46 | folly::Optional timeout /* = folly::none */) { 47 | return poll(items.data(), items.size(), timeout ? timeout->count() : -1); 48 | } 49 | 50 | folly::Expected 51 | proxy(void* frontend, void* backend, void* capture) { 52 | while (true) { 53 | auto rc = zmq_proxy(frontend, backend, capture); 54 | if (rc == 0) { 55 | return folly::unit; 56 | } 57 | 58 | const auto errNum = zmq_errno(); 59 | if (errNum == EINTR) { 60 | continue; 61 | } 62 | return folly::makeUnexpected(Error(errNum)); 63 | } 64 | } 65 | 66 | namespace util { 67 | 68 | #ifdef IS_BSD 69 | void 70 | setFdCloExec(int fd) { 71 | int flags = fcntl(fd, F_GETFD, 0); 72 | if (flags < 0) { 73 | LOG(FATAL) << "setFdCloExec: Failed to get fd flags"; 74 | } 75 | if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) { 76 | LOG(FATAL) << "setFdCloExec: Failed to set fd FD_CLOEXEC"; 77 | } 78 | } 79 | #endif 80 | 81 | KeyPair 82 | genKeyPair() { 83 | unsigned char pk[crypto_sign_PUBLICKEYBYTES]; 84 | unsigned char sk[crypto_sign_SECRETKEYBYTES]; 85 | 86 | ::crypto_sign_keypair(pk, sk); 87 | 88 | auto publicKey = std::string( 89 | reinterpret_cast(pk), crypto_sign_PUBLICKEYBYTES); 90 | auto privateKey = std::string( 91 | reinterpret_cast(sk), crypto_sign_SECRETKEYBYTES); 92 | 93 | return KeyPair{privateKey, publicKey}; 94 | } 95 | 96 | } // namespace util 97 | } // namespace fbzmq 98 | -------------------------------------------------------------------------------- /fbzmq/zmq/Common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | namespace fbzmq { 22 | 23 | /** 24 | * Generic error wrapper for ZMQ operations 25 | */ 26 | struct Error { 27 | // capture error from zmq_errno() 28 | Error(); 29 | explicit Error(int errNum); 30 | Error(int errNum, std::string errString); 31 | 32 | const int errNum{0}; 33 | const std::string errString; 34 | }; 35 | 36 | std::ostream& operator<<(std::ostream&, Error const&); 37 | 38 | /** 39 | * Crypto key pair 40 | */ 41 | struct KeyPair { 42 | std::string privateKey; 43 | std::string publicKey; 44 | }; 45 | 46 | /** 47 | * PollIem ... same as zmq_pollitem_t 48 | */ 49 | using PollItem = zmq_pollitem_t; 50 | 51 | /** 52 | * Polling. poll indefinitely by default 53 | */ 54 | folly::Expected poll( 55 | std::vector const& items, 56 | folly::Optional timeout = folly::none); 57 | 58 | /** 59 | * Proxy connects a frontend socket to a backend socket. 60 | * Conceptually, data flows from frontend to backend. 61 | * Depending on the socket types, replies may flow in the opposite direction. 62 | */ 63 | folly::Expected proxy( 64 | void* frontend, void* backend, void* capture); 65 | 66 | namespace util { 67 | 68 | #ifdef IS_BSD 69 | void setFdCloExec(int fd); 70 | #endif 71 | 72 | /** 73 | * Generate a crypto key pair 74 | */ 75 | KeyPair genKeyPair(); 76 | 77 | /** 78 | * Utility functions for conversion between thrift objects and string/IOBuf 79 | */ 80 | 81 | template 82 | std::unique_ptr 83 | writeThriftObj(ThriftType const& obj, Serializer& serializer) { 84 | auto queue = folly::IOBufQueue(); 85 | serializer.serialize(obj, &queue); 86 | 87 | return queue.move(); 88 | } 89 | 90 | template 91 | std::string 92 | writeThriftObjStr(ThriftType const& obj, Serializer& serializer) { 93 | std::string result; 94 | serializer.serialize(obj, &result); 95 | return result; 96 | } 97 | 98 | template 99 | ThriftType 100 | readThriftObj(folly::IOBuf& buf, Serializer& serializer) { 101 | ThriftType obj; 102 | serializer.deserialize(&buf, obj); 103 | return obj; 104 | } 105 | 106 | template 107 | ThriftType 108 | readThriftObjStr(const std::string& buf, Serializer& serializer) { 109 | ThriftType obj; 110 | serializer.deserialize(buf, obj); 111 | return obj; 112 | } 113 | 114 | } // namespace util 115 | } // namespace fbzmq 116 | -------------------------------------------------------------------------------- /fbzmq/zmq/Context.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | 10 | namespace fbzmq { 11 | 12 | Context::Context( 13 | folly::Optional numIoThreads, 14 | folly::Optional numMaxSockets) noexcept 15 | : ptr_(zmq_ctx_new()) { 16 | CHECK(ptr_); 17 | 18 | if (numIoThreads) { 19 | const int rc = zmq_ctx_set(ptr_, ZMQ_IO_THREADS, numIoThreads.value()); 20 | CHECK_EQ(0, rc) << zmq_strerror(zmq_errno()); 21 | } 22 | 23 | if (numMaxSockets) { 24 | const int rc = zmq_ctx_set(ptr_, ZMQ_MAX_SOCKETS, numMaxSockets.value()); 25 | CHECK_EQ(0, rc) << zmq_strerror(zmq_errno()); 26 | } 27 | } 28 | 29 | Context::~Context() { 30 | // if we have been moved out 31 | if (not ptr_) { 32 | return; 33 | } 34 | 35 | const int rc = zmq_ctx_destroy(const_cast(ptr_)); 36 | CHECK_EQ(0, rc) << zmq_strerror(zmq_errno()); 37 | } 38 | 39 | Context::Context(Context&& other) noexcept : ptr_(other.ptr_) { 40 | other.ptr_ = nullptr; 41 | } 42 | 43 | Context& 44 | Context::operator=(Context&& other) noexcept { 45 | Context tmp(std::move(other)); 46 | std::swap(ptr_, tmp.ptr_); 47 | return *this; 48 | } 49 | 50 | } // namespace fbzmq 51 | -------------------------------------------------------------------------------- /fbzmq/zmq/Context.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace fbzmq { 13 | 14 | namespace detail { 15 | // Forward declaration of SocketImpl friend class 16 | class SocketImpl; 17 | } // namespace detail 18 | 19 | /** 20 | * RAII over zmq_context 21 | */ 22 | class Context { 23 | public: 24 | /** 25 | * Can optionally be configured with 26 | * - custom number of IO threads 27 | * - custom cap on number of sockets supported by context 28 | * 29 | * Default values are defined by libzmq which is 1 for IO threads and 30 | * 1024 for max number of sockets. 31 | */ 32 | explicit Context( 33 | folly::Optional numIoThreads = folly::none, 34 | folly::Optional numMaxSockets = folly::none) noexcept; 35 | 36 | // non-copyable 37 | Context(Context const&) = delete; 38 | Context& operator=(Context const&) = delete; 39 | 40 | // movable 41 | Context(Context&&) noexcept; 42 | Context& operator=(Context&&) noexcept; 43 | ~Context(); 44 | 45 | private: 46 | friend class detail::SocketImpl; 47 | 48 | // pointer to zmq context object 49 | void* ptr_{nullptr}; 50 | }; 51 | 52 | } // namespace fbzmq 53 | -------------------------------------------------------------------------------- /fbzmq/zmq/README.md: -------------------------------------------------------------------------------- 1 | Zmq C++ Wrappers 2 | ============= 3 | 4 | ### Overview 5 | 6 | This is a collection of light-weight wrappers over low-level zmq library that 7 | aims at simplicity and type enforcement. It consists of four main classes: 8 | Context, Message, Socket and SocketMonitor. As compared to other libraries it 9 | has less functionality, but builds on more sophisticated abstractions from 10 | folly library (`folly::Expected`, `Optional`, `Range`, `IOBuf`, etc). 11 | 12 | One notable feature is lack of exception throwing - instead, all values are 13 | returned wrapped in `folly::Expected`, which allows for applying error-code 14 | based processing. The fbzmq::Error class wraps the error codes for zmq 15 | operations. 16 | 17 | ### Context 18 | 19 | This is rather straightforward, wraps zmq IO context object. Nothing too fancy, 20 | just new naming - mainly to provide the RAII logic for zmq context. 21 | 22 | ### Message 23 | 24 | This is the unit of information exchange in ZMQ universe. Messages are sent and 25 | received atomically from the sockets. Multiple messages could be "chained" on 26 | the wire using the "more" flag. A message with "more" flag set indicates that 27 | another atomic read could be performed to retrieve the following message. The 28 | payload of message is opaque byte array, which could be accessed directly using 29 | data() and writeableData() methods. 30 | 31 | Message could be constructed by direct allocation, or by wrapping an existing 32 | IOBuf chain. In the latter case, the chain will be coalesced first, since ZMQ 33 | can't deal with fragmented memory regions. 34 | 35 | In addition to this, messages could be constructed from primitive types, strings 36 | or thrift objects, using the `fromXXX()` static methods. For example: 37 | 38 | ``` 39 | // note: below will throw on error 40 | auto msg = fbzmq::Message::fromThriftObj(obj, serializer).value(); 41 | ``` 42 | 43 | Similarly, there are methods to read primitive types, strings or thrift objects 44 | from message. Notice that all of those read messages "atomically". E.g. if you 45 | read `uint32_t` from message, the assumption is that this is all that message 46 | has. 47 | 48 | ### Socket 49 | 50 | Most complicated class of them all. The socket is split in bottom half - 51 | SocketImpl class that wraps zmq socket, and descendant template class 52 | `Socket` 53 | 54 | The `Socket<>` template allows passing the socket type and mode (server/client) 55 | as part of the type signature. This makes reading code easier as socket 56 | operations become more transparent. Template specializations ensure that some 57 | socket types can only be used in fixed mode, e.g. PUB socket is always SERVER, 58 | but DEALER could be used in CLIENT or SERVER mode. 59 | 60 | The major difference b/w client and server modes is presence of bind/connect 61 | methods. Servers do not have connect() and clients do no have bind methods. 62 | 63 | Notice that Sockets only operate on Messages - you send and receive those as 64 | atomic units. The `hasMore()` method is expected to reflect the same value as 65 | `Message::isLast()` after the message has been received. Socket also exposes 66 | fancy and beautiful APIs to deal with send/recv of multi-part messages. 67 | 68 | ### Polling 69 | 70 | There is a simple poll() wrapper function added that can take arbitrary time 71 | units for delay. The overall logic of asynchronous work with ZMQ is as 72 | following: 73 | 74 | - Wait for event 75 | - Read messages as long as more flag is present on socket or 76 | `message.isLast() == false` 77 | - Resume waiting 78 | 79 | Previously we had to make read operations use timeout to avoid blocking forever 80 | on missing messages. This logic is now being replaced by relying on "more" 81 | flag in received messages. 82 | -------------------------------------------------------------------------------- /fbzmq/zmq/SocketMonitor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | 10 | namespace fbzmq { 11 | 12 | SocketMonitor::SocketMonitor( 13 | detail::SocketImpl const& sock, SocketUrl monitorUrl, CallbackT cb) noexcept 14 | : pairSock_{const_cast(sock.ctxPtr_)}, cb_{std::move(cb)} { 15 | auto ptr = const_cast(sock).ptr_; 16 | int rc = zmq_socket_monitor( 17 | ptr, static_cast(monitorUrl).c_str(), ZMQ_EVENT_ALL); 18 | 19 | CHECK_EQ(0, rc) << "Failed attaching monitor: " << Error(); 20 | pairSock_.connect(SocketUrl{monitorUrl}); 21 | cb_(SocketMonitorMessage::STARTED, SocketUrl{}); 22 | } 23 | 24 | // public 25 | folly::Expected 26 | SocketMonitor::runForever() noexcept { 27 | std::vector pollItems = { 28 | {reinterpret_cast(*pairSock_), 0, ZMQ_POLLIN, 0}}; 29 | 30 | while (true) { 31 | fbzmq::poll(pollItems); 32 | 33 | const auto ret = runOnce(); 34 | // error while trying to get monitoing message 35 | if (ret.hasError()) { 36 | return folly::makeUnexpected(ret.error()); 37 | } 38 | // has monitoring finished? 39 | if (not ret.value()) { 40 | break; 41 | } 42 | } // while 43 | 44 | return folly::unit; 45 | } 46 | 47 | folly::Expected 48 | SocketMonitor::runOnce() noexcept { 49 | EventT event; 50 | std::string address; 51 | 52 | { 53 | auto maybeMsg = pairSock_.recvOne(); 54 | if (maybeMsg.hasError()) { 55 | return folly::makeUnexpected(maybeMsg.error()); 56 | } 57 | ::memcpy( 58 | static_cast(&event), 59 | maybeMsg->writeableData().begin(), 60 | sizeof(EventT)); 61 | } 62 | 63 | { 64 | auto maybeMsg = pairSock_.recvOne(); 65 | if (maybeMsg.hasError()) { 66 | return folly::makeUnexpected(maybeMsg.error()); 67 | } 68 | address = maybeMsg->read().value(); 69 | } 70 | 71 | if (event.event == ZMQ_EVENT_MONITOR_STOPPED) { 72 | return false; 73 | } 74 | 75 | const auto url = SocketUrl{address}; 76 | 77 | switch (event.event) { 78 | case ZMQ_EVENT_CONNECTED: 79 | cb_(SocketMonitorMessage::CONNECTED, url); 80 | break; 81 | case ZMQ_EVENT_CONNECT_DELAYED: 82 | cb_(SocketMonitorMessage::CONNECT_DELAYED, url); 83 | break; 84 | case ZMQ_EVENT_CONNECT_RETRIED: 85 | cb_(SocketMonitorMessage::CONNECT_RETRIED, url); 86 | break; 87 | case ZMQ_EVENT_LISTENING: 88 | cb_(SocketMonitorMessage::LISTENING, url); 89 | break; 90 | case ZMQ_EVENT_BIND_FAILED: 91 | cb_(SocketMonitorMessage::BIND_FAILED, url); 92 | break; 93 | case ZMQ_EVENT_ACCEPTED: 94 | cb_(SocketMonitorMessage::ACCEPTED, url); 95 | break; 96 | case ZMQ_EVENT_ACCEPT_FAILED: 97 | cb_(SocketMonitorMessage::ACCEPT_FAILED, url); 98 | break; 99 | case ZMQ_EVENT_CLOSED: 100 | cb_(SocketMonitorMessage::CLOSED, url); 101 | break; 102 | case ZMQ_EVENT_CLOSE_FAILED: 103 | cb_(SocketMonitorMessage::CLOSE_FAILED, url); 104 | break; 105 | case ZMQ_EVENT_DISCONNECTED: 106 | cb_(SocketMonitorMessage::DISCONNECTED, url); 107 | break; 108 | #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 0) 109 | case ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL: 110 | cb_(SocketMonitorMessage::HANDSHAKE_FAILED_NO_DETAIL, url); 111 | break; 112 | case ZMQ_EVENT_HANDSHAKE_SUCCEEDED: 113 | cb_(SocketMonitorMessage::HANDSHAKE_SUCCEEDED, url); 114 | break; 115 | case ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL: 116 | cb_(SocketMonitorMessage::HANDSHAKE_FAILED_PROTOCOL, url); 117 | break; 118 | case ZMQ_EVENT_HANDSHAKE_FAILED_AUTH: 119 | cb_(SocketMonitorMessage::HANDSHAKE_FAILED_AUTH, url); 120 | break; 121 | #endif 122 | default: 123 | LOG(ERROR) << "Unknown event: " << event.event; 124 | break; 125 | } // switch 126 | 127 | return true; 128 | } 129 | 130 | } // namespace fbzmq 131 | -------------------------------------------------------------------------------- /fbzmq/zmq/SocketMonitor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace fbzmq { 15 | 16 | enum class SocketMonitorMessage { 17 | STARTED, 18 | CONNECTED, 19 | CONNECT_DELAYED, 20 | CONNECT_RETRIED, 21 | LISTENING, 22 | BIND_FAILED, 23 | ACCEPTED, 24 | ACCEPT_FAILED, 25 | CLOSED, 26 | CLOSE_FAILED, 27 | DISCONNECTED, 28 | HANDSHAKE_FAILED_NO_DETAIL, 29 | HANDSHAKE_SUCCEEDED, 30 | HANDSHAKE_FAILED_PROTOCOL, 31 | HANDSHAKE_FAILED_AUTH, 32 | }; 33 | 34 | /** 35 | * Socket monitor creates new PAIR socket that observes even on monitored 36 | * socket and reports it down. It runs synchronous loop and invokes the 37 | * callback 38 | */ 39 | class SocketMonitor { 40 | public: 41 | // the function we call on events 42 | using CallbackT = folly::Function; 43 | 44 | /** 45 | * Monitor event on socket. The intended use case it to have this running 46 | * in a different thread, hence the run() loop is blocking (per the zmq 47 | * man page recommendations) 48 | * 49 | * @param sock The socket to monitor for events 50 | * @param monitoUrl The URL to use for transient PAIR socket. This has to be 51 | * inproc:// only 52 | * @param cb The callback to invoke on every event. Will be invoked in 53 | * the monitoring thread 54 | */ 55 | SocketMonitor( 56 | detail::SocketImpl const& sock, 57 | SocketUrl monitorUrl, 58 | CallbackT cb) noexcept; 59 | 60 | /** 61 | * non-copyable 62 | */ 63 | SocketMonitor(SocketMonitor const&) = delete; 64 | SocketMonitor& operator=(SocketMonitor const&) = delete; 65 | 66 | /** 67 | * Starts the monitoring loop, until the monitored socket closes. this 68 | * should run in a new thread to avoid blocking 69 | */ 70 | folly::Expected runForever() noexcept; 71 | 72 | /** 73 | * Iterate monitoring loop to consume single event. Usually helpful with 74 | * external event loops. Return true if socket is still being monitored. 75 | * false if monitoring has finished (monitored socket has been closed) 76 | */ 77 | folly::Expected runOnce() noexcept; 78 | 79 | /** 80 | * return raw pointer to the pair socket so it could be added to event loops 81 | */ 82 | uintptr_t 83 | operator*() { 84 | return reinterpret_cast(pairSock_.ptr_); 85 | } 86 | 87 | private: 88 | /** 89 | * event object passed down the PAIR socket to monitor class 90 | */ 91 | struct EventT { 92 | uint16_t event; 93 | int32_t data; 94 | }; 95 | 96 | // this socket will be used to report monitored socket events 97 | Socket pairSock_; 98 | 99 | // we'll call this method on any event 100 | CallbackT cb_; 101 | }; 102 | 103 | } // namespace fbzmq 104 | -------------------------------------------------------------------------------- /fbzmq/zmq/Zmq.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /** 17 | * Umbrella to hold all of fbzmq headers 18 | */ 19 | -------------------------------------------------------------------------------- /fbzmq/zmq/tests/CommonTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | namespace fbzmq { 19 | 20 | TEST(Error, ErrorOutput) { 21 | std::stringstream ss; 22 | fbzmq::Error err = {1, "TEST"}; 23 | ss << err; 24 | EXPECT_EQ("TEST (errno=1)", ss.str()); 25 | } 26 | 27 | TEST(ZmqPollTest, EmptyPoll) { 28 | std::vector pollItems; 29 | const auto ret = 30 | fbzmq::poll(pollItems, std::chrono::milliseconds(100)).value(); 31 | EXPECT_EQ(0, ret); 32 | } 33 | 34 | TEST(ZmqProxy, EmptyProxy) { 35 | bool proxyExit = false; 36 | 37 | auto proxyThread = std::thread([&proxyExit]() { 38 | fbzmq::Socket frontend; 39 | fbzmq::Socket backend; 40 | frontend.bind(fbzmq::SocketUrl{"tcp://*:5555"}); 41 | backend.connect(fbzmq::SocketUrl{"tcp://*:5556"}); 42 | fbzmq::proxy( 43 | reinterpret_cast(*frontend), 44 | reinterpret_cast(*backend), 45 | nullptr); 46 | proxyExit = true; 47 | }); 48 | 49 | proxyThread.join(); 50 | EXPECT_TRUE(proxyExit); 51 | } 52 | 53 | } // namespace fbzmq 54 | 55 | int 56 | main(int argc, char* argv[]) { 57 | // Parse command line flags 58 | testing::InitGoogleTest(&argc, argv); 59 | gflags::ParseCommandLineFlags(&argc, &argv, true); 60 | google::InitGoogleLogging(argv[0]); 61 | 62 | // init sodium security library 63 | if (::sodium_init() == -1) { 64 | LOG(ERROR) << "Failed initializing sodium"; 65 | return -1; 66 | } 67 | 68 | // Run the tests 69 | return RUN_ALL_TESTS(); 70 | } 71 | -------------------------------------------------------------------------------- /fbzmq/zmq/tests/ContextTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace fbzmq { 15 | 16 | TEST(Context, Move) { 17 | // move construct and move assign 18 | fbzmq::Context ctx1(2 /* num-io-threads */, 32 /* num-max-sockets */); 19 | fbzmq::Context ctx2(std::move(ctx1)); 20 | fbzmq::Context ctx3; 21 | ctx3 = std::move(ctx2); 22 | } 23 | 24 | } // namespace fbzmq 25 | 26 | int 27 | main(int argc, char* argv[]) { 28 | // Parse command line flags 29 | testing::InitGoogleTest(&argc, argv); 30 | gflags::ParseCommandLineFlags(&argc, &argv, true); 31 | google::InitGoogleLogging(argv[0]); 32 | 33 | // init sodium security library 34 | if (::sodium_init() == -1) { 35 | LOG(ERROR) << "Failed initializing sodium"; 36 | return -1; 37 | } 38 | 39 | // Run the tests 40 | return RUN_ALL_TESTS(); 41 | } 42 | -------------------------------------------------------------------------------- /fbzmq/zmq/tests/MessageTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace { 15 | 16 | std::string 17 | genRandomStr(const int len) { 18 | std::string s; 19 | s.resize(len); 20 | 21 | static const std::string alphanum = 22 | "0123456789" 23 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 24 | "abcdefghijklmnopqrstuvwxyz"; 25 | 26 | for (int i = 0; i < len; ++i) { 27 | s[i] = alphanum.at(folly::Random::rand32() % alphanum.size()); 28 | } 29 | 30 | return s; 31 | } 32 | 33 | } // anonymous namespace 34 | 35 | namespace fbzmq { 36 | 37 | TEST(Message, Allocate) { 38 | auto msg = fbzmq::Message::allocate(128); 39 | EXPECT_TRUE(msg.hasValue()); 40 | EXPECT_EQ(128, msg.value().size()); 41 | } 42 | 43 | TEST(Message, isLastLocal) { 44 | auto msg = fbzmq::Message::allocate(128).value(); 45 | EXPECT_TRUE(msg.isLast()); 46 | } 47 | 48 | TEST(Message, CopyCtor) { 49 | auto msg1 = fbzmq::Message::from(genRandomStr(128)).value(); 50 | fbzmq::Message msg2 = msg1; 51 | EXPECT_TRUE( 52 | std::equal(msg1.data().begin(), msg1.data().end(), msg2.data().begin())); 53 | } 54 | 55 | TEST(Message, MoveCtor) { 56 | auto msg1 = fbzmq::Message::allocate(128).value(); 57 | fbzmq::Message msg2 = std::move(msg1); 58 | EXPECT_TRUE(msg1.empty()); 59 | EXPECT_FALSE(msg2.empty()); 60 | } 61 | 62 | TEST(Message, CopyAssign) { 63 | auto msg1 = fbzmq::Message::from(genRandomStr(128)).value(); 64 | fbzmq::Message msg2; 65 | msg2 = msg1; 66 | EXPECT_TRUE( 67 | std::equal(msg1.data().begin(), msg1.data().end(), msg2.data().begin())); 68 | } 69 | 70 | TEST(Message, MoveAssign) { 71 | auto msg1 = fbzmq::Message::allocate(128).value(); 72 | fbzmq::Message msg2; 73 | msg2 = std::move(msg1); 74 | EXPECT_EQ(128, msg2.size()); 75 | EXPECT_TRUE(msg1.empty()); 76 | } 77 | 78 | TEST(Message, WrapBuffer) { 79 | auto buf = folly::IOBuf::createCombined(128); 80 | // mark all space as used 81 | buf->append(128); 82 | { 83 | EXPECT_EQ(128, buf->length()); 84 | auto result = fbzmq::Message::wrapBuffer(buf->clone()); 85 | EXPECT_EQ(128, result->size()); 86 | EXPECT_TRUE(buf->isShared()); 87 | EXPECT_TRUE(result.hasValue()); 88 | } 89 | // message has been destructed, IOBuf should be released 90 | EXPECT_FALSE(buf->isShared()); 91 | } 92 | 93 | } // namespace fbzmq 94 | 95 | int 96 | main(int argc, char* argv[]) { 97 | // Parse command line flags 98 | testing::InitGoogleTest(&argc, argv); 99 | gflags::ParseCommandLineFlags(&argc, &argv, true); 100 | google::InitGoogleLogging(argv[0]); 101 | 102 | // init sodium security library 103 | if (::sodium_init() == -1) { 104 | LOG(ERROR) << "Failed initializing sodium"; 105 | return -1; 106 | } 107 | 108 | // Run the tests 109 | return RUN_ALL_TESTS(); 110 | } 111 | -------------------------------------------------------------------------------- /fbzmq/zmq/tests/SystemMetricsTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace fbzmq { 15 | 16 | TEST(SystemMetricsTest, MemoryStats) { 17 | SystemMetrics systemMetrics_{}; 18 | 19 | folly::Optional rssMem1 = systemMetrics_.getRSSMemBytes(); 20 | EXPECT_TRUE(rssMem1.hasValue()); 21 | 22 | // check sanity of return value, check for > 1MB and < 100MB 23 | EXPECT_GT(rssMem1.value() / 1e6, 1); 24 | EXPECT_LT(rssMem1.value() / 1e6, 100); 25 | 26 | // fill about 100 Mbytes of memory and check if monitor reports the increase 27 | std::vector v(13 * 0x100000); 28 | fill(v.begin(), v.end(), 1); 29 | 30 | folly::Optional rssMem2 = systemMetrics_.getRSSMemBytes(); 31 | EXPECT_TRUE(rssMem2.hasValue()); 32 | EXPECT_GT(rssMem2.value(), rssMem1.value() + 100); 33 | } 34 | 35 | } // namespace fbzmq 36 | 37 | int 38 | main(int argc, char* argv[]) { 39 | // Parse command line flags 40 | testing::InitGoogleTest(&argc, argv); 41 | gflags::ParseCommandLineFlags(&argc, &argv, true); 42 | google::InitGoogleLogging(argv[0]); 43 | 44 | // init sodium security library 45 | if (::sodium_init() == -1) { 46 | LOG(ERROR) << "Failed initializing sodium"; 47 | return -1; 48 | } 49 | 50 | // Run the tests 51 | return RUN_ALL_TESTS(); 52 | } 53 | -------------------------------------------------------------------------------- /fbzmq/zmq/tests/Test.thrift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | namespace cpp2 fbzmq.test 9 | 10 | cpp_include "folly/io/IOBuf.h" 11 | 12 | // we'll use raw IOBuf to pass our serialized thrift data 13 | typedef binary (cpp2.type = "folly::IOBuf") IOBuf 14 | 15 | // we'll be writing this structure into KV store 16 | struct TestValue { 17 | 1: string value; 18 | } 19 | 20 | // a value as reported in get replies/publications 21 | struct WrapperValue { 22 | 1: i64 version; 23 | // the use of move-only object makes Value non-copyable 24 | 2: IOBuf value; 25 | } 26 | --------------------------------------------------------------------------------