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