forked from vincentlaucsb/csv-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (75 loc) · 2.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Makefile used for building/testing on Travis CI
# Force Travis to use updated compilers
ifeq ($(TRAVIS_COMPILER), gcc)
CXX = g++-8
else ifeq ($(TRAVIS_COMPILER), clang)
CXX = clang++
endif
ifeq ($(STD), )
STD = c++11
endif
BUILD_DIR = build
SOURCE_DIR = include
SINGLE_INCLUDE_DIR = single_include
TEST_DIR = tests
CFLAGS = -pthread -std=$(STD)
TEST_OFLAGS =
ifeq ($(CXX), g++-8)
TEST_OFLAGS = -Og
endif
TEST_FLAGS = -Itests/ $(CFLAGS) $(TEST_OFLAGS) -g --coverage -Wno-unknown-pragmas -Wall
# Main Library
SOURCES = $(wildcard include/internal/*.cpp)
OBJECTS = $(subst .cpp,.o,$(subst src/,$(BUILD_DIR)/,$(SOURCES)))
TEST_SOURCES = $(wildcard tests/*.cpp)
TEST_SOURCES_NO_EXT = $(subst tests/,,$(subst .cpp,,$(TEST_SOURCES)))
all: csv_parser test_all clean distclean
################
# Main Library #
################
csv:
$(CXX) -c -O3 $(CFLAGS) $(SOURCES)
mkdir -p $(BUILD_DIR)
mv *.o $(BUILD_DIR)
libcsv.a:
make csv
ar rvs libcsv.a $(wildcard build/*.o)
docs:
doxygen Doxyfile
############
# Programs #
############
csv_stats:
$(CXX) -o csv_stats -O3 $(CFLAGS) programs/csv_stats.cpp -I$(SINGLE_INCLUDE_DIR)
#########
# Tests #
#########
csv_test:
$(CXX) -o csv_test $(SOURCES) $(TEST_SOURCES) -I${SOURCE_DIR} $(TEST_FLAGS)
run_csv_test: csv_test
mkdir -p tests/temp
./csv_test
# Test Clean-Up
rm -rf $(TEST_DIR)/temp
# Run code coverage analysis
code_cov: csv_test
mkdir -p test_results
mv *.gcno *.gcda $(PWD)/test_results
gcov-8 $(SOURCES) -o test_results --relative-only
mv *.gcov test_results
# Generate report
code_cov_report:
cd test_results
lcov --capture --directory test_results --output-file coverage.info
genhtml coverage.info --output-directory out
valgrind: csv_stats
# Can't run valgrind against csv_test because it mangles the working directory
# which causes csv_test to not be able to find test files
valgrind --leak-check=full ./csv_stats $(TEST_DIR)/data/real_data/2016_Gaz_place_national.txt
.PHONY: all clean distclean
clean:
rm -f build/*
rm -f *.gc*
rm -f libcsv.a
rm -f csv_*
distclean: clean