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 "-Wno-unused-function", 66 ] 67 68 if (enable_hilog) { 69 cflags += [ "-DENABLE_HILOG" ] 70 } 71 72 defines = [ 73 "PATH_SANE_CONFIG_DIR=$SANE_CONFIG_DIR", 74 "PATH_SANE_DATA_DIR=$SANE_DATA_DIR", 75 "PATH_SANE_LOCK_DIR=$SANE_LOCK_DIR", 76 "PATH_SANE_TMP_DIR=$SANE_TMP_DIR", 77 "V_MAJOR=$SANE_V_MAJOR", 78 "V_MINOR=$SANE_V_MINOR", 79 "LIBDIR=\"$SANE_LIB_DIR\"", 80 ] 81} 82 83#build targets in /lib 84ohos_source_set("lib") { 85 sources = [ "./lib/md5.c" ] 86 87 public_configs = [ ":backends_public_config" ] 88 89 configs = [ ":backends_private_config" ] 90 91 subsystem_name = "thirdparty" 92 part_name = "backends" 93} 94 95#build targets in /sanei 96sanei_names = [ 97 "sanei_directio", 98 "sanei_ab306", 99 "sanei_constrain_value", 100 "sanei_init_debug", 101 "sanei_net", 102 "sanei_wire", 103 "sanei_codec_ascii", 104 "sanei_codec_bin", 105 "sanei_scsi", 106 "sanei_config", 107 "sanei_config2", 108 "sanei_pio", 109 "sanei_pa4s2", 110 "sanei_auth", 111 "sanei_thread", 112 "sanei_pv8630", 113 "sanei_pp", 114 "sanei_lm983x", 115 "sanei_access", 116 "sanei_tcp", 117 "sanei_udp", 118 "sanei_magic", 119 "sanei_ir", 120 "sanei_jpeg", 121] 122 123ohos_source_set("sanei_usb") { 124 sources = [ "./sanei/sanei_usb.c" ] 125 126 external_deps = [ "libusb:libusb" ] 127 128 if (enable_hilog) { 129 external_deps += [ "hilog:libhilog" ] 130 } 131 132 public_configs = [ ":backends_public_config" ] 133 134 configs = [ ":backends_private_config" ] 135 136 subsystem_name = "thirdparty" 137 part_name = "backends" 138} 139 140foreach(name, sanei_names) { 141 ohos_source_set("$name") { 142 sources = [ "./sanei/$name.c" ] 143 144 if (enable_hilog) { 145 external_deps = [ "hilog:libhilog" ] 146 } 147 148 public_configs = [ ":backends_public_config" ] 149 150 configs = [ ":backends_private_config" ] 151 152 subsystem_name = "thirdparty" 153 part_name = "backends" 154 } 155} 156 157ohos_static_library("sanei") { 158 sources = [] 159 160 foreach(name, sanei_names) { 161 sources += [ "./sanei/$name.c" ] 162 } 163 164 if (enable_hilog) { 165 external_deps = [ "hilog:libhilog" ] 166 } 167 168 public_configs = [ ":backends_public_config" ] 169 170 configs = [ ":backends_private_config" ] 171 172 subsystem_name = "thirdparty" 173 part_name = "backends" 174} 175 176#build targets in /backend 177ohos_source_set("sane_strstatus") { 178 sources = [ "./backend/sane_strstatus.c" ] 179 180 public_configs = [ ":backends_public_config" ] 181 182 configs = [ ":backends_private_config" ] 183 184 subsystem_name = "thirdparty" 185 part_name = "backends" 186} 187 188ohos_shared_library("sane") { 189 sources = [ 190 "./backend/dll.c", 191 "./backend/stubs.c", 192 ] 193 194 public_configs = [ ":backends_public_config" ] 195 196 configs = [ ":backends_private_config" ] 197 198 defines = [ "BACKEND_NAME=dll" ] 199 200 deps = [ 201 ":backends_action", 202 ":lib", 203 ":sane_strstatus", 204 ":sanei_config", 205 ":sanei_constrain_value", 206 ":sanei_init_debug", 207 ":sanei_usb", 208 ] 209 210 if (enable_hilog) { 211 external_deps = [ "hilog:libhilog" ] 212 } 213 214 ldflags = [ "-ldl" ] 215 216 subsystem_name = "thirdparty" 217 part_name = "backends" 218} 219 220#the target group 221group("third_sane") { 222 deps = [ ":sane" ] 223} 224