Minor improvement to the test build system.

Signed-off-by: Eric Paniagua <epaniagua@google.com>
epan/testing/readable
Eric Paniagua 4 years ago
parent dba2d77a97
commit c21f367c2e

@ -1,25 +1,26 @@
LIB_DIR?=${PWD}/lib COMMON_LIB_DIR?=${PWD}/lib
TEST_DIRS=$(dir $(wildcard */*_test.cpp)) TEST_DIRS=$(shell dirname $(wildcard */Makefile))
Makefile: build-libs ${TEST_DIRS} Makefile: ${TEST_DIRS} FORCE
@: @echo TEST_DIRS="${TEST_DIRS}"
build-libs: googletest common
@:
googletest: FORCE googletest: FORCE
cd googletest && $(MAKE) cd googletest && $(MAKE)
common: FORCE common: FORCE
cd common && env LIB_DIR="${LIB_DIR}" $(MAKE) cd common && env COMMON_LIB_DIR="${COMMON_LIB_DIR}" $(MAKE)
clean: FORCE clean:
rm -rf "${LIB_DIR}" rm -rf "${COMMON_LIB_DIR}"
cd googletest && make clean
cd common && make clean cd common && make clean
cd hello-simulator && make clean cd hello-simulator && make clean
cd kaleidoscope && make clean cd kaleidoscope && make clean
%: common googltest FORCE hello-simulator:
if [ -f "$@/Makefile" ]; then cd "$@"; $(MAKE); fi @:
%: common googletest FORCE
cd "$@" && $(MAKE)
.PHONY: FORCE googletest build-libs .PHONY: FORCE googletest build-libs

@ -1,17 +1,16 @@
LIB_DIR ?= ${PWD}/lib COMMON_LIB_DIR ?= ${PWD}/lib
OBJ_DIR ?= ${PWD}/obj OBJ_DIR ?= ${PWD}/obj
CXX_FILES=$(wildcard *.cpp) CXX_FILES=$(wildcard *.cpp)
LIB_FILE=libcommon.a LIB_FILE=libcommon.a
OBJ_FILES=$(patsubst %.cpp,${OBJ_DIR}/%.o,$(CXX_FILES)) OBJ_FILES=$(patsubst %.cpp,${OBJ_DIR}/%.o,$(CXX_FILES))
Makefile: ${OBJ_FILES} ${LIB_DIR}/${LIB_FILE} Makefile: ${OBJ_FILES} ${COMMON_LIB_DIR}/${LIB_FILE}
@: @:
${LIB_DIR}/${LIB_FILE}: ${OBJ_FILES} ${COMMON_LIB_DIR}/${LIB_FILE}: ${OBJ_FILES}
mkdir -p "${LIB_DIR}" mkdir -p "${COMMON_LIB_DIR}"
ar rcs "${LIB_DIR}/${LIB_FILE}" ${OBJ_FILES} ar rcs "${COMMON_LIB_DIR}/${LIB_FILE}" ${OBJ_FILES}
${OBJ_DIR}/%.o: %.cpp $(wildcard *.h) ${OBJ_DIR}/%.o: %.cpp $(wildcard *.h)
@echo "compile $@" @echo "compile $@"
@ -36,4 +35,4 @@ ${OBJ_DIR}/%.o: %.cpp $(wildcard *.h)
$< $<
clean: clean:
rm -rf "${LIB_DIR}" "${OBJ_DIR}" rm -rf "${COMMON_LIB_DIR}" "${OBJ_DIR}"

@ -23,13 +23,13 @@ ${OBJ_DIR}/%.o: %.cpp
@echo "compile $@" @echo "compile $@"
mkdir -p "${OBJ_DIR}" mkdir -p "${OBJ_DIR}"
g++ -o "$@" -c \ g++ -o "$@" -c \
-I../.. \ -I${PWD}/../.. \
-I../../src \ -I${PWD}/../../src \
-I../../../../../virtual/cores/arduino \ -I${PWD}/../../../../../virtual/cores/arduino \
-I../../../Kaleidoscope-HIDAdaptor-KeyboardioHID/src \ -I${PWD}/../../../Kaleidoscope-HIDAdaptor-KeyboardioHID/src \
-I../../../KeyboardioHID/src \ -I${PWD}/../../../KeyboardioHID/src \
-I../../testing/googletest/googlemock/include \ -I${PWD}/../../testing/googletest/googlemock/include \
-I../../testing/googletest/googletest/include \ -I${PWD}/../../testing/googletest/googletest/include \
-DARDUINO=10607 \ -DARDUINO=10607 \
-DARDUINO_ARCH_VIRTUAL \ -DARDUINO_ARCH_VIRTUAL \
-DARDUINO_AVR_MODEL01 \ -DARDUINO_AVR_MODEL01 \
@ -41,7 +41,7 @@ ${OBJ_DIR}/%.o: %.cpp
'-DUSB_PRODUCT="Model 01"' \ '-DUSB_PRODUCT="Model 01"' \
$< $<
clean: FORCE clean:
rm -rf "${BIN_DIR}" "${LIB_DIR}" "${OBJ_DIR}" rm -rf "${BIN_DIR}" "${LIB_DIR}" "${OBJ_DIR}"
.PHONY: FORCE .PHONY: FORCE

@ -1,4 +1,5 @@
BIN_DIR=bin BIN_DIR=bin
COMMON_LIB_DIR ?= ${PWD}/../lib
LIB_DIR=lib LIB_DIR=lib
OBJ_DIR=obj OBJ_DIR=obj
SRC_DIR=test SRC_DIR=test
@ -23,7 +24,7 @@ ${BIN_DIR}/${BIN_FILE}: ${TEST_OBJS} FORCE
-g \ -g \
-w \ -w \
${TEST_OBJS} \ ${TEST_OBJS} \
-L"${PWD}/../lib" \ -L"${COMMON_LIB_DIR}" \
-lcommon \ -lcommon \
"${LIB_DIR}/${LIB_FILE}" \ "${LIB_DIR}/${LIB_FILE}" \
-L"$(PWD)/../googletest/lib" \ -L"$(PWD)/../googletest/lib" \

Loading…
Cancel
Save