1# Copyright (c) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15
16# Execute the script and extract jsoncpp
17action("jsoncpp_install_action") {
18  script = "//third_party/jsoncpp/install.py"
19  outputs = [
20    "${target_gen_dir}/jsoncpp-1.9.5/src/lib_json/json_reader.cpp",
21    "${target_gen_dir}/jsoncpp-1.9.5/src/lib_json/json_value.cpp",
22    "${target_gen_dir}/jsoncpp-1.9.5/src/lib_json/json_writer.cpp",
23  ]
24
25  inputs = [ "//third_party/jsoncpp/jsoncpp-1.9.5.tar.gz" ]
26
27  args = [
28    "--gen-dir",
29    rebase_path("${target_gen_dir}", root_build_dir),
30    "--source-file",
31    rebase_path("//third_party/jsoncpp"),
32  ]
33}
34
35config("config_static") {
36  cflags = [
37    "-std=c++17",
38    "-Wno-error=implicit-fallthrough",
39    "-Wno-deprecated-declarations",
40  ]
41  visibility = [ ":*" ]
42}
43
44config("jsoncpp_config") {
45  cflags = [
46    "-std=c++17",
47    "-Wno-error=implicit-fallthrough",
48    "-Wno-deprecated-declarations",
49  ]
50}
51
52config("flag_config") {
53  cflags_cc = [ "-fexceptions" ]
54}
55
56config("jsoncpp_public_config") {
57  include_dirs = [ get_label_info(":jsoncpp_install_action", "target_gen_dir") +
58                   "/jsoncpp-1.9.5/include" ]
59}
60
61ohos_shared_library("jsoncpp") {
62  branch_protector_ret = "pac_ret"
63  visibility = [ "*" ]
64  sources = get_target_outputs(":jsoncpp_install_action")
65  use_exceptions = true
66  configs = [ ":jsoncpp_config" ]
67  public_configs = [ ":jsoncpp_public_config" ]
68  innerapi_tags = [
69    "chipsetsdk",
70    "platformsdk",
71  ]
72  install_images = [
73    "system",
74    "updater",
75  ]
76  deps = [ ":jsoncpp_install_action" ]
77  part_name = "jsoncpp"
78  subsystem_name = "thirdparty"
79}
80
81ohos_static_library("jsoncpp_static") {
82  branch_protector_ret = "pac_ret"
83  sources = get_target_outputs(":jsoncpp_install_action")
84  use_exceptions = true
85  configs = [
86    ":config_static",
87    ":flag_config",
88  ]
89  public_configs = [ ":jsoncpp_public_config" ]
90  cflags_cc = [
91    "-Wall",
92    "-Werror",
93    "-Wno-implicit-fallthrough",
94  ]
95  deps = [ ":jsoncpp_install_action" ]
96  part_name = "jsoncpp"
97  subsystem_name = "thirdparty"
98}
99