diff --git a/static_core/cmake/HostTools.cmake b/static_core/cmake/HostTools.cmake index b8cdb67f599c3986d5cd03f2b9bbb1a1dd55b8df..534900b1fbff1d5a2e4dc483019f2a16b546eaf0 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 e06db46ab8b1ee050dae1d4fa36061c2d7898f25..c0e4a5a4d149b552fce3367c8845c9e55849b59f 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 94da8b8370441f5283ad3ad9cf0b2b5b0cd34936..e24ed9eef9701a094dd1e25b3c3208ccf5ce4df5 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 efa6693cec2b82dd83b6f9dc062f1fe318123bde..e676e3aefb186a707d3deed36a72f96ac864e6a8 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 a4a3fde28ec032c1cad1f260b97b060f37f1fe80..986a6f565c6f2ee27ef2eda0ae948454962700a2 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 f426767b3c579fb7b21a0073d606e5a9e290556a..5a73e47ed86ba955ebf061285df2bee2b5f33ddb 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 2188317c4a33d49c0f99b26642cf72438720eb28..10671ed53a7a91b69212e9514818f62cac2fdd42 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 2c489a033d7f4630a560b572149f7058f6cde8c5..35cf8f2f2c94f44d8b3e8115f0e4551f7396b0d0 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 dcba40a43d2382a22e41dd31e0d5ca8dfb0b751a..2dece8c4e14cc938c608e141791c432474526016 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 bf4c248afe6bc196e4a0ea3ee926c1e82dcc53e6..161d3e54fe167b16fc242fe2b2425cbdf6612d52 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 f792bc8b4f77a84846d638f5321cef2ed3b23437..e98002a267706b15b27727469618ccc44f4f2a5a 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 710d12ed8c60d848fb26f3e606815ea91b1a92aa..e19efc375d7214f930d6b5fcffb9f2f37dd70c51 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 544b5616be44c67f37a639d1154cc11055c5344b..130fe5c908f07881f86ba5261182fd261de69c96 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 4249a351e11c6ab71534114078d5b0bfe03f82cd..b5b322a3f584bb8c59016ef574efb3d06d17e568 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 b7230b4cea754409ac01aca1d7d3273b3c338c4a..e41cc5833f7a49846bfbffeb60b9ae922267a4f1 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 85769b854c7b0849880a68c2e7f95928892dabca..d8b2a9d48f2f896b997af122e089608c954f6ad2 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 448be48f87df6b1ad70bf475834ba1eb98d258ff..1c79e26de234a42b0871a5a7fc6070c54b56cd4f 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 1784c3645033ab27652092856014d787391fb2fd..3fd382e7142e55aaacc1cf9d88786b9ad50a9e8e 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 45a8e68b46e6dc4347f0a1efa4aa1e2d8a124b23..4611d5aa98a9e8ed91f469ff40d8a4b78b1f8a1d 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 e3e6bd8d54d80eb04c60cc3fac60679545fcc59a..5e8d0b34a983ce8be16847f05ef8aef5139b53b3 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}' ]), ]