From af3d49810d0d42cd9e72f5ce114a924b30569c19 Mon Sep 17 00:00:00 2001 From: aakmaev Date: Mon, 20 Feb 2023 23:11:46 +0300 Subject: [PATCH] Move icu deps to core Signed-off-by: Akmaev Alexey --- BUILD.gn | 23 +--------- runtime/CMakeLists.txt | 53 +----------------------- runtime/init_icu.cpp | 17 -------- runtime/init_icu.h | 25 ----------- runtime/templates/init_icu_gen.cpp.erb | 36 ---------------- runtime/templates/substitute_icu_path.rb | 25 ----------- subproject_sources.gn | 8 ---- 7 files changed, 3 insertions(+), 184 deletions(-) delete mode 100644 runtime/init_icu.cpp delete mode 100644 runtime/init_icu.h delete mode 100644 runtime/templates/init_icu_gen.cpp.erb delete mode 100755 runtime/templates/substitute_icu_path.rb diff --git a/BUILD.gn b/BUILD.gn index 8da11ac47..df42a4f8c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -61,11 +61,6 @@ config("runtime") { "$ark_root/plugins/ecmascript/runtime/", "$target_gen_dir", "$ark_root_gen_dir", - "$ark_third_party_root/icu/icu4c/source/common", - "$ark_third_party_root/icu/icu4c/source/common", - "$ark_third_party_root/icu/icu4c/source/i18n", - "$ark_third_party_root/icu/icu4c/source", - "$ark_third_party_root/icu", ] configs = [ "es2panda:libes2panda_public_config", @@ -75,12 +70,7 @@ config("runtime") { } config("runtime_interpreter_impl") { - include_dirs = [ - "$ark_third_party_root/icu/icu4c/source/common", - "$ark_third_party_root/icu/icu4c/source/i18n", - "$ark_third_party_root/icu/icu4c/source/", - "$ark_third_party_root/icu", - ] + # Required, but empty: nothing to add currently } ark_asm_gen("ecmastdlib") { @@ -103,17 +93,6 @@ action("ecmastdlib_inline_h") { deps = [ ":ecmastdlib" ] } -# Substitute ICU path -action("substitute_icu_path") { - script = "runtime/templates/substitute_icu_path.rb" - outputs = [ "$target_gen_dir/init_icu_gen.cpp" ] - args = [ - rebase_path("runtime/templates/init_icu_gen.cpp.erb"), - rebase_path("$target_gen_dir/init_icu_gen.cpp"), - rebase_path(ark_third_party_root), - ] -} - ark_gen_file("ecma_intrinsics_gen_arkruntime") { template_file = "$ark_root/plugins/ecmascript/runtime/templates/intrinsics_gen.cpp.erb" diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 0d309fede..a11ce6bce 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -13,6 +13,8 @@ panda_promote_to_definitions(PANDA_ECMASCRIPT_ENABLE_RUNTIME_STAT) +option(PANDA_LINK_ICU "Enable linking with icu third party library" true) + set(ECMA_SRC_DIR ${PANDA_ECMASCRIPT_PLUGIN_SOURCE}/runtime) if(PANDA_TARGET_ARM32) @@ -27,15 +29,6 @@ endif() set(ECMA_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") file(MAKE_DIRECTORY "${ECMA_GEN_DIR}") -add_custom_command(OUTPUT ${ECMA_GEN_DIR}/init_icu_gen.cpp - COMMAND ${ECMA_SRC_DIR}/templates/substitute_icu_path.rb ${ECMA_SRC_DIR}/templates/init_icu_gen.cpp.erb ${ECMA_GEN_DIR}/init_icu_gen.cpp ${PANDA_THIRD_PARTY_SOURCES_DIR} - DEPENDS ${ECMA_SRC_DIR}/templates/init_icu_gen.cpp.erb) - -add_custom_target(init_icu_gen_cpp - DEPENDS ${ECMA_GEN_DIR}/init_icu_gen.cpp) - -add_dependencies(arkruntime_static init_icu_gen_cpp) - set(ECMASCRIPT_SOURCES ${ECMA_SRC_DIR}/bridge/ecma_bridge_helpers.cpp ${ECMA_SRC_DIR}/builtins/builtins_collator.cpp @@ -121,7 +114,6 @@ set(ECMASCRIPT_SOURCES ${ECMA_SRC_DIR}/ic/ic_runtime_stub.cpp ${ECMA_SRC_DIR}/ic/property_box.cpp ${ECMA_SRC_DIR}/ic/proto_change_details.cpp - ${ECMA_SRC_DIR}/init_icu.cpp ${ECMA_SRC_DIR}/internal_call_params.cpp ${ECMA_SRC_DIR}/interpreter/slow_runtime_helper.cpp ${ECMA_SRC_DIR}/interpreter/slow_runtime_stub.cpp @@ -274,47 +266,6 @@ endif() add_dependencies(arkruntime_interpreter_impl arkcompiler) -# Runtime uses unicode and i18n. -set(ICU_INCLUDE_DIR - ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu/icu4c/source/common - ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu/icu4c/source/i18n - ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu/icu4c/source - ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu -) - -target_include_directories(arkruntime_static - PUBLIC ${ICU_INCLUDE_DIR} -) - -target_include_directories(arkruntime_interpreter_impl - PUBLIC ${ICU_INCLUDE_DIR} -) - -target_include_directories(csa_tests_arkruntime_interpreter_impl - PUBLIC ${ICU_INCLUDE_DIR} -) - -if (TARGET arkruntime_test_interpreter_impl) - target_include_directories(arkruntime_test_interpreter_impl - PUBLIC ${ICU_INCLUDE_DIR} - ) -endif() - -target_include_directories(asm_defines - PUBLIC ${ICU_INCLUDE_DIR} -) - -# Allow to link targets which is not built in this directory againt hmicuuc.z hmicui18n.z -if(POLICY CMP0079) - cmake_policy(SET CMP0079 NEW) -endif() - -target_link_libraries(arkruntime_static hmicuuc.z hmicui18n.z) - -if (TARGET arkruntime_for_relayout_static) - target_link_libraries(arkruntime_for_relayout_static hmicuuc.z hmicui18n.z) -endif() - set_source_files_properties(${ECMASCRIPT_SOURCES} PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) set_source_files_properties(${ECMA_SRC_DIR}/js_locale.cpp PROPERTIES COMPILE_FLAGS -Wno-shadow) diff --git a/runtime/init_icu.cpp b/runtime/init_icu.cpp deleted file mode 100644 index 368342f7e..000000000 --- a/runtime/init_icu.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "init_icu.h" -#include "init_icu_gen.cpp" diff --git a/runtime/init_icu.h b/runtime/init_icu.h deleted file mode 100644 index 8ceb84359..000000000 --- a/runtime/init_icu.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RUNTIME_INIT_ICU_H -#define RUNTIME_INIT_ICU_H - -#include "common/unicode/putil.h" - -/** - * convienient method to set icu data file directory to HW_DIRECTORY); - */ -void SetIcuDirectory(); -#endif // RUNTIME_INIT_ICU_H diff --git a/runtime/templates/init_icu_gen.cpp.erb b/runtime/templates/init_icu_gen.cpp.erb deleted file mode 100644 index 99eeead6d..000000000 --- a/runtime/templates/init_icu_gen.cpp.erb +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "init_icu.h" - -#include -#include - -/** - * set icu data files to hwDirectory - */ -void SetIcuDirectory() -{ - static int status = 0; - static std::mutex dataMutex; - std::string g_hwDirectory = std::string("<%= PANDA_THIRD_PARTY_SOURCES_DIR %>") + std::string("/icu/ohos_icu4j/data"); - - std::lock_guard lock(dataMutex); - if (status != 0) { - return; - } - u_setDataDirectory(g_hwDirectory.c_str()); - status = 1; -} diff --git a/runtime/templates/substitute_icu_path.rb b/runtime/templates/substitute_icu_path.rb deleted file mode 100755 index 950522d82..000000000 --- a/runtime/templates/substitute_icu_path.rb +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env ruby -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Huawei Technologies Co.,Ltd. - -require 'erb' - -template = File.read(File.expand_path(ARGV[0])) -output = File.open(File.expand_path(ARGV[1]), 'w') -PANDA_THIRD_PARTY_SOURCES_DIR = ARGV[2] - -t = ERB.new(template, 0, "%<>") -output.write(t.result) -output.close diff --git a/subproject_sources.gn b/subproject_sources.gn index 26d658548..5cc102be3 100644 --- a/subproject_sources.gn +++ b/subproject_sources.gn @@ -42,7 +42,6 @@ irtoc_plugins = [ arkruntime_header_sub_deps = [ "$_plugin_dir:ecma_intrinsics_gen_arkruntime", - "$_plugin_dir:substitute_icu_path", ] arkruntime_stdlib_sub_deps = [ "$_plugin_dir:ecmastdlib_inline_h", @@ -52,13 +51,7 @@ arkcompiler_deps = arkbytecodeopt_deps = [ "$_plugin_dir:isa_gen_ecma_bytecodeopt_ecmascript_codegen_intrinsics_gen_inc", ] -arkruntime_third_party_deps = [ - "icu/icu4c:shared_icui18n", - "icu/icu4c:shared_icuuc", -] arkruntime_deps = [ - "$ark_third_party_root/icu/icu4c:shared_icui18n", - "$ark_third_party_root/icu/icu4c:shared_icuuc", "$ark_root/assembler:libarkassembler_frontend_static", "$ark_root/libpandafile:libarkfile_frontend_static", "$_plugin_dir/es2panda:libes2panda_frontend_static", @@ -215,7 +208,6 @@ srcs_runtime = [ "runtime/class_info_extractor.cpp", "runtime/compiler/ecmascript_runtime_interface.cpp", "runtime/tooling/pt_ecmascript_extension.cpp", - "runtime/init_icu.cpp", ] # Should be files deleted??? -- Gitee