Skip to content

Commit 67b494d

Browse files
committed
Adapted the makefiles to the new build system
- Zephyr now requires two passes to create the configuration for the cross compiling - Added the missing bits required to build a valid new jerryscript minimal configuration JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez [email protected]
1 parent db36e94 commit 67b494d

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

targets/zephyr/Makefile.zephyr

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif
2828
TARGET_ZEPHYR ?= ./targets/zephyr
2929
TARGET_ZEPHYR_SRC_DIR = $(TARGET_ZEPHYR)/src
3030

31-
TYPE ?= release
31+
TYPE ?= jerry-core
3232
JERRYHEAP ?= 16
3333

3434
# Include functionality like regular expressions
@@ -44,27 +44,20 @@ ifndef ZEPHYR_BASE
4444
$(error Missing Zephyr base, did you source zephyr-env.sh? )
4545
endif
4646

47-
# -cp is required for user-friendly error messages in REPL
48-
VARIETY ?= -cp_minimal
49-
5047
INTERM = build/$(BOARD)/obj-$(BOARD)
5148
OUTPUT = build/$(BOARD)
5249

5350
-include $(ZEPHYR_BASE)/boards/$(BOARD_NAME)/Makefile.board
5451
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
5552

56-
CC = $(CROSS_COMPILE)gcc
57-
5853
EXT_CFLAGS := -fno-asynchronous-unwind-tables -fno-omit-frame-pointer
5954
EXT_CFLAGS += -fno-stack-protector -fno-strict-overflow -ffreestanding
6055
EXT_CFLAGS += -fno-reorder-functions -fno-defer-pop -fdata-sections
6156
EXT_CFLAGS += -ffunction-sections -fno-inline-functions
6257

63-
# TODO @sergioamr Read the arch and cflags from zephyr
64-
6558
ifeq ($(BOARD),qemu_x86)
6659
CONFIG_TOOLCHAIN_VARIANT = x86
67-
CPU = x86
60+
CPU = i686
6861
EXT_CFLAGS += -march=pentium
6962
EXT_CFLAGS += -mpreferred-stack-boundary=2 -mno-sse
7063
else ifeq ($(BOARD),$(filter $(BOARD),qemu_cortex_m3 frdm_k64f))
@@ -78,31 +71,36 @@ CPU = arc
7871
EXT_CFLAGS += -mARCv2EM -mav2em -mno-sdata
7972
else
8073
CONFIG_TOOLCHAIN_VARIANT = iamcu
81-
CPU = lakemont
74+
CPU = i686
8275
EXT_CFLAGS += -march=lakemont -mtune=lakemont -miamcu -msoft-float
8376
EXT_CFLAGS += -mpreferred-stack-boundary=2 -mno-sse
8477
endif
8578

8679
EXT_CFLAGS += -Wall -Wno-format-zero-length -Wno-pointer-sign
8780
EXT_CFLAGS += -Werror=format -Werror=implicit-int -Wno-unused-but-set-variable
88-
EXT_CFLAGS += -Wno-main -Wno-strict-aliasing
81+
EXT_CFLAGS += -Wno-main -Wno-strict-aliasing -Wno-old-style-declaration
8982
EXT_CFLAGS += -Wno-error=format=
9083

91-
EXT_CFLAGS += $(TOOLCHAIN_CFLAGS)
92-
EXT_CFLAGS += $(LIB_INCLUDE_DIR)
93-
EXT_CFLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
94-
EXT_CFLAGS += -isystem $(shell $(CC) -print-file-name=include-fixed)
84+
# Pass2
85+
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
86+
87+
CC = $(CROSS_COMPILE)gcc
9588

9689
ZEPHYR_LIBC_INC = $(subst -I,,$(TOOLCHAIN_CFLAGS))
9790
LIB_INCLUDE_DIR += -L $(CURDIR)/$(OUTPUT)
9891

