Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
Squashed 'deps/ccommon/' changes from f5efe29..6b1d8d5
Browse files Browse the repository at this point in the history
6b1d8d5 Improve the Rust build story (twitter#240)
5955d6b move nodelay setting to the server socket, and accepted connections will inherit that (twitter#238)
aafd20f formatting (twitter#237)
3b5c069 Update ccommon_rs to use bytes v5.0 (twitter#235)
df74087 Address clippy lints in rust code (twitter#234)
7c5bbd1 Make metrics and options Send + Sync (twitter#233)
c2e617e Ensure that manually implemented C options use the correct name (twitter#232)
6e76741 Add some docs
b5b4c5a Change check_pipe to use nanosleep instead of usleep (twitter#231)
eb0a389 Use name of field instead of description for C metrics (twitter#230)
16ddc76 Fix broken buf impls (twitter#229)
eefcdcb Avoid redundant rebuilds of rust packages in CI (twitter#228)
33f62a8 Update bindgen to also generate bindings recursively (twitter#227)
27ffc7c Implement bytes::Buf and Bytes::ButMut on Buf and OwnedBuf (twitter#226)
f873930 Various small bugfixes and usability improvements for rust code (twitter#225)
37a1ecd Port option parsing module to Rust (twitter#224)
38f7556 Fix failed test detection (twitter#215)
0ab1604 Conditionally use std::any::type_name if it's supported (twitter#223)
98176d3 Backport changes from twitter#265 (twitter#222)
ba54096 Remove test for removed rust logging functionality (twitter#221)
519118d Rewrite cmake cargo build wrapper (twitter#220)
5d23b3a Fix some small typos found in twitter#263 (twitter#219)
475dda7 Clean up logging shim (twitter#218)
1d28dd2 Expand rust bindings to add options, metrics, and ccbox (twitter#217)
88b5400 Upstream changes from twitter#261 (twitter#216)
4e99e63 fix a bug and change how check is found (twitter#214)
54067ef slightly simplify accept error-handling logic (twitter#210)
e9fe980 Fix synchronize ccommon with pelikan deps/ccommon (twitter#212)
7eb6424 Cleanup libcheck related code (twitter#211)
683bc1a cc_bstring simplify and fix (twitter#207)
8737d99 continue on server socket on non-blocking errors (twitter#209)
2a62281 add atoi64 to bstring (twitter#206)
f71c657 cc_option simplify _allowed_in_name (twitter#205)
24e3131 Add ITT instrumentation option (twitter#204)
236c98d Fix docs (twitter#200)
e58f6a8 cc_array and cc_ring_array NULL fixes (twitter#201)
1c8df42 Add basic support of build type (twitter#199)
7107988 Fix now_ns() (twitter#198)
da240e5 cc: extend cc_util module (twitter#196)
4846b15 Fix TAILQ_REINIT (twitter#195)
4f5dbb0 Update Cmake version to 2.8 (twitter#197)
2e6f78a cc_mm use OS_DARWIN macro to detect OS (twitter#194)
57acaf6 cc: extend queue module (twitter#193)
a64ada2 cc: extend duration module (twitter#192)
b117632 reverting CMake file changes (twitter#191)
dea5bee backport changes made to ccommon in pelikan (twitter#190)
a4c0334 add linebreak to stats_log() (twitter#188)
05eb03e fix inconsistent naming and bump version (twitter#187)
4acc53a Stats to file (twitter#186)
2168fec minimize osx build config (twitter#185)
42b24de Simplify rust options, specify fewer output targets (twitter#183)
c9fa905 update CMakeRust used to latest version, tweaks to make build work (twitter#184)
2ef0163 Reorder dependency includes in cmake, don't parallel build (twitter#182)
a6a54d9 remove endian-specific logic from str*cmp (twitter#177)
4c0668b epoll_create* ignores size hint in newer kernels, switch to new API (twitter#179)
c9c5ee5 improve cc_bstring string literal and cstring names (twitter#176)
0184d73 Add unit tests for buffer, fix buf/dbuf bugs and refactor (twitter#174)
d7dab43 create a .cargo/config so intellij uses the same target dir as cmake (twitter#173)
e710712 use accept4 for tcp_accept when available (twitter#171)
21ba10e Remove cargo lock for shared lib, closes twitter#169 (twitter#172)
24660f1 update style guide (twitter#170)
17baf1e Per thread logging (twitter#168)

git-subtree-dir: deps/ccommon
git-subtree-split: 6b1d8d56b214e2a9d448625fe53303d57b4ac6d1
  • Loading branch information
brayniac committed Mar 25, 2020
1 parent b93c69d commit 13dc94d
Show file tree
Hide file tree
Showing 130 changed files with 8,070 additions and 2,203 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ cscope.*
lcov

CMAKE_BINARY_DIR

# Generated Rust Bindings
bindings.rs

# Cargo lock file
Cargo.lock

# Cargo build path
target
110 changes: 15 additions & 95 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
sudo: false
language: c
dist: xenial

# using anchor to import sources into linux builds
addons:
apt: &apt
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- llvm-toolchain-precise-3.7
- llvm-toolchain-precise

# important for allowed-to-fail matching
# see https://docs.travis-ci.com/user/customizing-the-build#Rows-that-are-Allowed-to-Fail
Expand All @@ -18,115 +16,37 @@ env:
# travis currently does not support directly setting gcc/clang with versions
# (e.g. gcc-4.8) as value for the compiler key. So we will have to manually
# request these packages and use environment varibles to create the matrix.
#
# In the case of osx, use brew to install the paritcular versions, instead of
# specifying with packages.
matrix:
include:
# gcc 4.8 on linux
- env:
- C_COMPILER=gcc-4.8
- name: "gcc-5 on Linux"
compiler: gcc
addons:
apt:
<<: *apt
packages:
- gcc-4.8
- libsubunit-dev

- os: osx
osx_image: xcode10.1
compiler: clang

# gcc 4.9 on linux
- env:
- C_COMPILER=gcc-4.9
addons:
apt:
<<: *apt
packages:
- gcc-4.9
- libsubunit-dev

# gcc 5 on linux
- env:
- C_COMPILER=gcc-5
addons:
apt:
<<: *apt
packages:
- gcc-5
- libsubunit-dev

# gcc 5 on linux
- env:
- C_COMPILER=gcc-5
- RUST_ENABLED=1
addons:
apt:
<<: *apt
packages:
- gcc-5
- libsubunit-dev

# clang 3.6 on linux
- env:
- C_COMPILER=clang-3.6
addons:
apt:
<<: *apt
packages:
- clang-3.6
- libsubunit-dev

# clang 3.7 on linux
- env:
- C_COMPILER=clang-3.7
- name: "cargo build"
language: rust
addons:
apt:
<<: *apt
packages:
- clang-3.7
- libsubunit-dev

## gcc 4.8 on osx
#- os: osx
# env: FORMULA=gcc48 COMPILER=gcc C_COMPILER=gcc-4.8
#
## gcc 4.9 on osx
#- os: osx
# env: FORMULA=gcc49 COMPILER=gcc C_COMPILER=gcc-4.9
#
## gcc 5 on osx
#- os: osx
# env: FORMULA=gcc5 COMPILER=gcc C_COMPILER=gcc-5

# OSX 10.13
# Apple LLVM version 9.1.0 (clang-902.0.39.2)
# Target: x86_64-apple-darwin17.6.0
- os: osx
osx_image: xcode9.4
env:
- C_COMPILER=clang
- ALLOWED_TO_FAIL=1

# OSX 10.12
# Apple LLVM version 9.0.0 (clang-900.0.39.2)
# Target: x86_64-apple-darwin16.7.0
- os: osx
osx_image: xcode9.2
env:
- C_COMPILER=clang
- ALLOWED_TO_FAIL=1
script:
- cargo build
- cargo test
- cargo build --release
- cargo test --release

allow_failures:
- os: osx
osx_image: xcode9.4
env:
- C_COMPILER=clang
- ALLOWED_TO_FAIL=1

- os: osx
osx_image: xcode9.2
env:
- C_COMPILER=clang
- ALLOWED_TO_FAIL=1
osx_image: xcode10.1
compiler: clang

before_install:
- ./ci/before-install.sh
Expand Down
85 changes: 61 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.8)
project(ccommon C)

# Uncomment the following to output dependency graph debugging messages
# set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)

enable_testing()

###################
Expand Down Expand Up @@ -36,8 +39,8 @@ endif()
# config.h.in has to include entries set/tested here for them to have effect

# version info
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 2)
set(${PROJECT_NAME}_VERSION_MAJOR 2)
set(${PROJECT_NAME}_VERSION_MINOR 1)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}
Expand All @@ -54,6 +57,7 @@ option(HAVE_STATS "stats enabled by default" ON)
option(HAVE_DEBUG_MM "debugging oriented memory management disabled by default" OFF)
option(COVERAGE "code coverage" OFF)
option(HAVE_RUST "rust bindings not built by default" OFF)
option(HAVE_ITT_INSTRUMENTATION "instrument code with ITT API" OFF)

if(HAVE_RUST)
option(RUST_VERBOSE_BUILD "pass -vv to cargo compilation" OFF)
Expand All @@ -78,7 +82,6 @@ if(BUILD_AND_INSTALL_CHECK)

set(CHECK_ROOT_DIR "${LIBCHECK_PREFIX}")
set(CMAKE_REQUIRED_INCLUDES "${CHECK_ROOT_DIR}/include") # these make check link correctly in ccommon and pelikan
set(CMAKE_REQUIRED_LIBRARIES "${CHECK_ROOT_DIR}/lib")
endif()

include(CheckIncludeFiles)
Expand All @@ -96,9 +99,7 @@ check_symbol_exists(sys_signame signal.h HAVE_SIGNAME)

include(CheckFunctionExists)
check_function_exists(backtrace HAVE_BACKTRACE)

include(TestBigEndian)
test_big_endian(HAVE_BIG_ENDIAN)
check_function_exists(accept4 HAVE_ACCEPT4)

# how to use config.h.in to generate config.h
# this has to be set _after_ the above checks
Expand All @@ -114,12 +115,23 @@ configure_file(
# set compiler flags
# string concat is easier in 3.0, but older versions don't have the concat subcommand
# so we are using list as input until we move to new version
# TODO add build types
add_definitions(-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64)
# Set a default build type (Release) if none was specified

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()

set(CMAKE_MACOSX_RPATH 1)
set(CFLAGS_LIST
"-std=c11 "
"-ggdb3 -O2 "
"-ggdb3 "
"-Wall "
"-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls "
"-Wunused-function -Wunused-value -Wunused-variable "
Expand All @@ -132,13 +144,15 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()

if (COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -Wall -W -fprofile-arcs -ftest-coverage")
if(NOT ${CMAKE_BUILD_TYPE} MATCHES Debug)
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading" )
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
endif(COVERAGE)

# test dependencies
include(FindPackageHandleStandardArgs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

find_package(Check)
if(NOT CHECK_FOUND)
message(WARNING "Check is required to build and run tests")
Expand All @@ -150,6 +164,17 @@ if(CHECK_FOUND)
endif(NOT CHECK_WORKING)
endif(CHECK_FOUND)

if (HAVE_ITT_INSTRUMENTATION)
if(PKG_CONFIG_FOUND)
pkg_check_modules(ITTNOTIFY REQUIRED ittnotify>=1.0)
else()
find_package(ITTNOTIFY REQUIRED 1.0)
endif()
include_directories(${ITTNOTIFY_INCLUDE_DIRS})
link_directories(${ITTNOTIFY_LIBRARY_DIRS})
link_libraries(${ITTNOTIFY_LIBRARIES})
endif(HAVE_ITT_INSTRUMENTATION)

find_package(Threads)


Expand All @@ -159,28 +184,41 @@ include_directories(
"${PROJECT_BINARY_DIR}"
"include")

if(HAVE_RUST)
enable_language(Rust)
include(CMakeCargo)
add_subdirectory(rust)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_RUST=1")
endif()


###################
# things to build #
###################

add_subdirectory(src)
if(CHECK_WORKING)
include_directories(${include_directories} "${CHECK_INCLUDES}")

if(CHECK_FOUND)
include_directories(${include_directories} ${CHECK_INCLUDES})
add_subdirectory(test)
endif(CHECK_WORKING)
endif(CHECK_FOUND)

if(HAVE_RUST)
include(CMakeCargo)
add_subdirectory(rust)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_RUST=1")

if (${CMAKE_VERSION} VERSION_LESS "3.13.0")
# CMakeCargo requires the use of some newer features of cmake
# for changes to dependant libraries to cause a rebuild. This
# will never break the build, it is just annoying for development.
# Leave a warning here, but don't break the build for older cmake
# versions.
message(
WARNING
"Rust targets don't properly pick up changes to dependencies in cmake version <= 3.13"
)
endif()
endif()

###################
# print a summary #
###################

message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})

message(STATUS "PLATFORM: " ${OS_PLATFORM})

message(STATUS "CPPFLAGS: " ${CMAKE_CPP_FLAGS})
Expand All @@ -189,6 +227,5 @@ message(STATUS "CFLAGS: " ${CMAKE_C_FLAGS})
message(STATUS "HAVE_SIGNAME: " ${HAVE_SIGNAME})

message(STATUS "HAVE_BACKTRACE: " ${HAVE_BACKTRACE})
message(STATUS "HAVE_BIG_ENDIAN: " ${HAVE_BIG_ENDIAN})

message(STATUS "CHECK_WORKING: " ${CHECK_WORKING})
message(STATUS "CHECK_FOUND: " ${CHECK_FOUND})
17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[workspace]
members = [
"rust/ccommon-backend",
"rust/ccommon-derive",
"rust/ccommon-rs",
"rust/ccommon-sys",
]

[profile.bench]
debug = true
lto = true
codegen-units = 1

[profile.release]
debug = true
lto = true
codegen-units = 1
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2013-2015 Twitter, Inc
Copyright 2013-2018 Twitter, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
* Boston, MA 02111-1307, USA.
*/

We use the CMakeRust project (https://github.com/Devolutions/CMakeRust) under
the Apache 2.0 License.
15 changes: 0 additions & 15 deletions ci/before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ trap cleanup EXIT

TOPLEVEL="$(git -C "$(cd "$(dirname "$0")" >/dev/null || exit 1; pwd)" rev-parse --show-toplevel)" || die 'failed to find TOPLEVEL'

# for osx: 0. update brew; 1. install cmake if missing; 2. (gcc) unlink pre-installed gcc; 3. (gcc) install desired version of gcc

if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update &>/dev/null
brew install cmake || true # xcode 8.1 is missing cmake

if [[ "$C_COMPILER" =~ ^gcc && -n "${FORMULA:-}" ]]; then
brew unlink gcc || true
brew unlink "$FORMULA" || true
brew install "$FORMULA"
fi
fi

export CC="$C_COMPILER"

if [[ -n "${RUST_ENABLED:-}" ]]; then
curl https://sh.rustup.rs -sSf | sh -s -- -y
fi
Loading

0 comments on commit 13dc94d

Please sign in to comment.