Skip to content

Commit 290bc22

Browse files
pfalconLaszloLango
authored andcommitted
targets: zephyr: Update for Zephyr 1.10 which uses CMake-based build. (#2155)
In 1.10, Zephyr RTOS switched to CMake as means to generate application makefiles. Consequently, drop Makefile, and introduce CMakeLists.txt, and update master Makefile.zephyr accordingly. With these changes, take a chance to make following "cosmetic" changes: 1. Make "qemu_x86" board target the default instead of "arduino_101". Arduino 101 is just one of the boards of many supported by Zephyr (and thus JerryScript port), while qemu_x86 is something everyone has. 2. Zephyr make target to run QEMU switched from "qemu" to "run". 3. Don't rely that there's zephyr.strip, it's presence is now board-dependent. The most we can rely on is zephyr.elf. targets: zephyr: Remove deprecated prj.mdef file. MDEF files have been deprecated and ignored for few Zephyr releases. targets: zephyr: Increase main (i.e. interpreter) thread stack size. qemu_x86 target now has stack guard enabled by default and it trips with the default stack size. Set it to 2K for now. targets: zephyr: Makefile.travis: Update for Zephyr 1.10. Zephyr 1.10 requires SDK 0.9.2 and CMake 3.8.2. Also, don't hardcode CC path, it depends on a board and choosed automatically by Zephyr build system. JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
1 parent e0e6aa0 commit 290bc22

File tree

7 files changed

+69
-85
lines changed

7 files changed

+69
-85
lines changed

targets/zephyr/CMakeLists.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright JS Foundation and other contributors, http://js.foundation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
16+
project(NONE)
17+
18+
target_sources(app PRIVATE src/main-zephyr.c src/jerry-port.c src/getline-zephyr.c)
19+
20+
add_library(jerry-core STATIC IMPORTED)
21+
add_library(jerry-ext STATIC IMPORTED)
22+
set_target_properties(jerry-core PROPERTIES IMPORTED_LOCATION
23+
${CMAKE_CURRENT_BINARY_DIR}/../obj/lib/libjerry-core.a)
24+
set_target_properties(jerry-core PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
25+
${CMAKE_CURRENT_SOURCE_DIR}/../../jerry-core/include)
26+
set_target_properties(jerry-ext PROPERTIES IMPORTED_LOCATION
27+
${CMAKE_CURRENT_BINARY_DIR}/../obj/lib/libjerry-ext.a)
28+
set_target_properties(jerry-ext PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
29+
${CMAKE_CURRENT_SOURCE_DIR}/../../jerry-ext/include)
30+
target_link_libraries(app jerry-core jerry-ext)
31+
32+
zephyr_get_include_directories_for_lang_as_string(C includes)
33+
zephyr_get_system_include_directories_for_lang_as_string(C system_includes)
34+
zephyr_get_compile_definitions_for_lang_as_string(C definitions)
35+
zephyr_get_compile_options_for_lang_as_string(C options)
36+
37+
add_custom_target(
38+
outputexports
39+
COMMAND echo CC="${CMAKE_C_COMPILER}"
40+
COMMAND echo Z_CFLAGS=${system_includes} ${includes} ${definitions} ${options}
41+
COMMAND echo NOSTDINC_FLAGS=${system_includes}
42+
COMMAND echo ZEPHYRINCLUDE=${includes}
43+
COMMAND echo KBUILD_CFLAGS=${definitions}${options}
44+
VERBATIM
45+
USES_TERMINAL
46+
)
47+

targets/zephyr/Makefile

Lines changed: 0 additions & 62 deletions
This file was deleted.

targets/zephyr/Makefile.travis

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ install-apt-get-deps:
2727

2828
# Install Zephyr SDK.
2929
install-zephyr-sdk:
30-
wget https://github.com/zephyrproject-rtos/meta-zephyr-sdk/releases/download/0.9.1/zephyr-sdk-0.9.1-setup.run -O ../zephyr-sdk-0.9.1-setup.run
31-
sh ../zephyr-sdk-0.9.1-setup.run -- -y -d $(CURDIR)/../zephyr-sdk-0.9.1
30+
wget https://github.com/zephyrproject-rtos/meta-zephyr-sdk/releases/download/0.9.2/zephyr-sdk-0.9.2-setup.run -O ../zephyr-sdk-0.9.2-setup.run
31+
sh ../zephyr-sdk-0.9.2-setup.run -- -y -d $(CURDIR)/../zephyr-sdk-0.9.2
32+
wget https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.sh
33+
sudo sh cmake-3.8.2-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir
34+
cmake --version
3235

3336
# Fetch Zephyr Project repository and install python dependencies.
3437
install-zephyr: install-apt-get-deps
35-
git clone https://github.com/zephyrproject-rtos/zephyr.git ../zephyr -b zephyr-v1.9.1
38+
git clone https://github.com/zephyrproject-rtos/zephyr.git ../zephyr -b v1.10.0
3639
pip3 install --user -r ../zephyr/scripts/requirements.txt
3740

3841
# Perform all the necessary (JerryScript-independent) installation steps.
@@ -45,7 +48,6 @@ install: install-zephyr-sdk install-zephyr
4548
SHELL=bash
4649
script:
4750
export ZEPHYR_GCC_VARIANT=zephyr && \
48-
export ZEPHYR_SDK_INSTALL_DIR=$(CURDIR)/../zephyr-sdk-0.9.1 && \
51+
export ZEPHYR_SDK_INSTALL_DIR=$(CURDIR)/../zephyr-sdk-0.9.2 && \
4952
source ../zephyr/zephyr-env.sh && \
50-
CC=$(CURDIR)/../zephyr-sdk-0.9.1/sysroots/x86_64-pokysdk-linux/usr/bin/i586-zephyr-elfiamcu/i586-zephyr-elfiamcu-gcc \
5153
$(MAKE) -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101

targets/zephyr/Makefile.zephyr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ ifeq ($(.DEFAULT_GOAL),)
1818
$(warning no default goal is set)
1919
endif
2020

21-
BOARD ?= arduino_101
21+
BOARD ?= qemu_x86
22+
CONF_FILE = prj.conf
2223
export BOARD
2324

2425
TARGET_ZEPHYR ?= ./targets/zephyr
@@ -41,7 +42,7 @@ ifndef ZEPHYR_BASE
4142
$(error Missing Zephyr base, did you source zephyr-env.sh? )
4243
endif
4344

44-
INTERM = build/$(BOARD)/obj-$(BOARD)
45+
INTERM = build/$(BOARD)/obj
4546
OUTPUT = build/$(BOARD)/zephyr
4647

4748
include $(OUTPUT)/Makefile.export
@@ -94,25 +95,24 @@ endif
9495

9596
make -C $(INTERM) $(COMPONENTS) V=1
9697

97-
$(OUTPUT)/Makefile.export: $(OUTPUT)/include/config/auto.conf
98-
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) outputexports
98+
$(OUTPUT)/Makefile.export: $(OUTPUT)/Makefile
99+
make --no-print-directory -C $(OUTPUT) outputexports CMAKE_COMMAND=: >$@
99100

