From b43057c90be3c0106c25d78e3bfe7b05d1e479b1 Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Thu, 16 Nov 2017 16:31:30 +0100 Subject: [PATCH] Add grouping macro guards for disabling engine features (#2084) Until now, the engine's feature set was configurable either via `CONFIG_*` macro guards defined individually on compiler command line or via profiles (which are text files listing macro guards, picked up by the cmake build system and turning them into compiler command line options). And the features under profile control are all enabled by default (i.e., all macros are `CONFIG_DISABLE_*`). This causes a maintenance issue when new features are added to the engine, because the disabling macros have to be added to all profiles that don't include the new features. This can even cause "compatibility break" for applications that embed JerryScript but don't use the cmake or the python build system, because then profiles are unavailable and all feature disabling guards have to be explicitly passed to the compiler. (I.e., if such an application wants to use the ES5.1 feature set, it must define all the ES2015 disable macros; if the engine is developed further and a new ES2015 feature gets implemented, then the new feature will sneak into the application's binary unless its own build system is changed to add the new feature guard.) Even the in-repo example Curie BSP target seems to have suffered from this maintenance problem. This patch introduces two new grouping macro guards that enable the disabling of all ES5.1 builtins and all ES2015 features. As the grouping logic is in config.h, the maintenance of non-cmake-based build systems becomes easier (and there is no change for the python and cmake-based build systems). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu --- jerry-core/config.h | 27 +++++++++++++++++++++++++++ jerry-core/profiles/es5.1.profile | 6 +----- jerry-core/profiles/minimal.profile | 17 ++--------------- targets/curie_bsp/setup.py | 5 +---- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/jerry-core/config.h b/jerry-core/config.h index 8e10ae0c6..69feb92d7 100644 --- a/jerry-core/config.h +++ b/jerry-core/config.h @@ -16,6 +16,33 @@ #ifndef CONFIG_H #define CONFIG_H +/** + * Group of builtin-related features that can be disabled together. + */ +#ifdef CONFIG_DISABLE_BUILTINS +# define CONFIG_DISABLE_ANNEXB_BUILTIN +# define CONFIG_DISABLE_ARRAY_BUILTIN +# define CONFIG_DISABLE_BOOLEAN_BUILTIN +# define CONFIG_DISABLE_DATE_BUILTIN +# define CONFIG_DISABLE_ERROR_BUILTINS +# define CONFIG_DISABLE_JSON_BUILTIN +# define CONFIG_DISABLE_MATH_BUILTIN +# define CONFIG_DISABLE_NUMBER_BUILTIN +# define CONFIG_DISABLE_REGEXP_BUILTIN +# define CONFIG_DISABLE_STRING_BUILTIN +#endif /* CONFIG_DISABLE_BUILTINS */ + +/** + * Group of ES2015-related features that can be disabled together. + */ +#ifdef CONFIG_DISABLE_ES2015 +# define CONFIG_DISABLE_ES2015_ARROW_FUNCTION +# define CONFIG_DISABLE_ES2015_BUILTIN +# define CONFIG_DISABLE_ES2015_PROMISE_BUILTIN +# define CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS +# define CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN +#endif /* CONFIG_DISABLE_ES2015 */ + /** * Limit of data (system heap, engine's data except engine's own heap) */ diff --git a/jerry-core/profiles/es5.1.profile b/jerry-core/profiles/es5.1.profile index 79fecd842..a57059829 100644 --- a/jerry-core/profiles/es5.1.profile +++ b/jerry-core/profiles/es5.1.profile @@ -1,5 +1 @@ -CONFIG_DISABLE_ES2015_ARROW_FUNCTION -CONFIG_DISABLE_ES2015_BUILTIN -CONFIG_DISABLE_ES2015_PROMISE_BUILTIN -CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS -CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN +CONFIG_DISABLE_ES2015 diff --git a/jerry-core/profiles/minimal.profile b/jerry-core/profiles/minimal.profile index f32fab9f2..bacb322ef 100644 --- a/jerry-core/profiles/minimal.profile +++ b/jerry-core/profiles/minimal.profile @@ -1,16 +1,3 @@ -CONFIG_DISABLE_ANNEXB_BUILTIN -CONFIG_DISABLE_ARRAY_BUILTIN -CONFIG_DISABLE_BOOLEAN_BUILTIN -CONFIG_DISABLE_DATE_BUILTIN -CONFIG_DISABLE_ERROR_BUILTINS -CONFIG_DISABLE_ES2015_ARROW_FUNCTION -CONFIG_DISABLE_ES2015_BUILTIN -CONFIG_DISABLE_ES2015_PROMISE_BUILTIN -CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS -CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN -CONFIG_DISABLE_JSON_BUILTIN -CONFIG_DISABLE_MATH_BUILTIN -CONFIG_DISABLE_NUMBER_BUILTIN -CONFIG_DISABLE_REGEXP_BUILTIN -CONFIG_DISABLE_STRING_BUILTIN +CONFIG_DISABLE_BUILTINS +CONFIG_DISABLE_ES2015 CONFIG_DISABLE_UNICODE_CASE_CONVERSION diff --git a/targets/curie_bsp/setup.py b/targets/curie_bsp/setup.py index 38a5a9b05..2ed0669fc 100755 --- a/targets/curie_bsp/setup.py +++ b/targets/curie_bsp/setup.py @@ -96,10 +96,7 @@ def build_jerry_data(jerry_path): '-DCONFIG_DISABLE_DATE_BUILTIN', '-DCONFIG_DISABLE_REGEXP_BUILTIN', '-DCONFIG_DISABLE_ANNEXB_BUILTIN', - '-DCONFIG_DISABLE_ES2015_ARROW_FUNCTION' - '-DCONFIG_DISABLE_ES2015_ARRAYBUFFER_BUILTIN', - '-DCONFIG_DISABLE_ES2015_TEMPLATE_STRINGS', - '-DCONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN', + '-DCONFIG_DISABLE_ES2015', '-DCONFIG_ECMA_LCACHE_DISABLE', '-DCONFIG_ECMA_PROPERTY_HASHMAP_DISABLE', ]