It's generally considered a bad programming practice to have function declarations without parameter names.
This is another legacy from the early days of the project. Fix in one go to minimize history disruption.
Used a custom clang-tidy check to create the bulk of the change.
JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
Extern keywords on function declarations/definitions provide no additional value since function declarations/definitions default to external linkage in C99, e.g. removing them won't change the semantics of the program.
The extern keywords were essentially a legacy from the early days of the project. This commit cleans this up across the whole codebase in one go to minimize history disruption.
The bulk of the changes in this commit were produced by a custom clang-tidy checker.
Note that variables declarations carrying the extern keyword are untouched by this commit since there the presence of the keyword actually has an impact on the semantics of the program.
JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
Update mbed OS target to latest version of mbed OS (5.2.3). Also rename all files in jerryscript-mbed-drivers/ to include -js.cpp, as our build tools now generate warnings for C++ files with the same name. mbed-events library is now mainlined, so no longer required to pull this library in as a separate dependency.
JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
We're building a REPL (as user-space program) on top of mbedos5 target. For this I need to override the jerry_port_console and jerry_port_log functions from the REPL. This commit wraps these functions in an ifndef, so we can define macros to not include these files.
JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
Since the project is now hosted at the JS Foundation we can move to unified copyright notices for the project.
Starting with this commit all future contributions to the project should only carry the following copyright notice (except for third-party code which requires copyright information to be preserved):
"Copyright JS Foundation and other contributors, http://js.foundation" (without the quotes)
This avoids cluttering the codebase with contributor-specific copyright notices which have a higher maintenance overhead and tend to get outdated quickly. Also dropping the year from the copyright notices helps to avoid yearly code changes just to update the copyright notices.
Note that each contributor still retains full copyright ownership of his/her contributions and the respective authorship is tracked very accurately via Git.
JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
Zephyr 1.6 switched to "unified kernel API". Old API is supported, but
deprecated and leads to warnings.
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
mbed OS 5 target is currently missing wrappers around PwmOut and AnalogIn interface, which are part of the standard library of mbed OS. This commit adds them. Tested with mbed CI test shield. I've followed the coding style in jerryscript-mbed, rather than JerryScript coding style.
JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
In the mbedos5 target the setTimeout and setInterval functions are not on spec, as they return 'undefined' instead of an event ID. Also clearTimeout and clearInterval are not implemented, so scheduled events cannot be canceled. This patch changes the behavior of the set* functions, and implements clear* functions.
JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
Serial monitors (like screen on macOS / Linux) expect both CR and LF characters for new lines. Due to jerryscript only printing a line feed after calls to `print()` this makes log messages look wrong. This patch adds a CR when it encounters a LF character in jerry_port_console or jerry_port_log for the mbedos5 target.
JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
If we are building JerryScript from some other makefile that passes
down a -j option to make we should respect that when we build Zephyr.
JerryScript-DCO-1.0-Signed-off-by: Kumar Gala kumar.gala@linaro.org
For a normal zephyr application the pristine target simply runs
"rm -rf outdir". However the JerryScript build overrides the output
directory [O=$(OUTPUT)] so Zephyr's implementation pristine is not able
to to a full aggressive clean up for all boards.
For this reason it is better for the JerryScript build wrapper to have
its own implementation of pristine.
JerryScript-DCO-1.0-Signed-off-by: Daniel Thompson daniel.thompson@linaro.org
Currently if USE_CCACHE=1 is set to one than the Zephyr build system
will include ccache in the CC variable. ccache cannot be passed to
cmake using EXTERNAL_CMAKE_C_COMPILER (even if we fix the quoting)
because it fails a PATH reachability test within cmake. For that
reasons we solve the build failure simply by removing ccahce from CC
before we pass it into cmake.
The problem described about is a regression due to commit ac1bf19c90d6
("build: Adopt outputexports") and the fix contained in this patch
restores the original behaviour (zephyr exploits ccache, jerryscript
library build does not).
JerryScript-DCO-1.0-Signed-off-by: Daniel Thompson daniel.thompson@linaro.org
The file was named jerry-entry.c and not even built. Rename for clarity,
and add jerry_port_fatal(), jerry_port_get_current_time(),
jerry_port_get_time_zone() functions. User-visible result is that
if Date builtin is enabled (e.g. if building "full" config, its
Date.now() method can be used to measure relative time difference,
e.g. for benchmarking).
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
* Rename 'jerry_targetjs.h' to 'jerry-targetjs.h',
because we use dashes in filen ames instead of underscores.
* Made destination and js souce directory configurable.
* Updated esp8266 target to the recent changes.
* Updated mbed and mbedos5 target to the recent changes.
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This patch simplifies the integration with the zephyr build system
whilst at the same time enriching the set of build targets to allow
zephyr to be configured using its kbuild features.
It works by exploiting "make outputexports", a feature of the zephyr
build system that makes the zephyr compiler configuration available to
other build systems in an easily accessible manner.
Whilst looking at the build we also correct the implementation of clean
so that it no longer destroys any custom zephyr configuration. Like any
other zephyr application one must use "make pristine" to remove the
config too.
JerryScript-DCO-1.0-Signed-off-by: Daniel Thompson daniel.thompson@linaro.org
JerryScript Zephyr port overrides standard Zephyr output location. But
components integrating Zephyr port may want to override it again. Make
sure that arbitrary overrides are possible, and just set the default
value to Zephyr port's custom preference.
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
The new zephyr build system doesn't support the arduino_101_factory
board.
This change restores the default BOARD to arduino_101 which
is the current recommended method.
If you are in an older SDK / Zephyr you can still use.
`make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101_factory`
JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
Currently the zephyr port fails to build with some cross-toolsets because
warnings from the system headers are being treated as errors. Using
-isystem for any includes in TOOLCHAIN_CFLAGS allows us to crank up the
warning levels without worrying about newlib headers breaking the build.
JerryScript-DCO-1.0-Signed-off-by: Daniel Thompson daniel.thompson@linaro.org
Currently we need to modify the JerryScript Makefiles for every new
board we want to work with. It is better to study the zephyr configuration
and used the CONFIG_ options to determine the right compiler flags.
We expose the CONFIG_ options to make by adding machinary to the makefiles
to import the Zephyr .config file, allow us to make the decisions we
need.
JerryScript-DCO-1.0-Signed-off-by: Daniel Thompson daniel.thompson@linaro.org
Several non-script files have been added with exec permission to
the repository. This patch revokes the erroneous permissions.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
It's stated in the Guidelines that all contributions must be under
the Apache License 2.0. To avoid potential mistakes from manual
reviews, this patch adds the check-license.py script to
automatically check all source files for license headers.
Travis CI is also configured to run the check.
Fallout: it turned out that some files already in the code base
either miss a license header or have some minor typo differences.
The patch fixes up some of these deficiences.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
- Wrappers for mbed I/O drivers
- Makefile for automating build process
- Script to generate pin definitions from mbed OS source tree
- Updates to js2c to enable building without a main.js file
JerryScript-DCO-1.0-Signed-off-by: Matthew Else Matthew.Else@arm.com
Although both jerry-libc and jerry-libm have configuration options
that enable/disable their build, in practice, only jerry-libc can be
replaced with the system (compiler-default) libc. If jerry-libm is
disabled, the build of jerry-main fails, as there is no way to
instruct the linker to link the system libm to the binary. (The
build system does have a way to pass flags to the linker, but those
flags are listed before the linked objects. For the references to
get resolved correctly, the libraries to be linked have to be
specified _after_ the objects.)
This patch adds the EXTERNAL_LINK_LIBS configuration option to
CMakeLists, which ensures that the specified libraries get
correctly passed to the linker. (E.g, replacing jerry-libm with
system libm becomes possible with
`JERRY_LIBM=OFF EXTERNAL_LINK_LIBS='-lm'`.)
Additionally, the patch also makes the following related changes:
* Removes the COMPILER_DEFAULT_LIBC configuration option, as it is
(almost) always the opposite of JERRY_LIBC. Moreover, its name is
misleading: its only role is to add `-nostdlib` to the linker
flags.
* Makes use of transitive library dependencies: if a library has
another library as dependency, and it is linked to a binary, its
dependency is linked as well. Thus, jerry-libc, jerry-libm, and
any external libraries are added to jerry-core as dependency, and
then only jerry-core is linked to executables (cmake will take
care of the rest).
* build.py and run-tests.py follow up the changes, along with some
minor syntax changes.
* Moves static linking option to global CMakeLists, as unit test
binaries should be linked the same way as jerry-main.
* Adds EXTERNAL_COMPILER_FLAGS and EXTERNAL_LINKER_FLAGS as last to
the flag list, to allow user override of (nearly) anything.
The patch speculatively follows up the build system changes in the
mbed, riot-stm32f4, and zephyr targets.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Fix Zephyr build
With the changes to the zephyr sdk, gettimeofday is being guarded
by XOPEN_SOURCE_EXTENDED which requires at least 700 on XOPEN_SOURCE to be active
This little patch also helps on removing most of the warnings we had before
related to that issue.
More info on this feature:
http://man7.org/linux/man-pages/man7/feature_test_macros.7.html
Another option was to enable _GNU_SOURCE for this port.
There are still some harmless warnings related to __sputc_r for which we still require
the convertion warning.
Tested on qemu_cortex_m3, qemu_x86, arduino_101 and frdm_k64f.
Zephyr Sdk 0.8.2, Zephyr 1.5.0-rc4 & Zephyr ec39b216
Closes#1311.
JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
The original implementation used shell facility, but it was designed for
a unix shell like input, and automatically tokenized it into
space-separated "words", with limit of 10 (i.e. 9 spaces per line). For
JavaScript input, it is quite easy to have more than 9 spaces per line,
and get error:
Too many parameters (max 10)
After consultation with upstream
(https://jira.zephyrproject.org/browse/ZEP-532) it was decided that the
best approach is to skip using shell facility and use Zephyr console
facility. That however requires some Zephyr-specific boilerplate code.
This code was implemented as reusable modules in
https://github.com/pfalcon/zephyr_console_helpers repository, to be
usable for other console-based projects too. zephyr_getline.h/c in this
commits are direct imports from this repository.
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
This is now required, as Zephyr for frdm_k64f is built with hard float ABI.
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
Zephyr SDK 0.8.2 contains newlib 2.4.0 which doesn't provide gettimeofday()
declaration by default, but needs _XOPEN_SOURCE defined for this. While
this is definitely an issue with newlib 2.4.0 (to be fixed in one of the
next releases), defining _XOPEN_SOURCE is quite a harmless workaround.
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
This patch:
* Ensures that all calls to `jerry_port_log` in jerry-core happen
via macros defined in jrt.h. Also, it unifies the names of those
macros: as `JERRY_ERROR_MSG` and `JERRY_WARNING_MSG` gave a good
pattern that was well aligned with the naming scheme of the log
level enum, `JERRY_DLOG` and `JERRY_DDLOG` were rewritten to
`JERRY_DEBUG_MSG` and `JERRY_TRACE_MSG`.
* Ensures that all debug logging code parts of jerry-core (i.e.,
memory statistics, JS byte-code dumps, and RegExp byte-code
dumps) are guarded by macros: `JMEM_STATS`,
`PARSER_DUMP_BYTE_CODE`, and `REGEXP_DUMP_BYTE_CODE`, which in
turn are controled by cmake build system feature flags
`FEATURE_MEM_STATS`, `FEATURE_PARSER_DUMP`, and
`FEATURE_REGEXP_DUMP`.
* Ensures that all debug logging functionalities can be controled
during run time (provided that they were enabled during build
time): the engine has `JERRY_INIT_MEM_STATS[_SEPARATE]`,
`JERRY_INIT_SHOW_OPCODES`, `JERRY_INIT_SHOW_REGEXP_OPCODES` init
flags, and the default unix/linux command line app has
corresponding command line switches.`
* Drops `FEATURE_LOG`, `JERRY_ENABLE_LOG`, and
`JERRY_INIT_ENABLE_LOG`, as their name was misleadingly general,
even though they mostly controled the regexp engine only. The
above-mentioned `*REGEXP*` things mostly act as their
replacements.
* Updates build, test, and measurement tool scripts, and
documentation.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
- Update the API changes in mbed targets
- Build fix for mbed target after the build system patch.
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
The `cmake` directory already contains several toolchain files for
various platforms (operating system + architecture). However,
`tools/build.py` does not define a toolchain file for cmake unless
explicitly specified. This patch changes the script to look into
the `cmake` directory for a file named
`toolchain_$(os)_$(arch).cmake` and, if found, pass that to cmake
by default.
OS and arch are determined by `os.uname()`. As Linux on Raspberry
Pi identifies itself as "armv7l", the legacy "armv7l-hf" arch name
is shortened to "armv7l". This way, building jerry on RPi
(natively, not cross) becomes possible by simply running
`tools/build.py` without any extra options.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
- Zephyr now requires two passes to create the configuration for the cross compiling
- Added the missing bits required to build a valid new jerryscript minimal configuration
JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
With this change, REPL works almost the same as a standard JS REPL does
(browser console, Node.js, etc.). A result of each expression is
printed, e.g. "2+2" will print "4". Result is printed even if its
value is "undefined", e.g. "print(1)" will print "1", and on the next
line "undefined" (which is again how "normal" JS console work, except
a normal JS way to print to console is console.log()).
If an exception occured, a message "Error executing statement:", followed
by external representation of exception object, is printed. Note that
distinctive exception objects are supported only in "cp" (compact profile),
not in "cp_minimal". In the latter case, there's only exception hierarchy
top-level prototype, so any error message will look like:
Error executing statement: [object Function]
(That's the reason why there's error message prefix - so it weren't too
confusing even if used in cp_minimal config. Unfortunately, compile-time
JerryScript configuration isn't available to Zephyr's main.c, so there's
no easy way to implement cp vs cp_minimal distinction).
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org