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

Commit

Permalink
Squashed 'deps/ccommon/' changes from f5efe29..1c8df42
Browse files Browse the repository at this point in the history
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: 1c8df42
  • Loading branch information
Yao Yue committed Jul 11, 2019
1 parent b93c69d commit d6ed7ed
Show file tree
Hide file tree
Showing 66 changed files with 2,896 additions and 1,702 deletions.
103 changes: 10 additions & 93 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,34 @@ 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


# 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
- name: "gcc-5 on Linux, Rust enabled"
compiler: gcc
env:
- 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
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
osx_image: xcode10.1
compiler: clang

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
54 changes: 36 additions & 18 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 Down Expand Up @@ -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,7 +144,10 @@ 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
Expand All @@ -159,28 +174,32 @@ 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}")
add_subdirectory(test)
endif(CHECK_WORKING)


if(HAVE_RUST)
enable_language(Rust)
include(CMakeCargo)
add_subdirectory(rust)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_RUST=1")
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 +208,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})
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
20 changes: 18 additions & 2 deletions ci/install-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,28 @@ CHECK_VERSION=0.12.0
CHECK_TARBALL="check-${CHECK_VERSION}.tar.gz"
CHECK_DIR="check-${CHECK_VERSION}"

echo "building and installing check" >&2

(
cd "$TEMP" &&
wget "https://github.com/libcheck/check/releases/download/${CHECK_VERSION}/${CHECK_TARBALL}" &&
tar xvfz "${CHECK_TARBALL}" &&
tar xfz "${CHECK_TARBALL}" &&
cd "${CHECK_DIR}" &&
./configure --prefix="$CHECK_PREFIX" &&
make &&
make install
) || die "check build failed"
) >$TEMP/cmake-build.log 2>&1

RESULT=$?
if [[ $RESULT -ne 0 ]]; then
cat >&2 <<EOS
check build failed! log below:
EOS

cat $TEMP/cmake-build.log
else
echo "Success!" >&2
fi

exit $RESULT
55 changes: 55 additions & 0 deletions ci/local-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

## This file is potentially useful for doing a clean environment build on MacOS ##
## This is my personal way of running the build, YMMV - jsimms ##

set -euo pipefail
IFS=$'\n\t'

die() { echo "fatal: $*" >&2; exit 1; }

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

cd "$TOPLEVEL"

TEMP="$(mktemp -d -t TEMP.XXXXXXX)" || die "failed to make tmpdir"
cleanup() { [[ -n "${TEMP:-}" ]] && rm -rf "${TEMP}"; }
trap cleanup EXIT

BUILD_PATH=(
"$HOME/.cargo/bin"
"/usr/local/bin"
"/usr/local/sbin"
"/usr/bin"
"/usr/sbin"
"/bin"
"/sbin"
"/opt/X11/bin"
"/usr/X11R6/bin"
)

PATH=$(echo "${BUILD_PATH[@]}"|tr ' ' ':')

cat >&2 <<EOS
CC=${CC:-}
CFLAGS=${CFLAGS:-}
LDFLAGS=${LDFLAGS:-}
PATH=${PATH:-}
EOS

CMAKEFLAGS=(
-DHAVE_RUST=yes
-DRUST_VERBOSE_BUILD=yes
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
)

BUILD_DIR="${BUILD_DIR:-$TEMP}"

mkdir -p "$BUILD_DIR" && (
cd "$BUILD_DIR" &&
cmake "${CMAKEFLAGS[@]}" "$TOPLEVEL" &&
make all &&
make check &&
cd rust &&
cargo test
)
2 changes: 1 addition & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi

export RUST_BACKTRACE=full

mkdir -p _build && ( cd _build && "${cmake_cmd[@]}" .. && make -j && make check )
mkdir -p _build && ( cd _build && "${cmake_cmd[@]}" .. && make && make check )
RESULT=$?

egrep -r ":F:|:E:" . |grep -v 'Binary file' || true
Expand Down
Loading

0 comments on commit d6ed7ed

Please sign in to comment.