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 rtakacs.uszeged@partner.samsung.com
This commit is contained in:
Roland Takacs
2018-01-09 11:27:51 +01:00
committed by yichoi
parent ded0d5a846
commit 680bafdc8c
6 changed files with 63 additions and 70 deletions
+22
View File
@@ -0,0 +1,22 @@
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(CMAKE_SYSTEM_NAME TizenRT)
set(CMAKE_SYSTEM_PROCESSOR armv7l)
set(CMAKE_SYSTEM_VERSION ARTIK053)
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)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_C_COMPILER_WORKS TRUE)
+3 -18
View File
@@ -13,15 +13,8 @@
# limitations under the License. # limitations under the License.
JERRYHEAP ?= 16 JERRYHEAP ?= 16
BUILD_DIR ?= build/tizenrt-artik053 BUILD_DIR ?= build
LIBTARGET_DIR ?= $(abspath $(PWD)/../TizenRT/build/output/libraries)
EXT_CFLAGS += -mcpu=cortex-r4 -mfpu=vfpv3
EXT_CFLAGS += -fno-builtin -fno-strict-aliasing
EXT_CFLAGS += -fomit-frame-pointer
EXT_CFLAGS += -fno-strength-reduce
EXT_CFLAGS += -Wall -Werror -Wshadow
EXT_CFLAGS += -Wno-error=conversion
EXT_CFLAGS += -I. -isystem ../TizenRT/os/include EXT_CFLAGS += -I. -isystem ../TizenRT/os/include
.PHONY: libjerry clean .PHONY: libjerry clean
@@ -29,25 +22,17 @@ EXT_CFLAGS += -I. -isystem ../TizenRT/os/include
all: libjerry all: libjerry
libjerry: libjerry:
mkdir -p $(BUILD_DIR)
mkdir -p $(LIBTARGET_DIR)
cmake -B$(BUILD_DIR) -H./ \ cmake -B$(BUILD_DIR) -H./ \
-DCMAKE_SYSTEM_NAME=TizenRT \
-DCMAKE_SYSTEM_PROCESSOR=armv7l \
-DCMAKE_C_COMPILER=arm-none-eabi-gcc \
-DCMAKE_C_COMPILER_WORKS=TRUE \
-DENABLE_LTO=OFF \ -DENABLE_LTO=OFF \
-DENABLE_ALL_IN_ONE=OFF \ -DENABLE_ALL_IN_ONE=OFF \
-DJERRY_LIBC=OFF \ -DJERRY_LIBC=OFF \
-DJERRY_CMDLINE=OFF \ -DJERRY_CMDLINE=OFF \
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \ -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \ -DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_mcu_artik053.cmake
make -C$(BUILD_DIR) jerry-core jerry-libm jerry-ext make -C$(BUILD_DIR) jerry-core jerry-libm jerry-ext
cp $(BUILD_DIR)/lib/libjerry-core.a $(LIBTARGET_DIR)
cp $(BUILD_DIR)/lib/libjerry-libm.a $(LIBTARGET_DIR)
cp $(BUILD_DIR)/lib/libjerry-ext.a $(LIBTARGET_DIR)
clean: clean:
rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
+16
View File
@@ -81,6 +81,22 @@ $ mkdir res
#### 5. Build JerryScript for TizenRT #### 5. Build JerryScript for TizenRT
```
# assuming you are in jerry-tizenrt folder
jerryscript/tools/build.py \
--clean \
--lto=OFF \
--jerry-cmdline=OFF \
--jerry-libc=OFF \
--all-in-one=OFF \
--mem-heap=70 \
--profile=es2015-subset \
--compile-flag="--sysroot=${PWD}/TizenRT/os" \
--toolchain=${PWD}/jerryscript/cmake/toolchain_mcu_artik053.cmake
```
**Note**: there is a Makefile in the `targets/tizenrt-artik053/` folder that also helps to build JerryScript for TizenRT.
``` ```
# assuming you are in jerry-tizenrt folder # assuming you are in jerry-tizenrt folder
$ cd jerryscript $ cd jerryscript
@@ -27,23 +27,4 @@ config JERRYSCRIPT_STACKSIZE
int "Jerryscript stack size" int "Jerryscript stack size"
default 16384 default 16384
config JERRYSCRIPT_HEAPSIZE endif # JERRYSCRIPT
int "Jerryscript heap size"
default 107520
config JERRYSCRIPT_ERROR_MESSAGES
bool "Enable error messages for builtin error objects"
default n
config JERRYSCRIPT_MEM_STATS
bool "Enable memory statistics"
default n
config JERRYSCRIPT_SHOW_OPCODES
bool "Enable parser byte-code dumps"
default n
config JERRYSCRIPT_DEBUGGER
bool "Jerryscript debugger"
default n
endif
@@ -67,40 +67,28 @@
-include $(TOPDIR)/Make.defs -include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs include $(APPDIR)/Make.defs
# Jerryscript built-in application info # JerryScript built-in application information.
CONFIG_JERRYSCRIPT_PRIORITY ?= SCHED_PRIORITY_DEFAULT CONFIG_JERRYSCRIPT_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
CONFIG_JERRYSCRIPT_STACKSIZE ?= 32768 CONFIG_JERRYSCRIPT_STACKSIZE ?= 32768
CONFIG_JERRYSCRIPT_HEAPSIZE ?= 64000
APPNAME = jerry
# path to the project dir, "tizenrt-artik053" by default
ROOT_DIR = ../../../..
PRIORITY = $(CONFIG_JERRYSCRIPT_PRIORITY) PRIORITY = $(CONFIG_JERRYSCRIPT_PRIORITY)
PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
STACKSIZE = $(CONFIG_JERRYSCRIPT_STACKSIZE) STACKSIZE = $(CONFIG_JERRYSCRIPT_STACKSIZE)
CFLAGS += -std=c99 -DJERRY_NDEBUG '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
CFLAGS += -I$(ROOT_DIR)/ $(shell find $(ROOT_DIR)/jerryscript/jerry-core -type d | sed -r -e 's/^/-I/g')
CFLAGS += -I$(ROOT_DIR)/jerryscript/jerry-ext/include
ifeq ($(CONFIG_JERRYSCRIPT_MEM_STATS),y) # Path to the JerryScript project. If not specified, it is supposed
CFLAGS += -DJMEM_STATS # that JerryScript is located next to the TizenRT folder.
endif JERRYSCRIPT_ROOT_DIR ?= ../../../../jerryscript
ifeq ($(CONFIG_JERRYSCRIPT_SHOW_OPCODES),y)
CFLAGS += -DPARSER_DUMP_BYTE_CODE
endif
ifeq ($(CONFIG_JERRYSCRIPT_DEBUGGER),y)
CFLAGS += -DJERRY_DEBUGGER
endif
CFLAGS += -std=c99
CFLAGS += -I$(JERRYSCRIPT_ROOT_DIR)/jerry-core/include
CFLAGS += -I$(JERRYSCRIPT_ROOT_DIR)/jerry-ext/include
EXTRA_LIBS += libjerry-core.a libjerry-libm.a EXTRA_LIBS += libjerry-core.a libjerry-libm.a
LINKLIBS=$(EXTRA_LIBS) LINKLIBS=$(EXTRA_LIBS)
APPNAME = jerry
ASRCS = setjmp.S ASRCS = setjmp.S
CSRCS =
MAINSRC = jerry_main.c MAINSRC = jerry_main.c
AOBJS = $(ASRCS:.S=$(OBJEXT)) AOBJS = $(ASRCS:.S=$(OBJEXT))
@@ -130,8 +118,6 @@ else
INSTALL_DIR = $(BIN_DIR) INSTALL_DIR = $(BIN_DIR)
endif endif
CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
ROOTDEPPATH = --dep-path . ROOTDEPPATH = --dep-path .
@@ -139,8 +125,9 @@ ROOTDEPPATH = --dep-path .
VPATH = VPATH =
all: .built
.PHONY: context depend clean distclean all: copylibs .built
.PHONY: copylibs context depend clean distclean
$(AOBJS): %$(OBJEXT): %.S $(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@) $(call ASSEMBLE, $<, $@)
@@ -152,6 +139,9 @@ $(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
$(call ARCHIVE, $(BIN), $(OBJS)) $(call ARCHIVE, $(BIN), $(OBJS))
$(Q) touch .built $(Q) touch .built
copylibs:
cp $(JERRYSCRIPT_ROOT_DIR)/build/lib/lib*.a $(TOPDIR)/../build/output/libraries/
install: install:
context: context:
@@ -21,7 +21,6 @@
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handler.h"
#include "jerryscript-port.h" #include "jerryscript-port.h"
#include "jmem.h"
#include "setjmp.h" #include "setjmp.h"
#include <apps/shell/tash.h> // To register tash command #include <apps/shell/tash.h> // To register tash command
@@ -63,7 +62,7 @@ print_help (char *name)
/** /**
* Read source code into buffer. * Read source code into buffer.
* *
* Returned value must be freed with jmem_heap_free_block if it's not NULL. * Returned value must be freed if it's not NULL.
* @return NULL, if read or allocation has failed * @return NULL, if read or allocation has failed
* pointer to the allocated memory block, otherwise * pointer to the allocated memory block, otherwise
*/ */
@@ -96,7 +95,7 @@ read_file (const char *file_name, /**< source code */
rewind (file); rewind (file);
uint8_t *buffer = jmem_heap_alloc_block_null_on_error (script_len); uint8_t *buffer = (uint8_t *) malloc (script_len);
if (buffer == NULL) if (buffer == NULL)
{ {
@@ -110,7 +109,7 @@ read_file (const char *file_name, /**< source code */
if (!bytes_read || bytes_read != script_len) if (!bytes_read || bytes_read != script_len)
{ {
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: failed to read file: %s\n", file_name); jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: failed to read file: %s\n", file_name);
jmem_heap_free_block ((void*) buffer, script_len); free ((void*) buffer);
fclose (file); fclose (file);
return NULL; return NULL;
@@ -458,12 +457,12 @@ jerry_cmd_main (int argc, char *argv[])
if (jerry_value_has_error_flag (ret_value)) if (jerry_value_has_error_flag (ret_value))
{ {
print_unhandled_exception (ret_value, source_p); print_unhandled_exception (ret_value, source_p);
jmem_heap_free_block ((void*) source_p, source_size); free ((void*) source_p);
break; break;
} }
jmem_heap_free_block ((void*) source_p, source_size); free ((void*) source_p);
jerry_release_value (ret_value); jerry_release_value (ret_value);
ret_value = jerry_create_undefined (); ret_value = jerry_create_undefined ();