Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ docs/*
test/obj/*
test/bin/*
test/conan/*
cov/*

!**/.gitkeep

compile_flags.txt
coverage.info
37 changes: 25 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ TEST_DIR=$(abspath ./test/src/)
INSTALL_DIR=/usr/include/fpgen
INCL_PATH=$(abspath ./inc)
DOC_DIR=$(abspath ./docs/)
HTMLDIR=$(abspath ./cov/)
BROWSER=firefox

CC=g++
CXXARGS=-I$(abspath ./inc) -g -c -std=c++20 -MMD
LDARGS=
CXXARGS=-I$(abspath ./inc) -g -c -std=c++20 -MMD -fprofile-arcs -ftest-coverage
LDARGS=-fprofile-arcs -ftest-coverage

all:
@echo "Please choose a target:"
Expand All @@ -18,22 +20,27 @@ all:
@echo " -> make docs: generates the documentation using doxygen under $(DOC_DIR)"
@echo " -> make test: builds and runs the tests in $(BUILD_DIR) and $(BIN_DIR) from $(TEST_DIR)"
@echo " -> make clean: cleans up test builds and documentation (from $(BUILD_DIR), $(BIN_DIR), $(DOC_DIR))"
@echo " -> make coverage: builds and runs the tests, then generates a coverage report in $(HTMLDIR) and opens it in $(BROWSER)"
@echo ""
@echo "Some targets accept additional arguments in the form of KEY=VALUE pairs:"
@echo " -> CC (for test): sets the command for the C++ compiler (g++ by default)"
@echo " -> CXXARGS (for test): current arguments to the compiler - not recommended to change"
@echo " -> EXTRA_CXX (for test): additional compilation flags/arguments"
@echo " -> LDARGS (for test): current arguments to the linker - not recommended to change"
@echo " -> EXTRA_LD (for test): additional linker flags/arguments"
@echo " -> BUILD_DIR (for test): build directory"
@echo " -> BIN_DIR (for test): binary directory"
@echo " -> TEST_DIR (for test): test sources directory"
@echo " -> CC (for test and coverage): sets the command for the C++ compiler (g++ by default)"
@echo " -> CXXARGS (for test and coverage): current arguments to the compiler - not recommended to change"
@echo " -> EXTRA_CXX (for test and coverage): additional compilation flags/arguments"
@echo " -> LDARGS (for test and coverage): current arguments to the linker - not recommended to change"
@echo " -> EXTRA_LD (for test and coverage): additional linker flags/arguments"
@echo " -> BUILD_DIR (for test and coverage): build directory"
@echo " -> BIN_DIR (for test and coverage): binary directory"
@echo " -> TEST_DIR (for test and coverage): test sources directory"
@echo " -> INSTALL_DIR (for install and uninstall): sets the installation directory"
@echo " -> INCL_PATH (for install, docs and test): the path to the directory with the headers, if you run make from another directory"
@echo " -> INCL_PATH (for install, docs, test and coverage): the path to the directory with the headers, if you run make from another directory"
@echo " -> DOC_DIR (for docs): the path to the build directory for the documentation"
@echo " -> BROWSER (for coverage): the browser in which to open the coverage report"
@echo " -> HTMLDIR (for coverage): the directory in which to generate the coverage report"
@echo " Current/default arguments: "
@echo " CC=$(CC) CXXARGS=$(CXXARGS) LDARGS=$(LDARGS) EXTRA_CXX=$(EXTRA_CXX) EXTRA_LD=$(EXTRA_LD)"
@echo " BUILD_DIR=$(BUILD_DIR) BIN_DIR=$(BIN_DIR) TEST_DIR=$(TEST_DIR) INSTALL_DIR=$(INSTALL_DIR) INCL_PATH=$(INCL_PATH) DOC_DIR=$(DOC_DIR)"
@echo " BROWSER=$(BROWSER) HTMLDIR=$(HTMLDIR)"
@echo ""

install:
([ ! -d $(INSTALL_DIR) ] && mkdir -p $(INSTALL_DIR)) || true
Expand All @@ -53,4 +60,10 @@ clean:
rm -rf $(DOC_DIR)/*
cd $(TEST_DIR)/.. && make clean OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)"

.PHONY: install uninstall test clean docs
coverage:
make CC="$(CC)" OBJD="$(BUILD_DIR)" BIND="$(BIN_DIR)" SRCD="$(TEST_DIR)" CXXARGS="$(CXXARGS) $(EXTRA_CXX) -I$(INCL_PATH)" LDARGS="$(LDARGS) $(EXTRA_LD)" -C $(TEST_DIR)/..
lcov --directory "$(BUILD_DIR)" --output-file coverage.info -c --exclude '*gmock' --exclude '*gtest*' --exclude '/usr/*'
genhtml coverage.info --output-directory "$(HTMLDIR)"
$(BROWSER) $(HTMLDIR)/index.html

.PHONY: install uninstall test clean docs coverage
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# fpgen
*Functional programming in C++ using C++20 coroutines*
*Functional programming in C++ using C++20 coroutines*
![](https://img.shields.io/badge/test_coverage-98%25-brightgreen)


## Aim
`fpgen` aims to bring you an easy-to-use framework for stream programming in C++. Generators can be created, manipulated and lazily aggregated at will using a set of simple functions. Iterators over the generator make it easy to iterate over lazy functions.
Expand Down Expand Up @@ -28,4 +30,4 @@ Got another idea? Drop a feature request on the repo.
## Requirements
This project strongly depends on C++20. For an optimal experience, I recommend GCC version 11.2 or greater.
For the tests, we rely on Google Test via the Conan package manager, so make sure you have that installed as well.
To generate coverage reports, we require `gcov`, `lcov` and `genhtml`.
To generate coverage reports, we require `gcov`, `lcov` and `genhtml`.
Empty file added cov/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions test/src/test_sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ TEST(sources, from_set) {
}

TEST(sources, enumerate_vector) {
std::vector<char> values = { 'a', 'c', 'e', 'k', 'j', 't' };
std::vector<char> values = {'a', 'c', 'e', 'k', 'j', 't'};
size_t prev = 0;
for(auto v : fpgen::enumerate(values)) {
for (auto v : fpgen::enumerate(values)) {
EXPECT_EQ(std::get<0>(v), prev);
EXPECT_EQ(values[prev], std::get<1>(v));
prev++;
Expand Down