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