Merge pull request #66 from kosma/makeremove

Makeremove
This commit is contained in:
Kosma Moczek 2022-06-18 15:41:25 +02:00 committed by GitHub
commit db46128e73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 37 deletions

View File

@ -9,7 +9,6 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install dependencies - name: Install dependencies
run: sudo apt-get install -y clang-tools check cmake run: sudo apt-get install -y clang-tools check cmake
- name: make
run: make
- name: cmake - name: cmake
run: "( rm -rf build && mkdir build && cd build && cmake .. && make && ./tests && echo OK )" run: "( rm -rf build && mkdir build && cd build && cmake .. && make && CTEST_OUTPUT_ON_FAILURE=1 make
test && echo OK )"

View File

@ -1,19 +1,39 @@
cmake_minimum_required(VERSION 3.3) cmake_minimum_required(VERSION 3.3)
enable_testing()
project(minmea) project(minmea)
find_package(Threads REQUIRED) # Workaround for https://github.com/libcheck/check/issues/48#issuecomment-322965461 find_package(Threads REQUIRED) # Workaround for https://github.com/libcheck/check/issues/48#issuecomment-322965461
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(CHECK REQUIRED check) pkg_check_modules(CHECK REQUIRED check)
link_directories(${CHECK_LIBRARY_DIRS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Werror -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Werror -std=c99")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE")
set(minmea_SRCS minmea.c minmea.h) set(minmea_SRCS minmea.c minmea.h)
add_library(minmea ${minmea_SRCS}) add_library(minmea ${minmea_SRCS})
add_executable(example example.c) add_executable(example example.c)
add_executable(tests tests.c)
target_link_libraries(example minmea) target_link_libraries(example minmea)
add_executable(tests tests.c)
target_link_libraries(tests minmea ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(tests minmea ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(tests PUBLIC ${CHECK_INCLUDE_DIRS}) target_include_directories(tests PUBLIC ${CHECK_INCLUDE_DIRS})
target_compile_options(tests PUBLIC ${CHECK_CFLAGS_OTHER}) target_compile_options(tests PUBLIC ${CHECK_CFLAGS_OTHER})
add_test(NAME tests COMMAND $<TARGET_FILE:tests>)
find_program(SCAN_FOUND scan-build)
if (SCAN_FOUND)
add_test(
NAME clang_static_analysis
COMMAND scan-build make
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
else()
MESSAGE(STATUS "scan-build not found, not scanning code")
endif()

View File

@ -1,31 +0,0 @@
# Copyright © 2014 Kosma Moczek <kosma@cloudyourcar.com>
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law. You can redistribute it and/or modify it under
# the terms of the Do What The Fuck You Want To Public License, Version 2, as
# published by Sam Hocevar. See the COPYING file for more details.
CFLAGS = -g -Wall -Wextra -Werror -std=c99
CFLAGS += -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE
CFLAGS += $(shell pkg-config --cflags check)
LDLIBS += $(shell pkg-config --libs check)
all: scan-build test example
@echo "+++ All good."""
test: tests
@echo "+++ Running Check test suite..."
./tests
scan-build: clean
@echo "+++ Running Clang Static Analyzer..."
scan-build --status-bugs --keep-going $(MAKE) tests
clean:
$(RM) tests example *.o
tests: tests.o minmea.o
example: example.o minmea.o
tests.o: tests.c minmea.h
minmea.o: minmea.c minmea.h
.PHONY: all test scan-build clean

View File

@ -132,11 +132,19 @@ good to go.
Building and running the tests requires the following: Building and running the tests requires the following:
* CMake
* Check Framework (https://libcheck.github.io/check/). * Check Framework (https://libcheck.github.io/check/).
* Clang Static Analyzer (https://clang-analyzer.llvm.org/). * Clang Static Analyzer (https://clang-analyzer.llvm.org/).
If you have both in your ``$PATH``, running the tests should be as simple as If you have both in your ``$PATH``, running the tests should be as simple as:
typing ``make``.
```
mkdir build
cd build
cmake ../
make
make test
```
## Limitations ## Limitations