100-
$(OUTPUT)/include/config/auto.conf:
101-
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) initconfig
101+
$(OUTPUT)/Makefile:
102+
mkdir -p $(OUTPUT) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -B$(OUTPUT) -Htargets/zephyr/
102103

103104
zephyr: jerry
104105
ifdef V
105106
@echo "- ZEPHYR -------------------------------------------------------"
106107
endif
107-
+make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG)
108+
+make -C $(OUTPUT)
108109
@echo "Finished"
109-
@file $(OUTPUT)/zephyr.strip
110-
@size $(OUTPUT)/zephyr.strip
110+
@size $(OUTPUT)/zephyr/zephyr.elf
111111

112112
jerry: $(EXTERNAL_LIB)
113113
@touch $(EXTERNAL_LIB)
114114

115-
GENERIC_TARGETS = qemu qemugdb flash debug debugserver
115+
GENERIC_TARGETS = run qemugdb flash debug debugserver
116116
KCONFIG_TARGETS = \
117117
initconfig config nconfig menuconfig xconfig gconfig \
118118
oldconfig silentoldconfig defconfig savedefconfig \
@@ -127,7 +127,7 @@ $(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
127127
ifdef V
128128
@echo "- ZEPHYR -------------------------------------------------------"
129129
endif
130-
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) $@
130+
make -C $(OUTPUT) $@
131131

132132
dfu-x86: all
133133
@- dfu-util -a x86_app -D build/$(BOARD)/zephyr/zephyr.bin; \

targets/zephyr/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ The easiest way is to build and run on a QEMU emulator:
5555
For x86 architecture:
5656

5757
```
58-
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_x86 qemu
58+
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_x86 run
5959
```
6060

6161
For ARM (Cortex-M) architecture:
6262

6363
```
64-
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 qemu
64+
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 run
6565
```
6666

6767
#### 4. Build for Arduino 101

targets/zephyr/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
CONFIG_BUILD_OUTPUT_BIN=y
12
CONFIG_STDOUT_CONSOLE=y
23
CONFIG_NEWLIB_LIBC=y
34
CONFIG_FLOAT=y
5+
CONFIG_MAIN_STACK_SIZE=2048
46
CONFIG_CONSOLE_HANDLER=y
57
CONFIG_CONSOLE_HANDLER_SHELL=y
68
CONFIG_ARC_INIT=n

targets/zephyr/prj.mdef

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)