Browse Source

Minor doc cleanup, and revamp test/Makefile

make-cleanup
Damiano Boppart 3 years ago
parent
commit
d4bc9b7b04
4 changed files with 62 additions and 121 deletions
  1. +1
    -1
      Makefile
  2. +19
    -16
      Makefile.conf
  3. +1
    -1
      src/Makefile
  4. +41
    -103
      test/Makefile

+ 1
- 1
Makefile View File

@ -51,7 +51,7 @@ tags:
.PHONY: test
test: all
$(MAKE) -C test test
$(MAKE) -C test all
.PHONY: package
package: clean


+ 19
- 16
Makefile.conf View File

@ -51,12 +51,12 @@ endif
# If empty, create a release build.
# Otherwise, create a debug build.
# This variable is ineffective in your local.conf file.
# This variable is ineffective when set anywhere else but here.
DEBUG=placeholder
# If empty, suppress compiler warnings.
# Otherwise, print warnings.
# This variable is ineffective in your local.conf file.
# This variable is ineffective when set anywhere else but here.
WARN=placeholder
@ -64,7 +64,7 @@ WARN=placeholder
TARGET_ARCH=
# The following two variables will be appended to.
# You can thus not set them to a fixed value here.
# You can thus not set them to a final, fixed value here.
ifeq ($(BUILD_FOR),Linux)
LDFLAGS=
else ifeq ($(BUILD_FOR),Darwin)
@ -174,7 +174,7 @@ CPPFLAGS=
######### YML2 #########
YML2_PATH=$(HOME)/yml2
YML2_PROC=$(YML2_PATH)/yml2proc
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
YML2_OPTS=--encoding=utf8
@ -185,17 +185,17 @@ ASN1C=asn1c
# asn1c include search flag
ASN1C_INC=
#ASN1C_INC=-I$(PREFIX)/include
#ASN1C_INC=-I$(HOME)/include
######### libetpan #########
# libetpan library search flag
ETPAN_LIB=
#ETPAN_LIB=-L$(PREFIX)/lib
#ETPAN_LIB=-L$(HOME)/lib
# libetpan include search flag
ETPAN_INC=
#ETPAN_INC=-I$(PREFIX)/include
#ETPAN_INC=-I$(HOME)/include
######### sqlite3 #########
@ -213,10 +213,12 @@ GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit
OPENPGP=GPG
# libGPGME filename
ifeq ($(BUILD_FOR),Linux)
LIBGPGME=libgpgme.so.11
else ifeq ($(BUILD_FOR),Darwin)
LIBGPGME=libgpgme.11.dylib
ifeq ($(OPENPGP),GPG)
ifeq ($(BUILD_FOR),Linux)
LIBGPGME=libgpgme.so.11
else ifeq ($(BUILD_FOR),Darwin)
LIBGPGME=libgpgme.11.dylib
endif
endif
# libGPGME library search flag
@ -229,11 +231,11 @@ GPGME_INC=
# NETPGP library search flag
NETPGP_LIB=
#NETPGP_LIB=-L$(PREFIX)/lib
#NETPGP_LIB=-L$(HOME)/lib
# libGPGME include search flag
NETPGP_INC=
#NETPGP_INC=-I$(PREFIX)/include
#NETPGP_INC=-I$(HOME)/include
######### CppUnit #########
@ -256,11 +258,12 @@ EXTRA_MACROS=
######### Misc #########
#LLDB_BIN
# add this for running tests in debugger
# Add this for running tests in debugger
#TEST_DEBUGGER=lldb --batch -o r
# comma-separated list of tests to exclude from gensuite (relevant for running tests only)
EXCLUDE=
######### Footer #########
-include $(HERE)/local.conf


+ 1
- 1
src/Makefile View File

