Skip to content

Commit 9652424

Browse files
author
Roland Takacs
committed
Modify the build method of TizenRT target
Introduced a cmake/toolchain_mcu_artik053.cmake file that defines all the target specific compiler options. Modified the Makefile.tizenrt to do not copy the created static libraries to the TizenRT folder. Instead, the application builder Makefile (tizenrt-artik053/apps/jerryscript/Makefile) copies the required static libraries to TizenRT. JerryScript-DCO-1.0-Signed-off-by: Roland Takacs [email protected]
1 parent f833da2 commit 9652424

File tree

6 files changed

+63
-70
lines changed

6 files changed

+63
-70
lines changed

cmake/toolchain_mcu_artik053.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
set(CMAKE_SYSTEM_NAME TizenRT)
16+
set(CMAKE_SYSTEM_PROCESSOR armv7l)
17+
set(CMAKE_SYSTEM_VERSION ARTIK053)
18+
19+
set(FLAGS_COMMON_ARCH -mcpu=cortex-r4 -mfpu=vfpv3 -fno-builtin -fno-strict-aliasing -fomit-frame-pointer -fno-strength-reduce -Wall -Werror -Wshadow -Wno-error=conversion)
20+
21+
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
22+
set(CMAKE_C_COMPILER_WORKS TRUE)

targets/tizenrt-artik053/Makefile.tizenrt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,26 @@
1313
# limitations under the License.
1414

1515
JERRYHEAP ?= 16
16-
BUILD_DIR ?= build/tizenrt-artik053
17-
LIBTARGET_DIR ?= $(abspath $(PWD)/../TizenRT/build/output/libraries)
16+
BUILD_DIR ?= build
1817

19-
EXT_CFLAGS += -mcpu=cortex-r4 -mfpu=vfpv3
20-
EXT_CFLAGS += -fno-builtin -fno-strict-aliasing
21-
EXT_CFLAGS += -fomit-frame-pointer
22-
EXT_CFLAGS += -fno-strength-reduce
23-
EXT_CFLAGS += -Wall -Werror -Wshadow
24-
EXT_CFLAGS += -Wno-error=conversion
2518
EXT_CFLAGS += -I. -isystem ../TizenRT/os/include
2619

2720
.PHONY: libjerry clean
2821

2922
all: libjerry
3023

3124
libjerry:
32-
mkdir -p $(BUILD_DIR)
33-
mkdir -p $(LIBTARGET_DIR)
3425
cmake -B$(BUILD_DIR) -H./ \
35-
-DCMAKE_SYSTEM_NAME=TizenRT \
36-
-DCMAKE_SYSTEM_PROCESSOR=armv7l \
37-
-DCMAKE_C_COMPILER=arm-none-eabi-gcc \
38-
-DCMAKE_C_COMPILER_WORKS=TRUE \
3926
-DENABLE_LTO=OFF \
4027
-DENABLE_ALL_IN_ONE=OFF \
4128
-DJERRY_LIBC=OFF \
4229
-DJERRY_CMDLINE=OFF \
4330
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
4431
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \
45-
-DCMAKE_BUILD_TYPE=Release
32+
-DCMAKE_BUILD_TYPE=Release \
33+
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_mcu_artik053.cmake
4634

4735
make -C$(BUILD_DIR) jerry-core jerry-libm jerry-ext
48-
cp $(BUILD_DIR)/lib/libjerry-core.a $(LIBTARGET_DIR)
49-
cp $(BUILD_DIR)/lib/libjerry-libm.a $(LIBTARGET_DIR)
50-
cp $(BUILD_DIR)/lib/libjerry-ext.a $(LIBTARGET_DIR)
5136

5237
clean:
5338
rm -rf $(BUILD_DIR)

targets/tizenrt-artik053/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ $ mkdir res
8181

8282
#### 5. Build JerryScript for TizenRT
8383

