Skip to content

Commit

Permalink
initial cmake
Browse files Browse the repository at this point in the history
rework build system
  • Loading branch information
mszabo-wikia committed Jul 27, 2024
1 parent c18055d commit 69bde06
Show file tree
Hide file tree
Showing 182 changed files with 15,818 additions and 18 deletions.
172 changes: 172 additions & 0 deletions .github/workflows/getdeps_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# This file was @generated by getdeps.py

name: linux

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Show disk space at start
run: df -h
- name: Free up disk space
run: sudo rm -rf /usr/local/lib/android
- name: Show disk space after freeing up
run: df -h
- name: Update system package info
run: sudo apt-get update
- name: Install system deps
run: sudo python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive mcrouter
- name: Install packaging system deps
run: sudo python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive patchelf
- name: Fetch ninja
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests ninja
- name: Fetch cmake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests cmake
- name: Fetch fmt
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests fmt
- name: Fetch googletest
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests googletest
- name: Fetch python-six
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests python-six
- name: Fetch zstd
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests zstd
- name: Fetch zlib
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests zlib
- name: Fetch boost
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests boost
- name: Fetch double-conversion
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests double-conversion
- name: Fetch gflags
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests gflags
- name: Fetch glog
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests glog
- name: Fetch libdwarf
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests libdwarf
- name: Fetch libevent
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests libevent
- name: Fetch lz4
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests lz4
- name: Fetch snappy
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests snappy
- name: Fetch bz2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests bz2
- name: Fetch autoconf
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests autoconf
- name: Fetch automake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests automake
- name: Fetch libtool
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests libtool
- name: Fetch ragel
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests ragel
- name: Fetch libiberty
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests libiberty
- name: Fetch libsodium
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests libsodium
- name: Fetch libunwind
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests libunwind
- name: Fetch xz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests xz
- name: Fetch folly
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests folly
- name: Fetch fizz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests fizz
- name: Fetch wangle
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests wangle
- name: Fetch mvfst
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests mvfst
- name: Fetch libffi
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests libffi
- name: Fetch ncurses
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests ncurses
- name: Fetch python
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests python
- name: Fetch fbthrift
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests fbthrift
- name: Build ninja
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests ninja
- name: Build cmake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests cmake
- name: Build fmt
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests fmt
- name: Build googletest
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests googletest
- name: Build python-six
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests python-six
- name: Build zstd
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests zstd
- name: Build zlib
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests zlib
- name: Build boost
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests boost
- name: Build double-conversion
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests double-conversion
- name: Build gflags
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests gflags
- name: Build glog
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests glog
- name: Build libdwarf
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests libdwarf
- name: Build libevent
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests libevent
- name: Build lz4
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests lz4
- name: Build snappy
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests snappy
- name: Build bz2
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests bz2
- name: Build autoconf
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests autoconf
- name: Build automake
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests automake
- name: Build libtool
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests libtool
- name: Build ragel
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests ragel
- name: Build libiberty
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests libiberty
- name: Build libsodium
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests libsodium
- name: Build libunwind
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests libunwind
- name: Build xz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests xz
- name: Build folly
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests folly
- name: Build fizz
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests fizz
- name: Build wangle
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests wangle
- name: Build mvfst
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests mvfst
- name: Build libffi
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests libffi
- name: Build ncurses
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests ncurses
- name: Build python
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests python
- name: Build fbthrift
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests fbthrift
- name: Build mcrouter
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --src-dir=. mcrouter --project-install-prefix mcrouter:/usr/local
- name: Copy artifacts
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fixup-dyn-deps --strip --src-dir=. mcrouter _artifacts/linux --project-install-prefix mcrouter:/usr/local --final-install-prefix /usr/local
- uses: actions/upload-artifact@v2
with:
name: mcrouter
path: _artifacts
- name: Test mcrouter
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages test --src-dir=. mcrouter --project-install-prefix mcrouter:/usr/local
- name: Show disk space at end
run: df -h
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
compile_commands.json
1 change: 1 addition & 0 deletions .projectid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mcrouter
69 changes: 69 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE file
# in the root directory of this source tree.

cmake_minimum_required(VERSION 3.10)

project(mcrouter)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build/fbcode_builder/CMake"
${CMAKE_MODULE_PATH})

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(BUILD_TESTS "If enabled, compile the tests." OFF)

# Disable Meta-specific functionality for the OSS build.
add_compile_definitions(LIBMC_FBTRACE_DISABLE DISABLE_COMPRESSION)

if(WIN32)
include(FBCompilerSettingsMSVC)
else()
include(FBCompilerSettingsUnix)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fno-coroutines -Wno-unused-parameter -Wno-uninitialized -Wno-maybe-uninitialized"
)

# Create symlink to compile_commands.json for IDE to pick it up
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
)
endif()

# Set up options for generated Thrift client code
include(FBThriftLibrary)
set(THRIFT_OPTIONS stack_arguments sync_methods_return_try
deprecated_terse_writes)

find_package(Boost 1.65.1 REQUIRED COMPONENTS system thread filesystem regex
context program_options)

find_package(fmt REQUIRED)
find_package(folly REQUIRED)
find_package(Fizz REQUIRED)
find_package(Glog REQUIRED)
find_package(gflags REQUIRED)
find_package(wangle REQUIRED)
find_package(FBThrift REQUIRED)

include_directories(.)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

if(BUILD_TESTS)
enable_testing()
include(CTest)

find_package(GTest MODULE REQUIRED)

include(GoogleTest)
endif()

add_subdirectory(mcrouter)

install(TARGETS mcrouter mcpiper)
5 changes: 5 additions & 0 deletions build/fbcode_builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Facebook-internal CI builds don't have write permission outside of the
# source tree, so we install all projects into this directory.
/facebook_ci
__pycache__/
*.pyc
15 changes: 15 additions & 0 deletions build/fbcode_builder/CMake/FBBuildOptions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Facebook, Inc. and its affiliates.

function (fb_activate_static_library_option)
option(USE_STATIC_DEPS_ON_UNIX
"If enabled, use static dependencies on unix systems. This is generally discouraged."
OFF
)
# Mark USE_STATIC_DEPS_ON_UNIX as an "advanced" option, since enabling it
# is generally discouraged.
mark_as_advanced(USE_STATIC_DEPS_ON_UNIX)

if(UNIX AND USE_STATIC_DEPS_ON_UNIX)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE)
endif()
endfunction()
Loading

0 comments on commit 69bde06

Please sign in to comment.