Compare commits
4 Commits
float32-fix
...
v1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 63f739e5a0 | |||
| a59cbfe1a2 | |||
| de9c27b122 | |||
| 57d8b39f3f |
@@ -0,0 +1,210 @@
|
|||||||
|
# Reference
|
||||||
|
|
||||||
|
## Termination
|
||||||
|
|
||||||
|
It is questionable whether a library should be able to terminate an application. Any API function can signal an error (ex.: cannot allocate memory), so the engine use the termination approach with this port function.
|
||||||
|
|
||||||
|
```c
|
||||||
|
/**
|
||||||
|
* Signal the port that jerry experienced a fatal failure from which it cannot
|
||||||
|
* recover.
|
||||||
|
*
|
||||||
|
* @param code gives the cause of the error.
|
||||||
|
*
|
||||||
|
* Note: jerry expects the function not to return.
|
||||||
|
*
|
||||||
|
* Example: a libc-based port may implement this with exit() or abort(), or both.
|
||||||
|
*/
|
||||||
|
void jerry_port_fatal (jerry_fatal_code_t code);
|
||||||
|
```
|
||||||
|
|
||||||
|
Error codes
|
||||||
|
|
||||||
|
```c
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ERR_OUT_OF_MEMORY = 10,
|
||||||
|
ERR_SYSCALL = 11,
|
||||||
|
ERR_REF_COUNT_LIMIT = 12,
|
||||||
|
ERR_FAILED_INTERNAL_ASSERTION = 120
|
||||||
|
} jerry_fatal_code_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
## I/O
|
||||||
|
|
||||||
|
These are the only I/O functions jerry calls.
|
||||||
|
|
||||||
|
```c
|
||||||
|
/**
|
||||||
|
* Print a string to the console. The function should implement a printf-like
|
||||||
|
* interface, where the first argument specifies a format string on how to
|
||||||
|
* stringify the rest of the parameter list.
|
||||||
|
*
|
||||||
|
* This function is only called with strings coming from the executed ECMAScript
|
||||||
|
* wanting to print something as the result of its normal operation.
|
||||||
|
*
|
||||||
|
* It should be the port that decides what a "console" is.
|
||||||
|
*
|
||||||
|
* Example: a libc-based port may implement this with vprintf().
|
||||||
|
*/
|
||||||
|
void jerry_port_console (const char *fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jerry log levels. The levels are in severity order
|
||||||
|
* where the most serious levels come first.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
JERRY_LOG_LEVEL_ERROR, /**< the engine will terminate after the message is printed */
|
||||||
|
JERRY_LOG_LEVEL_WARNING, /**< a request is aborted, but the engine continues its operation */
|
||||||
|
JERRY_LOG_LEVEL_DEBUG, /**< debug messages from the engine, low volume */
|
||||||
|
JERRY_LOG_LEVEL_TRACE /**< detailed info about engine internals, potentially high volume */
|
||||||
|
} jerry_log_level_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display or log a debug/error message. The function should implement a printf-like
|
||||||
|
* interface, where the first argument specifies the log level
|
||||||
|
* and the second argument specifies a format string on how to stringify the rest
|
||||||
|
* of the parameter list.
|
||||||
|
*
|
||||||
|
* This function is only called with messages coming from the jerry engine as
|
||||||
|
* the result of some abnormal operation or describing its internal operations
|
||||||
|
* (e.g., data structure dumps or tracing info).
|
||||||
|
*
|
||||||
|
* It should be the port that decides whether error and debug messages are logged to
|
||||||
|
* the console, or saved to a database or to a file.
|
||||||
|
*
|
||||||
|
* Example: a libc-based port may implement this with vfprintf(stderr) or
|
||||||
|
* vfprintf(logfile), or both, depending on log level.
|
||||||
|
*/
|
||||||
|
void jerry_port_log (jerry_log_level_t level, const char *fmt, ...);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Date
|
||||||
|
|
||||||
|
```c
|
||||||
|
/**
|
||||||
|
* Jerry time zone structure
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int offset; /**< minutes from west */
|
||||||
|
int daylight_saving_time; /**< daylight saving time (1 - DST applies, 0 - not on DST) */
|
||||||
|
} jerry_time_zone_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get timezone and daylight saving data
|
||||||
|
*
|
||||||
|
* @return true - if success
|
||||||
|
* false - otherwise
|
||||||
|
*/
|
||||||
|
bool jerry_port_get_time_zone (jerry_time_zone_t *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get system time
|
||||||
|
*
|
||||||
|
* @return milliseconds since Unix epoch
|
||||||
|
*/
|
||||||
|
double jerry_port_get_current_time (void);
|
||||||
|
```
|
||||||
|
|
||||||
|
# How to port JerryScript
|
||||||
|
|
||||||
|
This section describes a basic port implementation which was created for Unix based systems.
|
||||||
|
|
||||||
|
## Termination
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "jerry-port.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation of jerry_port_fatal.
|
||||||
|
*/
|
||||||
|
void jerry_port_fatal (jerry_fatal_code_t code)
|
||||||
|
{
|
||||||
|
exit (code);
|
||||||
|
} /* jerry_port_fatal */
|
||||||
|
```
|
||||||
|
|
||||||
|
## I/O
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "jerry-port.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide console message implementation for the engine.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
jerry_port_console (const char *format, /**< format string */
|
||||||
|
...) /**< parameters */
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start (args, format);
|
||||||
|
vfprintf (stdout, format, args);
|
||||||
|
va_end (args);
|
||||||
|
} /* jerry_port_console */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide log message implementation for the engine.
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
* This example ignores the log level.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
jerry_port_log (jerry_log_level_t level, /**< log level */
|
||||||
|
const char *format, /**< format string */
|
||||||
|
...) /**< parameters */
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start (args, format);
|
||||||
|
vfprintf (stderr, format, args);
|
||||||
|
va_end (args);
|
||||||
|
} /* jerry_port_log */
|
||||||
|
```
|
||||||
|
|
||||||
|
## Date
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include "jerry-port.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation of jerry_port_get_time_zone.
|
||||||
|
*/
|
||||||
|
bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
struct timezone tz;
|
||||||
|
|
||||||
|
/* gettimeofday may not fill tz, so zero-initializing */
|
||||||
|
tz.tz_minuteswest = 0;
|
||||||
|
tz.tz_dsttime = 0;
|
||||||
|
|
||||||
|
if (gettimeofday (&tv, &tz) != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tz_p->offset = tz.tz_minuteswest;
|
||||||
|
tz_p->daylight_saving_time = tz.tz_dsttime > 0 ? 1 : 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} /* jerry_port_get_time_zone */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation of jerry_port_get_current_time.
|
||||||
|
*/
|
||||||
|
double jerry_port_get_current_time ()
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
if (gettimeofday (&tv, NULL) != 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;
|
||||||
|
} /* jerry_port_get_current_time */
|
||||||
|
```
|
||||||
+187
-155
@@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright 2016 Intel Corporation
|
# Copyright 2016 Intel Corporation
|
||||||
|
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||||
|
# Copyright 2016 University of Szeged
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -14,138 +16,147 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
import sys
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
|
|
||||||
project_name = 'curie_bsp_jerry'
|
def build_soft_links(project_path, jerry_path):
|
||||||
|
""" Creates soft links into the @project_path. """
|
||||||
|
|
||||||
# create soft link
|
if not os.path.exists(project_path):
|
||||||
def build_soft_links(curie_path, jerry_path):
|
os.makedirs(project_path)
|
||||||
location_path = os.path.join(curie_path, 'wearable_device_sw/projects/' +
|
|
||||||
project_name)
|
|
||||||
if not os.path.exists(location_path):
|
|
||||||
os.makedirs(location_path)
|
|
||||||
os.chdir(location_path)
|
|
||||||
# arc
|
|
||||||
if not os.path.islink(os.path.join(location_path, 'arc')):
|
|
||||||
os.symlink(os.path.join(jerry_path,
|
|
||||||
'targets/curie_bsp/jerry_app/arc'), 'arc')
|
|
||||||
|
|
||||||
# include
|
links = [
|
||||||
if not os.path.islink(os.path.join(location_path, 'include')):
|
{ # arc
|
||||||
os.symlink(os.path.join(jerry_path,
|
'src': os.path.join('targets', 'curie_bsp', 'jerry_app', 'arc'),
|
||||||
'targets/curie_bsp/jerry_app/include'), 'include')
|
'link_name': 'arc'
|
||||||
# quark
|
},
|
||||||
if not os.path.islink(os.path.join(location_path, 'quark')):
|
{ # include
|
||||||
os.symlink(os.path.join(jerry_path,
|
'src': os.path.join('targets', 'curie_bsp', 'jerry_app', 'include'),
|
||||||
'targets/curie_bsp/jerry_app/quark'), 'quark')
|
'link_name': 'include'
|
||||||
|
},
|
||||||
|
{ # quark
|
||||||
|
'src': os.path.join('targets', 'curie_bsp', 'jerry_app', 'quark'),
|
||||||
|
'link_name': 'quark'
|
||||||
|
},
|
||||||
|
{ # quark/jerryscript
|
||||||
|
'src': jerry_path,
|
||||||
|
'link_name': os.path.join('quark', 'jerryscript')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
# jerryscript
|
for link in links:
|
||||||
location_path = os.path.join(location_path, 'quark')
|
src = os.path.join(jerry_path, link['src'])
|
||||||
os.chdir(location_path)
|
link_name = os.path.join(project_path, link['link_name'])
|
||||||
if not os.path.islink(os.path.join(location_path, 'jerryscript')):
|
if not os.path.islink(link_name):
|
||||||
os.symlink(jerry_path, 'jerryscript')
|
os.symlink(src, link_name)
|
||||||
|
print("Created symlink '{link_name}' -> '{src}'".format(src=src, link_name=link_name))
|
||||||
|
|
||||||
|
|
||||||
# create Kbuild.mk
|
def find_sources(root_dir, sub_dir):
|
||||||
def breadth_first_travel(root_dir):
|
"""
|
||||||
out_put = ''
|
Find .c and .S files inside the @root_dir/@sub_dir directory.
|
||||||
lists = os.listdir(root_dir)
|
Note: the returned paths will be relative to the @root_dir directory.
|
||||||
dirs = []
|
"""
|
||||||
for line in lists:
|
src_dir = os.path.join(root_dir, sub_dir)
|
||||||
full_path = os.path.join(root_dir, line)
|
|
||||||
if os.path.isdir(full_path):
|
|
||||||
dirs.append(line)
|
|
||||||
else:
|
|
||||||
c_file = line.endswith('.c')
|
|
||||||
if c_file:
|
|
||||||
npos = line.find('.c')
|
|
||||||
out_put += 'obj-y += ' + line[0:npos] + '.o\n'
|
|
||||||
continue
|
|
||||||
asm_file = line.endswith('.S')
|
|
||||||
if asm_file:
|
|
||||||
npos = line.find('.S')
|
|
||||||
out_put += 'obj-y += ' + line[0:npos] + '.o\n'
|
|
||||||
for line in dirs:
|
|
||||||
out_put += 'obj-y += ' + line + '/\n'
|
|
||||||
|
|
||||||
file_path = os.path.join(root_dir, 'Kbuild.mk')
|
matches = []
|
||||||
file_to_be_created = open(file_path, 'w+')
|
for root, dirnames, filenames in os.walk(src_dir):
|
||||||
file_to_be_created.write(out_put)
|
for filename in fnmatch.filter(filenames, '*.[c|S]'):
|
||||||
file_to_be_created.close()
|
file_path = os.path.join(root, filename)
|
||||||
for line in dirs:
|
relative_path = os.path.relpath(file_path, root_dir)
|
||||||
breadth_first_travel(os.path.join(root_dir, line))
|
matches.append(relative_path)
|
||||||
|
|
||||||
|
return matches
|
||||||
|
|
||||||
|
|
||||||
# create Kbuild.mk in jerryscript/
|
def build_jerry_data(jerry_path):
|
||||||
def create_kbuild_in_jerryscript(jerry_path):
|
"""
|
||||||
breadth_first_travel(os.path.join(jerry_path, 'jerry-core'))
|
Build up a dictionary which contains the following items:
|
||||||
breadth_first_travel(os.path.join(jerry_path, 'jerry-libm'))
|
- sources: list of JerryScript sources which should be built.
|
||||||
#jerryscript/
|
- dirs: list of JerryScript dirs used.
|
||||||
out_put = '''
|
- cflags: CFLAGS for the build.
|
||||||
obj-y += jerry-core/
|
"""
|
||||||
obj-y += jerry-libm/
|
jerry_sources = []
|
||||||
obj-y += targets/
|
jerry_dirs = set()
|
||||||
subdir-cflags-y += -DCONFIG_MEM_HEAP_AREA_SIZE=10*1024
|
for sub_dir in ['jerry-core', 'jerry-libm', os.path.join('targets', 'curie_bsp', 'source')]:
|
||||||
subdir-cflags-y += -DJERRY_NDEBUG
|
for file in find_sources(os.path.normpath(jerry_path), sub_dir):
|
||||||
subdir-cflags-y += -DJERRY_DISABLE_HEAVY_DEBUG
|
path = os.path.join('jerryscript', file)
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_NUMBER_BUILTIN
|
jerry_sources.append(path)
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_STRING_BUILTIN
|
jerry_dirs.add(os.path.split(path)[0])
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_BOOLEAN_BUILTIN
|
|
||||||
#subdir-cflags-y += -DCONFIG_DISABLE_ERROR_BUILTINS
|
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_ARRAY_BUILTIN
|
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_MATH_BUILTIN
|
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_JSON_BUILTIN
|
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_DATE_BUILTIN
|
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_REGEXP_BUILTIN
|
|
||||||
subdir-cflags-y += -DCONFIG_DISABLE_ANNEXB_BUILTIN
|
|
||||||
subdir-cflags-y += -DCONFIG_ECMA_LCACHE_DISABLE
|
|
||||||
subdir-cflags-y += -DCONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
|
||||||
'''
|
|
||||||
|
|
||||||
file_path = os.path.join(jerry_path, 'Kbuild.mk')
|
jerry_cflags = [
|
||||||
file_to_be_created = open(file_path, 'w+')
|
'-DCONFIG_MEM_HEAP_AREA_SIZE=10*1024',
|
||||||
file_to_be_created.write(out_put)
|
'-DJERRY_NDEBUG',
|
||||||
file_to_be_created.close()
|
'-DJERRY_DISABLE_HEAVY_DEBUG',
|
||||||
|
'-DCONFIG_DISABLE_NUMBER_BUILTIN',
|
||||||
|
'-DCONFIG_DISABLE_STRING_BUILTIN',
|
||||||
|
'-DCONFIG_DISABLE_BOOLEAN_BUILTIN',
|
||||||
|
#'-DCONFIG_DISABLE_ERROR_BUILTINS',
|
||||||
|
'-DCONFIG_DISABLE_ARRAY_BUILTIN',
|
||||||
|
'-DCONFIG_DISABLE_MATH_BUILTIN',
|
||||||
|
'-DCONFIG_DISABLE_JSON_BUILTIN',
|
||||||
|
'-DCONFIG_DISABLE_DATE_BUILTIN',
|
||||||
|
'-DCONFIG_DISABLE_REGEXP_BUILTIN',
|
||||||
|
'-DCONFIG_DISABLE_ANNEXB_BUILTIN',
|
||||||
|
'-DCONFIG_ECMA_LCACHE_DISABLE',
|
||||||
|
'-DCONFIG_ECMA_PROPERTY_HASHMAP_DISABLE',
|
||||||
|
]
|
||||||
|
|
||||||
# jerryscript/targets
|
return {
|
||||||
out_put = 'obj-y += curie_bsp/'
|
'sources': jerry_sources,
|
||||||
file_path = os.path.join(jerry_path, 'targets/Kbuild.mk')
|
'dirs': jerry_dirs,
|
||||||
file_to_be_created = open(file_path, 'w+')
|
'cflags': jerry_cflags,
|
||||||
file_to_be_created.write(out_put)
|
}
|
||||||
file_to_be_created.close()
|
|
||||||
|
|
||||||
# jerryscript/targets/curie_bsp
|
|
||||||
out_put = 'obj-y += source/'
|
|
||||||
file_path = os.path.join(jerry_path, 'targets/curie_bsp/Kbuild.mk')
|
|
||||||
file_to_be_created = open(file_path, 'w+')
|
|
||||||
file_to_be_created.write(out_put)
|
|
||||||
file_to_be_created.close()
|
|
||||||
|
|
||||||
breadth_first_travel(os.path.join(jerry_path, 'targets/curie_bsp/source'))
|
def write_file(path, content):
|
||||||
|
""" Writes @content into the file at specified by the @path. """
|
||||||
|
norm_path = os.path.normpath(path)
|
||||||
|
with open(norm_path, "w+") as f:
|
||||||
|
f.write(content)
|
||||||
|
print("Wrote file '{0}'".format(norm_path))
|
||||||
|
|
||||||
# create Makefile in wearable_device_sw/projects/curie_bsp_jerry/
|
|
||||||
def create_makefile_in_curie(curie_path):
|
|
||||||
|
|
||||||
# Kbuild.mk
|
def build_obj_y(source_list):
|
||||||
out_put = '''
|
"""
|
||||||
|
Build obj-y additions from the @source_list.
|
||||||
|
Note: the input sources should have their file extensions.
|
||||||
|
"""
|
||||||
|
return '\n'.join(['obj-y += {0}.o'.format(os.path.splitext(fname)[0]) for fname in source_list])
|
||||||
|
|
||||||
|
|
||||||
|
def build_cflags_y(cflags_list):
|
||||||
|
"""
|
||||||
|
Build cflags-y additions from the @cflags_list.
|
||||||
|
Note: the input sources should have their file extensions.
|
||||||
|
"""
|
||||||
|
return '\n'.join(['cflags-y += {0}'.format(cflag) for cflag in cflags_list])
|
||||||
|
|
||||||
|
|
||||||
|
def build_mkdir(dir_list):
|
||||||
|
""" Build mkdir calls for each dir in the @dir_list. """
|
||||||
|
return '\n'.join(['\t$(AT)mkdir -p {0}'.format(os.path.join('$(OUT_SRC)', path)) for path in dir_list])
|
||||||
|
|
||||||
|
|
||||||
|
def create_root_kbuild(project_path):
|
||||||
|
""" Creates @project_path/Kbuild.mk file. """
|
||||||
|
|
||||||
|
root_kbuild_path = os.path.join(project_path, 'Kbuild.mk')
|
||||||
|
root_kbuild_content = '''
|
||||||
obj-$(CONFIG_QUARK_SE_ARC) += arc/
|
obj-$(CONFIG_QUARK_SE_ARC) += arc/
|
||||||
obj-$(CONFIG_QUARK_SE_QUARK) += quark/
|
obj-$(CONFIG_QUARK_SE_QUARK) += quark/
|
||||||
'''
|
'''
|
||||||
file_path = os.path.join(curie_path, 'wearable_device_sw/projects/' \
|
write_file(root_kbuild_path, root_kbuild_content)
|
||||||
+ project_name + '/Kbuild.mk')
|
|
||||||
|
|
||||||
file_to_be_created = open(file_path, 'w+')
|
|
||||||
file_to_be_created.write(out_put)
|
|
||||||
file_to_be_created.close()
|
|
||||||
|
|
||||||
# Makefile
|
def create_root_makefile(project_path):
|
||||||
out_put = '''
|
""" Creates @project_path/Makefile file. """
|
||||||
|
|
||||||
|
root_makefile_path = os.path.join(project_path, 'Makefile')
|
||||||
|
root_makefile_content = '''
|
||||||
THIS_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
|
THIS_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||||
T := $(abspath $(THIS_DIR)/../..)
|
T := $(abspath $(THIS_DIR)/../..)
|
||||||
'''
|
PROJECT := {project_name}
|
||||||
out_put += 'PROJECT :=' + project_name
|
|
||||||
out_put += '''
|
|
||||||
BOARD := curie_101
|
BOARD := curie_101
|
||||||
ifeq ($(filter curie_101, $(BOARD)),)
|
ifeq ($(filter curie_101, $(BOARD)),)
|
||||||
$(error The curie jerry sample application can only run on the curie_101 Board)
|
$(error The curie jerry sample application can only run on the curie_101 Board)
|
||||||
@@ -159,62 +170,83 @@ VERSION_MAJOR := 1
|
|||||||
VERSION_MINOR := 0
|
VERSION_MINOR := 0
|
||||||
VERSION_PATCH := 0
|
VERSION_PATCH := 0
|
||||||
include $(T)/build/project.mk
|
include $(T)/build/project.mk
|
||||||
'''
|
'''.format(project_name=project_name)
|
||||||
file_path = os.path.join(curie_path, 'wearable_device_sw/projects/' \
|
|
||||||
+ project_name + '/Makefile')
|
write_file(root_makefile_path, root_makefile_content)
|
||||||
file_to_be_created = open(file_path, 'w+')
|
|
||||||
file_to_be_created.write(out_put)
|
|
||||||
file_to_be_created.close()
|
def create_arc_kbuild(project_path):
|
||||||
|
""" Creates @project_path/arc/Kbuild.mk file. """
|
||||||
|
|
||||||
|
arc_path = os.path.join(project_path, 'arc')
|
||||||
|
arc_kbuild_path = os.path.join(arc_path, 'Kbuild.mk')
|
||||||
|
arc_sources = find_sources(arc_path, '.')
|
||||||
|
arc_kbuild_content = build_obj_y(arc_sources)
|
||||||
|
|
||||||
|
write_file(arc_kbuild_path, arc_kbuild_content)
|
||||||
|
|
||||||
|
|
||||||
|
def create_quark_kbuild(project_path, jerry_path):
|
||||||
|
""" Creates @project_path/quark/Kbuild.mk file. """
|
||||||
|
quark_kbuild_path = os.path.join(project_path, 'quark', 'Kbuild.mk')
|
||||||
|
|
||||||
|
# Extract a few JerryScript related data
|
||||||
|
jerry_data = build_jerry_data(jerry_path)
|
||||||
|
jerry_objects = build_obj_y(jerry_data['sources'])
|
||||||
|
jerry_defines = jerry_data['cflags']
|
||||||
|
jerry_build_dirs = build_mkdir(jerry_data['dirs'])
|
||||||
|
|
||||||
|
quark_include_paths = [
|
||||||
|
'include',
|
||||||
|
'jerryscript',
|
||||||
|
os.path.join('jerryscript', 'jerry-libm', 'include'),
|
||||||
|
os.path.join('jerryscript', 'targets' ,'curie_bsp', 'include')
|
||||||
|
] + list(jerry_data['dirs'])
|
||||||
|
|
||||||
|
quark_includes = [
|
||||||
|
'-Wno-error',
|
||||||
|
] + ['-I%s' % os.path.join(project_path, 'quark', path) for path in quark_include_paths]
|
||||||
|
|
||||||
|
quark_cflags = build_cflags_y(jerry_defines + quark_includes)
|
||||||
|
|
||||||
|
quark_kbuild_content = '''
|
||||||
|
{cflags}
|
||||||
|
|
||||||
# Kbuild.mk in arc/
|
|
||||||
breadth_first_travel(os.path.join(curie_path, 'wearable_device_sw/projects/' \
|
|
||||||
+ project_name + '/arc/'))
|
|
||||||
# Kbuild.mk in quark/
|
|
||||||
file_path = os.path.join(curie_path, 'wearable_device_sw/projects/' \
|
|
||||||
+ project_name + '/quark/Kbuild.mk')
|
|
||||||
out_put = '''
|
|
||||||
obj-y += jerryscript/
|
|
||||||
obj-y += main.o
|
obj-y += main.o
|
||||||
subdir-cflags-y += -Wno-error
|
{objects}
|
||||||
subdir-cflags-y += -I$(PROJECT_PATH)/quark/include
|
|
||||||
subdir-cflags-y += -I$(PROJECT_PATH)/quark/jerryscript
|
build_dirs:
|
||||||
subdir-cflags-y += -I$(PROJECT_PATH)/quark/jerryscript/targets/curie_bsp/include
|
{dirs}
|
||||||
'''
|
|
||||||
jerry_core_path = os.path.join(curie_path, 'wearable_device_sw/projects/' \
|
$(OUT_SRC): build_dirs
|
||||||
+ project_name \
|
'''.format(objects=jerry_objects, cflags=quark_cflags, dirs=jerry_build_dirs)
|
||||||
+ '/quark/jerryscript/jerry-core/')
|
|
||||||
for line in os.walk(jerry_core_path):
|
write_file(quark_kbuild_path, quark_kbuild_content)
|
||||||
npos = line[0].find(project_name)
|
|
||||||
out_put += 'subdir-cflags-y += -I$(PROJECT_PATH)' \
|
|
||||||
+ line[0][npos + len(project_name):] + '\n'
|
|
||||||
|
|
||||||
|
|
||||||
jerry_libm_path = os.path.join(curie_path, 'wearable_device_sw/projects/' \
|
def main(curie_path, project_name, jerry_path):
|
||||||
+ project_name \
|
project_path = os.path.join(curie_path, 'wearable_device_sw', 'projects', project_name)
|
||||||
+ '/quark/jerryscript/jerry-libm/')
|
|
||||||
|
|
||||||
for line in os.walk(jerry_libm_path):
|
build_soft_links(project_path, jerry_path)
|
||||||
npos = line[0].find(project_name)
|
|
||||||
out_put += 'subdir-cflags-y += -I$(PROJECT_PATH)' \
|
|
||||||
+ line[0][npos + len(project_name):] + '\n'
|
|
||||||
|
|
||||||
file_to_be_created = open(file_path, 'w+')
|
|
||||||
file_to_be_created.write(out_put)
|
|
||||||
file_to_be_created.close()
|
|
||||||
|
|
||||||
def main(curie_path, jerry_path):
|
|
||||||
build_soft_links(curie_path, jerry_path)
|
|
||||||
create_kbuild_in_jerryscript(jerry_path)
|
|
||||||
create_makefile_in_curie(curie_path)
|
|
||||||
|
|
||||||
|
create_root_kbuild(project_path)
|
||||||
|
create_root_makefile(project_path)
|
||||||
|
create_arc_kbuild(project_path)
|
||||||
|
create_quark_kbuild(project_path, jerry_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print 'Usage:'
|
print('Usage:')
|
||||||
print sys.argv[0] + ' [full or relative path of Curie_BSP]'
|
print('{script_name} [full or relative path of Curie_BSP]'.format(script_name=sys.argv[0]))
|
||||||
else:
|
sys.exit(1)
|
||||||
|
|
||||||
|
project_name = 'curie_bsp_jerry'
|
||||||
|
|
||||||
file_dir = os.path.dirname(os.path.abspath(__file__))
|
file_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
jerry_path = os.path.join(file_dir, "..", "..")
|
jerry_path = os.path.join(file_dir, "..", "..")
|
||||||
curie_path = os.path.join(os.getcwd(), sys.argv[1])
|
curie_path = os.path.join(os.getcwd(), sys.argv[1])
|
||||||
main(curie_path, jerry_path)
|
|
||||||
|
main(curie_path, project_name, jerry_path)
|
||||||
|
|||||||
@@ -156,9 +156,9 @@ read_sources (const char *script_file_names[],
|
|||||||
} /* read_sources */
|
} /* read_sources */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JerryScript debug level (0-3).
|
* JerryScript log level
|
||||||
*/
|
*/
|
||||||
static int jerry_debug_level;
|
static jerry_log_level_t jerry_log_level = JERRY_LOG_LEVEL_ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main program.
|
* Main program.
|
||||||
@@ -171,7 +171,7 @@ int main (int argc, FAR char *argv[])
|
|||||||
int jerry_main (int argc, char *argv[])
|
int jerry_main (int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (argc >= JERRY_MAX_COMMAND_LINE_ARGS)
|
if (argc > JERRY_MAX_COMMAND_LINE_ARGS)
|
||||||
{
|
{
|
||||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR,
|
jerry_port_log (JERRY_LOG_LEVEL_ERROR,
|
||||||
"Too many command line arguments. Current maximum is %d\n",
|
"Too many command line arguments. Current maximum is %d\n",
|
||||||
@@ -204,7 +204,7 @@ int jerry_main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (++i < argc && strlen (argv[i]) == 1 && argv[i][0] >='0' && argv[i][0] <= '3')
|
if (++i < argc && strlen (argv[i]) == 1 && argv[i][0] >='0' && argv[i][0] <= '3')
|
||||||
{
|
{
|
||||||
jerry_debug_level = argv[i][0] - '0';
|
jerry_log_level = argv[i][0] - '0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -276,7 +276,7 @@ jerry_port_log (jerry_log_level_t level, /**< log level */
|
|||||||
const char *format, /**< format string */
|
const char *format, /**< format string */
|
||||||
...) /**< parameters */
|
...) /**< parameters */
|
||||||
{
|
{
|
||||||
if (level >= jerry_debug_level)
|
if (level <= jerry_log_level)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ EXT_CFLAGS += -Wall -Wno-format-zero-length -Wno-pointer-sign
|
|||||||
EXT_CFLAGS += -Werror=format -Werror=implicit-int -Wno-unused-but-set-variable
|
EXT_CFLAGS += -Werror=format -Werror=implicit-int -Wno-unused-but-set-variable
|
||||||
EXT_CFLAGS += -Wno-main -Wno-strict-aliasing -Wno-old-style-declaration
|
EXT_CFLAGS += -Wno-main -Wno-strict-aliasing -Wno-old-style-declaration
|
||||||
EXT_CFLAGS += -Wno-error=format=
|
EXT_CFLAGS += -Wno-error=format=
|
||||||
EXT_CFLAGS += -D_XOPEN_SOURCE
|
EXT_CFLAGS += -D_XOPEN_SOURCE=700
|
||||||
|
|
||||||
# Pass2
|
# Pass2
|
||||||
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
|
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
|
||||||
@@ -94,9 +94,8 @@ CC = $(CROSS_COMPILE)gcc
|
|||||||
ZEPHYR_LIBC_INC = $(subst -I,,$(TOOLCHAIN_CFLAGS))
|
ZEPHYR_LIBC_INC = $(subst -I,,$(TOOLCHAIN_CFLAGS))
|
||||||
LIB_INCLUDE_DIR += -L $(CURDIR)/$(OUTPUT)
|
LIB_INCLUDE_DIR += -L $(CURDIR)/$(OUTPUT)
|
||||||
|
|
||||||
# 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
|
# TODO: There is a warning when compiling in some architectures related to __sputc_r
|
||||||
# this will generate warnings on the default date port.
|
EXT_CFLAGS += -Wno-error=conversion
|
||||||
EXT_CFLAGS += -Wno-error=conversion -Wno-error=sign-conversion
|
|
||||||
EXT_CFLAGS += $(LIB_INCLUDE_DIR)
|
EXT_CFLAGS += $(LIB_INCLUDE_DIR)
|
||||||
EXT_CFLAGS += $(TOOLCHAIN_CFLAGS)
|
EXT_CFLAGS += $(TOOLCHAIN_CFLAGS)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user