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