• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16SANE_CONFIG_DIR = "/data/service/el1/public/print_service/sane/config"
17SANE_DATA_DIR = "/data/service/el1/public/print_service/sane/data"
18SANE_TMP_DIR = "/data/service/el2/public/print_service/sane/tmp"
19SANE_LOCK_DIR = "/data/service/el1/public/print_service/sane/lock"
20SANE_LIB_DIR = "/data/service/el1/public/print_service/sane/backend"
21SANE_V_MAJOR = 1
22SANE_V_MINOR = 2
23enable_hilog = true
24source_dir = "//third_party/backends"
25target_dir = "${target_gen_dir}/sane"
26
27action("backends_action") {
28  print("backends_action is exec")
29  script = "//third_party/backends/install.py"
30  inputs = [
31    "${source_dir}/patches/modifying_driver_search_path.patch",
32    "${source_dir}/patches/dll.c.patch",
33  ]
34  outputs = [
35    "${target_dir}/include/config.h",
36    "${target_dir}/src/dll.c",
37  ]
38  backends_source_dir = rebase_path("${source_dir}", root_build_dir)
39  args = [
40    "--source-dir",
41    "$backends_source_dir",
42  ]
43}
44
45config("backends_public_config") {
46  include_dirs = [
47    "./include",
48    "./include/sane",
49  ]
50}
51
52config("backends_private_config") {
53  cflags = [
54    "-Wall",
55    "-g",
56    "-O2",
57    "-fPIC",
58    "-DPIC",
59    "-D_REENTRANT",
60    "-DHAVE_CONFIG_H",
61    "-Wno-format",
62    "-Wno-unused-const-variable",
63    "-Wno-unused-variable",
64    "-Wno-unused-but-set-variable",
65  ]
66
67  if (enable_hilog) {
68    cflags += [ "-DENABLE_HILOG" ]
69  }
70
71  defines = [
72    "PATH_SANE_CONFIG_DIR=$SANE_CONFIG_DIR",
73    "PATH_SANE_DATA_DIR=$SANE_DATA_DIR",
74    "PATH_SANE_LOCK_DIR=$SANE_LOCK_DIR",
75    "PATH_SANE_TMP_DIR=$SANE_TMP_DIR",
76    "V_MAJOR=$SANE_V_MAJOR",
77    "V_MINOR=$SANE_V_MINOR",
78    "LIBDIR=\"$SANE_LIB_DIR\"",
79  ]
80}
81
82#build targets in /lib
83ohos_source_set("lib") {
84  sources = [ "./lib/md5.c" ]
85
86  public_configs = [ ":backends_public_config" ]
87
88  configs = [ ":backends_private_config" ]
89
90  subsystem_name = "thirdparty"
91  part_name = "backends"
92}
93
94#build targets in /sanei
95sanei_names = [
96  "sanei_directio",
97  "sanei_ab306",
98  "sanei_constrain_value",
99  "sanei_init_debug",
100  "sanei_net",
101  "sanei_wire",
102  "sanei_codec_ascii",
103  "sanei_codec_bin",
104  "sanei_scsi",
105  "sanei_config",
106  "sanei_config2",
107  "sanei_pio",
108  "sanei_pa4s2",
109  "sanei_auth",
110  "sanei_thread",
111  "sanei_pv8630",
112  "sanei_pp",
113  "sanei_lm983x",
114  "sanei_access",
115  "sanei_tcp",
116  "sanei_udp",
117  "sanei_magic",
118  "sanei_ir",
119  "sanei_jpeg",
120]
121
122ohos_source_set("sanei_usb") {
123  sources = [ "./sanei/sanei_usb.c" ]
124
125  external_deps = [ "libusb:libusb" ]
126
127  if (enable_hilog) {
128    external_deps += [ "hilog:libhilog" ]
129  }
130
131  public_configs = [ ":backends_public_config" ]
132
133  configs = [ ":backends_private_config" ]
134
135  subsystem_name = "thirdparty"
136  part_name = "backends"
137}
138
139foreach(name, sanei_names) {
140  ohos_source_set("$name") {
141    sources = [ "./sanei/$name.c" ]
142
143    if (enable_hilog) {
144      external_deps = [ "hilog:libhilog" ]
145    }
146
147    public_configs = [ ":backends_public_config" ]
148
149    configs = [ ":backends_private_config" ]
150
151    subsystem_name = "thirdparty"
152    part_name = "backends"
153  }
154}
155
156ohos_static_library("sanei") {
157  sources = []
158
159  foreach(name, sanei_names) {
160    sources += [ "./sanei/$name.c" ]
161  }
162
163  if (enable_hilog) {
164    external_deps = [ "hilog:libhilog" ]
165  }
166
167  public_configs = [ ":backends_public_config" ]
168
169  configs = [ ":backends_private_config" ]
170
171  subsystem_name = "thirdparty"
172  part_name = "backends"
173}
174
175#build targets in /backend
176ohos_source_set("sane_strstatus") {
177  sources = [ "./backend/sane_strstatus.c" ]
178
179  public_configs = [ ":backends_public_config" ]
180
181  configs = [ ":backends_private_config" ]
182
183  subsystem_name = "thirdparty"
184  part_name = "backends"
185}
186
187ohos_shared_library("sane") {
188  sources = [
189    "./backend/dll.c",
190    "./backend/stubs.c",
191  ]
192
193  public_configs = [ ":backends_public_config" ]
194
195  configs = [ ":backends_private_config" ]
196
197  defines = [ "BACKEND_NAME=dll" ]
198
199  deps = [
200    ":backends_action",
201    ":lib",
202    ":sane_strstatus",
203    ":sanei_config",
204    ":sanei_constrain_value",
205    ":sanei_init_debug",
206    ":sanei_usb",
207  ]
208
209  if (enable_hilog) {
210    external_deps = [ "hilog:libhilog" ]
211  }
212
213  ldflags = [ "-ldl" ]
214
215  subsystem_name = "thirdparty"
216  part_name = "backends"
217}
218
219#the target group
220group("third_sane") {
221  deps = [ ":sane" ]
222}
223