Turn port implementations into proper libraries (#1777)
This commit changes the concept of JerryScript port implementations
from a simple directory of C source files (which get injected among
the sources of `jerry-core`) into a proper static library (which
may be linked to an application together with `jerry-core`). As a
consequence, this commit introduces a new library to the
JerryScript component architecture: the sources of the default port
implementation form `jerry-port-default`.
Changes in more detail:
- The sources in `targets/default` are moved to `jerry-port/default`
and are turned into a proper static library.
- Actually, the default port implementation has two library
variants, one that implements the bare minimum only
(`jerry-port-default-minimal`) and one that has some extra
functionalities specific to this implementation (the "full"
`jerry-port-default`).
- The new libraries have an interface header in
`jerry-port/default/include`, which extends the common
`jerryscript-port.h` API with functions specific to these
libraries.
- All non-standard port functions have now the
`jerry_port_default_` prefix (this affects `jobqueue_init` and
`jobqueue_run`).
- The jobqueue implementation functions became config macro
independent: it is now the responsibility of the linker to pick
the needed objects from the library, and omit those (e.g.,
jobqueue-related code) that are not referenced.
- Build of the libraries can be controlled with the new
`JERRY_PORT_DEFAULT` cmake option.
- The cmake option `PORT_DIR` is dropped, and `PORT_DIR/*.c` is not
appended to `jerry-core` sources.
- Instead, the `jerry` tool of `jerry-main` links to
`jerry-port-default`, while `jerry-minimal` links to
`jerry-port-default-minimal`.
- `tests/unit-core` tests are also linked to
`jerry-port-default-minimal`.
- Tools adapted.
- `build.py` has `--jerry-port-default` instead of `--port-dir`.
- `check-*.sh` have paths updated (`jerry-port/default` instead
of `targets/default`).
- Miscellaneous.
- Dropped `#ifndef`s from `jerryscript-port.h`. It is a public
header of the `jerry-core` library, which means that it must
not contain configuration-dependent parts (once the library is
built with some config macros and the archive and the headers
are installed, there is no way for the header to tell what
those config macrose were).
- Added documentation comments to the JobQueue Port API (in
`jerryscript-port.h`) and to several default port
implementation functions (in `jerry-port/default`).
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -106,9 +106,6 @@ if(FEATURE_DEBUGGER)
|
||||
set(SOURCE_CORE_FILES ${SOURCE_CORE_FILES} ${SOURCE_CORE_DEBUGGER})
|
||||
endif()
|
||||
|
||||
# Jerry port
|
||||
file(GLOB SOURCE_PORT_FILES "${PORT_DIR}/*.c")
|
||||
|
||||
# All-in-one build
|
||||
if(ENABLE_ALL_IN_ONE)
|
||||
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/jerry-all-in.c")
|
||||
|
||||
@@ -140,16 +140,31 @@ bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p);
|
||||
*/
|
||||
double jerry_port_get_current_time (void);
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
|
||||
|
||||
#define JERRY_PORT_ENABLE_JOBQUEUE
|
||||
/*
|
||||
* JobQueue Port API
|
||||
*/
|
||||
|
||||
/**
|
||||
* Jerry job handler function type
|
||||
*/
|
||||
typedef uint32_t (*jerry_job_handler_t) (void *);
|
||||
|
||||
/**
|
||||
* Enqueue a job described by a pair of function and data pointers. The port is
|
||||
* expected to call the handler function with the given data at some (later)
|
||||
* point of time.
|
||||
*
|
||||
* @param handler the pointer of the handler function associated with the job.
|
||||
* @param job_p the data pointer to be passed to handler when called.
|
||||
*
|
||||
* Note:
|
||||
* This port function is only called by the implementation of the Promise
|
||||
* builtin (mandated by the ES2015 standard). If the engine is built with
|
||||
* Promise disabled (e.g., with ES5.1 profile), then the port does not have
|
||||
* to implement this function.
|
||||
*/
|
||||
void jerry_port_jobqueue_enqueue (jerry_job_handler_t handler, void *job_p);
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user