Add GN build for pixman for use elsewhere in Fuchsia

Change-Id: Ia50bee2ccd3fe010d2120269bd2990211ab6e19e
diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 0000000..ffe8896
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,125 @@
+# Copyright 2017 The Fuchsia Authors. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#    * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#    * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#    * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This configuration is for consumers of the pixman library
+config("pixman_config") {
+  include_dirs = [
+    "pixman",
+    "$target_gen_dir/pixman-version",
+  ]
+}
+
+# This configuration is for building the pixman code.
+config("pixman_private_config") {
+  visibility = [ ":*" ]
+  cflags = [
+    "-Wno-expansion-to-defined",
+    "-Wno-missing-field-initializers",
+    "-Wno-shift-negative-value",
+    "-Wno-sign-compare",
+    "-Wno-tautological-constant-out-of-range-compare",
+    "-Wno-unused-const-variable",
+    "-Wno-unused-local-typedef",
+  ]
+}
+
+# The autoconf build generates these headers after following a series of steps that will produce the
+# same thing every time in Fuchsia, so we just check the results in and copy them to the out
+# directory.
+copy("pixman_config_h") {
+  visibility = [ ":*" ]
+  sources = [
+    "config.h.fuchsia",
+  ]
+
+  # The GN source expansion {{source_name_part}} strips the '.fuchsia' extension.
+  outputs = [
+    "$target_gen_dir/{{source_name_part}}",
+  ]
+}
+
+# This header needs to be exposed to users of the library, but we don't want to put our config.h on
+# the include path downstream to avoid colliding with other headers of this name, so we put it in
+# its own directory.
+copy("pixman_version_h") {
+  visibility = [ ":*" ]
+  sources = [
+    "pixman-version.h.fuchsia",
+  ]
+
+  outputs = [
+    # The GN source expansion {{source_name_part}} strips the '.fuchsia' extension.
+    "$target_gen_dir/pixman-version/{{source_name_part}}",
+  ]
+}
+
+source_set("pixman") {
+  sources = [
+    "pixman/pixman-access-accessors.c",
+    "pixman/pixman-access.c",
+    "pixman/pixman-arm.c",
+    "pixman/pixman-bits-image.c",
+    "pixman/pixman-combine-float.c",
+    "pixman/pixman-combine32.c",
+    "pixman/pixman-conical-gradient.c",
+    "pixman/pixman-edge-accessors.c",
+    "pixman/pixman-edge.c",
+    "pixman/pixman-fast-path.c",
+    "pixman/pixman-filter.c",
+    "pixman/pixman-general.c",
+    "pixman/pixman-glyph.c",
+    "pixman/pixman-gradient-walker.c",
+    "pixman/pixman-image.c",
+    "pixman/pixman-implementation.c",
+    "pixman/pixman-linear-gradient.c",
+    "pixman/pixman-matrix.c",
+    "pixman/pixman-mips.c",
+    "pixman/pixman-noop.c",
+    "pixman/pixman-ppc.c",
+    "pixman/pixman-radial-gradient.c",
+    "pixman/pixman-region16.c",
+    "pixman/pixman-region32.c",
+    "pixman/pixman-solid-fill.c",
+    "pixman/pixman-timer.c",
+    "pixman/pixman-trap.c",
+    "pixman/pixman-utils.c",
+    "pixman/pixman-x86.c",
+    "pixman/pixman.c",
+  ]
+
+  public_configs = [ ":pixman_config" ]
+  configs += [ ":pixman_private_config" ]
+
+  defines = [ "HAVE_CONFIG_H" ]
+  include_dirs = [ target_gen_dir ]
+
+  deps = [
+    ":pixman_config_h",
+    ":pixman_version_h",
+  ]
+}
diff --git a/config.h.fuchsia b/config.h.fuchsia
new file mode 100644
index 0000000..89e6b7e
--- /dev/null
+++ b/config.h.fuchsia
@@ -0,0 +1,183 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* Whether we have alarm() */
+#define HAVE_ALARM 1
+
+/* Whether the compiler supports __builtin_clz */
+#define HAVE_BUILTIN_CLZ /**/
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Whether we have feenableexcept() */
+/* #undef HAVE_FEENABLEEXCEPT */
+
+/* Define to 1 if we have <fenv.h> */
+#define HAVE_FENV_H 1
+
+/* Whether the tool chain supports __float128 */
+/* #undef HAVE_FLOAT128 */
+
+/* Whether the compiler supports GCC vector extensions */
+/* #undef HAVE_GCC_VECTOR_EXTENSIONS */
+
+/* Define to 1 if you have the `getisax' function. */
+/* #undef HAVE_GETISAX */
+
+/* Whether we have getpagesize() */
+#define HAVE_GETPAGESIZE 1
+
+/* Whether we have gettimeofday() */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `pixman-1' library (-lpixman-1). */
+/* #undef HAVE_LIBPIXMAN_1 */
+
+/* Whether we have libpng */
+#define HAVE_LIBPNG 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Whether we have mmap() */
+#define HAVE_MMAP 1
+
+/* Whether we have mprotect() */
+#define HAVE_MPROTECT 1
+
+/* Whether we have posix_memalign() */
+#define HAVE_POSIX_MEMALIGN 1
+
+/* Whether pthreads is supported */
+#define HAVE_PTHREADS /**/
+
+/* Whether we have sigaction() */
+#define HAVE_SIGACTION 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if we have <sys/mman.h> */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "pixman"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "pixman@lists.freedesktop.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "pixman"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "pixman 0.32.6"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "pixman"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "0.32.6"
+
+/* enable TIMER_BEGIN/TIMER_END macros */
+/* #undef PIXMAN_TIMERS */
+
+/* The size of `long', as computed by sizeof. */
+#define SIZEOF_LONG 8
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* The compiler supported TLS storage class */
+#define TLS __thread
+
+/* Whether the tool chain supports __attribute__((constructor)) */
+#define TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR /**/
+
+/* use ARM IWMMXT compiler intrinsics */
+/* #undef USE_ARM_IWMMXT */
+
+/* use ARM NEON assembly optimizations */
+/* #undef USE_ARM_NEON */
+
+/* use ARM SIMD assembly optimizations */
+/* #undef USE_ARM_SIMD */
+
+/* use GNU-style inline assembler */
+#define USE_GCC_INLINE_ASM 1
+
+/* use Loongson Multimedia Instructions */
+/* #undef USE_LOONGSON_MMI */
+
+/* use MIPS DSPr2 assembly optimizations */
+/* #undef USE_MIPS_DSPR2 */
+
+/* use OpenMP in the test suite */
+/* #undef USE_OPENMP */
+
+/* use SSE2 compiler intrinsics */
+#define USE_SSE2 1
+
+/* use SSSE3 compiler intrinsics */
+#define USE_SSSE3 1
+
+/* use VMX compiler intrinsics */
+/* #undef USE_VMX */
+
+/* use x86 MMX compiler intrinsics */
+#define USE_X86_MMX 1
+
+/* Version number of package */
+#define VERSION "0.32.6"
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* #  undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to sqrt if you do not have the `sqrtf' function. */
+/* #undef sqrtf */
diff --git a/pixman-version.h.fuchsia b/pixman-version.h.fuchsia
new file mode 100644
index 0000000..c671e98
--- /dev/null
+++ b/pixman-version.h.fuchsia
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#ifndef PIXMAN_VERSION_H__
+#define PIXMAN_VERSION_H__
+
+#ifndef PIXMAN_H__
+#  error pixman-version.h should only be included by pixman.h
+#endif
+
+#define PIXMAN_VERSION_MAJOR 0
+#define PIXMAN_VERSION_MINOR 35
+#define PIXMAN_VERSION_MICRO 1
+
+#define PIXMAN_VERSION_STRING "0.35.1"
+
+#define PIXMAN_VERSION_ENCODE(major, minor, micro) (	\
+	  ((major) * 10000)				\
+	+ ((minor) *   100)				\
+	+ ((micro) *     1))
+
+#define PIXMAN_VERSION PIXMAN_VERSION_ENCODE(	\
+	PIXMAN_VERSION_MAJOR,			\
+	PIXMAN_VERSION_MINOR,			\
+	PIXMAN_VERSION_MICRO)
+
+#endif /* PIXMAN_VERSION_H__ */