1#
2# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15import("//base/startup/init/begetd.gni")
16import("//build/lite/config/component/lite_component.gni")
17import("//build/lite/ndk/ndk.gni")
18
19if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
20  shared_library("token_shared") {
21    include_dirs = [
22      "//base/startup/init/interfaces/innerkits/include",
23      "//base/startup/init/interfaces/innerkits/include/token",
24      "//commonlibrary/utils_lite/include",
25      "//base/startup/init/interfaces/innerkits/token",
26    ]
27    sources = [ "src/token_impl_posix/token.c" ]
28
29    public_deps = [
30      "$ohos_product_adapter_dir/utils/token:haltoken_shared",
31      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
32    ]
33  }
34}
35
36if (ohos_kernel_type == "liteos_m") {
37  static_library("token_static") {
38    sources = [ "src/token_impl_hal/token.c" ]
39
40    include_dirs = [
41      "//base/startup/init/interfaces/innerkits/include",
42      "//base/startup/init/interfaces/innerkits/include/token",
43      "//commonlibrary/utils_lite/include",
44      "//base/startup/init/interfaces/innerkits/token",
45      "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite",
46    ]
47    PRODUCT_HAL_TOKEN_PATH =
48        rebase_path("${ohos_product_adapter_dir}/utils/token")
49    cmd = "if [ -f ${PRODUCT_HAL_TOKEN_PATH}/BUILD.gn ]; then echo true; else echo false; fi"
50    PRODUCT_HAL_TOKEN_EXISTS =
51        exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
52    if (PRODUCT_HAL_TOKEN_EXISTS) {
53      deps += [ "$ohos_product_adapter_dir/utils/token:hal_token_static" ]
54    }
55    deps +=
56        [ "//base/startup/init/interfaces/hals/utils/token:static_hal_token" ]
57  }
58}
59
60lite_component("token") {
61  features = []
62
63  if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
64    features += [ ":token_shared" ]
65  }
66  if (ohos_kernel_type == "liteos_m") {
67    features += [ ":token_static" ]
68  }
69}
70
71ndk_lib("token_notes") {
72  deps = []
73  head_files = []
74  if (ohos_kernel_type != "liteos_m") {
75    lib_extension = ".so"
76  }
77  if (ohos_kernel_type != "liteos_m") {
78    deps += [ "//base/startup/init/interfaces/innerkits/token:token_shared" ]
79  }
80  head_files += [ "//base/startup/init/interfaces/include/token" ]
81}
82