1# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. 2 3import("//build/ohos.gni") 4 5action("libpng_action") { 6 script = "//third_party/libpng/install.py" 7 outputs = [ 8 "${target_gen_dir}/libpng-1.6.44/png.c", 9 "${target_gen_dir}/libpng-1.6.44/pngerror.c", 10 "${target_gen_dir}/libpng-1.6.44/pngget.c", 11 "${target_gen_dir}/libpng-1.6.44/pngmem.c", 12 "${target_gen_dir}/libpng-1.6.44/pngpread.c", 13 "${target_gen_dir}/libpng-1.6.44/pngread.c", 14 "${target_gen_dir}/libpng-1.6.44/pngrio.c", 15 "${target_gen_dir}/libpng-1.6.44/pngrtran.c", 16 "${target_gen_dir}/libpng-1.6.44/pngrutil.c", 17 "${target_gen_dir}/libpng-1.6.44/pngset.c", 18 "${target_gen_dir}/libpng-1.6.44/pngtrans.c", 19 "${target_gen_dir}/libpng-1.6.44/pngwio.c", 20 "${target_gen_dir}/libpng-1.6.44/pngwrite.c", 21 "${target_gen_dir}/libpng-1.6.44/pngwtran.c", 22 "${target_gen_dir}/libpng-1.6.44/pngwutil.c", 23 "${target_gen_dir}/libpng-1.6.44/arm/arm_init.c", 24 "${target_gen_dir}/libpng-1.6.44/arm/filter_neon_intrinsics.c", 25 "${target_gen_dir}/libpng-1.6.44/arm/palette_neon_intrinsics.c", 26 ] 27 28 inputs = [ "//third_party/libpng/libpng-1.6.44.tar.gz" ] 29 30 inputs += [ 31 "backport-libpng-1.6.37-enable-valid.patch", 32 "CVE-2018-14048.patch", 33 "CVE-2019-6129.patch", 34 "huawei_libpng_CMakeList.patch", 35 "libpng-fix-arm-neon.patch", 36 "libpng-multilib.patch", 37 "libpng_optimize.patch", 38 ] 39 40 libpng_path = rebase_path("${target_gen_dir}", root_build_dir) 41 libpng_source_path = rebase_path("//third_party/libpng", root_build_dir) 42 args = [ 43 "--gen-dir", 44 "$libpng_path", 45 "--source-dir", 46 "$libpng_source_path", 47 ] 48} 49 50if (defined(ohos_lite)) { 51 import("//build/lite/config/component/lite_component.gni") 52 53 config("libpng_config") { 54 include_dirs = [ "${target_gen_dir}/libpng-1.6.44/" ] 55 } 56 57 libpng_source = get_target_outputs(":libpng_action") 58 59 lite_library("libpng") { 60 if (ohos_kernel_type == "liteos_m") { 61 target_type = "static_library" 62 deps = [ "//build/lite/config/component/zlib:zlib_static" ] 63 } else { 64 target_type = "shared_library" 65 deps = [ "//build/lite/config/component/zlib:zlib_shared" ] 66 } 67 deps += [ ":libpng_action" ] 68 if (defined(board_toolchain_type) && board_toolchain_type == "iccarm") { 69 cflags = [ 70 "--diag_suppress", 71 "Pa082,Pa084", 72 ] 73 cflags_cc = cflags 74 } 75 sources = libpng_source 76 public_configs = [ ":libpng_config" ] 77 } 78} else { 79 import("//build/ohos.gni") 80 81 config("libpng_config") { 82 include_dirs = [ "${target_gen_dir}/libpng-1.6.44/" ] 83 } 84 85 config("libpng_wno_config") { 86 cflags = [ "-Wno-implicit-fallthrough" ] 87 if (target_platform == "pc") { 88 if (is_ohos && is_clang && 89 (target_cpu == "arm" || target_cpu == "arm64")) { 90 ldflags = [ "-Wl,-Bsymbolic" ] 91 defines = [ "PNG_ARM_NEON" ] 92 } 93 } 94 } 95 96 config("libpng_wno_config_static") { 97 if (target_platform == "pc") { 98 if (is_ohos && is_clang && 99 (target_cpu == "arm" || target_cpu == "arm64")) { 100 cflags = [ "-fvisibility=hidden" ] 101 } 102 } 103 } 104 105 ohos_source_set("png_static") { 106 sources = get_target_outputs(":libpng_action") 107 include_dirs = [ "${target_gen_dir}/libpng-1.6.44/" ] 108 external_deps = [ "zlib:libz" ] 109 deps = [ ":libpng_action" ] 110 public_configs = [ ":libpng_config" ] 111 part_name = "libpng" 112 subsystem_name = "thirdparty" 113 } 114 115 ohos_shared_library("libpng") { 116 sources = get_target_outputs(":libpng_action") 117 include_dirs = [ "${target_gen_dir}/libpng-1.6.44/" ] 118 deps = [ ":libpng_action" ] 119 if (is_arkui_x) { 120 deps += [ "//third_party/zlib:libz" ] 121 } else { 122 external_deps = [ "zlib:libz" ] 123 } 124 125 public_configs = [ ":libpng_config" ] 126 configs = [ ":libpng_wno_config" ] 127 innerapi_tags = [ 128 "platformsdk", 129 "chipsetsdk", 130 ] 131 subsystem_name = "thirdparty" 132 install_images = [ 133 "system", 134 "updater", 135 ] 136 part_name = "libpng" 137 output_name = "libpng" 138 install_enable = true 139 } 140 141 ohos_static_library("libpng_static") { 142 sources = get_target_outputs(":libpng_action") 143 144 include_dirs = [ "${target_gen_dir}/libpng-1.6.44/" ] 145 deps = [ ":libpng_action" ] 146 if (is_arkui_x) { 147 deps += [ "//third_party/zlib:libz" ] 148 } else { 149 external_deps = [ "zlib:libz" ] 150 } 151 public_configs = [ ":libpng_config" ] 152 configs = [ ":libpng_wno_config" ] 153 configs += [ ":libpng_wno_config_static" ] 154 part_name = "libpng" 155 subsystem_name = "thirdparty" 156 } 157} 158