@ -92,7 +92,7 @@ install: $(TARGET)
timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h \
labeled_int_list.h key_reset.h base64.h sync_codec.h \
../asn.1/*.h $(PREFIX)/include/pEp/
../asn.1/*.h $(PREFIX)/include/pEp/
.PHONY: uninstall
uninstall:


+ 41
- 103
test/Makefile View File

@ -1,126 +1,73 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
HERE:=$(CURDIR)
include ../Makefile.conf
# This is done this way because we presume that users who don't have python3 installed are also not bothering with the generated parts of the test suite (i.e. non-devs).
# Tests will totally build and run without it.
# User's without python3 will skip the generated parts of the test suite. That's OK.
PY_ENV:=$(shell command -v python3 2> /dev/null)
# Since you 'include' before evaluating CURDIR, I think it's possible that CURDIR does not have the value you think it might have. Yes, make is awkward.
# KB: These are probably redundant anyway. But it is supposed to correspond to the directory in src/TestDriver.cc, which is whatever the cwd is that TestDriver is running in.
# It's a pretty trivial point anyway - it's only used in the clean target, and only really matters if tests were interrupted because of a seg fault or non-test assert;
# in that case, the test directory not being cleaned up *might* be problematic, but really probably isn't.
HERE:=$(CURDIR)
TEST_HOME=$(HERE)/pEp_test_home
TARGET=TestDriver
SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
OBJS := $(addsuffix .o,$(basename $(SRCS)))
DEPS := $(OBJS:.o=.d)
SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
DEPS:=$(OBJS:.o=.d)
# Using '/usr/local/include' is very much a "works on my machine" solution to the problem. Either, the compiler search paths are enough, otherwise define a BLA_INC and BLA_LIB path to make clear to other developers what you are looking for outside the standard paths.
# KB: Sure. Then fix that - again, audience of 1-4, and we needed to make our tests work. This file tends to get hacked when settings from above don't end up in compilation.
INC_DIRS := ./include /usr/local/include ../src ../sync ../asn.1
# Whoa dude... addprefix is brilliant. Why didn't I find this before!? This could make setting all the *_INC and *_LIB so much nicer!
INC_FLAGS := $(addprefix -I,$(INC_DIRS)) $(GPGME_INC) $(CPPUNIT_INC)
# '+=' is a magic assignment operators. It ensures that there is exactly one space between the old value and the suffix. Yes, this means it might strip spaces. At any rate, there is no need to add a space after the operator.
# KB: I doubt this was in any way intentional.
LDFLAGS+=-L/usr/local/lib
LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
# For setting both C and C++ compiler flags, there is CPPFLAGS
# KB: This was almost certainly desperation because something wasn't working as it should.
CFLAGS+=-Wno-deprecated
CXXFLAGS+=-Wno-deprecated
CFLAGS:=$(filter-out -Wall,$(CFLAGS))
ifeq ($(OPENPGP),GPG)
LDFLAGS+= $(GPGME_LIB)
else ifeq ($(OPENPGP),NETPGP)
LDFLAGS+= $(NETGPG_LIB)
endif
LDFLAGS+= $(ETPAN_LIB) $(CPPUNIT_LIB) -L../asn.1 -L../src
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
# Caution: you're using tab to indent here, but none of the lines from here to 60 are recipes. Indentation should be done with spaces. This only works because Make is such a gratious tool. (Yeah, right...)
# KB: Feel free to change it.
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -luuid
endif
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lcpptest
ifeq ($(OPENPGP),NETPGP)
LDLIBS+= -lnetpgp
CFLAGS+= -DUSE_NETPGP
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -ltre
endif
LDLIBS+= -luuid
endif
ifdef SQLITE3_FROM_OS
LDLIBS+= -lsqlite3
LDLIBS+= -lsqlite3
endif
# Looks like both LIBPATH and LLDB_BIN aren't needed any more.
# KB: I don't know. Building on MacOS is tetchy, so if it works without it, feel free to remove it.
# But if you break Volker, prepare to hear about it :) Of all the Makefiles to be careful about optimising,
# this one is the worst, because it's the ones devs need to "just work" at all times.
ifeq ($(shell uname),Darwin)
LIBPATH=DYLD_LIBRARY_PATH
LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
else
LIBPATH=LD_LIBRARY_PATH
LLDB_BIN=lldb
ifeq ($(OPENPGP),GPG)
#LDLIBS+= -lgpgme
else ifeq ($(OPENPGP),NETPGP)
LDLIBS+= -lnetpgp
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -ltre
endif
endif
LDLIBS+= -lcpptest
# Probably everything from here to 81 is not needed any more either...
# Create a list of the extra library paths for the loader. I do not assume that the engine (and its dependencies) are installed for testing.
# Note that += can not be used here, as it changes the amount of whitespace
# KB: See above.
EXTRA_LIB_PATHS=../src:
ifdef ETPAN_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
endif
ifdef GPGME_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
endif
ifdef NETPGP_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
endif
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
# Remove trailing ':'
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
# FIXME Possibly missing incdirs: ASN1C_INC
CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) -Wno-deprecated
CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
ifneq ($(MAKECMDGOALS),clean)
ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
$(error The macro NDEBUG must not be defined for test compilation.)
endif
ifeq ($(OPENPGP),GPG)
CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
else ifeq ($(OPENPGP),NETPGP)
CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
endif
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
ifneq ($(MAKECMDGOALS),clean)
ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
$(error The macro NDEBUG must not be defined for test compilation.)
endif
endif
CPPFLAGS += $(INC_FLAGS) -MMD -MP
.PHONY: all
all: suitemaker $(TARGET) scripts
# Forgot the phony for all?
# KB: I have no idea. Again, was just making it work. I bow to the master ;)
all: suitemaker $(TARGET) test_home_ scripts
# There is probably a built-in rules that makes this redundant. Unless we're not using '.cc' or 'CPPFLAGS' as is canon in GNU Make land.
# KB: NOPE. This had to be readded because the built-in rules did NOT use them. Leave it unless you can fix that. I didn't have time to
# investigate why not, I needed the tests to run with the right flags.
# You can do what you want here, as long as I get all the flags I expect to see :)
%.o: %.cc
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
%.d: %.cc
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
$(TARGET): $(OBJS)
$(CXX) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
.PHONY: suitemaker
suitemaker:
@ -134,16 +81,9 @@ else
$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
endif
endif
# This target does nothing.
.PHONY: test_home_
test_home_:
# So, if there is no python, then 'scripts' will trivially be up to date, because there is no recipe associated with this rule. That's probably not what you want.
# KB: That is totally what I want here.
.PHONY: scripts
scripts:
scripts:
ifdef PY_ENV
$(PY_ENV) genscripts.py
endif
@ -151,15 +91,13 @@ endif
.PHONY: test
test: all
$(TEST_DEBUGGER) ./$(TARGET)
.PHONY: clean
clean:
$(RM) $(TARGET) $(OBJS) $(DEPS)
$(RM) $(HERE)/*Tests msg_2.0.asc
# You know, I think we have this "compiler generates Makefiles" pattern in another makefile in the engine, but there it looks completly different. From reading just this makefile: are you sure, the compiler generated Makefiles are actually every generated? You don't have DEPS as a prerequisite anywhere. Is there some built-in rule that has %.d as a prerequisite? Without further investigation I am not convinced the %.d files are ever generated...
# KB: This might be leftover.
-include $(DEPS)
# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif

Loading…
Cancel
Save