opts.gypi -> opts.gni

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4026

Change-Id: Ib687bd7ce87ddbbc60f95e7a30e20575971e5c59
Reviewed-on: https://skia-review.googlesource.com/4026
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/gn/opts.gni b/gn/opts.gni
new file mode 100644
index 0000000..2332de3
--- /dev/null
+++ b/gn/opts.gni
@@ -0,0 +1,61 @@
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Things are easiest for everyone if these source paths are absolute.
+_src = get_path_info("../src", "abspath")
+
+none = [
+  "$_src/opts/SkBitmapProcState_opts_none.cpp",
+  "$_src/opts/SkBlitMask_opts_none.cpp",
+  "$_src/opts/SkBlitRow_opts_none.cpp",
+]
+
+armv7 = [
+  "$_src/opts/SkBitmapProcState_opts_arm.cpp",
+  "$_src/opts/SkBlitMask_opts_arm.cpp",
+  "$_src/opts/SkBlitRow_opts_arm.cpp",
+]
+
+neon = [
+  "$_src/opts/SkBitmapProcState_arm_neon.cpp",
+  "$_src/opts/SkBitmapProcState_matrixProcs_neon.cpp",
+  "$_src/opts/SkBlitMask_opts_arm_neon.cpp",
+  "$_src/opts/SkBlitRow_opts_arm_neon.cpp",
+]
+
+arm64 = [
+  "$_src/opts/SkBitmapProcState_arm_neon.cpp",
+  "$_src/opts/SkBitmapProcState_matrixProcs_neon.cpp",
+  "$_src/opts/SkBitmapProcState_opts_arm.cpp",
+  "$_src/opts/SkBlitMask_opts_arm.cpp",
+  "$_src/opts/SkBlitMask_opts_arm_neon.cpp",
+  "$_src/opts/SkBlitRow_opts_arm.cpp",
+  "$_src/opts/SkBlitRow_opts_arm_neon.cpp",
+]
+
+crc32 = [ "$_src/opts/SkOpts_crc32.cpp" ]
+
+mips_dsp = [
+  "$_src/opts/SkBitmapProcState_opts_mips_dsp.cpp",
+  "$_src/opts/SkBlitMask_opts_none.cpp",
+  "$_src/opts/SkBlitRow_opts_mips_dsp.cpp",
+]
+
+sse2 = [
+  "$_src/opts/SkBitmapFilter_opts_SSE2.cpp",
+  "$_src/opts/SkBitmapProcState_opts_SSE2.cpp",
+  "$_src/opts/SkBlitRow_opts_SSE2.cpp",
+  "$_src/opts/opts_check_x86.cpp",
+]
+
+ssse3 = [
+  "$_src/opts/SkBitmapProcState_opts_SSSE3.cpp",
+  "$_src/opts/SkOpts_ssse3.cpp",
+]
+
+sse41 = [ "$_src/opts/SkOpts_sse41.cpp" ]
+sse42 = [ "$_src/opts/SkOpts_sse42.cpp" ]
+avx = [ "$_src/opts/SkOpts_avx.cpp" ]
+hsw = [ "$_src/opts/SkOpts_hsw.cpp" ]
diff --git a/gn/shared_sources.gni b/gn/shared_sources.gni
index 50367c3..cb81dd2 100644
--- a/gn/shared_sources.gni
+++ b/gn/shared_sources.gni
@@ -3,32 +3,29 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-# This file is used to shared GN source lists between the standalone Skia
-# and Chrome skia build. All paths produced by this header must be
-# source-absolute since it will be included in different contexts in each
-# checkout.
-_path_to_include = get_path_info("../include", "abspath")
-_path_to_src = get_path_info("../src", "abspath")
-
-# Opts.
-#
-# Unlike the other variables here, this is a "scope" consisting of many
-# sub-lists.
-skia_opts = exec_script("gypi_to_gn.py",
-                        [
-                          rebase_path("../gyp/opts.gypi"),
-                          "--replace=<(skia_include_path)=$_path_to_include",
-                          "--replace=<(skia_src_path)=$_path_to_src",
-                        ],
-                        "scope",
-                        [ "../gyp/opts.gypi" ])
 import("core.gni")
 import("effects.gni")
 import("gpu.gni")
+import("opts.gni")
 import("pdf.gni")
 import("sksl.gni")
 import("utils.gni")
 
+skia_opts = {
+  none_sources = none
+  armv7_sources = armv7
+  neon_sources = neon
+  arm64_sources = arm64
+  crc32_sources = crc32
+  mips_dsp_sources = mips_dsp
+  sse2_sources = sse2
+  ssse3_sources = ssse3
+  sse41_sources = sse41
+  sse42_sources = sse42
+  avx_sources = avx
+  hsw_sources = hsw
+}
+
 # Skia Chromium defines. These flags will be defined in chromium If these
 # become 'permanent', they should be moved into Chrome's skia build file.
 skia_for_chromium_defines = [ "SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS" ]
