Skip to content

Commit

Permalink
Squashed 'deps/ccommon/' changes from bb298bc..f5efe29
Browse files Browse the repository at this point in the history
f5efe29 forgot to remove unused include (twitter#167)
441934b update ring_array docs for new API, add multi threaded unit test for ring_array (twitter#166)
67ce9c2 Adding issue and pull request templates to comply with twitter OSS policies (twitter#151)
6b59401 Rust build tweak (twitter#165)
b39086d fix docs to new ring_array_destroy semantics (twitter#163)
95e04b0 Additional ring_array API (twitter#159)
3c994cc a single job in the travis-ci matrix for building with rust enabled (twitter#161)
1fe907e rust support - Native bstrings (twitter#160)
b3de2ee add HAVE_RUST option defaulted to off (twitter#158)
ffc70a8 Port travis ci changes - closes twitter#186 (twitter#155)
a2d5c01 add a function that will reject all pending incoming connections (twitter#154)
dd56abd break up ASSERT in buf_sock_read (twitter#153)
727905b adding a new API to duration timer (twitter#152)
9406717 add missing "extern C" qualifiers to a few headers for C++ linking; (twitter#150)
a0aafdf Add missing semicolon to ring array example code in documentation. (twitter#149)
9264bbb Zero byte (twitter#147) (emergency fix needed for pelikan)
d4002d7 simplify cc_print_int64 (twitter#146)
b164fcf Clean-up hash functions and introduce MurmurHash3 (twitter#145)
b1babb2 change wheel's sleep timer to make it less flaky (twitter#143)
ce0b9ea allow printing negative integers in cc_print (twitter#141)
ab0edc8 add metrics to track buf_sock objects (twitter#138)
ae02038 add travis ci (copied from pelikan) (twitter#139)
964645a Merge pull request twitter#135 from paegun/fix_cmake_install
70710c2 fixed and re-added cmake install instructions, w/ following notes: include directory made proper relative; opened pattern match b/c include directory should only contain files meant for inclusion.
5b095bc Merge pull request twitter#126 from kevyang/kevyang/120
426d56a return NULL when cc_alloc/cc_realloc is called with size == 0
ad271d4 Merge pull request twitter#133 from kevyang/132
47dbdba suppress unused parameter warning in debug_log_flush
648d19e Merge pull request twitter#127 from kevyang/56
780941a Merge pull request twitter#130 from kevyang/129
b8af6c0 Merge pull request twitter#131 from kevyang/128
6ecc318 fix duplicate symbols in cc_signal
080c41d cc_array - stop doing arithmetic on void *
d526f7a add debug oriented memory management
a4fb927 Update bool member rules in style guide
05c6e1e explicitly make ccommon a C project to avoid checking for CXX related variables

git-subtree-dir: deps/ccommon
git-subtree-split: f5efe29
  • Loading branch information
slyphon committed Jul 21, 2018
1 parent fdc7370 commit b93c69d
Show file tree
Hide file tree
Showing 65 changed files with 2,988 additions and 643 deletions.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
One line summary of the issue here.

### Expected behavior

As concisely as possible, describe the expected behavior.

### Actual behavior

As concisely as possible, describe the observed behavior.

### Steps to reproduce the behavior

Please list all relevant steps to reproduce the observed behavior.
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Problem

Explain the context and why you're making that change. What is the
problem you're trying to solve? In some cases there is not a problem
and this can be thought of being the motivation for your change.

Solution

Describe the modifications you've done.

Result

What will change as a result of your pull request? Note that sometimes
this section is unnecessary because it is self-explanatory based on
the solution.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ tags
# cscope
cscope.*
lcov

CMAKE_BINARY_DIR
135 changes: 135 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
sudo: false
language: c

# 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
env:
- ALLOWED_TO_FAIL=0

# 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
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
- 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

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

before_install:
- ./ci/before-install.sh

script:
- ./ci/run.sh
51 changes: 47 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.6)
project(ccommon)
project(ccommon C)

enable_testing()

Expand Down Expand Up @@ -37,8 +37,8 @@ endif()

# version info
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 0)
set(${PROJECT_NAME}_VERSION_PATCH 2)
set(${PROJECT_NAME}_VERSION_MINOR 2)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}
)
Expand All @@ -51,7 +51,35 @@ option(HAVE_ASSERT_LOG "assert_log enabled by default" ON)
option(HAVE_ASSERT_PANIC "assert_panic disabled by default" OFF)
option(HAVE_LOGGING "logging enabled by default" ON)
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)

if(HAVE_RUST)
option(RUST_VERBOSE_BUILD "pass -vv to cargo compilation" OFF)
endif()

if(BUILD_AND_INSTALL_CHECK)
# (simms) What follows is a crime against build systems as we run the build/install
# for the check library up front, during the planning phase.

set(LIBCHECK_PREFIX "${CMAKE_BINARY_DIR}/check")

# check for a local install of check
if(NOT EXISTS "${LIBCHECK_PREFIX}")
# (simms) This is terrible and I did it this way to ensure this gets built
# before the rest of the 'check' tests run. This should be rewritten so that
# the other dependencies know that there's a target that can build check
execute_process(
COMMAND "bash" "${PROJECT_SOURCE_DIR}/ci/install-check.sh" "${LIBCHECK_PREFIX}"
TIMEOUT 300 # if this doesn't build in 5 minutes something is hosed
)
endif()

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)
if(OS_PLATFORM STREQUAL "OS_LINUX")
Expand Down Expand Up @@ -99,13 +127,18 @@ set(CFLAGS_LIST
string(REPLACE "" "" CFLAGS ${CFLAGS_LIST})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS}")

if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--no-as-needed -ldl -pthread -fPIC")
endif()

if (COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -Wall -W -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 @@ -119,11 +152,21 @@ endif(CHECK_FOUND)

find_package(Threads)


# where to find include files
include_directories(${include_directories}
include_directories(
${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 #
###################
Expand Down
31 changes: 31 additions & 0 deletions ci/before-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

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

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

TEMP="$(mktemp -d -t TEMP.XXXXXXX)" || die "failed to make tmpdir"
cleanup() { [[ -n "${TEMP:-}" ]] && rm -rf "${TEMP}"; }
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
34 changes: 34 additions & 0 deletions ci/install-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

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

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

if [[ $# -lt 1 ]]; then
echo "Usage: $0 check-install-path"
exit 1
fi

CHECK_PREFIX="$1"
shift

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

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

CHECK_VERSION=0.12.0
CHECK_TARBALL="check-${CHECK_VERSION}.tar.gz"
CHECK_DIR="check-${CHECK_VERSION}"

(
cd "$TEMP" &&
wget "https://github.com/libcheck/check/releases/download/${CHECK_VERSION}/${CHECK_TARBALL}" &&
tar xvfz "${CHECK_TARBALL}" &&
cd "${CHECK_DIR}" &&
./configure --prefix="$CHECK_PREFIX" &&
make &&
make install
) || die "check build failed"
33 changes: 33 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

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

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

export PATH=$HOME/.cargo/bin:$PATH

cmake_cmd=(
cmake
-DBUILD_AND_INSTALL_CHECK=yes
)

if [[ -n "${RUST_ENABLED:-}" ]]; then
cmake_cmd+=( -DHAVE_RUST=yes -DRUST_VERBOSE_BUILD=yes )
fi

export RUST_BACKTRACE=full

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

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


if [[ $RESULT -ne 0 ]]; then
echo "Build failure" >&2
exit $RESULT
else
echo "success!" >&2
exit 0
fi
Loading

0 comments on commit b93c69d

Please sign in to comment.