diff --git a/.gitmodules b/.gitmodules
index 7e38e13e9..2d07bfe72 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,4 @@
[submodule "googletest"]
path = googletest
url = https://github.com/google/googletest
+ branch = master
diff --git a/.travis.yml b/.travis.yml
index 09197147b..d29b209b0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,5 @@
-language: c
+language: cpp
+
compiler:
- clang
- gcc
@@ -6,7 +7,7 @@ compiler:
script:
- export CPPFLAGS=-DSWDEBUG && make cleaner bint_run
- make cleaner cov test_run
- - make cleaner
after_success:
- bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
+ - make cleaner
diff --git a/README.md b/README.md
index aa11e6007..efa887fd0 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@
[11]: https://img.shields.io/github/downloads/DrylandEcology/SOILWAT2/total.svg
[12]: https://github.com/DrylandEcology/SOILWAT2
+
# SOILWAT2
@@ -38,6 +39,7 @@ Some recent references
* Schlaepfer, D. R., W. K. Lauenroth, and J. B. Bradford. 2012. Ecohydrological
niche of sagebrush ecosystems. Ecohydrology 5:453-466.
+
## How to contribute
You can help us in different ways:
@@ -68,7 +70,9 @@ __Tests, documentation, and code__ form a trinity
but don't push them to the repository
- Code tests
* Use [GoogleTest](https://github.com/google/googletest/blob/master/googletest/docs/Documentation.md)
- to add unit tests to the existing framework
+ to add unit tests to the existing framework in the folder `test/` where
+ each unit test file uses the naming scheme `test/test_*.cc`.
+ * Note: `SOILWAT2` is written in C whereas `GoogleTest` is a C++ framework.
* Run unit tests locally on the command-line with
```
make test # compiles the unit-test binary/executable (with `-DSWDEBUG`)
@@ -116,13 +120,19 @@ __Tests, documentation, and code__ form a trinity
```
make cleaner bint_run CPPFLAGS=-DSWDEBUG
```
- * The "makefile" also contains pre-configured debugging targets including
- `bin_debug`, `bind`, and `bind_valgrind` (see description in `makefile`).
- If **valgrind** is installed, then for example
+ * Alternatively, you can use the pre-configured debugging targets
+ `bin_debug` and `bind`, for instance, with
+ ```
+ make cleaner bind bint_run
+ ```
+ * If **valgrind** is installed, then you can call the target `bind_valgrind`
+ (see description in `makefile`) with
```
make cleaner bind_valgrind
```
+
+
## Notes
__Version numbers__
diff --git a/SW_Output_mock.c b/SW_Output_mock.c
index 1770fc299..347625d61 100644
--- a/SW_Output_mock.c
+++ b/SW_Output_mock.c
@@ -1,12 +1,12 @@
/********************************************************/
/********************************************************/
/**
- @file
- @brief All content is for mock purposes only and to reduce compile warnings
+ @file
+ @brief All content is for mock purposes only and to reduce compile warnings
- Our unit testing framework `googletest` is c++ which doesn't like some of
- the constructs we use in the output code. Thus, we currently cannot test
- any output code and use these mock functions instead as placeholders.
+ Our unit testing framework `googletest` is c++ which doesn't like some of
+ the constructs we use in the output code. Thus, we currently cannot test
+ any output code and use these mock functions instead as placeholders.
*/
/********************************************************/
/********************************************************/
@@ -44,15 +44,48 @@ extern SW_VEGESTAB SW_VegEstab;
extern Bool EchoInits;
extern SW_CARBON SW_Carbon;
-#define OUTSTRLEN 3000 /* max output string length: in get_transp: 4*every soil layer with 14 chars */
+// Copy-paste from SW_Output.c (lines 81-103)
+SW_OUTPUT SW_Output[SW_OUTNKEYS];
-SW_OUTPUT SW_Output[SW_OUTNKEYS]; /* declared here, externed elsewhere */
+char _Sep; /* output delimiter */
+TimeInt tOffset; /* 1 or 0 means we're writing previous or current period */
+
+
+// Global variables describing output periods:
+/** `timeSteps` is the array that keeps track of the output time periods that
+ are required for `text` and/or `array`-based output for each output key. */
+OutPeriod timeSteps[SW_OUTNKEYS][SW_OUTNPERIODS];
+/** The number of different time steps/periods that are used/requested
+ Note: Under STEPWAT2, this may be larger than the sum of `use_OutPeriod`
+ because it also incorporates information from `timeSteps_SXW`. */
+IntUS used_OUTNPERIODS;
+/** TRUE if time step/period is active for any output key. */
+Bool use_OutPeriod[SW_OUTNPERIODS];
+
+
+// Global variables describing size and names of output
+/** names of output columns for each output key; number is an expensive guess */
+char *colnames_OUT[SW_OUTNKEYS][5 * NVEGTYPES + MAX_LAYERS];
+/** number of output columns for each output key */
+IntUS ncol_OUT[SW_OUTNKEYS];
+
+
+
+// Mock definitions
+char const *key2str[] = {};
+char const *pd2longstr[] = {};
/* =================================================== */
/* Public Function Definitions */
/* --------------------------------------------------- */
+void SW_OUT_set_colnames(void)
+{}
+
+void SW_OUT_set_ncol(void)
+{}
+
void SW_OUT_construct(void)
{}
@@ -67,202 +100,261 @@ void SW_OUT_new_year(void)
void SW_OUT_read(void)
{}
-#ifndef RSOILWAT
-void SW_OUT_close_files(void)
-{}
-#endif
-
void _collect_values(void)
{}
void SW_OUT_flush(void)
{
- _collect_values();
+ _collect_values();
}
void SW_OUT_sum_today(ObjType otyp)
{
- ObjType x = otyp;
- if (x == eF) {}
+ ObjType x = otyp;
+ if (x == eF) {}
}
void SW_OUT_write_today(void)
{}
-void get_none(void)
-{}
+void get_none(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_co2effects(void)
-{}
+void get_co2effects(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_estab(void)
-{}
+void get_estab(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_temp(void)
-{}
+void get_temp(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_precip(void)
-{}
+void get_precip(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_vwcBulk(void)
-{}
+void get_vwcBulk(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_vwcMatric(void)
-{}
+void get_vwcMatric(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_swcBulk(void)
-{}
+void get_swcBulk(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_swpMatric(void)
-{}
+void get_swpMatric(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_swaBulk(void)
-{}
+void get_swaBulk(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_swaMatric(void)
-{}
+void get_swaMatric(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_surfaceWater(void)
-{}
+void get_surfaceWater(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_runoff(void)
-{}
+void get_runoff(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_transp(void)
-{}
+void get_transp(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_evapSoil(void)
-{}
+void get_evapSoil(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_evapSurface(void)
-{}
+void get_evapSurface(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_interception(void)
-{}
+void get_interception(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_soilinf(void)
-{}
+void get_soilinf(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_lyrdrain(void)
-{}
+void get_lyrdrain(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_hydred(void)
-{}
+void get_hydred(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_aet(void)
-{}
+void get_aet(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_pet(void)
-{}
+void get_pet(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_wetdays(void)
-{}
+void get_wetdays(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_snowpack(void)
-{}
+void get_snowpack(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_deepswc(void)
-{}
+void get_deepswc(OutPeriod pd)
+{
+ if (pd) {}
+}
-void get_soiltemp(void)
-{}
+void get_soiltemp(OutPeriod pd)
+{
+ if (pd) {}
+}
static void sumof_vpd(SW_VEGPROD *v, SW_VEGPROD_OUTPUTS *s, OutKey k)
{
- OutKey x = k;
- if ((int)x == 1) {}
+ OutKey x = k;
+ if ((int)x == 1) {}
- if (EQ(0., v->bare_cov.fCover)) {}
- if (EQ(0., s->veg[SW_GRASS].biomass)) {}
+ if (EQ(0., v->bare_cov.fCover)) {}
+ if (EQ(0., s->veg[SW_GRASS].biomass)) {}
}
static void sumof_ves(SW_VEGESTAB *v, SW_VEGESTAB_OUTPUTS *s, OutKey k)
{
- if ((int)k == 1) {}
- if (0 == v->count) {}
- if (0 == s->days) {}
+ if ((int)k == 1) {}
+ if (0 == v->count) {}
+ if (0 == s->days) {}
}
static void sumof_wth(SW_WEATHER *v, SW_WEATHER_OUTPUTS *s, OutKey k)
{
- OutKey x = k;
- if ((int)x == 1) {}
+ OutKey x = k;
+ if ((int)x == 1) {}
- if (EQ(0., v->pct_snowdrift)) {}
- if (EQ(0., s->temp_max)) {}
+ if (EQ(0., v->pct_snowdrift)) {}
+ if (EQ(0., s->temp_max)) {}
}
static void sumof_swc(SW_SOILWAT *v, SW_SOILWAT_OUTPUTS *s, OutKey k)
{
- OutKey x = k;
- if ((int)x == 1) {}
+ OutKey x = k;
+ if ((int)x == 1) {}
- if (EQ(0., v->snowdepth)) {}
- if (EQ(0., s->snowdepth)) {}
+ if (EQ(0., v->snowdepth)) {}
+ if (EQ(0., s->snowdepth)) {}
}
static void average_for(ObjType otyp, OutPeriod pd)
{
- if (pd == eSW_Day) {}
- SW_OUT_sum_today(otyp);
+ if (pd == eSW_Day) {}
+ SW_OUT_sum_today(otyp);
}
static void collect_sums(ObjType otyp, OutPeriod op)
{
- if (op == eSW_Day) {}
- SW_OUT_sum_today(otyp);
+ if (op == eSW_Day) {}
+ SW_OUT_sum_today(otyp);
}
void _echo_outputs(void)
{
- get_none();
- get_estab();
- get_temp();
- get_precip();
- get_vwcBulk();
- get_vwcMatric();
- get_swcBulk();
- get_swpMatric();
- get_swaBulk();
- get_swaMatric();
- get_surfaceWater();
- get_runoff();
- get_transp();
- get_evapSoil();
- get_evapSurface();
- get_interception();
- get_soilinf();
- get_lyrdrain();
- get_hydred();
- get_aet();
- get_pet();
- get_wetdays();
- get_snowpack();
- get_deepswc();
- get_soiltemp();
- get_co2effects();
-
- OutKey k = eSW_NoKey;
- SW_VEGPROD *vveg = NULL;
- SW_VEGPROD_OUTPUTS *sveg = NULL;
- SW_VEGESTAB *vestab = NULL;
- SW_VEGESTAB_OUTPUTS *sestab = NULL;
- SW_WEATHER *vweath = NULL;
- SW_WEATHER_OUTPUTS *sweath = NULL;
- SW_SOILWAT *vswc = NULL;
- SW_SOILWAT_OUTPUTS *sswc = NULL;
-
- sumof_vpd(vveg, sveg, k);
- sumof_ves(vestab, sestab, k);
- sumof_wth(vweath, sweath, k);
- sumof_swc(vswc, sswc, k);
-
- ObjType otyp = eF;
- OutPeriod pd = eSW_Year;
-
- average_for(otyp, pd);
- collect_sums(otyp, pd);
+ OutPeriod pd = eSW_Year;
+
+ get_none(pd);
+ get_estab(pd);
+ get_temp(pd);
+ get_precip(pd);
+ get_vwcBulk(pd);
+ get_vwcMatric(pd);
+ get_swcBulk(pd);
+ get_swpMatric(pd);
+ get_swaBulk(pd);
+ get_swaMatric(pd);
+ get_surfaceWater(pd);
+ get_runoff(pd);
+ get_transp(pd);
+ get_evapSoil(pd);
+ get_evapSurface(pd);
+ get_interception(pd);
+ get_soilinf(pd);
+ get_lyrdrain(pd);
+ get_hydred(pd);
+ get_aet(pd);
+ get_pet(pd);
+ get_wetdays(pd);
+ get_snowpack(pd);
+ get_deepswc(pd);
+ get_soiltemp(pd);
+ get_co2effects(pd);
+
+ OutKey k = eSW_NoKey;
+ SW_VEGPROD *vveg = NULL;
+ SW_VEGPROD_OUTPUTS *sveg = NULL;
+ SW_VEGESTAB *vestab = NULL;
+ SW_VEGESTAB_OUTPUTS *sestab = NULL;
+ SW_WEATHER *vweath = NULL;
+ SW_WEATHER_OUTPUTS *sweath = NULL;
+ SW_SOILWAT *vswc = NULL;
+ SW_SOILWAT_OUTPUTS *sswc = NULL;
+
+ sumof_vpd(vveg, sveg, k);
+ sumof_ves(vestab, sestab, k);
+ sumof_wth(vweath, sweath, k);
+ sumof_swc(vswc, sswc, k);
+
+ ObjType otyp = eF;
+
+ average_for(otyp, pd);
+ collect_sums(otyp, pd);
+}
+
+
+Bool has_OutPeriod_inUse(OutPeriod pd, OutKey k)
+{
+ Bool res = swTRUE;
+
+ if (k) {}
+ if (pd) {}
+
+ return res;
}
diff --git a/googletest b/googletest
index ba96d0b11..7888184f2 160000
--- a/googletest
+++ b/googletest
@@ -1 +1 @@
-Subproject commit ba96d0b1161f540656efdaed035b3c062b60e006
+Subproject commit 7888184f28509dba839e3683409443e0b5bb8948
diff --git a/makefile b/makefile
index 1cc6d5731..ef7b21fd7 100644
--- a/makefile
+++ b/makefile
@@ -23,36 +23,63 @@
uname_m = $(shell uname -m)
+
+#------ OUTPUT NAMES
+target = SOILWAT2
+bin_test = sw_test
+target_test = $(target)_test
+target_severe = $(target)_severe
+target_cov = $(target)_cov
+
+lib_target = lib$(target).a
+lib_target_test = lib$(target_test).a
+lib_target_severe = lib$(target_severe).a
+lib_target_cov = lib$(target_cov).a
+
+
#------ COMMANDS AND STANDARDS
# CC = gcc
# CXX = g++
# AR = ar
+# RM = rm
+
use_c11 = -std=c11
-use_gnu11 = -std=gnu++11 # gnu++11 required for googletest on Windows/cygwin
+use_gnu++11 = -std=gnu++11 # gnu++11 required for googletest on Windows/cygwin
#------ FLAGS
# Diagnostic warning/error messages
-warning_flags = -Wall -Wextra -Werror
-warning_flags_bin = $(warning_flags) -Wpedantic
+warning_flags = -Wall -Wextra
+warning_flags_bin = $(warning_flags) -Wpedantic -Werror
-# Instrumentation options
+# Instrumentation options for debugging and testing
instr_flags = -fstack-protector-all
-instr_flags_severe = -D_FORTIFY_SOURCE=2 -fsanitize=undefined -fsanitize=address
+instr_flags_severe = -D_FORTIFY_SOURCE=2 -Wno-macro-redefined \
+ -fsanitize=undefined -fsanitize=address
# -fstack-protector-strong (gcc >= v4.9)
# (gcc >= 4.0) -D_FORTIFY_SOURCE: lightweight buffer overflow protection to some memory and string functions
# (gcc >= 4.8; llvm >= 3.1) -fsanitize=address: replaces `mudflap` run time checker; https://github.com/google/sanitizers/wiki/AddressSanitizer
-# Precompiler, compiler, and linker flags
-CFLAGS = -O2 $(warning_flags_bin)
-debug_flags = -g -O0 -DSWDEBUG $(instr_flags)
+# Precompiler and compiler flags and options
+sw_CPPFLAGS = $(CPPFLAGS)
+sw_CFLAGS = $(CFLAGS)
+sw_CXXFLAGS = $(CXXFLAGS) -Wno-error=deprecated # TODO: clang++: "treating 'c' input as 'c++' when in C++ mode"
-CXXFLAGS = $(warning_flags)
+bin_flags = -O2
+debug_flags = -g -O0 -DSWDEBUG
cov_flags = -coverage
-gtest_flags = $(CXXFLAGS) $(CPPFLAGS) $(debug_flags) $(use_gnu11)
-LDFLAGS = -L.
-LDLIBS = -l$(target) -lm # order of libraries is important for GNU gcc (libSOILWAT2 depends on libm)
+# Linker flags and libraries
+# order of libraries is important for GNU gcc (libSOILWAT2 depends on libm)
+sw_LDFLAGS = $(LDFLAGS) -L.
+sw_LDLIBS = $(LDLIBS) -lm
+
+target_LDLIBS = -l$(target) $(sw_LDLIBS)
+test_LDLIBS = -l$(target_test) $(sw_LDLIBS)
+severe_LDLIBS = -l$(target_severe) $(sw_LDLIBS)
+cov_LDLIBS = -l$(target_cov) $(sw_LDLIBS)
+
+gtest_LDLIBS = -l$(gtest)
#------ CODE FILES
@@ -76,80 +103,86 @@ sources_tests = SW_Main_lib.c SW_VegEstab.c SW_Control.c generic.c \
objects_tests = $(sources_tests:.c=.o)
-#------ OUTPUT NAMES
bin_sources = SW_Main.c SW_Output_outtext.c # SOILWAT2-standalone
bin_objects = $(bin_sources:.c=.o)
-target = SOILWAT2
-bin_test = sw_test
-lib_target = lib$(target).a
-lib_target++ = lib$(target)++.a
-lib_covtarget++ = libcov$(target)++.a
-lib_target_ci++ = lib$(target)_ci++.a
-lib_covtarget_ci++ = libcov$(target)_ci++.a
-
-
gtest = gtest
lib_gtest = lib$(gtest).a
GTEST_DIR = googletest/googletest
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
-GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
- $(GTEST_DIR)/include/gtest/internal/*.h
-gtest_LDLIBS = -l$(gtest) -l$(target)++ -lm
-cov_LDLIBS = -l$(gtest) -lcov$(target)++ -lm
-gtest_LDLIBS_ci = -l$(gtest) -l$(target)_ci++ -lm
-cov_LDLIBS_ci = -l$(gtest) -lcov$(target)_ci++ -lm
+GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h $(GTEST_DIR)/include/gtest/internal/*.h
+
#------ TARGETS
+bin : $(target)
+
lib : $(lib_target)
$(lib_target) :
- $(CC) $(CPPFLAGS) $(CFLAGS) $(use_c11) -c $(sources)
- @rm -f $(lib_target)
+ $(CC) $(sw_CPPFLAGS) $(sw_CFLAGS) $(bin_flags) $(warning_flags_bin) \
+ $(use_c11) -c $(sources)
+
+ -@$(RM) -f $(lib_target)
$(AR) -rcs $(lib_target) $(objects)
- @rm -f $(objects)
+ -@$(RM) -f $(objects)
-$(lib_target++) :
- $(CXX) $(gtest_flags) $(instr_flags_severe) -c $(sources_tests)
- $(AR) -rcsu $(lib_target++) $(objects_tests)
- @rm -f $(objects_tests)
-$(lib_covtarget++) :
- $(CXX) $(gtest_flags) $(instr_flags_severe) $(cov_flags) -c $(sources_tests)
- $(AR) -rcsu $(lib_covtarget++) $(objects_tests)
- @rm -f $(objects_tests)
+$(lib_target_test) :
+ $(CXX) $(sw_CPPFLAGS) $(sw_CXXFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags) $(use_gnu++11) -c $(sources_tests)
-$(lib_target_ci++) :
- $(CXX) $(gtest_flags) -c $(sources_tests)
- $(AR) -rcsu $(lib_target_ci++) $(objects_tests)
- @rm -f $(objects_tests)
+ -@$(RM) -f $(lib_target_test)
+ $(AR) -rcs $(lib_target_test) $(objects_tests)
+ -@$(RM) -f $(objects_tests)
-$(lib_covtarget_ci++) :
- $(CXX) $(gtest_flags) $(cov_flags) -c $(sources_tests)
- $(AR) -rcsu $(lib_covtarget_ci++) $(objects_tests)
- @rm -f $(objects_tests)
+$(lib_target_severe) :
+ $(CXX) $(sw_CPPFLAGS) $(sw_CXXFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags_severe) $(use_gnu++11) -c $(sources_tests)
+ -@$(RM) -f $(lib_target_severe)
+ $(AR) -rcs $(lib_target_severe) $(objects_tests)
+ -@$(RM) -f $(objects_tests)
+
+$(lib_target_cov) :
+ $(CXX) $(sw_CPPFLAGS) $(sw_CXXFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags) $(cov_flags) $(use_gnu++11) -c $(sources_tests)
+
+ -@$(RM) -f $(lib_target_cov)
+ $(AR) -rcs $(lib_target_cov) $(objects_tests)
+ -@$(RM) -f $(objects_tests)
-bin : $(target)
$(target) : $(lib_target)
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(use_c11) -o $(target) $(bin_sources) $(LDLIBS)
+ $(CC) $(sw_CPPFLAGS) $(sw_CFLAGS) $(bin_flags) $(warning_flags_bin) \
+ $(use_c11) \
+ -o $(target) $(bin_sources) $(target_LDLIBS) $(sw_LDFLAGS)
bin_debug :
- $(CC) $(CPPFLAGS) $(debug_flags) $(instr_flags_severe) $(use_c11) -c $(sources)
- @rm -f $(lib_target)
- $(AR) -rcs $(lib_target) $(objects)
- @rm -f $(objects)
- $(CC) $(CPPFLAGS) $(debug_flags) $(instr_flags_severe) $(LDFLAGS) $(use_c11) -o $(target) $(bin_sources) $(LDLIBS)
+ $(CC) $(sw_CPPFLAGS) $(sw_CFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags_severe) $(use_c11) -c $(sources_tests)
+
+ -@$(RM) -f $(lib_target_severe)
+ $(AR) -rcs $(lib_target_severe) $(objects_tests)
+ -@$(RM) -f $(objects_tests)
+
+ $(CC) $(sw_CPPFLAGS) $(sw_CFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags_severe) $(use_c11) \
+ -o $(target) $(bin_sources) $(severe_LDLIBS) $(sw_LDFLAGS)
bin_debug_ci :
- $(CC) $(CPPFLAGS) $(debug_flags) $(use_c11) -c $(sources)
- @rm -f $(lib_target)
- $(AR) -rcs $(lib_target) $(objects)
- @rm -f $(objects)
- $(CC) $(CPPFLAGS) $(debug_flags) $(LDFLAGS) $(use_c11) -o $(target) $(bin_sources) $(LDLIBS)
+ $(CC) $(sw_CPPFLAGS) $(sw_CFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags) $(use_c11) -c $(sources_tests)
+
+ -@$(RM) -f $(lib_target_test)
+ $(AR) -rcs $(lib_target_test) $(objects_tests)
+ -@$(RM) -f $(objects_tests)
+
+ $(CC) $(sw_CPPFLAGS) $(sw_CFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags) $(use_c11) \
+ -o $(target) $(bin_sources) $(test_LDLIBS) $(sw_LDFLAGS)
+
.PHONY : bint
bint : bin
@@ -170,31 +203,40 @@ bind_valgrind : bin_debug_ci
# GoogleTest:
-# based on section 'Generic Build Instructions' in https://github.com/google/googletest/tree/master/googletest)
+# based on section 'Generic Build Instructions' at
+# https://github.com/google/googletest/tree/master/googletest)
# 1) build googletest library
# 2) compile SOILWAT2 test source file
lib_test : $(lib_gtest)
$(lib_gtest) :
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(use_gnu11) -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \
- -pthread -c ${GTEST_DIR}/src/gtest-all.cc
- $(AR) -r $(lib_gtest) gtest-all.o
+ @$(CXX) $(sw_CPPFLAGS) $(sw_CXXFLAGS) $(use_gnu++11) \
+ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \
+ -pthread -c ${GTEST_DIR}/src/gtest-all.cc
-test : $(lib_gtest) $(lib_target++)
- $(CXX) $(gtest_flags) $(instr_flags_severe) $(LDFLAGS) -isystem ${GTEST_DIR}/include -pthread \
- test/*.cc -o $(bin_test) $(gtest_LDLIBS)
+ @$(AR) -r $(lib_gtest) gtest-all.o
-testci : $(lib_gtest) $(lib_target_ci++)
- $(CXX) $(gtest_flags) $(LDFLAGS) -isystem ${GTEST_DIR}/include -pthread \
- test/*.cc -o $(bin_test) $(gtest_LDLIBS_ci)
+test : $(lib_gtest) $(lib_target_severe)
+ $(CXX) $(sw_CPPFLAGS) $(sw_CXXFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags_severe) $(use_gnu++11) \
+ -isystem ${GTEST_DIR}/include -pthread \
+ test/*.cc -o $(bin_test) $(gtest_LDLIBS) $(severe_LDLIBS) $(sw_LDFLAGS)
+
+testci : $(lib_gtest) $(lib_target_test)
+ $(CXX) $(sw_CPPFLAGS) $(sw_CXXFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags) $(use_gnu++11) \
+ -isystem ${GTEST_DIR}/include -pthread \
+ test/*.cc -o $(bin_test) $(gtest_LDLIBS) $(test_LDLIBS) $(sw_LDFLAGS)
.PHONY : test_run
test_run :
./$(bin_test)
-cov : cov_clean $(lib_gtest) $(lib_covtarget_ci++)
- $(CXX) $(gtest_flags) $(cov_flags) $(LDFLAGS) -isystem ${GTEST_DIR}/include \
- -pthread test/*.cc -o $(bin_test) $(cov_LDLIBS_ci)
+cov : cov_clean $(lib_gtest) $(lib_target_cov)
+ $(CXX) $(sw_CPPFLAGS) $(sw_CXXFLAGS) $(debug_flags) $(warning_flags) \
+ $(instr_flags) $(cov_flags) $(use_gnu++11) \
+ -isystem ${GTEST_DIR}/include -pthread \
+ test/*.cc -o $(bin_test) $(gtest_LDLIBS) $(cov_LDLIBS) $(sw_LDFLAGS)
.PHONY : cov_run
cov_run : cov
@@ -206,25 +248,31 @@ cov_run : cov
.PHONY : clean1
clean1 :
- @rm -f $(objects) $(bin_objects)
+ -@$(RM) -f $(objects) $(bin_objects)
.PHONY : clean2
clean2 :
- @rm -f $(target) $(lib_target) $(lib_target++) $(lib_target_ci++)
- @rm -f testing/$(target)
+ -@$(RM) -f $(target) $(lib_target)
+ -@$(RM) -f testing/$(target)
.PHONY : bint_clean
bint_clean :
- @rm -f testing/Output/*
+ -@$(RM) -f testing/Output/*
.PHONY : test_clean
test_clean :
- @rm -f gtest-all.o $(lib_gtest) $(bin_test)
+ -@$(RM) -f gtest-all.o $(lib_gtest) $(bin_test)
+ -@$(RM) -f $(lib_target_test) $(lib_target_severe) $(lib_target_cov)
+ -@$(RM) -fr *.dSYM
+ -@$(RM) -f $(objects_tests)
.PHONY : cov_clean
cov_clean :
- @rm -f $(lib_covtarget++) $(lib_covtarget_ci++) *.gcda *.gcno *.gcov
- @rm -fr *.dSYM
+ -@$(RM) -f $(lib_target_cov) *.gcda *.gcno *.gcov
+ -@$(RM) -fr *.dSYM
.PHONY : cleaner
cleaner : clean1 clean2 bint_clean test_clean cov_clean
+
+.PHONY : clean
+clean : cleaner