diff --git a/gyp/opts.gyp b/gyp/opts.gyp
index f872083..6dc6f85 100644
--- a/gyp/opts.gyp
+++ b/gyp/opts.gyp
@@ -4,10 +4,9 @@
 # found in the LICENSE file.
 # Gyp file for building opts target.
 {
-  # Source lists live in opts.gypi.  This makes it easier to maintain our Chrome GYP/GN setup.
   # (To be honest, I'm not sure why we need to include common.gypi.  I thought it was automatic.)
   'variables': {
-    'includes': [ 'common.gypi', 'opts.gypi' ],
+    'includes': [ 'common.gypi' ],
   },
 
   # Generally we shove things into one 'opts' target conditioned on platform.
@@ -35,15 +34,15 @@
         [ '"x86" in skia_arch_type and skia_os != "ios"', {
           'cflags': [ '-msse2' ],
           'dependencies': [ 'opts_ssse3', 'opts_sse41', 'opts_sse42', 'opts_avx', 'opts_hsw' ],
-          'sources': [ '<@(sse2_sources)' ],
+          'sources': [ '<!@(python read_gni.py ../gn/opts.gni sse2)' ],
         }],
 
         [ 'skia_arch_type == "mips"', {
           'conditions': [
             [ '(mips_arch_variant == "mips32r2") and (mips_dsp == 1 or mips_dsp == 2)', {
-                'sources': [ '<@(mips_dsp_sources)' ],
+                'sources': [ '<!@(python read_gni.py ../gn/opts.gni mips_dsp)' ],
             },{
-                'sources': [ '<@(none_sources)' ],
+                'sources': [ '<!@(python read_gni.py ../gn/opts.gni none)' ],
             }],
           ]
         }],
@@ -53,7 +52,7 @@
             or (skia_os == "android" \
                 and skia_arch_type not in ["x86", "x86_64", "arm", "mips", \
                                            "arm64"])', {
-          'sources': [ '<@(none_sources)' ],
+          'sources': [ '<!@(python read_gni.py ../gn/opts.gni none)' ],
         }],
 
         [ 'skia_arch_type == "arm" and arm_version >= 7', {
@@ -61,7 +60,7 @@
           # ARM), the compiler doesn't like that.
           'cflags!': [ '-fno-omit-frame-pointer', '-mapcs-frame', '-mapcs' ],
           'cflags':  [ '-fomit-frame-pointer' ],
-          'sources': [ '<@(armv7_sources)' ],
+          'sources': [ '<!@(python read_gni.py ../gn/opts.gni armv7)' ],
           'conditions': [
             [ 'arm_neon == 1', {
               'dependencies': [ 'opts_neon' ]
@@ -70,7 +69,7 @@
         }],
 
         [ 'skia_arch_type == "arm64"', {
-          'sources': [ '<@(arm64_sources)' ],
+          'sources': [ '<!@(python read_gni.py ../gn/opts.gni arm64)' ],
           'dependencies': [ 'opts_crc32' ]
         }],
 
@@ -94,7 +93,7 @@
           '../src/core',
           '../src/utils',
       ],
-      'sources': [ '<@(crc32_sources)' ],
+      'sources': [ '<!@(python read_gni.py ../gn/opts.gni crc32)' ],
       'conditions': [
         [ 'not skia_android_framework', { 'cflags': [ '-march=armv8-a+crc' ] }],
       ],
@@ -110,7 +109,7 @@
           '../src/core',
           '../src/utils',
       ],
-      'sources': [ '<@(ssse3_sources)' ],
+      'sources': [ '<!@(python read_gni.py ../gn/opts.gni ssse3)' ],
       'conditions': [
         [ 'skia_os == "win"', { 'defines' : [ 'SK_CPU_SSE_LEVEL=31' ] }],
         [ 'not skia_android_framework', { 'cflags': [ '-mssse3' ] }],
@@ -127,7 +126,7 @@
           '../src/core',
           '../src/utils',
       ],
-      'sources': [ '<@(sse41_sources)' ],
+      'sources': [ '<!@(python read_gni.py ../gn/opts.gni sse41)' ],
       'xcode_settings': { 'GCC_ENABLE_SSE41_EXTENSIONS': 'YES' },
       'conditions': [
         [ 'skia_os == "win"', { 'defines' : [ 'SK_CPU_SSE_LEVEL=41' ] }],
@@ -145,7 +144,7 @@
           '../src/core',
           '../src/utils',
       ],
-      'sources': [ '<@(sse42_sources)' ],
+      'sources': [ '<!@(python read_gni.py ../gn/opts.gni sse42)' ],
       'xcode_settings': { 'GCC_ENABLE_SSE42_EXTENSIONS': 'YES' },
       'conditions': [
         [ 'skia_os == "win"', { 'defines' : [ 'SK_CPU_SSE_LEVEL=42' ] }],
@@ -163,7 +162,7 @@
           '../src/core',
           '../src/utils',
       ],
-      'sources': [ '<@(avx_sources)' ],
+      'sources': [ '<!@(python read_gni.py ../gn/opts.gni avx)' ],
       'msvs_settings': { 'VCCLCompilerTool': { 'EnableEnhancedInstructionSet': '3' } },
       'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS': [ '-mavx' ] },
       'conditions': [
@@ -181,7 +180,7 @@
           '../src/core',
           '../src/utils',
       ],
