Skip to content

Commit

Permalink
Add Makefile and run tests on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Mar 3, 2016
1 parent 6246659 commit 93fee9d
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ os:
- linux

script:
- set -e
- pushd $TRAVIS_BUILD_DIR/tests/host
- make
- popd
- wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
- tar xf arduino.tar.xz
- mv arduino-nightly $HOME/arduino_ide
Expand Down
79 changes: 79 additions & 0 deletions tests/host/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
OBJECT_DIRECTORY := obj
BINARY_DIRECTORY := bin
OUTPUT_BINARY := $(BINARY_DIRECTORY)/host_tests
CORE_PATH := ../../cores/esp8266

CORE_CPP_FILES := $(addprefix $(CORE_PATH)/,\
StreamString.cpp \
Stream.cpp \
WString.cpp \
Print.cpp \
FS.cpp \
spiffs_api.cpp \
)

CORE_C_FILES := $(addprefix $(CORE_PATH)/,\
core_esp8266_noniso.c \
spiffs/spiffs_cache.c \
spiffs/spiffs_check.c \
spiffs/spiffs_gc.c \
spiffs/spiffs_hydrogen.c \
spiffs/spiffs_nucleus.c \
)

MOCK_CPP_FILES := $(addprefix common/,\
Arduino.cpp \
spiffs_mock.cpp \
WMath.cpp \
)

INC_PATHS += $(addprefix -I, \
common \
$(CORE_PATH) \
)

TEST_CPP_FILES := \
fs/test_fs.cpp \

CXXFLAGS += -std=c++11 -Wall
CFLAGS += -std=c99 -Wall

remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))

C_SOURCE_FILES = $(CORE_C_FILES)
CPP_SOURCE_FILES = $(MOCK_CPP_FILES) $(CORE_CPP_FILES) $(TEST_CPP_FILES)
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES:.c=.c.o) )

CPP_SOURCE_FILE_NAMES = $(notdir $(CPP_SOURCE_FILES))
CPP_PATHS = $(call remduplicates, $(dir $(CPP_SOURCE_FILES) ))
CPP_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(CPP_SOURCE_FILE_NAMES:.cpp=.cpp.o) )

$(warning $(call remduplicates, $(dir $(CPP_SOURCE_FILES) )))
vpath %.c $(C_PATHS)
vpath %.cpp $(CPP_PATHS)

OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS)

all: $(OUTPUT_BINARY) test

test: $(OUTPUT_BINARY)
$(OUTPUT_BINARY)

$(OBJECT_DIRECTORY):
mkdir -p $@

$(BINARY_DIRECTORY):
mkdir -p $@

$(C_OBJECTS): $(OBJECT_DIRECTORY)/%.c.o: %.c
$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<

$(CPP_OBJECTS): $(OBJECT_DIRECTORY)/%.cpp.o: %.cpp
$(CXX) $(CXXFLAGS) $(INC_PATHS) -c -o $@ $<


# Link
$(OUTPUT_BINARY): $(BINARY_DIRECTORY) $(OBJECT_DIRECTORY) $(OBJECTS)
$(CXX) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY)

0 comments on commit 93fee9d

Please sign in to comment.