From ae939d40ab4ffa136a359a062a0b498190028e25 Mon Sep 17 00:00:00 2001 From: swx1119547 Date: Wed, 9 Feb 2022 17:02:39 +0800 Subject: [PATCH 1/2] extract source_set Signed-off-by: swx1119547 --- BUILD.gn | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 3bcff22..68b4ef4 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,7 +11,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/ohos.gni") +if (!defined(ark_flag)){ + import("//build/ohos.gni") +}else{ + import("//build/ark.gni") +} config("jsoncpp_config") { cflags = [ @@ -22,22 +26,41 @@ config("jsoncpp_config") { } config("jsoncpp_public_config") { + cflags_cc = [ "-fexceptions", "-fPIC",] include_dirs = [ "//third_party/jsoncpp/include/" ] } -ohos_shared_library("jsoncpp") { - visibility = [ "*" ] +source_set("jsoncpp_static"){ 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_config" ] + public_configs = [ ":jsoncpp_config" ] + include_dirs = [ "//third_party/jsoncpp/include/json/", "//third_party/jsoncpp/include/", ] - public_configs = [ ":jsoncpp_public_config" ] - subsystem_name = "distributeddatamgr" + public_configs += [ ":jsoncpp_public_config" ] +} + +group("jsoncpp_target") { + # Config to apply to all targets that depend on this one. + public_configs = [ ":jsoncpp_public_config" ] +} + +if (!defined(ark_flag)){ + ohos_shared_library("jsoncpp") { + visibility = [ "*" ] + deps = [ ":jsoncpp_static" ] + public_deps = [ ":jsoncpp_target" ] + subsystem_name = "distributeddatamgr" + } +}else { + ark_shared_library("jsoncpp") { + visibility = [ "*" ] + deps = [ ":jsoncpp_static" ] + public_deps = [ ":jsoncpp_target" ] + } } -- Gitee From 31b80e148a137f2da0a7342e68e9bc2eeab10b4d Mon Sep 17 00:00:00 2001 From: swx1119547 Date: Thu, 10 Feb 2022 13:53:41 +0800 Subject: [PATCH 2/2] extract source_set Signed-off-by: swx1119547 --- BUILD.gn | 60 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 68b4ef4..6d7eba8 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ if (!defined(ark_flag)){ import("//build/ark.gni") } + config("jsoncpp_config") { cflags = [ "-std=c++17", @@ -26,38 +27,49 @@ config("jsoncpp_config") { } config("jsoncpp_public_config") { - cflags_cc = [ "-fexceptions", "-fPIC",] + if (defined(ark_flag)){ + cflags_cc = [ "-fexceptions", "-fPIC",] + } include_dirs = [ "//third_party/jsoncpp/include/" ] } -source_set("jsoncpp_static"){ - 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", - ] - public_configs = [ ":jsoncpp_config" ] - - include_dirs = [ - "//third_party/jsoncpp/include/json/", - "//third_party/jsoncpp/include/", - ] - public_configs += [ ":jsoncpp_public_config" ] -} - -group("jsoncpp_target") { - # Config to apply to all targets that depend on this one. - public_configs = [ ":jsoncpp_public_config" ] -} - if (!defined(ark_flag)){ ohos_shared_library("jsoncpp") { visibility = [ "*" ] - deps = [ ":jsoncpp_static" ] - public_deps = [ ":jsoncpp_target" ] + 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_config" ] + include_dirs = [ + "//third_party/jsoncpp/include/json/", + "//third_party/jsoncpp/include/", + ] + public_configs = [ ":jsoncpp_public_config" ] subsystem_name = "distributeddatamgr" } -}else { +}else{ + source_set("jsoncpp_static"){ + 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", + ] + public_configs = [ ":jsoncpp_config" ] + + include_dirs = [ + "//third_party/jsoncpp/include/json/", + "//third_party/jsoncpp/include/", + ] + public_configs += [ ":jsoncpp_public_config" ] + } + + group("jsoncpp_target") { + # Config to apply to all targets that depend on this one. + public_configs = [ ":jsoncpp_public_config" ] + } ark_shared_library("jsoncpp") { visibility = [ "*" ] deps = [ ":jsoncpp_static" ] -- Gitee