-      'sources': [ '<@(hsw_sources)' ],
+      'sources': [ '<!@(python read_gni.py ../gn/opts.gni hsw)' ],
       'msvs_settings': { 'VCCLCompilerTool': { 'EnableEnhancedInstructionSet': '5' } },
       'xcode_settings': {
           'OTHER_CPLUSPLUSFLAGS': [ '-mavx2', '-mbmi', '-mbmi2', '-mf16c', '-mfma' ]
@@ -207,7 +206,7 @@
         '../src/opts',
         '../src/utils',
       ],
-      'sources': [ '<@(neon_sources)' ],
+      'sources': [ '<!@(python read_gni.py ../gn/opts.gni neon)' ],
       'cflags!': [
         '-fno-omit-frame-pointer',
         '-mfpu=vfp',  # remove them all, just in case.
diff --git a/gyp/opts.gypi b/gyp/opts.gypi
deleted file mode 100644
index 5f07101..0000000
--- a/gyp/opts.gypi
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright 2015 Google Inc.
-#
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
-        'none_sources': [
-            '<(skia_src_path)/opts/SkBitmapProcState_opts_none.cpp',
-            '<(skia_src_path)/opts/SkBlitMask_opts_none.cpp',
-            '<(skia_src_path)/opts/SkBlitRow_opts_none.cpp',
-        ],
-
-        'armv7_sources': [
-            '<(skia_src_path)/opts/SkBitmapProcState_opts_arm.cpp',
-            '<(skia_src_path)/opts/SkBlitMask_opts_arm.cpp',
-            '<(skia_src_path)/opts/SkBlitRow_opts_arm.cpp',
-        ],
-        'neon_sources': [
-            '<(skia_src_path)/opts/SkBitmapProcState_arm_neon.cpp',
-            '<(skia_src_path)/opts/SkBitmapProcState_matrixProcs_neon.cpp',
-            '<(skia_src_path)/opts/SkBlitMask_opts_arm_neon.cpp',
-            '<(skia_src_path)/opts/SkBlitRow_opts_arm_neon.cpp',
-        ],
-        'arm64_sources': [
-            '<(skia_src_path)/opts/SkBitmapProcState_arm_neon.cpp',
-            '<(skia_src_path)/opts/SkBitmapProcState_matrixProcs_neon.cpp',
-            '<(skia_src_path)/opts/SkBitmapProcState_opts_arm.cpp',
-            '<(skia_src_path)/opts/SkBlitMask_opts_arm.cpp',
-            '<(skia_src_path)/opts/SkBlitMask_opts_arm_neon.cpp',
-            '<(skia_src_path)/opts/SkBlitRow_opts_arm.cpp',
-            '<(skia_src_path)/opts/SkBlitRow_opts_arm_neon.cpp',
-        ],
-        'crc32_sources': [
-            '<(skia_src_path)/opts/SkOpts_crc32.cpp',
-        ],
-
-        'mips_dsp_sources': [
-            '<(skia_src_path)/opts/SkBitmapProcState_opts_mips_dsp.cpp',
-            '<(skia_src_path)/opts/SkBlitMask_opts_none.cpp',
-            '<(skia_src_path)/opts/SkBlitRow_opts_mips_dsp.cpp',
-        ],
-
-        'sse2_sources': [
-            '<(skia_src_path)/opts/SkBitmapFilter_opts_SSE2.cpp',
-            '<(skia_src_path)/opts/SkBitmapProcState_opts_SSE2.cpp',
-            '<(skia_src_path)/opts/SkBlitRow_opts_SSE2.cpp',
-            '<(skia_src_path)/opts/opts_check_x86.cpp',
-        ],
-        'ssse3_sources': [
-            '<(skia_src_path)/opts/SkBitmapProcState_opts_SSSE3.cpp',
-            '<(skia_src_path)/opts/SkOpts_ssse3.cpp',
-        ],
-        'sse41_sources': [
-            '<(skia_src_path)/opts/SkOpts_sse41.cpp',
-        ],
-        'sse42_sources': [
-            '<(skia_src_path)/opts/SkOpts_sse42.cpp',
-        ],
-        'avx_sources': [
-            '<(skia_src_path)/opts/SkOpts_avx.cpp',
-        ],
-        'hsw_sources': [
-            '<(skia_src_path)/opts/SkOpts_hsw.cpp',
-        ],
-}