Skip to content

Commit

Permalink
Adding top-level "master" make file and CTest integration
Browse files Browse the repository at this point in the history
 On branch master
 Your branch is ahead of 'origin/master' by 1 commit.
   (use "git push" to publish your local commits)

 Changes to be committed:
	modified:   .travis.yml
	modified:   CMakeLists.txt
	new file:   Makefile
	modified:   README.md
	modified:   bin/project.sh
	modified:   docs/CMakeLists.txt
	modified:   src/CMakeLists.txt
  • Loading branch information
ben-marshall committed Jul 29, 2016
1 parent 22ad024 commit 5024eec
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 49 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ install:
- sudo pip install cpp-coveralls

before_script:
- ./bin/project.sh
- make setup

script:
- cd ./build/debug/
- make parser
- make test
- make docs
- make debug
- make release
- make coverage
- make test-debug
- make test-release
- make test-coverage

after_success:
- pwd
- make coverage-report
- pwd
- coveralls -i ../../src/ -i ./src -b .src/CMakeFiles/verilogparser.dir/

- echo "Success"

after_failure:
- echo "Failure"
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ cmake_minimum_required(VERSION 2.8)

project(verilog-parser)

enable_testing()

add_subdirectory(./src)
add_subdirectory(./docs)

add_custom_target(test
add_custom_target(verilogparser-test
COMMAND ./bin/run-tests.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${EXECUTABLE_NAME}
Expand Down
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

#
# This is a simple top-level wrapper makefile for the rest of the project.
#

all: docs debug release coverage

.PHONY: docs setup clean

setup:
./bin/project.sh

docs:
$(MAKE) -C ./build/debug -B verilogparser-docs

debug:
$(MAKE) -C ./build/debug parser

release:
$(MAKE) -C ./build/release parser

coverage:
$(MAKE) -C ./build/coverage parser

clean:
$(MAKE) -C ./build/coverage clean
$(MAKE) -C ./build/debug clean
$(MAKE) -C ./build/release clean
rm -rf ./build/docs


test-all: test-debug test-release test-coverage

test-debug: debug
$(MAKE) -C ./build/debug test

test-release: release
$(MAKE) -C ./build/release test

test-coverage: coverage
$(MAKE) -C ./build/coverage test
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ Standard.
This will get you going workspace wise.

```sh
$> ./bin/project.sh
$> cd ./build/debug
$> make test
$> make all
$> make test-all
```

This will download the test suite files, setup the build directory, and
Expand Down
10 changes: 5 additions & 5 deletions bin/project.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

echo "Setting up project workspace..."
echo "----------------- Setup Project Workspace ---------------------------"

# Remove any remnant of the old work environment
rm -rf ./build
Expand All @@ -11,19 +11,19 @@ mkdir -p build/debug
mkdir -p build/coverage
mkdir -p build/docs

echo "Setup debug build environment..."
echo "----------------- Setup Debug Build Environment ---------------------"

cd ./build/debug
cmake -DCMAKE_BUILD_TYPE=Debug ../../
cd -

echo "Setup release build environment..."
echo "----------------- Setup Release Build Environment -------------------"

cd ./build/release
cmake -DCMAKE_BUILD_TYPE=Release ../../
cd -

echo "Setup coverage build environment..."
echo "----------------- Setup Coverage Build Environment ------------------"

cd ./build/coverage
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_COVERAGE=YES ../../
Expand All @@ -36,4 +36,4 @@ cd ../


echo " "
echo "Project workspace setup complete."
echo "----------------- Setup Coverage Build Environment ------------------"
2 changes: 1 addition & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(verilog-parser-docs)

find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(docs
add_custom_target(verilogparser-docs
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
Expand Down
82 changes: 52 additions & 30 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ SET(COV_FLAGS_LINK "-fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -W")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_C_FLAGS_RELEASE}")

if(${WITH_COVERAGE} == "YES" and ${CMAKE_BUILD_TYPE} == "Debug")
message(STATUS "Building with coverage flags set.")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COV_FLAGS_C}")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_C_FLAGS_RELEASE}
${COV_FLAGS_LINK}")
else
message(STATUS "Building without coverage.")
endif
if( ${WITH_COVERAGE} )

message(STATUS "Building with coverage flags set.")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COV_FLAGS_C}")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_C_FLAGS_RELEASE} ${COV_FLAGS_LINK}")

