From 5078b899eafed14c0031ab050c2d5337d2afcb15 Mon Sep 17 00:00:00 2001 From: Maxim Bolshov Date: Thu, 28 Aug 2025 16:04:55 +0300 Subject: [PATCH] [etsstdlib] Specialize 'arktsconfig' Because of it's special purpose it is renamed to 'stdconfig'. Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICWWVO?from=project-issue Signed-off-by: Maxim Bolshov Co-authored-by: Zhelyapov Aleksey Co-authored-by: Daniil Kofanov Change-Id: I2194b7a865b06caead83232dd965ec4b136a72c3 --- static_core/cmake/HostTools.cmake | 2 ++ static_core/plugins/CMakeLists.txt | 12 ++++++--- static_core/plugins/ets/BUILD.gn | 2 +- static_core/plugins/ets/CMakeLists.txt | 26 ++++++++++++------- .../plugins/ets/stdlib/std/core/Null.ets | 2 +- .../{arktsconfig.json => stdconfig.json} | 10 +++---- .../multiple_import_simple_name.ets | 3 ++- .../multiple_import_simple_name_as.ets | 3 ++- ...multiple_import_simple_name_as_non_neg.ets | 3 ++- .../02.import_directives/import.params.yaml | 1 - .../import_as.params.yaml | 1 - .../std/math/BoundariesTest.ets | 2 +- .../ets/tests/runtime/tooling/CMakeLists.txt | 2 +- .../utils/test_constructor.j2 | 2 +- .../utils/test_instance_method.j2 | 2 +- .../utils/test_instance_property.j2 | 2 +- .../utils/test_static_method.j2 | 2 +- .../test-lists/ets-cts/ets-cts-ignored.txt | 5 ++++ .../runner/plugins/ets/runner_ets.py | 10 ------- .../runner/plugins/parser/runner_js_parser.py | 6 ++--- 20 files changed, 51 insertions(+), 47 deletions(-) rename static_core/plugins/ets/stdlib/{arktsconfig.json => stdconfig.json} (70%) diff --git a/static_core/cmake/HostTools.cmake b/static_core/cmake/HostTools.cmake index b8cdb67f59..534900b1fb 100644 --- a/static_core/cmake/HostTools.cmake +++ b/static_core/cmake/HostTools.cmake @@ -151,6 +151,8 @@ function(panda_configure_host_tools) set(CHECK_COMMAND "${PANDA_ROOT}/cross_values/diff_check_values.sh ${TARGET_CROSS_VALUES} ${HOST_CROSS_VALUES}") separate_arguments(CHECK_COMMAND UNIX_COMMAND ${CHECK_COMMAND}) + message(STATUS "Host-tools configure args: '${HOST_TOOLS_CMAKE_ARGS}'") + # In case of dependency on panda_host_tools it's mandatory to use the panda_host_tools-build target as the dependency target ExternalProject_Add(panda_host_tools DEPENDS host_tools_depends diff --git a/static_core/plugins/CMakeLists.txt b/static_core/plugins/CMakeLists.txt index e06db46ab8..c0e4a5a4d1 100644 --- a/static_core/plugins/CMakeLists.txt +++ b/static_core/plugins/CMakeLists.txt @@ -16,11 +16,15 @@ cmake_minimum_required(VERSION 3.5.2 FATAL_ERROR) if(PANDA_WITH_TOOLCHAIN AND (EXISTS ${ES2PANDA_PATH})) if(CMAKE_CROSSCOMPILING) ExternalProject_Get_Property(panda_host_tools binary_dir) - set(es2panda_target panda_host_tools-build) - set(es2panda_bin "${binary_dir}/tools/es2panda/aot/es2panda") + set(es2panda_target panda_host_tools-build) + set(es2panda_target_stdlib panda_host_tools-build) + set(es2panda_bin "${binary_dir}/tools/es2panda/aot/es2panda") + set(es2panda_bin_stdlib "${binary_dir}/tools/es2panda/aot/es2panda_stdlib_compiler") else() - set(es2panda_target es2panda) - set(es2panda_bin $) + set(es2panda_target es2panda) + set(es2panda_target_stdlib es2panda_stdlib_compiler) + set(es2panda_bin $) + set(es2panda_bin_stdlib $) endif() endif() diff --git a/static_core/plugins/ets/BUILD.gn b/static_core/plugins/ets/BUILD.gn index 94da8b8370..e24ed9eef9 100644 --- a/static_core/plugins/ets/BUILD.gn +++ b/static_core/plugins/ets/BUILD.gn @@ -64,7 +64,7 @@ if (!(ark_standalone_build || (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) || (defined(ark_static_standalone_build) && ark_static_standalone_build))) { generate_static_abc("ets2abc_etsstdlib_bootabc") { - arktsconfig = "$ark_root/plugins/ets/stdlib/arktsconfig.json" + arktsconfig = "$ark_root/plugins/ets/stdlib/stdconfig.json" dst_file = "$target_out_dir/etsstdlib_bootabc.abc" out_puts = [ "$target_out_dir/etsstdlib_bootabc.abc" ] is_boot_abc = "True" diff --git a/static_core/plugins/ets/CMakeLists.txt b/static_core/plugins/ets/CMakeLists.txt index efa6693cec..e676e3aefb 100644 --- a/static_core/plugins/ets/CMakeLists.txt +++ b/static_core/plugins/ets/CMakeLists.txt @@ -20,6 +20,7 @@ include(cmake/import.cmake) add_custom_target(ets_tests COMMENT "Running ets test suites") set(DEFAULT_TEST_GROUP ets_tests) +set(STDLIB ${CMAKE_CURRENT_SOURCE_DIR}/stdlib) function(compile_ets_code ETS_SRC OUTPUT_ABC TARGET) set(oneValueArgs ARKTS_CONFIG ETSPATH OPT_LEVEL) @@ -45,33 +46,38 @@ function(compile_ets_code ETS_SRC OUTPUT_ABC TARGET) list(APPEND ES2PANDA_ARGUMENTS "--ets-path=${ARG_ETSPATH}") endif() - set(COMPILE_DEPENDENCIES - ${es2panda_target} - ) - + set(COMPILE_DEPENDENCIES) + set(E2P) get_filename_component(OUTPUT_DIR ${OUTPUT_ABC} DIRECTORY) file(MAKE_DIRECTORY ${OUTPUT_DIR}) if ("${ETS_SRC}" STREQUAL "GEN_STD_LIB") + set(E2P ${es2panda_bin_stdlib}) + set(DECLS_DST_DIR "${OUTPUT_DIR}/stdlib/decls") + file(MAKE_DIRECTORY ${DECLS_DST_DIR}) list(APPEND ES2PANDA_ARGUMENTS "--gen-stdlib=true") + list(APPEND ES2PANDA_ARGUMENTS "--generate-decl:enabled,path=${DECLS_DST_DIR}") + list(APPEND ES2PANDA_ARGUMENTS "--arktsconfig=${STDLIB}/stdconfig.json") + set(STAMP "${OUTPUT_ABC}.stamp") - set(STDLIB ${CMAKE_CURRENT_LIST_DIR}/stdlib/) file(WRITE ${STAMP} "") add_custom_target(${TARGET}.stamp BYPRODUCTS ${STAMP} COMMAND find ${STDLIB} -newer ${STAMP} -exec touch ${STAMP} ";" || touch ${STAMP} VERBATIM ) - list(APPEND COMPILE_DEPENDENCIES ${TARGET}.stamp ${STAMP}) + list(APPEND COMPILE_DEPENDENCIES ${es2panda_target_stdlib} ${TARGET}.stamp ${STAMP}) else() + set(E2P ${es2panda_bin}) list(APPEND ES2PANDA_ARGUMENTS ${ETS_SRC}) - list(APPEND COMPILE_DEPENDENCIES etsstdlib ${ETS_SRC}) + list(APPEND COMPILE_DEPENDENCIES ${es2panda_target} etsstdlib ${ETS_SRC}) endif() + add_custom_command( OUTPUT ${OUTPUT_ABC} COMMENT "Running es2panda for ets file: ${ETS_SRC}" - COMMAND ${es2panda_bin} ${ES2PANDA_ARGUMENTS} + COMMAND ${E2P} ${ES2PANDA_ARGUMENTS} DEPENDS ${COMPILE_DEPENDENCIES} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) @@ -79,6 +85,7 @@ function(compile_ets_code ETS_SRC OUTPUT_ABC TARGET) add_custom_target(${TARGET} DEPENDS ${OUTPUT_ABC}) if(TARGET etsstdlib) + add_dependencies(es2panda etsstdlib) if (NOT TARGET regenerate_and_check_stdlib AND ${CMAKE_GENERATOR} MATCHES "Ninja") # Note(ivan-tyulyandin): -P replaces CMAKE_CURRENT_SOURCE_DIR so using ETS_PLUGIN_SOURCE_DIR add_custom_target(regenerate_and_check_stdlib @@ -170,7 +177,8 @@ if(TARGET es2panda) add_dependencies(ark etsstdlib) add_subdirectory(sdk) - if(NOT CMAKE_CROSSCOMPILING) + # host-tools cannot have libarkruntime as for and verifier as well. + if(NOT CMAKE_CROSSCOMPILING AND NOT HOST_TOOLS) set(verifier_target verifier) set(verifier_bin $) diff --git a/static_core/plugins/ets/stdlib/std/core/Null.ets b/static_core/plugins/ets/stdlib/std/core/Null.ets index a4a3fde28e..986a6f565c 100644 --- a/static_core/plugins/ets/stdlib/std/core/Null.ets +++ b/static_core/plugins/ets/stdlib/std/core/Null.ets @@ -15,7 +15,7 @@ package std.core; -final class Null { +export final class Null { private constructor() { }; public override toString(): String { return "null"; } diff --git a/static_core/plugins/ets/stdlib/arktsconfig.json b/static_core/plugins/ets/stdlib/stdconfig.json similarity index 70% rename from static_core/plugins/ets/stdlib/arktsconfig.json rename to static_core/plugins/ets/stdlib/stdconfig.json index f426767b3c..5a73e47ed8 100644 --- a/static_core/plugins/ets/stdlib/arktsconfig.json +++ b/static_core/plugins/ets/stdlib/stdconfig.json @@ -8,10 +8,6 @@ "escompat": [ "ets/stdlib/escompat" ] - }, - "outDir": "../cache" - }, - "include": [ - "./**/*.ets" - ] -} \ No newline at end of file + } + } +} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name.ets index 2188317c4a..10671ed53a 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name.ets @@ -17,7 +17,8 @@ desc: import multiple simple names ---*/ -import {sin, PI} from "std/math"; +import {sin} from "std/math"; +import {PI} from "std/math/consts"; function main(): void { let x = sin(PI); diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as.ets index 2c489a033d..35cf8f2f2c 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as.ets @@ -17,7 +17,8 @@ desc: import multiple simple names with as ---*/ -import {sin as Sine, PI as PNumber} from "std/math"; +import {sin as Sine} from "std/math"; +import {PI as PNumber} from "std/math/consts"; function main(): void { let x = Sine(PNumber); diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as_non_neg.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as_non_neg.ets index dcba40a43d..2dece8c4e1 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as_non_neg.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/03.selective_binding/multiple_import_simple_name_as_non_neg.ets @@ -18,7 +18,8 @@ desc: ‘sin’ is an stdlib method, it should be accessible. tags: [compile-only] ---*/ -import {sin as Sine, PI as PNumber} from "std/math"; +import {sin as Sine} from "std/math"; +import {PI as PNumber} from "std/math/consts"; function main(): void { let x = sin(PNumber); diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import.params.yaml b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import.params.yaml index bf4c248afe..161d3e54fe 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import.params.yaml @@ -14,5 +14,4 @@ --- # List of classes in package classes: - sin - - PI - abs diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import_as.params.yaml b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import_as.params.yaml index f792bc8b4f..e98002a267 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import_as.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/import_as.params.yaml @@ -14,7 +14,6 @@ --- # List of classes in package classes: - sin - - PI - abs # List of simple words that can be used as identifiers diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/math/BoundariesTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/math/BoundariesTest.ets index 710d12ed8c..e19efc375d 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/math/BoundariesTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/math/BoundariesTest.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { PI } from "std/math"; +import { PI } from "std/math/consts"; const nan = Double.NaN; const posInf = Double.POSITIVE_INFINITY; diff --git a/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt b/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt index 544b5616be..130fe5c908 100644 --- a/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt +++ b/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt @@ -36,7 +36,7 @@ panda_ets_add_gtest( ) add_custom_target(es2panda_ets_stdlib_debug_info - COMMAND ${es2panda_bin} --opt-level=0 --debug-info --gen-stdlib=true + COMMAND ${es2panda_bin} --opt-level=0 --debug-info --gen-stdlib=true --arktsconfig=${STDLIB}/stdconfig.json --extension=ets --output ${CMAKE_CURRENT_BINARY_DIR}/etsstdlib.abc DEPENDS ${es2panda_target} ) diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_constructor.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_constructor.j2 index 4249a351e1..b5b322a3f5 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_constructor.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_constructor.j2 @@ -13,7 +13,7 @@ * limitations under the License. */ -import { PI, E } from "std/math"; +import { PI, E } from "std/math/consts"; {%- for number in item.init_object_param_list.keys() %} const TEST_DATA_{{.number|upper}} : {{.item. init_object_data_types[number]}} = {{.item. init_object_param_list[number]}}; diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 index b7230b4cea..e41cc5833f 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_method.j2 @@ -13,7 +13,7 @@ * limitations under the License. */ -import { E } from "std/math"; +import { E } from "std/math/consts"; {%- if item.init_object_complex_constructor is defined %} {%- for number in item.init_object_param_list.keys() %} diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_property.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_property.j2 index 85769b854c..d8b2a9d48f 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_property.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_instance_property.j2 @@ -13,7 +13,7 @@ * limitations under the License. */ -import { E } from "std/math"; +import { E } from "std/math/consts"; const TEST_DATA_OBJECT_INIT : {{.item.init_object_data_type}} ={{.item.init_object_data}}; {%- for number, param in item.param_list.items() %} diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 index 448be48f87..1c79e26de2 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_static_method.j2 @@ -13,7 +13,7 @@ * limitations under the License. */ -import { E } from "std/math"; +import { E } from "std/math/consts"; {%- for number, param in item.param_list.items() %} const TEST_DATA_{{.number|upper}} : {{.item.param_init_data_types[number]}} = {{.item.param_list[number]}}; diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt index 1784c36450..3fd382e714 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt @@ -2835,3 +2835,8 @@ #29866 09.classes/07.method_declarations/method_declaration_with_existed_name_3.ets + +#29939 +13.compilation_units/02.import_directives/05.import_path/file/import_path_file_global_0.ets +13.compilation_units/02.import_directives/05.import_path/file/import_path_file_global_1.ets + diff --git a/static_core/tests/tests-u-runner/runner/plugins/ets/runner_ets.py b/static_core/tests/tests-u-runner/runner/plugins/ets/runner_ets.py index 45a8e68b46..4611d5aa98 100644 --- a/static_core/tests/tests-u-runner/runner/plugins/ets/runner_ets.py +++ b/static_core/tests/tests-u-runner/runner/plugins/ets/runner_ets.py @@ -131,7 +131,6 @@ class RunnerETS(RunnerFileBased): def _check_binary_artifacts(self) -> None: stdlib_path_obj = Path(self.stdlib_path) - stdlib_src_path_obj = Path(self._get_std_from_arktsconfig()) if not stdlib_path_obj.is_file(): Log.exception_and_raise( @@ -139,15 +138,6 @@ class RunnerETS(RunnerFileBased): f"Standard library at {self.stdlib_path} was not found", FileNotFoundError) - if not stdlib_src_path_obj.is_dir(): - path_as_string = str(stdlib_src_path_obj) - - Log.exception_and_raise( - _LOGGER, - f"Source code of standard library at {path_as_string} was not found, " - "please set the correct eTS stdlib root!", - FileNotFoundError) - # We use Log.exception_and_raise which throws exception. no need in return # pylint: disable=inconsistent-return-statements def _get_std_from_arktsconfig(self) -> Any: diff --git a/static_core/tests/tests-u-runner/runner/plugins/parser/runner_js_parser.py b/static_core/tests/tests-u-runner/runner/plugins/parser/runner_js_parser.py index e3e6bd8d54..5e8d0b34a9 100644 --- a/static_core/tests/tests-u-runner/runner/plugins/parser/runner_js_parser.py +++ b/static_core/tests/tests-u-runner/runner/plugins/parser/runner_js_parser.py @@ -64,15 +64,13 @@ class RunnerJSParser(RunnerJS): TestDirectory('compiler/ts', 'ts', flags=['--extension=ts']), TestDirectory('compiler/ets', 'ets', flags=[ '--extension=ets', - f'--arktsconfig={self.arktsconfig}', - f'--ets-path={es2panda_test}' + f'--arktsconfig={self.arktsconfig}' ]), TestDirectory('parser/ts', 'ts', flags=['--parse-only', '--extension=ts']), TestDirectory('parser/as', 'ts', flags=['--parse-only', '--extension=as']), TestDirectory('parser/ets', 'ets', flags=[ '--extension=ets', - f'--arktsconfig={self.arktsconfig}', - f'--ets-path={es2panda_test}' + f'--arktsconfig={self.arktsconfig}' ]), ] -- Gitee