Skip to content

Commit 022e66c

Browse files
committed
WIP compile examples on host with 'make examples'
1 parent 53edcfd commit 022e66c

File tree

5 files changed

+528
-0
lines changed

5 files changed

+528
-0
lines changed

tests/host/Makefile

+44
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,47 @@ $(BINARY_DIRECTORY)/core.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE)
123123

124124
$(OUTPUT_BINARY): $(BINARY_DIRECTORY) $(CPP_OBJECTS_TESTS) $(BINARY_DIRECTORY)/core.a
125125
$(CXX) $(LDFLAGS) $(CPP_OBJECTS_TESTS) $(BINARY_DIRECTORY)/core.a $(LIBS) -o $(OUTPUT_BINARY)
126+
127+
#################################################
128+
# building ino sources
129+
-include Makefile.inc.ino
130+
131+
%.ino-host: %.ino-host.o
132+
133+
SDK_PATH := core-mock ../../tools/sdk/include
134+
CORE_LIB_PATH := ../../libraries/ESP8266WiFi/src
135+
136+
INC_CORE_PATHS += $(addprefix -I, \
137+
$(CORE_LIB_PATH) \
138+
$(SDK_PATH) \
139+
)
140+
141+
%.ino-host.o: %.ino-host.cpp
142+
$(CXX) -include core-mock/mock.h $(CXXFLAGS) $(INC_PATHS) $(INC_CORE_PATHS) -c -o $@ $<
143+
144+
.PRECIOUS: %-host.cpp
145+
%.ino-host.cpp: %.ino
146+
cp $< $@
147+
148+
#################################################
149+
# Makefile.inc.ino generation
150+
151+
# default "examples" rule (overridden in Makefile.inc.ino when built)
152+
.PHONY: examples
153+
examples:
154+
# copy examples locally
155+
rm -f Makefile.inc.ino
156+
all=""; \
157+
for dir in ../../libraries/*/examples; do \
158+
exampledir=$${dir%/*}; \
159+
exampledirname=$${exampledir##*/}; \
160+
for subdir in $$dir/*; do \
161+
exname=$${subdir##*/}; \
162+
mkdir -p examples/$$exampledirname/$$exname; \
163+
(cd $$subdir && tar cf - .) | (cd examples/$$exampledirname/$$exname; tar xf -); \
164+
echo examples/$$exampledirname/$$exname/$$exname-host: examples/$$exampledirname/$$exname/$$exname.ino >> Makefile.inc.ino; \
165+
all="$$all examples/$$exampledirname/$$exname/$$exname.ino-host"; \
166+
done; \
167+
done; \
168+
echo "$@: $$all" >> Makefile.inc.ino
169+
$(MAKE) $@

tests/host/core-mock/machine/ansi.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* dummy header file to support BSD compiler */

tests/host/core-mock/mock.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
// include host's STL before any other include file
3+
// because core definition like max() is in the way
4+
#include <vector>
5+
6+
// exotic typedefs used in the sdk
7+
#include <stdint.h>
8+
typedef uint8_t uint8;
9+
typedef uint32_t uint32;

0 commit comments

Comments
 (0)