From f856c9e0b0e146e00b5f8aa181fa351297cc1912 Mon Sep 17 00:00:00 2001 From: Rokashevich Svetlana Date: Tue, 12 Aug 2025 17:52:52 +0800 Subject: [PATCH] [GN] Add ability to use prebuilt targets Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICSTZC Signed-off-by: Rokashevich Svetlana Signed-off-by: ivagin Change-Id: Ic2a3c2b64ee3350fb6398eb17f87b220681bb1a2 --- ets2panda/BUILD.gn | 5 +- ets2panda/aot/BUILD.gn | 3 +- ets2panda/declgen_ets2ts/BUILD.gn | 3 +- ets2panda/driver/dependency_analyzer/BUILD.gn | 3 +- ets2panda/ets2abc_template.gni | 57 +++++++++++++++++++ ets2panda/lsp/BUILD.gn | 3 +- 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 ets2panda/ets2abc_template.gni diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index 18f112daff..26cfe696d5 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -18,6 +18,7 @@ if ((defined(ark_standalone_build) && ark_standalone_build) || import( "//build/config/components/runtime_core/static_core/ark_common_config.gni") } +import("//arkcompiler/ets_frontend/ets2panda/ets2abc_template.gni") if (ark_standalone_build) { import("$build_root/ark.gni") @@ -1192,7 +1193,7 @@ libes2panda_public_configs += [ ":libes2panda_config", ] -ohos_shared_library("libes2panda") { +ark_frontend_shared_library("libes2panda") { deps = [ ":libes2panda_frontend_static" ] output_extension = "so" part_name = "ets_frontend" @@ -1248,7 +1249,7 @@ ohos_source_set("libes2panda_frontend_static") { subsystem_name = "arkcompiler" } -ohos_shared_library("libes2panda_public") { +ark_frontend_shared_library("libes2panda_public") { configs = [ ":libes2panda_config" ] deps = [ ":libes2panda_public_frontend_static" ] if (is_mingw || is_win) { diff --git a/ets2panda/aot/BUILD.gn b/ets2panda/aot/BUILD.gn index a861d7d1a4..4c2c4b08c2 100644 --- a/ets2panda/aot/BUILD.gn +++ b/ets2panda/aot/BUILD.gn @@ -18,6 +18,7 @@ if ((defined(ark_standalone_build) && ark_standalone_build) || import( "//build/config/components/runtime_core/static_core/ark_common_config.gni") } +import("//arkcompiler/ets_frontend/ets2panda/ets2abc_template.gni") if (ark_standalone_build) { import("$build_root/ark.gni") @@ -25,7 +26,7 @@ if (ark_standalone_build) { import("//build/ohos.gni") } -ohos_executable("ets2panda") { +ark_frontend_executable("ets2panda") { sources = [ "main.cpp" ] include_dirs = [ diff --git a/ets2panda/declgen_ets2ts/BUILD.gn b/ets2panda/declgen_ets2ts/BUILD.gn index 6fdca2dbfb..457387e636 100644 --- a/ets2panda/declgen_ets2ts/BUILD.gn +++ b/ets2panda/declgen_ets2ts/BUILD.gn @@ -19,8 +19,9 @@ if ((defined(ark_standalone_build) && ark_standalone_build) || import( "//build/config/components/runtime_core/static_core/ark_common_config.gni") } +import("//arkcompiler/ets_frontend/ets2panda/ets2abc_template.gni") -ohos_executable("declgen_ets2ts") { +ark_frontend_executable("declgen_ets2ts") { sources = [ "isolatedDeclgenChecker.cpp", "declgenEts2Ts.cpp", diff --git a/ets2panda/driver/dependency_analyzer/BUILD.gn b/ets2panda/driver/dependency_analyzer/BUILD.gn index 0dedd66e58..d98ae3f6e9 100644 --- a/ets2panda/driver/dependency_analyzer/BUILD.gn +++ b/ets2panda/driver/dependency_analyzer/BUILD.gn @@ -19,8 +19,9 @@ if ((defined(ark_standalone_build) && ark_standalone_build) || import( "//build/config/components/runtime_core/static_core/ark_common_config.gni") } +import("//arkcompiler/ets_frontend/ets2panda/ets2abc_template.gni") -ohos_executable("dependency_analyzer") { +ark_frontend_executable("dependency_analyzer") { sources = [ "dep_analyzer.cpp", "main.cpp", diff --git a/ets2panda/ets2abc_template.gni b/ets2panda/ets2abc_template.gni new file mode 100644 index 0000000000..de3f2a37b9 --- /dev/null +++ b/ets2panda/ets2abc_template.gni @@ -0,0 +1,57 @@ +# Copyright (c) 2025 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. + +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} + +declare_args() { + if (!defined(ark_frontend_rebuild)) { + ark_frontend_rebuild = false + } +} + +template("ark_frontend_shared_library") { + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + ark_shared_library(target_name) { + forward_variables_from(invoker, "*") + force_rebuild = false + if (ark_frontend_rebuild) { + force_rebuild = true + } + } + } else { + ohos_shared_library(target_name) { + forward_variables_from(invoker, "*") + } + } +} + +template("ark_frontend_executable") { + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + ark_executable(target_name) { + forward_variables_from(invoker, "*") + force_rebuild = false + if (ark_frontend_rebuild) { + force_rebuild = true + } + } + } else { + ohos_executable(target_name) { + forward_variables_from(invoker, "*") + } + } +} diff --git a/ets2panda/lsp/BUILD.gn b/ets2panda/lsp/BUILD.gn index 5927ee5e68..9eab7115dc 100644 --- a/ets2panda/lsp/BUILD.gn +++ b/ets2panda/lsp/BUILD.gn @@ -18,6 +18,7 @@ if ((defined(ark_standalone_build) && ark_standalone_build) || import( "//build/config/components/runtime_core/static_core/ark_common_config.gni") } +import("//arkcompiler/ets_frontend/ets2panda/ets2abc_template.gni") if (ark_standalone_build) { import("$build_root/ark.gni") @@ -147,7 +148,7 @@ ohos_source_set("libes2panda_lsp_static") { subsystem_name = "arkcompiler" } -ohos_shared_library("libes2panda_lsp") { +ark_frontend_shared_library("libes2panda_lsp") { deps = [ ":libes2panda_lsp_static" ] output_extension = "so" part_name = "ets_frontend" -- Gitee