84+
```
85+
# assuming you are in jerry-tizenrt folder
86+
jerryscript/tools/build.py \
87+
--clean \
88+
--lto=OFF \
89+
--jerry-cmdline=OFF \
90+
--jerry-libc=OFF \
91+
--all-in-one=OFF \
92+
--mem-heap=70 \
93+
--profile=es2015-subset \
94+
--compile-flag="--sysroot=${PWD}/TizenRT/os" \
95+
--toolchain=${PWD}/jerryscript/cmake/toolchain_mcu_artik053.cmake
96+
```
97+
98+
**Note**: there is a Makefile in the `targets/tizenrt-artik053/` folder that also helps to build JerryScript for TizenRT.
99+
84100
```
85101
# assuming you are in jerry-tizenrt folder
86102
$ cd jerryscript

targets/tizenrt-artik053/apps/jerryscript/Kconfig

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,4 @@ config JERRYSCRIPT_STACKSIZE
2727
int "Jerryscript stack size"
2828
default 16384
2929

30-
config JERRYSCRIPT_HEAPSIZE
31-
int "Jerryscript heap size"
32-
default 107520
33-
34-
config JERRYSCRIPT_ERROR_MESSAGES
35-
bool "Enable error messages for builtin error objects"
36-
default n
37-
38-
config JERRYSCRIPT_MEM_STATS
39-
bool "Enable memory statistics"
40-
default n
41-
42-
config JERRYSCRIPT_SHOW_OPCODES
43-
bool "Enable parser byte-code dumps"
44-
default n
45-
46-
config JERRYSCRIPT_DEBUGGER
47-
bool "Jerryscript debugger"
48-
default n
49-
endif
30+
endif # JERRYSCRIPT

targets/tizenrt-artik053/apps/jerryscript/Makefile

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,40 +67,28 @@
6767
-include $(TOPDIR)/Make.defs
6868
include $(APPDIR)/Make.defs
6969

70-
# Jerryscript built-in application info
71-
70+
# JerryScript built-in application information.
7271
CONFIG_JERRYSCRIPT_PRIORITY ?= SCHED_PRIORITY_DEFAULT
72+
CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
7373
CONFIG_JERRYSCRIPT_STACKSIZE ?= 32768
74-
CONFIG_JERRYSCRIPT_HEAPSIZE ?= 64000
7574

76-
APPNAME = jerry
77-
# path to the project dir, "tizenrt-artik053" by default
78-
ROOT_DIR = ../../../..
7975
PRIORITY = $(CONFIG_JERRYSCRIPT_PRIORITY)
76+
PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
8077
STACKSIZE = $(CONFIG_JERRYSCRIPT_STACKSIZE)
81-
CFLAGS += -std=c99 -DJERRY_NDEBUG '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
82-
CFLAGS += -I$(ROOT_DIR)/ $(shell find $(ROOT_DIR)/jerryscript/jerry-core -type d | sed -r -e 's/^/-I/g')
83-
CFLAGS += -I$(ROOT_DIR)/jerryscript/jerry-ext/include
8478

85-
ifeq ($(CONFIG_JERRYSCRIPT_MEM_STATS),y)
86-
CFLAGS += -DJMEM_STATS
87-
endif
88-
89-
ifeq ($(CONFIG_JERRYSCRIPT_SHOW_OPCODES),y)
90-
CFLAGS += -DPARSER_DUMP_BYTE_CODE
91-
endif
92-
93-
ifeq ($(CONFIG_JERRYSCRIPT_DEBUGGER),y)
94-
CFLAGS += -DJERRY_DEBUGGER
95-
endif
79+
# Path to the JerryScript project. If not specified, it is supposed
80+
# that JerryScript is located next to the TizenRT folder.
81+
JERRYSCRIPT_ROOT_DIR ?= ../../../../jerryscript
9682

83+
CFLAGS += -std=c99
84+
CFLAGS += -I$(JERRYSCRIPT_ROOT_DIR)/jerry-core/include
85+
CFLAGS += -I$(JERRYSCRIPT_ROOT_DIR)/jerry-ext/include
9786

9887
EXTRA_LIBS += libjerry-core.a libjerry-libm.a
9988
LINKLIBS=$(EXTRA_LIBS)
10089

101-
90+
APPNAME = jerry
10291
ASRCS = setjmp.S
103-
CSRCS =
10492
MAINSRC = jerry_main.c
10593

10694
AOBJS = $(ASRCS:.S=$(OBJEXT))
@@ -130,17 +118,16 @@ else
130118
INSTALL_DIR = $(BIN_DIR)
131119
endif
132120

133-
CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
134-
PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
135121

136122
ROOTDEPPATH = --dep-path .
137123

138124
# Common build
139125

140126
VPATH =
141127

142-
all: .built
143-
.PHONY: context depend clean distclean
128+
129+
all: copylibs .built
130+
.PHONY: copylibs context depend clean distclean
144131

145132
$(AOBJS): %$(OBJEXT): %.S
146133
$(call ASSEMBLE, $<, $@)
@@ -152,6 +139,9 @@ $(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
152139
$(call ARCHIVE, $(BIN), $(OBJS))
153140
$(Q) touch .built
154141

142+
copylibs:
143+
cp $(JERRYSCRIPT_ROOT_DIR)/build/lib/lib*.a $(TOPDIR)/../build/output/libraries/
144+
155145
install:
156146

157147
context:

targets/tizenrt-artik053/apps/jerryscript/jerry_main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "jerryscript.h"
2222
#include "jerryscript-ext/handler.h"
2323
#include "jerryscript-port.h"
24-
#include "jmem.h"
2524
#include "setjmp.h"
2625

2726
#include <apps/shell/tash.h> // To register tash command
@@ -63,7 +62,7 @@ print_help (char *name)
6362
/**
6463
* Read source code into buffer.
6564
*
66-
* Returned value must be freed with jmem_heap_free_block if it's not NULL.
65+
* Returned value must be freed if it's not NULL.
6766
* @return NULL, if read or allocation has failed
6867
* pointer to the allocated memory block, otherwise
6968
*/
@@ -96,7 +95,7 @@ read_file (const char *file_name, /**< source code */
9695

9796
rewind (file);
9897

99-
uint8_t *buffer = jmem_heap_alloc_block_null_on_error (script_len);
98+
uint8_t *buffer = (uint8_t *) malloc (script_len);
10099

101100
if (buffer == NULL)
102101
{
@@ -110,7 +109,7 @@ read_file (const char *file_name, /**< source code */
110109
if (!bytes_read || bytes_read != script_len)
111110
{
112111
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: failed to read file: %s\n", file_name);
113-
jmem_heap_free_block ((void*) buffer, script_len);
112+
free ((void*) buffer);
114113

115114
fclose (file);
116115
return NULL;
@@ -458,12 +457,12 @@ jerry_cmd_main (int argc, char *argv[])
458457
if (jerry_value_has_error_flag (ret_value))
459458
{
460459
print_unhandled_exception (ret_value, source_p);
461-
jmem_heap_free_block ((void*) source_p, source_size);
460+
free ((void*) source_p);
462461

463462
break;
464463
}
465464

466-
jmem_heap_free_block ((void*) source_p, source_size);
465+
free ((void*) source_p);
467466

468467
jerry_release_value (ret_value);
469468
ret_value = jerry_create_undefined ();

0 commit comments

Comments
 (0)