1# Copyright (c) 2022 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 14if (defined(ohos_lite)) { 15 import("//build/lite/config/component/lite_component.gni") 16} else { 17 import("//build/ohos.gni") 18} 19 20jpeg_sources = [ 21 "jcapimin.c", 22 "jcapistd.c", 23 "jccoefct.c", 24 "jccolor.c", 25 "jcdctmgr.c", 26 "jchuff.c", 27 "jcicc.c", 28 "jcinit.c", 29 "jcmainct.c", 30 "jcmarker.c", 31 "jcmaster.c", 32 "jcomapi.c", 33 "jcparam.c", 34 "jcphuff.c", 35 "jcprepct.c", 36 "jcsample.c", 37 "jctrans.c", 38 "jdapimin.c", 39 "jdapistd.c", 40 "jdatadst.c", 41 "jdatasrc.c", 42 "jdcoefct.c", 43 "jdcolor.c", 44 "jddctmgr.c", 45 "jdhuff.c", 46 "jdicc.c", 47 "jdinput.c", 48 "jdmainct.c", 49 "jdmarker.c", 50 "jdmaster.c", 51 "jdmerge.c", 52 "jdphuff.c", 53 "jdpostct.c", 54 "jdsample.c", 55 "jdtrans.c", 56 "jerror.c", 57 "jfdctflt.c", 58 "jfdctfst.c", 59 "jfdctint.c", 60 "jidctflt.c", 61 "jidctfst.c", 62 "jidctint.c", 63 "jidctred.c", 64 "jmemmgr.c", 65 "jmemnobs.c", 66 "jquant1.c", 67 "jquant2.c", 68 "jutils.c", 69] 70 71mkernel = defined(ohos_kernel_type) && ohos_kernel_type == "liteos_m" 72if (mkernel || is_win) { 73 jpeg_sources += [ "jsimd_none.c" ] 74} else if (current_cpu == "arm") { 75 jpeg_sources += [ 76 "simd/arm/jsimd.c", 77 "simd/arm/jsimd_neon.S", 78 ] 79} else if (current_cpu == "arm64") { 80 jpeg_sources += [ 81 "simd/arm64/jsimd.c", 82 "simd/arm64/jsimd_neon.S", 83 ] 84} else { 85 jpeg_sources += [ "jsimd_none.c" ] 86} 87 88define_config = [] 89if (!defined(ohos_lite)) { 90 jpeg_sources += [ 91 # enable arith codec 92 "jaricom.c", 93 "jcarith.c", 94 "jdarith.c", 95 "jdatadst-tj.c", 96 "jdatasrc-tj.c", 97 "rdbmp.c", 98 "rdppm.c", 99 "transupp.c", 100 101 # enable turbo 102 "turbojpeg.c", 103 "wrbmp.c", 104 "wrppm.c", 105 ] 106 define_config += [ 107 "C_ARITH_CODING_SUPPORTED=1", #Support arithmetic encoding 108 "D_ARITH_CODING_SUPPORTED=1", #Support arithmetic decoding 109 "BMP_SUPPORTED=1", #Support arithmetic decoding 110 "PPM_SUPPORTED=1", #Support arithmetic decoding 111 ] 112} 113 114config("turbojpeg_config") { 115 include_dirs = [ "//third_party/libjpeg-turbo" ] 116 defines = define_config 117} 118 119if (defined(ohos_lite)) { 120 lite_library("libjpeg") { 121 if (ohos_kernel_type == "liteos_m") { 122 target_type = "static_library" 123 } else { 124 target_type = "shared_library" 125 } 126 sources = jpeg_sources 127 public_configs = [ ":turbojpeg_config" ] 128 if (defined(board_toolchain_type) && board_toolchain_type == "iccarm") { 129 cflags = [ 130 "--diag_suppress", 131 "Pa181,Pe301,Pe546", 132 ] 133 cflags_cc = cflags 134 } 135 } 136} else { 137 ohos_static_library("turbojpeg_static") { 138 sources = jpeg_sources 139 public_configs = [ ":turbojpeg_config" ] 140 } 141 ohos_shared_library("turbojpeg") { 142 sources = jpeg_sources 143 public_configs = [ ":turbojpeg_config" ] 144 } 145} 146