Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add travis and small cleanups #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
language: cpp

dist: trusty
addons:
apt:
sources:
- george-edison55-precise-backports # For cmake
- llvm-toolchain-precise-3.6
- llvm-toolchain-trusty-6.0
- llvm-toolchain-trusty-7
- llvm-toolchain-trusty-8
- ubuntu-toolchain-r-test
packages:
- bison
- binutils
- binutils-gold
- build-essential
- cmake
- flex
# All the compilers!
- g++-4.9
- gcc-4.9
- g++-5
- gcc-5
- g++-6
- gcc-6
- g++-8
- gcc-8
- g++-9
- gcc-9
- clang-3.6
- clang-6.0
- clang-8

script:
- eval $MATRIX_EVAL
- make

jobs:
include:
- stage: Build
name: "GCC 5 (Ubuntu Xenial - 16.04)"
env:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- stage: Build
name: "GCC 6 (Debian Stretch)"
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
- stage: Build
name: "GCC 8 (Ubuntu Latest)"
env:
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
- stage: Build
name: "GCC 9 (Latest Release)"
env:
- MATRIX_EVAL="CC=gcc-9 && CXX=g++-9"
- stage: Build
name: "clang-3.6 (Earliest supported)"
env:
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
- stage: Build
name: "clang-6.0 (Debian + Ubuntu common)"
env:
- MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
- stage: Build
name: "clang-8 (Latest Release)"
env:
- MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ project("libsdcparse")
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
#Only set compiler settings if we are not a sub-project
set(WARN_FLAGS "-Wall -Wextra -Wpedantic -Wcast-qual -Wcast-align -Wshadow -Wformat=2 -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wswitch-default -Wundef -Wunused-variable -Wdisabled-optimization -Wnoexcept -Woverloaded-virtual -Wctor-dtor-privacy -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 ${WARN_FLAGS}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 ${WARN_FLAGS}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
set(FLEX_BISON_WARN_SUPPRESS_FLAGS "-Wno-switch-default -Wno-unused-parameter -Wno-missing-declarations")
endif()

Expand Down Expand Up @@ -40,11 +40,28 @@ if(FLEX_BISON_WARN_SUPPRESS_FLAGS)
PROPERTIES COMPILE_FLAGS ${FLEX_BISON_WARN_SUPPRESS_FLAGS})
endif()

# Grammars generated by Bison 3.0.4 and below emit a null pointer dereference warning
# when compiled with GCC 7
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Werror=null-dereference NULL_DEREFERENCE)
if (${NULL_DEREFERENCE} AND ${BISON_VERSION} VERSION_LESS 3.0.5)
get_source_file_property(BISON_COMPILE_FLAGS ${BISON_SdcParser_OUTPUT_SOURCE} COMPILE_FLAGS)
set_source_files_properties(${BISON_SdcParser_OUTPUT_SOURCE}
PROPERTIES COMPILE_FLAGS ${BISON_COMILE_FLAGS} -Wno-error=null-dereference)
endif()

check_cxx_compiler_flag(-Wswitch-default SWITCH_DEFAULT)
if (${SWITCH_DEFAULT})
get_source_file_property(BISON_COMPILE_FLAGS ${BISON_SdcParser_OUTPUT_SOURCE} COMPILE_FLAGS)
set_source_files_properties(${BISON_SdcParser_OUTPUT_SOURCE}
PROPERTIES COMPILE_FLAGS ${BISON_COMILE_FLAGS} -Wno-switch-default)
endif()

#Create the library
add_library(libsdcparse STATIC
${LIB_HEADERS}
${LIB_SOURCES}
${FLEX_SdcLexer_OUTPUTS}
${FLEX_SdcLexer_OUTPUTS}
${BISON_SdcParser_OUTPUT_SOURCE})
target_include_directories(libsdcparse PUBLIC ${LIB_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(libsdcparse PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
NUM_PROC=$(shell nproc)

SOURCE_DIR := $(PWD)
BUILD_DIR ?= build

.PHONY: all clean $(MAKECMDGOALS)

${BUILD_DIR}/Makefile:
mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR} && cmake ${SOURCE_DIR}

all $(MAKECMDGOALS): $(BUILD_DIR)/Makefile
$(MAKE) -k -j${NUM_PROC} -C $(BUILD_DIR) $(MAKECMDGOALS) \
|| $(MAKE) -j1 -C $(BUILD_DIR) $(MAKECMDGOALS)