Modify the profile option to specify external compile definitions. (#1497)

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
Robert Sipka 2017-01-02 10:47:50 +01:00 committed by László Langó
parent 080e78d7c2
commit 392f6d4a3b
7 changed files with 81 additions and 26 deletions

View File

@ -23,7 +23,7 @@ set(FEATURE_JS_PARSER ON CACHE BOOL "Enable js-parser?")
set(FEATURE_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?")
set(FEATURE_PARSER_DUMP OFF CACHE BOOL "Enable parser byte-code dumps?")
set(FEATURE_PROFILE "es5.1" CACHE STRING "Profile types: es5.1, minimal, es2015-subset")
set(FEATURE_PROFILE "es5.1" CACHE STRING "Use default or other profile?")
set(FEATURE_REGEXP_DUMP OFF CACHE BOOL "Enable regexp byte-code dumps?")
set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
@ -163,28 +163,17 @@ if(FEATURE_PARSER_DUMP)
set(DEFINES_JERRY ${DEFINES_JERRY} PARSER_DUMP_BYTE_CODE)
endif()
# Profile modes
set(CONFIG_DISABLE_ES2015
CONFIG_DISABLE_ARRAYBUFFER_BUILTIN)
# Minimal profile
if(FEATURE_PROFILE STREQUAL "minimal")
set(DEFINES_JERRY ${DEFINES_JERRY}
${CONFIG_DISABLE_ES2015}
CONFIG_DISABLE_ANNEXB_BUILTIN
CONFIG_DISABLE_ARRAY_BUILTIN
CONFIG_DISABLE_BOOLEAN_BUILTIN
CONFIG_DISABLE_DATE_BUILTIN
CONFIG_DISABLE_ERROR_BUILTINS
CONFIG_DISABLE_JSON_BUILTIN
CONFIG_DISABLE_MATH_BUILTIN
CONFIG_DISABLE_NUMBER_BUILTIN
CONFIG_DISABLE_REGEXP_BUILTIN
CONFIG_DISABLE_STRING_BUILTIN)
elseif(FEATURE_PROFILE STREQUAL "es5.1")
set(DEFINES_JERRY ${DEFINES_JERRY}
${CONFIG_DISABLE_ES2015})
elseif(NOT FEATURE_PROFILE STREQUAL "es2015-subset")
message(FATAL_ERROR "FEATURE_PROFILE='${FEATURE_PROFILE}' isn't supported")
if (NOT IS_ABSOLUTE ${FEATURE_PROFILE})
set(FEATURE_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/profiles/${FEATURE_PROFILE}.profile")
endif()
if(EXISTS ${FEATURE_PROFILE})
FILE(READ "${FEATURE_PROFILE}" PROFILE_SETTINGS)
STRING(REGEX REPLACE "^#.*$" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
STRING(REGEX REPLACE "[\r|\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
set(DEFINES_JERRY ${DEFINES_JERRY} ${PROFILE_SETTINGS})
else()
MESSAGE(FATAL_ERROR "Profile file: '${FEATURE_PROFILE}' doesn't exist!")
endif()
# RegExp byte-code dumps

View File

@ -0,0 +1,39 @@
### About profile files
Specify compile definitions in profile files to use when compiling the `jerry-core` target.
The default profile is ``es5.1`` which disables the ArrayBuffer built-in.
### Using profiles with the build system
You can specify the profile for the build system in the following ways:
* with absolute path
* with a name (this options selects profiles/$(name).profile file)
#### Restrictions
Only single line options are allowed in the profile file. Any line starting with hash-mark is ignored. Semicolon character is not allowed.
### Example usage:
#### 1. Using the build script
```
# assuming you are in jerryscript folder
./tools/build.py --profile=/absolute/path/to/my_profile.any_extension
```
or
```
# assuming you are in jerryscript folder
./tools/build.py --profile=minimal
```
This command selects the profile/minimal.profile file.
#### 2. Using only CMake build system
Set FEATURE_PROFILE option to one of the following values:
* the profile with absolute path
* name of the profile (which needs to exist in the `profiles` folder)

View File

@ -0,0 +1 @@
# Currently an empty profile.

View File

@ -0,0 +1 @@
CONFIG_DISABLE_ARRAYBUFFER_BUILTIN

View File

@ -0,0 +1,11 @@
CONFIG_DISABLE_ARRAYBUFFER_BUILTIN
CONFIG_DISABLE_ANNEXB_BUILTIN
CONFIG_DISABLE_ARRAY_BUILTIN
CONFIG_DISABLE_BOOLEAN_BUILTIN
CONFIG_DISABLE_DATE_BUILTIN
CONFIG_DISABLE_ERROR_BUILTINS
CONFIG_DISABLE_JSON_BUILTIN
CONFIG_DISABLE_MATH_BUILTIN
CONFIG_DISABLE_NUMBER_BUILTIN
CONFIG_DISABLE_REGEXP_BUILTIN
CONFIG_DISABLE_STRING_BUILTIN

View File

@ -15,7 +15,11 @@
cmake_minimum_required (VERSION 2.8.12)
project (Unittest C)
if(NOT FEATURE_PROFILE STREQUAL "es5.1")
if (NOT IS_ABSOLUTE ${FEATURE_PROFILE})
set(FEATURE_PROFILE "${CMAKE_SOURCE_DIR}/jerry-core/profiles/${FEATURE_PROFILE}.profile")
endif()
if(NOT ${FEATURE_PROFILE} STREQUAL "${CMAKE_SOURCE_DIR}/jerry-core/profiles/es5.1.profile")
message(FATAL_ERROR "FEATURE_PROFILE='${FEATURE_PROFILE}' isn't supported with UNITTESTS=ON")
endif()

View File

@ -25,6 +25,9 @@ from settings import *
BUILD_DIR = path.join(PROJECT_DIR, 'build')
DEFAULT_PORT_DIR = path.join(PROJECT_DIR, 'targets/default')
PROFILE_DIR = path.join(PROJECT_DIR, 'jerry-core/profiles')
DEFAULT_PROFILE = 'es5.1'
def default_toolchain():
(sysname, _, _, _, machine) = uname()
toolchain = path.join(PROJECT_DIR, 'cmake', 'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower()))
@ -61,7 +64,7 @@ def get_arguments():
parser.add_argument('--lto', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable link-time optimizations (%(choices)s; default: %(default)s)')
parser.add_argument('--mem-heap', metavar='SIZE', action='store', type=int, default=512, help='size of memory heap, in kilobytes (default: %(default)s)')
parser.add_argument('--port-dir', metavar='DIR', action='store', default=DEFAULT_PORT_DIR, help='add port directory (default: %(default)s)')
parser.add_argument('--profile', metavar='PROFILE', choices=['es5.1', 'minimal', 'es2015-subset'], default='es5.1', type=str.lower, help='specify the profile (%(choices)s; default: %(default)s)')
parser.add_argument('--profile', metavar='FILE', action='store', default=DEFAULT_PROFILE, help='specify profile file (default: %(default)s)')
parser.add_argument('--snapshot-exec', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable executing snapshot files (%(choices)s; default: %(default)s)')
parser.add_argument('--snapshot-save', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable saving snapshot files (%(choices)s; default: %(default)s)')
parser.add_argument('--static-link', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable static linking of binaries (%(choices)s; default: %(default)s)')
@ -105,7 +108,14 @@ def generate_build_options(arguments):
build_options.append('-DENABLE_LTO=%s' % arguments.lto)
build_options.append('-DMEM_HEAP_SIZE_KB=%d' % arguments.mem_heap)
build_options.append('-DPORT_DIR=%s' % arguments.port_dir)
build_options.append('-DFEATURE_PROFILE=%s' % arguments.profile)
if path.isabs(arguments.profile):
PROFILE = arguments.profile
else:
PROFILE = path.join(PROFILE_DIR, arguments.profile + '.profile')
build_options.append('-DFEATURE_PROFILE=%s' % PROFILE)
build_options.append('-DFEATURE_SNAPSHOT_EXEC=%s' % arguments.snapshot_exec)
build_options.append('-DFEATURE_SNAPSHOT_SAVE=%s' % arguments.snapshot_save)
build_options.append('-DENABLE_STATIC_LINK=%s' % arguments.static_link)