1# Copyright 2016 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6declare_args() {
7  skia_use_system_libpng = is_official_build
8}
9
10import("../third_party.gni")
11
12if (skia_use_system_libpng) {
13  system("libpng") {
14    libs = [ "png" ]
15  }
16} else {
17  third_party("libpng") {
18    public_include_dirs = [
19      ".",
20      "../externals/libpng",
21    ]
22
23    defines = [ "PNG_SET_OPTION_SUPPORTED" ]
24    deps = [ "//third_party/zlib" ]
25    sources = [
26      "../externals/libpng/png.c",
27      "../externals/libpng/pngerror.c",
28      "../externals/libpng/pngget.c",
29      "../externals/libpng/pngmem.c",
30      "../externals/libpng/pngpread.c",
31      "../externals/libpng/pngread.c",
32      "../externals/libpng/pngrio.c",
33      "../externals/libpng/pngrtran.c",
34      "../externals/libpng/pngrutil.c",
35      "../externals/libpng/pngset.c",
36      "../externals/libpng/pngtrans.c",
37      "../externals/libpng/pngwio.c",
38      "../externals/libpng/pngwrite.c",
39      "../externals/libpng/pngwtran.c",
40      "../externals/libpng/pngwutil.c",
41    ]
42
43    if (current_cpu == "arm" || current_cpu == "arm64") {
44      sources += [
45        "../externals/libpng/arm/arm_init.c",
46        "../externals/libpng/arm/filter_neon_intrinsics.c",
47        "../externals/libpng/arm/palette_neon_intrinsics.c",
48      ]
49    }
50
51    if (current_cpu == "x86" || current_cpu == "x64") {
52      defines += [ "PNG_INTEL_SSE" ]
53      sources += [
54        "../externals/libpng/intel/filter_sse2_intrinsics.c",
55        "../externals/libpng/intel/intel_init.c",
56      ]
57    }
58  }
59}
60