1# Copyright (c) 2023 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") 15import("//third_party/cups/cups.gni") 16 17CUPS_CODE_DIR = "//third_party/cups/cups-2.4.0" 18CUPS_FILTERS_CODE_DIR = "//third_party/cups-filters" 19SUBSYSTEM_NAME = "thirdparty" 20PART_NAME = "cups-filters" 21PDFIUM_ENABLE = false 22 23group("third_party_cupsfilters") { 24 deps = [ 25 ":cupsfilters", 26 ":cupsfilters.convs", 27 ":cupsfilters.types", 28 ":imagetoraster", 29 ] 30 if (PDFIUM_ENABLE) { 31 deps += [ 32 ":cupsfilters_poppler.convs", 33 ":pdftoraster", 34 ] 35 } 36} 37 38config("cups_filters_config") { 39 include_dirs = [ 40 ".", 41 "$CUPS_CODE_DIR", 42 "$CUPS_FILTERS_CODE_DIR/cupsfilters/", 43 "$CUPS_FILTERS_CODE_DIR/filter/", 44 ] 45 if (PDFIUM_ENABLE) { 46 include_dirs += [ 47 "//third_party/pdfium", 48 "//third_party/pdfium/public", 49 "//third_party/pdfium/third_party/lcms/include", 50 ] 51 } 52 53 defines = cups_defines 54 55 cflags = [ 56 "-D_PPD_DEPRECATED=", 57 "-Wextra", 58 "-Wall", 59 "-Wno-unused-parameter", 60 "-Wno-unused-function", 61 "-Wno-unused-variable", 62 "-Wno-unused-value", 63 "-Wno-sign-compare", 64 "-Wno-missing-field-initializers", 65 66 "-Wno-strlcpy-strlcat-size", 67 "-Wtautological-pointer-compare", 68 "-Wimplicit-fallthrough", 69 "-Wno-implicit-function-declaration", 70 "-w", 71 "-D_FORTIFY_SOURCE=2", 72 "-fstack-protector-all", 73 ] 74} 75 76action("cupsfilters_action") { 77 script = "//third_party/cups-filters/install.py" 78 outputs = [ "${target_gen_dir}/cupsfilters.convs" ] 79 inputs = [ "//third_party/cups/cups-2.4.0-source.tar.gz" ] 80 gen_path = rebase_path("${target_gen_dir}", root_build_dir) 81 source_path = rebase_path("//third_party/cups-filters", root_build_dir) 82 args = [ 83 "--gen-dir", 84 "$gen_path", 85 "--source-dir", 86 "$source_path", 87 ] 88} 89 90ohos_shared_library("cupsfilters") { 91 sources = [ 92 "$CUPS_FILTERS_CODE_DIR/cupsfilters/attr.c", 93 "$CUPS_FILTERS_CODE_DIR/cupsfilters/check.c", 94 "$CUPS_FILTERS_CODE_DIR/cupsfilters/cmyk.c", 95 "$CUPS_FILTERS_CODE_DIR/cupsfilters/colord.c", 96 "$CUPS_FILTERS_CODE_DIR/cupsfilters/colormanager.c", 97 "$CUPS_FILTERS_CODE_DIR/cupsfilters/dither.c", 98 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-bmp.c", 99 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-colorspace.c", 100 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-gif.c", 101 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-jpeg.c", 102 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-photocd.c", 103 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-pix.c", 104 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-png.c", 105 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-pnm.c", 106 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-sgi.c", 107 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-sgilib.c", 108 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-sun.c", 109 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-tiff.c", 110 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image-zoom.c", 111 "$CUPS_FILTERS_CODE_DIR/cupsfilters/image.c", 112 "$CUPS_FILTERS_CODE_DIR/cupsfilters/ipp.c", 113 "$CUPS_FILTERS_CODE_DIR/cupsfilters/lut.c", 114 "$CUPS_FILTERS_CODE_DIR/cupsfilters/pack.c", 115 "$CUPS_FILTERS_CODE_DIR/cupsfilters/pdftoippprinter.c", 116 "$CUPS_FILTERS_CODE_DIR/cupsfilters/ppdgenerator.c", 117 "$CUPS_FILTERS_CODE_DIR/cupsfilters/raster.c", 118 "$CUPS_FILTERS_CODE_DIR/cupsfilters/rgb.c", 119 "$CUPS_FILTERS_CODE_DIR/cupsfilters/srgb.c", 120 ] 121 122 public_configs = [ ":cups_filters_config" ] 123 124 deps = [ 125 "//third_party/cups:cups", 126 "//third_party/libjpeg-turbo:turbojpeg", 127 "//third_party/libpng:libpng", 128 "//third_party/zlib:libz", 129 ] 130 131 install_enable = true 132 subsystem_name = "$SUBSYSTEM_NAME" 133 part_name = "$PART_NAME" 134} 135 136ohos_executable("imagetoraster") { 137 sources = [ 138 "$CUPS_FILTERS_CODE_DIR/filter/common.c", 139 "$CUPS_FILTERS_CODE_DIR/filter/imagetoraster.c", 140 ] 141 142 deps = [ 143 "//third_party/cups:cups", 144 "//third_party/cups-filters:cupsfilters", 145 ] 146 147 public_configs = [ ":cups_filters_config" ] 148 149 module_install_dir = "$cups_serverbin_dir/filter" 150 install_enable = true 151 subsystem_name = "$SUBSYSTEM_NAME" 152 part_name = "$PART_NAME" 153} 154 155ohos_executable("pdftoraster") { 156 sources = [ "$CUPS_FILTERS_CODE_DIR/filter/pdftoraster.cxx" ] 157 158 deps = [ 159 ":cupsfilters_action", 160 "//third_party/cups:cups", 161 "//third_party/cups-filters:cupsfilters", 162 ] 163 if (PDFIUM_ENABLE) { 164 deps += [ "//third_party/pdfium:pdfium_shared" ] 165 } 166 167 public_configs = [ ":cups_filters_config" ] 168 169 module_install_dir = "$cups_serverbin_dir/filter" 170 install_enable = true 171 subsystem_name = "$SUBSYSTEM_NAME" 172 part_name = "$PART_NAME" 173} 174 175ohos_prebuilt_etc("cupsfilters_poppler.convs") { 176 source = "mime/cupsfilters-poppler.convs" 177 deps = [ ":cupsfilters_action" ] 178 relative_install_dir = "cups/share/mime" 179 subsystem_name = "$SUBSYSTEM_NAME" 180 part_name = "$PART_NAME" 181} 182 183ohos_prebuilt_etc("cupsfilters.convs") { 184 source = "${target_gen_dir}/cupsfilters.convs" 185 deps = [ ":cupsfilters_action" ] 186 relative_install_dir = "cups/share/mime" 187 subsystem_name = "$SUBSYSTEM_NAME" 188 part_name = "$PART_NAME" 189} 190 191ohos_prebuilt_etc("cupsfilters.types") { 192 source = "mime/cupsfilters.types" 193 deps = [ ":cupsfilters_action" ] 194 relative_install_dir = "cups/share/mime" 195 subsystem_name = "$SUBSYSTEM_NAME" 196 part_name = "$PART_NAME" 197} 198