1# Copyright (C) 2022 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.
13import("//base/update/updater/updater_default_cfg.gni")
14import("//build/ohos.gni")
15
16config("diff_config") {
17  cflags_cc = [
18    "-frtti",
19    "-std=c++17",
20  ]
21  if (is_mingw) {
22    cflags_cc += [ "-Wno-inconsistent-dllimport" ]
23  }
24  defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
25}
26
27updater_path = rebase_path("${updater_absolutely_path}", ".")
28ohos_executable("diff") {
29  use_exceptions = true
30  configs = [ ":diff_config" ]
31
32  sources = [
33    "${updater_path}/services/package/pkg_manager/pkg_utils.cpp",
34    "./bzip2/bzip2_adapter.cpp",
35    "./bzip2/lz4_adapter.cpp",
36    "./bzip2/zip_adapter.cpp",
37    "./diff/blocks_diff.cpp",
38    "./diff/image_diff.cpp",
39    "./diff/update_diff.cpp",
40    "./diff_main.cpp",
41    "./diffpatch.cpp",
42    "./patch/blocks_patch.cpp",
43    "./patch/image_patch.cpp",
44    "./patch/update_patch.cpp",
45  ]
46
47  include_dirs = [
48    ".",
49    "${updater_path}/interfaces/kits/include",
50    "${updater_path}/services/common",
51    "${updater_path}/services/include/package",
52    "${updater_path}/services/include/patch",
53    "${updater_path}/services/include",
54    "${updater_path}/utils/include",
55    "${updater_path}/services/diffpatch/bzip2",
56    "${updater_path}/services/diffpatch/diff",
57    "${updater_path}/services/diffpatch/patch",
58    "${updater_path}/services/diffpatch",
59    "${updater_path}/services/package/pkg_manager",
60    "${updater_path}/services/include/log",
61  ]
62
63  deps = [
64    "${updater_path}/services/log:libupdaterlog",
65    "${updater_path}/services/package:libupdaterpackage",
66  ]
67
68  external_deps = [
69    "bounds_checking_function:libsec_static",
70    "bzip2:libbz2",
71    "lz4:liblz4_static",
72    "openssl:libcrypto_static",
73    "zlib:libz",
74  ]
75
76  if (is_mingw) {
77    static_link = false
78    libs = [ "setupapi" ]
79    ldflags = [
80      "-Wl,--whole-archive",
81      "-lpthread",
82      "-Wl,--no-whole-archive",
83    ]
84  }
85
86  if (is_linux) {
87    static_link = false
88
89    ldflags = [
90      "-Wl,--whole-archive",
91      "-lpthread",
92      "-latomic",
93      "-ldl",
94      "-lrt",
95      "-Wl,--no-whole-archive",
96    ]
97  }
98  install_enable = false
99  subsystem_name = "updater"
100  part_name = "updater"
101}
102