From a658f33eb01620d0b5ba193b5a6fdaa6a012ae00 Mon Sep 17 00:00:00 2001 From: jiangyong Date: Mon, 14 Feb 2022 17:06:12 +0800 Subject: [PATCH] extract source_set Signed-off-by: jiangyong --- ts2panda/ts2abc/BUILD.gn | 59 ++++++++++++++++++++++++++------------ ts2panda/ts2abc_config.gni | 40 +++++++++++++++++--------- 2 files changed, 67 insertions(+), 32 deletions(-) diff --git a/ts2panda/ts2abc/BUILD.gn b/ts2panda/ts2abc/BUILD.gn index 7e9b058c91..83d7500511 100755 --- a/ts2panda/ts2abc/BUILD.gn +++ b/ts2panda/ts2abc/BUILD.gn @@ -11,8 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//ark/runtime_core/ark_config.gni") -import("//build/ohos.gni") +if (!defined(ark_flag)) { + import("//ark/runtime_core/ark_config.gni") + import("//build/ohos.gni") +} else { + import("//build/ark.gni") + import("//runtime_core/ark_config.gni") +} jsoncpp_root = "//third_party/jsoncpp" @@ -46,13 +51,13 @@ config("ts2abc_config") { } } -ohos_executable("ts2abc") { +source_set("ts2abc_static") { sources = [ "main.cpp", "ts2abc.cpp", ] - configs = [ ":ts2abc_config" ] + public_configs = [ ":ts2abc_config" ] deps = [ sdk_libc_secshared_dep ] @@ -85,30 +90,48 @@ ohos_executable("ts2abc") { ] } } +} - if (is_linux) { - if (build_public_version) { - ldflags = [ "-static-libstdc++" ] - } else { - libs = [ libcpp_static_lib ] - } - } - - output_name = "js2abc" - install_enable = true - subsystem_name = "ark" +config("flag_config") { + cflags_cc = [ "-fexceptions" ] } -ohos_static_library("jsoncpp_static") { +source_set("jsoncpp_set") { sources = [ "//third_party/jsoncpp/src/lib_json/json_reader.cpp", "//third_party/jsoncpp/src/lib_json/json_value.cpp", "//third_party/jsoncpp/src/lib_json/json_writer.cpp", ] - use_exceptions = true - configs = [ "$jsoncpp_root:jsoncpp_config" ] + public_configs = [ "$jsoncpp_root:jsoncpp_config" ] include_dirs = [ "$jsoncpp_root/include", "$jsoncpp_root/include/json/", ] } + +if (!defined(ark_flag)) { + ohos_executable("ts2abc") { + deps = [ ":ts2abc_static" ] + + if (is_linux) { + if (build_public_version) { + ldflags = [ "-static-libstdc++" ] + } else { + libs = [ libcpp_static_lib ] + } + } + + output_name = "js2abc" + install_enable = true + subsystem_name = "ark" + } + + ohos_static_library("jsoncpp_static") { + deps = [ ":jsoncpp_set" ] + use_exceptions = true + } +} else { + ark_static_library("jsoncpp_static") { + deps = [ ":jsoncpp_set" ] + } +} diff --git a/ts2panda/ts2abc_config.gni b/ts2panda/ts2abc_config.gni index 9a1db65616..6a7a0a4426 100755 --- a/ts2panda/ts2abc_config.gni +++ b/ts2panda/ts2abc_config.gni @@ -11,15 +11,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/ohos.gni") -import("//build/test.gni") +if (!defined(ark_flag)) { + import("//build/ohos.gni") + ts2abc_root = "//ark/ts2abc/ts2panda" +} else { + import("//build/ark.gni") + ts2abc_root = "//ts2abc/ts2panda" +} declare_args() { buildtool_linux = "//build/toolchain/linux:clang_x64" buildtool_mac = "//build/toolchain/mac:clang_x64" buildtool_win = "//build/toolchain/mingw:mingw_x86_64" - ts2abc_root = "//ark/ts2abc/ts2panda" nodejs_dir = "" node_path = "" node_modules = "" @@ -36,17 +40,25 @@ if (build_public_version) { node_modules = "//prebuilts/ace-toolkit/ace-loader/panda/node_modules" } -if (host_toolchain == buildtool_mac) { - ts2abc_build_deps = [ "$ts2abc_root:ts2abc_build_mac($buildtool_mac)" ] - ts2abc_build_path = - get_label_info("//ark/ts2abc/ts2panda:ts2abc_build_mac($buildtool_mac)", - "root_out_dir") + "/obj/ark/ts2abc/ts2panda/build-mac" - node_path = "${nodejs_dir}/node-v12.18.4-darwin-x64/bin/" -} else if (host_toolchain == buildtool_win) { - ts2abc_build_deps = [ "$ts2abc_root:ts2abc_build_win($buildtool_win)" ] - ts2abc_build_path = - get_label_info("//ark/ts2abc/ts2panda:ts2abc_build_win($buildtool_win)", - "root_out_dir") + "/obj/ark/ts2abc/ts2panda/build_win" +if (!defined(ark_flag)) { + if (host_toolchain == buildtool_mac) { + ts2abc_build_deps = [ "$ts2abc_root:ts2abc_build_mac($buildtool_mac)" ] + ts2abc_build_path = + get_label_info("//ark/ts2abc/ts2panda:ts2abc_build_mac($buildtool_mac)", + "root_out_dir") + "/obj/ark/ts2abc/ts2panda/build-mac" + node_path = "${nodejs_dir}/node-v12.18.4-darwin-x64/bin/" + } else if (host_toolchain == buildtool_win) { + ts2abc_build_deps = [ "$ts2abc_root:ts2abc_build_win($buildtool_win)" ] + ts2abc_build_path = + get_label_info("//ark/ts2abc/ts2panda:ts2abc_build_win($buildtool_win)", + "root_out_dir") + "/obj/ark/ts2abc/ts2panda/build_win" + } else { + ts2abc_build_deps = [ "$ts2abc_root:ts2abc_build($buildtool_linux)" ] + ts2abc_build_path = + get_label_info("//ark/ts2abc/ts2panda:ts2abc_build($buildtool_linux)", + "root_out_dir") + "/obj/ark/ts2abc/ts2panda/build" + node_path = "${nodejs_dir}/node-v12.18.4-linux-x64/bin/" + } } else { ts2abc_build_deps = [ "$ts2abc_root:ts2abc_build($buildtool_linux)" ] ts2abc_build_path = -- Gitee