Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
rizsotto committed Sep 13, 2020
2 parents beee984 + 5733a68 commit f8d5c95
Show file tree
Hide file tree
Showing 292 changed files with 16,258 additions and 4,749 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build_on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: continuous integration

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-20.04, macos-10.15]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install package dependencies
if: startsWith( matrix.os, 'ubuntu' )
run: |
sudo apt-get update -y
sudo apt-get install -y cmake pkg-config gfortran nvidia-cuda-toolkit valgrind \
libfmt-dev libspdlog-dev nlohmann-json3-dev
- name: Install package dependencies
if: startsWith( matrix.os, 'macos' )
run: |
brew install fmt spdlog nlohmann-json grpc pkg-config
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install python test dependencies
run: |
python -m pip install --upgrade pip
pip install lit pex pycodestyle
- name: Prepare
run: |
mkdir "$HOME/work/bear_build"
echo "::set-env name=BUILD_DIR::$HOME/work/bear_build"
mkdir "$HOME/work/bear_install"
echo "::set-env name=INSTALL_DIR::$HOME/work/bear_install"
echo "::add-path::$HOME/work/bear_install/bin"
- name: Build
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
cmake -B "$BUILD_DIR" -S "$GITHUB_WORKSPACE" -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR"
cmake --build "$BUILD_DIR" --parallel 4 --target install
- name: Prepare [functional test]
run: |
echo "::set-env name=ZLIB_SRC_DIR::$HOME/work/zlib"
git clone https://github.com/madler/zlib.git $HOME/work/zlib -b v1.2.11
- name: Execute [functional test]
run: |
mkdir $HOME/work/zlib_compilations && cd $HOME/work/zlib_compilations
bear -- $ZLIB_SRC_DIR/configure
bear -- make
cat compile_commands.json
$GITHUB_WORKSPACE/test/bin/assert_compilation compile_commands.json count -gt 30
- name: Execute [functional test]
run: |
mkdir $HOME/work/zlib_intercept && cd $HOME/work/zlib_intercept
intercept --output ignore.json -- $ZLIB_SRC_DIR/configure
intercept --output commands.json -- make
cat commands.json
$GITHUB_WORKSPACE/test/bin/assert_intercepted commands.json count -gt 30
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Output/
Cargo.lock
target/
.DS_Store
cmake-build-debug/
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

122 changes: 90 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,104 @@
cmake_minimum_required(VERSION 2.8)

project(bear C)
set(BEAR_VERSION "2.4.4")

option(USE_SHELL_COMPLETION "Optionally add shell completion" ON)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
if (${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else ()
cmake_policy(VERSION 3.12)
endif ()

include(GNUInstallDirs)
install(FILES COPYING README.md ChangeLog.md
DESTINATION ${CMAKE_INSTALL_DOCDIR})
set(default_build_type "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

include(CheckCCompilerFlag)
check_c_compiler_flag("-std=c99" C99_SUPPORTED)
if (C99_SUPPORTED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
endif()
project(Bear
VERSION 3.0.0
DESCRIPTION "Bear is a tool to generate compilation database for clang tooling."
LANGUAGES C CXX
)

add_definitions(-D_GNU_SOURCE)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
option(ENABLE_UNIT_TESTS "Build and run unit test for this project" ON)
option(ENABLE_FUNC_TESTS "Build and run functional test for this project" ON)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Rogue")
# Superbuild variables for sub projects
include(ExternalProject)
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/subprojects)
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage)
set(DEPENDENCIES_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/subprojects/Install)

set(EAR_LIB_FILE ${CMAKE_SHARED_LIBRARY_PREFIX}ear${CMAKE_SHARED_LIBRARY_SUFFIX})
set(EAR_LIB_PATH "${CMAKE_INSTALL_LIBDIR}/bear")
set(DEFAULT_PRELOAD_FILE ${CMAKE_INSTALL_PREFIX}/${EAR_LIB_PATH}/${EAR_LIB_FILE} CACHE STRING "Default path to libear.")
# Verify or install dependencies
add_subdirectory(third_party)

add_subdirectory(libear)
add_subdirectory(bear)
add_subdirectory(test)
add_subdirectory(man)
# Build the project itself
ExternalProject_Add(BearSource
SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/source"
DEPENDS
nlohmann_json_dependency fmt_dependency spdlog_dependency grpc_dependency
googletest_dependency
CMAKE_ARGS
-DCMAKE_PROJECT_VERSION=${CMAKE_PROJECT_VERSION}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
CMAKE_CACHE_ARGS
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_INSTALL_PREFIX:PATH=${STAGED_INSTALL_PREFIX}
-DROOT_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DENABLE_UNIT_TESTS:BOOL=${ENABLE_UNIT_TESTS}
BUILD_ALWAYS
1
TEST_BEFORE_INSTALL
1
TEST_COMMAND
ctest # or `ctest -T memcheck`
)

if (USE_SHELL_COMPLETION)
add_subdirectory(shell-completion)
# Run the functional tests
if (ENABLE_FUNC_TESTS)
ExternalProject_Add(BearTest
SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/test"
DEPENDS
BearSource
CMAKE_CACHE_ARGS
-DSTAGED_INSTALL_PREFIX:PATH=${STAGED_INSTALL_PREFIX}
TEST_BEFORE_INSTALL
1
INSTALL_COMMAND
""
TEST_COMMAND
ctest --verbose
)
endif ()

# Install the project artifacts from the staged directory
install(
DIRECTORY
${STAGED_INSTALL_PREFIX}/
DESTINATION
.
USE_SOURCE_PERMISSIONS
)
include(GNUInstallDirs)
install(FILES COPYING README.md INSTALL.md CONTRIBUTING.md CODE_OF_CONDUCT.md
DESTINATION ${CMAKE_INSTALL_DOCDIR})

# Set up package from this project
set(CPACK_PACKAGE_NAME "bear")
set(CPACK_PACKAGE_CONTACT "László Nagy")
set(CPACK_PACKAGE_VENDOR ${CPACK_PACKAGE_CONTACT})
set(CPACK_PACKAGE_VERSION ${BEAR_VERSION})
set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "BuildEAR")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
Expand All @@ -51,7 +109,7 @@ set(CPACK_RPM_PACKAGE_GROUP "Development/Tools")
set(CPACK_RPM_PACKAGE_URL "http://github.com/rizsotto/Bear")
set(CPACK_RPM_PACKAGE_DESCRIPTION "Bear is a tool to generate compilation database for clang tooling.")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
"${CMAKE_INSTALL_MANDIR}"
"${CMAKE_INSTALL_MANDIR}/man1")
"${CMAKE_INSTALL_MANDIR}"
"${CMAKE_INSTALL_MANDIR}/man1")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
include(CPack)
86 changes: 86 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at *[email protected]*. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

File renamed without changes.
Loading

0 comments on commit f8d5c95

Please sign in to comment.