else()

message(STATUS "NOT building with coverage.")

endif()


SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
Expand All @@ -52,6 +55,8 @@ message(STATUS "Parser Link Flags Release: ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")

# ------------------------------------------------------------------------

cmake_policy(SET CMP0050 OLD)

ADD_CUSTOM_COMMAND(
SOURCE ${SOURCE_DIR}/${BISON_INPUT}
COMMAND ${BISON_EXECUTABLE}
Expand All @@ -69,6 +74,8 @@ ADD_CUSTOM_COMMAND(
OUTPUTS ${BINARY_DIR}/${FLEX_OUTPUT}
)

cmake_policy(SET CMP0050 NEW)

SET_SOURCE_FILES_PROPERTIES(${BINARY_DIR}/${FLEX_OUTPUT} GENERATED)
SET_SOURCE_FILES_PROPERTIES(${BINARY_DIR}/${BISON_OUTPUT} GENERATED)

Expand Down Expand Up @@ -96,30 +103,45 @@ target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME})

# ------------------------------------------------------------------------

file(GLOB COVERAGE_TEST_FILE_LIST "../tests/*.v")

file(GLOB COVERAGE_SRC_FILES "./*.c")
file(GLOB TEST_FILE_LIST "../tests/*.[vh]")

set(COVERAGE_GEN_FILES
${BINARY_DIR}/${FLEX_OUTPUT} ${BINARY_DIR}/${BISON_OUTPUT}
)
foreach ( TESTFILE ${TEST_FILE_LIST} )

add_custom_target(coverage-tests
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/parser ${COVERAGE_TEST_FILE_LIST}
WORKING_DIRECTORY ../
DEPENDS ${EXECUTABLE_NAME}
COMMENT "Running Coverage Tests"
VERBATIM
)
add_test(NAME verilog_parser_${TESTFILE}
COMMAND parser ${TESTFILE}
WORKING_DIRECTORY ../
)

# -s ../../src/*.c ./src/*.c
endforeach ( TESTFILE )

add_custom_target(coverage-report
COMMAND gcov -f -b -c -o ../../build/debug/src/CMakeFiles/verilogparser.dir -s ${COVERAGE_SRC_FILES} ${COVERAGE_GEN_FILES}
COMMAND lcov --directory . -c -o coverage.info -t "Verilog Parser"
COMMAND genhtml -o ./coverage -t "Verilog Parser Test Coverage" --num-spaces 4 coverage.info
DEPENDS coverage-tests
COMMENT "Generating Coverage Report With GCOV"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../
VERBATIM
)

# ------------------------------------------------------------------------

#file(GLOB COVERAGE_TEST_FILE_LIST "../tests/*.v")
#
#file(GLOB COVERAGE_SRC_FILES "./*.c")
#
#set(COVERAGE_GEN_FILES
# ${BINARY_DIR}/${FLEX_OUTPUT} ${BINARY_DIR}/${BISON_OUTPUT}
#)
#
#add_custom_target(coverage-tests
# COMMAND ${CMAKE_CURRENT_BINARY_DIR}/parser ${COVERAGE_TEST_FILE_LIST}
# WORKING_DIRECTORY ../
# DEPENDS ${EXECUTABLE_NAME}
# COMMENT "Running Coverage Tests"
# VERBATIM
#)
#
## -s ../../src/*.c ./src/*.c
#
#add_custom_target(coverage-report
# COMMAND gcov -f -b -c -o ../../build/debug/src/CMakeFiles/verilogparser.dir -s ${COVERAGE_SRC_FILES} ${COVERAGE_GEN_FILES}
# COMMAND lcov --directory . -c -o coverage.info -t "Verilog Parser"
# COMMAND genhtml -o ./coverage -t "Verilog Parser Test Coverage" --num-spaces 4 coverage.info
# DEPENDS coverage-tests
# COMMENT "Generating Coverage Report With GCOV"
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../
# VERBATIM
#)

0 comments on commit 5024eec

Please sign in to comment.