Skip to content

Modify the build method of TizenRT target #2164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cmake/toolchain_mcu_artik053.cmake
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 3 additions & 18 deletions targets/tizenrt-artik053/Makefile.tizenrt
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,26 @@
# limitations under the License.

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

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

.PHONY: libjerry clean

all: libjerry

libjerry:
mkdir -p $(BUILD_DIR)
mkdir -p $(LIBTARGET_DIR)
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_ALL_IN_ONE=OFF \
-DJERRY_LIBC=OFF \
-DJERRY_CMDLINE=OFF \
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
-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
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:
rm -rf $(BUILD_DIR)
16 changes: 16 additions & 0 deletions targets/tizenrt-artik053/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ $ mkdir res

#### 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
$ cd jerryscript
Expand Down
21 changes: 1 addition & 20 deletions targets/tizenrt-artik053/apps/jerryscript/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,4 @@ config JERRYSCRIPT_STACKSIZE
int "Jerryscript stack size"
default 16384

config JERRYSCRIPT_HEAPSIZE
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
endif # JERRYSCRIPT
42 changes: 16 additions & 26 deletions targets/tizenrt-artik053/apps/jerryscript/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,40 +67,28 @@
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs

# Jerryscript built-in application info

# JerryScript built-in application information.
CONFIG_JERRYSCRIPT_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
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)
PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
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)
CFLAGS += -DJMEM_STATS
endif

ifeq ($(CONFIG_JERRYSCRIPT_SHOW_OPCODES),y)
CFLAGS += -DPARSER_DUMP_BYTE_CODE
endif

ifeq ($(CONFIG_JERRYSCRIPT_DEBUGGER),y)
CFLAGS += -DJERRY_DEBUGGER
endif
# Path to the JerryScript project. If not specified, it is supposed
# that JerryScript is located next to the TizenRT folder.
JERRYSCRIPT_ROOT_DIR ?= ../../../../jerryscript

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
LINKLIBS=$(EXTRA_LIBS)


APPNAME = jerry
ASRCS = setjmp.S
CSRCS =
MAINSRC = jerry_main.c

AOBJS = $(ASRCS:.S=$(OBJEXT))
Expand Down Expand Up @@ -130,17 +118,16 @@ else
INSTALL_DIR = $(BIN_DIR)
endif

CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)

ROOTDEPPATH = --dep-path .

# Common build

VPATH =

all: .built
.PHONY: context depend clean distclean

all: copylibs .built
.PHONY: copylibs context depend clean distclean

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

copylibs:
cp $(JERRYSCRIPT_ROOT_DIR)/build/lib/lib*.a $(TOPDIR)/../build/output/libraries/

install:

context:
Expand Down
11 changes: 5 additions & 6 deletions targets/tizenrt-artik053/apps/jerryscript/jerry_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "jerryscript.h"
#include "jerryscript-ext/handler.h"
#include "jerryscript-port.h"
#include "jmem.h"
#include "setjmp.h"

#include <apps/shell/tash.h> // To register tash command
Expand Down Expand Up @@ -63,7 +62,7 @@ print_help (char *name)
/**
* 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
* pointer to the allocated memory block, otherwise
*/
Expand Down Expand Up @@ -96,7 +95,7 @@ read_file (const char *file_name, /**< source code */

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)
{
Expand All @@ -110,7 +109,7 @@ read_file (const char *file_name, /**< source code */
if (!bytes_read || bytes_read != script_len)
{
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);
return NULL;
Expand Down Expand Up @@ -458,12 +457,12 @@ jerry_cmd_main (int argc, char *argv[])
if (jerry_value_has_error_flag (ret_value))
{
print_unhandled_exception (ret_value, source_p);
jmem_heap_free_block ((void*) source_p, source_size);
free ((void*) source_p);

break;
}

jmem_heap_free_block ((void*) source_p, source_size);
free ((void*) source_p);

jerry_release_value (ret_value);
ret_value = jerry_create_undefined ();
Expand Down