gyp: add osmesa target to factor out common code

Test this out with `GYP_DEFINES=skia_mesa=1`.

Also uses the `library_dirs` keyword, which is relatively new.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1903233002

Review URL: https://codereview.chromium.org/1903233002
diff --git a/gyp/gputest.gyp b/gyp/gputest.gyp
index 2e90518..d1067e5 100644
--- a/gyp/gputest.gyp
+++ b/gyp/gputest.gyp
@@ -32,23 +32,7 @@
         '<!@(python find.py ../tools/gpu "*")'
       ],
       'conditions': [
-        [ 'skia_mesa and skia_os == "linux"', {
-          'link_settings': {
-            'libraries': [
-              '-lOSMesa',
-            ],
-          },
-        }],
-        [ 'skia_mesa and skia_os == "mac"', {
-          'link_settings': {
-            'libraries': [
-              '/opt/X11/lib/libOSMesa.dylib',
-            ],
-          },
-          'include_dirs': [
-             '/opt/X11/include/',
-          ],
-        }],
+        [ 'skia_mesa', { 'dependencies': [ 'osmesa' ] } ],
         [ 'skia_angle', {
           'dependencies': [
             'angle.gyp:*',
@@ -121,5 +105,18 @@
         }],
       ],
     },
+    {
+      'target_name': 'osmesa',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'link_settings': { 'libraries': [ '-lOSMesa', ], },
+        'conditions': [
+          [ 'skia_os == "mac"', {
+            'link_settings': { 'library_dirs' : [ '/opt/X11/lib' ], },
+            'include_dirs': [ '/opt/X11/include', ],
+          }],
+        ],
+      },
+    },
   ],
 }
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index 8af0dfd..cd92233 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -351,7 +351,7 @@
         '../tools/picture_utils.cpp',
         '../tools/picture_utils.h',
       ],
-	  'include_dirs': [
+      'include_dirs': [
           '../src/core/',
       ],
       'dependencies': [
@@ -608,18 +608,9 @@
             'dependencies': [
               'skia_lib.gyp:skia_lib',
               'pdf.gyp:pdf',
+              'gputest.gyp:osmesa',
             ],
             'defines': [ 'FIDDLE_BUILD_TEST' ],
-            'conditions': [
-              [ 'skia_os == "mac"',
-                {
-                  'link_settings': { 'libraries': [ '/opt/X11/lib/libOSMesa.dylib', ], },
-                  'include_dirs': [ '/opt/X11/include/', ],
-                }, {
-                  'link_settings': { 'libraries': [ '-lOSMesa' ], },
-                }
-              ],
-            ],
           },
         ],
       },