99-
EXTERNAL_LIB = $(INTERM)/lib$(TYPE).external$(VARIETY)-entry.a
92+
# TODO: Order of includes seems to have changed and time_t seems to be defined differently. Temporary disable the conversion and sign-conversion until we find what is happening
93+
# this will generate warnings on the default date port.
94+
EXT_CFLAGS += -Wno-error=conversion -Wno-error=sign-conversion
95+
EXT_CFLAGS += $(LIB_INCLUDE_DIR)
96+
EXT_CFLAGS += $(TOOLCHAIN_CFLAGS)
97+
98+
EXTERNAL_LIB = $(INTERM)/lib/libjerry-core.a
10099
ZEPHYR_BIN = $(OUTPUT)/zephyr/zephyr.strip
101100

102-
PREFIX = $(TYPE)$(VARIETY)
103-
LIBS = $(TYPE).external$(VARIETY)-entry $(PREFIX).jerry-core $(PREFIX).jerry-libm.lib
101+
LIBS = jerry-core
104102

105-
BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(OUTPUT)" TARGET_ZEPHYR=$(TARGET_ZEPHYR)
103+
BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(INTERM)/lib" TARGET_ZEPHYR=$(TARGET_ZEPHYR)
106104

107105
.PHONY: all
108106
all: jerry zephyr
@@ -114,23 +112,24 @@ endif
114112
mkdir -p $(INTERM)
115113
mkdir -p $(OUTPUT)
116114
cmake -B$(INTERM) -H./ \
117-
-DENABLE_LTO=OFF \
118-
-DENABLE_VALGRIND=OFF \
115+
-DENABLE_LTO=OFF \
116+
-DFEATURE_VALGRIND=OFF \
117+
-DFEATURE_PROFILE=minimal \
119118
-DCMAKE_BUILD_TYPE=Release \
120119
-DCMAKE_VERBOSE_MAKEFILE=$(V) \
120+
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \
121121
-DEXTERNAL_CMAKE_C_COMPILER=$(CC) \
122122
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
123123
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=$(CPU) \
124-
-DEXTERNAL_MEM_HEAP_SIZE_KB=$(JERRYHEAP) \
124+
-DCOMPILER_DEFAULT_LIBC=OFF \
125+
-DJERRY_CMDLINE=OFF \
125126
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
126-
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=lakemont \
127-
-DEXTERNAL_LIBC_INTERFACE="$(ZEPHYR_LIBC_INC)" \
128-
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
129-
-DEXTERNAL_BUILD_ENTRY_FILE=$(TARGET_ZEPHYR_SRC_DIR)/jerry-entry.c
127+
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \
128+
-DFEATURE_SNAPSHOT_EXEC=OFF \
129+
-DENABLE_ALL_IN_ONE=OFF \
130+
-DJERRY_LIBC=OFF
130131

131-
make -C $(INTERM) $(TYPE).external$(VARIETY) V=1
132-
cp `cat $(INTERM)/$(TYPE).external$(VARIETY)/list` $(OUTPUT)/.
133-
cp $(EXTERNAL_LIB) $(OUTPUT)/.
132+
make -C $(INTERM) $(TYPE)$(VARIETY) V=1
134133

135134
$(ZEPHYR_BIN):
136135
ifdef V
@@ -153,6 +152,9 @@ qemu: $(EXTERNAL_LIB) $(ZEPHYR_BIN)
153152
flash: $(EXTERNAL_LIB) $(OUTPUT)/zephyr/zephyr.strip
154153
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) flash
155154

155+
debugserver:
156+
make -f $(TARGET_ZEPHYR)/Makefile BOARD=$(BOARD_NAME) debugserver
157+
156158
dfu-x86: all
157159
@- dfu-util -a x86_app -D build/$(BOARD)/zephyr/zephyr.bin; \
158160
if [ $$? -eq 0 ] ; then echo "\nYour program will launch in 5 seconds." ; \
@@ -178,10 +180,9 @@ showconfig:
178180
@echo "LIBS = $(LIBS) "
179181
@echo "LIB_INCLUDE_DIR = $(LIB_INCLUDE_DIR) "
180182
@echo "BUILD_CONFIG = $(BUILD_CONFIG) "
183+
@echo "ZEPHYR_LIBC_INC = $(ZEPHYR_LIBC_INC) "
181184
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) showconfig
182185

183-
# TODO @sergioamr Temporal cleanup before finding why Zephyr is ignoring my
184-
# outdir for the project
185186
clean:
186187
@echo "Clearing Jerryscript"
187188
@rm -rf $(OUTPUT)

0 commit comments

Comments
 (0)