Support building Vulkan on Linux.
authorbsalomon <bsalomon@google.com>
Fri, 4 Mar 2016 21:38:26 +0000 (13:38 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 4 Mar 2016 21:38:27 +0000 (13:38 -0800)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1761163003

Review URL: https://codereview.chromium.org/1761163003

gyp/gpu.gyp
gyp/shaderc.gyp

index 7b644bb474b4bfafd7aa50855f493bd62440f6d8..c6202555db4a76b85928445b4c5ea7c843192397 100644 (file)
           },
         }],
         [ 'skia_vulkan', {
-          'variables': {
-            'conditions': [
-              [ 'skia_os == "win"', {
+          'conditions': [
+            [ 'skia_os == "win"', {
+             'variables': {
+                'vulkan_lib_name': '-lvulkan-1',
                 'vulkan_sdk_path' : '<!(echo %VK_SDK_PATH%)',
-              }, {
-                'vulkan_sdk_path' : '<!(echo $VK_SDK_PATH)',
-              }],
-            ],
-          },
+              },
+              'include_dirs': [
+                '<(vulkan_sdk_path)/Include',
+              ],
+              'direct_dependent_settings': {
+                'include_dirs': [
+                  '<(vulkan_sdk_path)/Include',
+                ],
+              },
+              'link_settings': {
+                'library_dirs': [ '<(vulkan_sdk_path)/Bin', ],
+              },
+            }, {
+              'variables': {
+                'vulkan_lib_name': '-lvulkan',
+              },
+            }],
+          ],
           'dependencies': [
             'shaderc.gyp:shaderc_combined',
           ],
           'include_dirs': [
-            '../third_party/', # To include files under third_party/vulkan
             '../third_party/externals/shaderc2/libshaderc/include',
-            '<(vulkan_sdk_path)/Include',
           ],
           'direct_dependent_settings': {
             'include_dirs': [
-              '../third_party/', # To include files under third_party/vulkan
               '../third_party/externals/shaderc2/libshaderc/include',
-              '<(vulkan_sdk_path)/Include',
             ],
           },
           'link_settings': {
-            'library_dirs': [ '<(vulkan_sdk_path)/Bin', ],
-            'libraries': [ '-lvulkan-1', ],
+            'libraries': [ '<(vulkan_lib_name)', ],
           },
         }, {
           'sources!': [
index 2b1b8f1debc0f76b18eb8a4bd552e10b25a305d1..26af80a4d1e19f5f0613dc214bd7c21c368f19ad 100644 (file)
@@ -6,25 +6,49 @@
 # Builds shaderc for the Vulkan backend
 {
   'variables': {
+    'variables': { # This is the dreaded nested variables dict so that we can
+                   # have dependent variables
+      'conditions': [
+        [ 'CONFIGURATION_NAME == "Release_Developer"', {
+          'shaderc_build_configuration' : 'Release',
+        }, {
+          'shaderc_build_configuration' : '<(CONFIGURATION_NAME)',
+        }],
+        [ 'skia_os == "win"', {
+          'shaderc_lib_name' : 'shaderc_combined.lib',
+        }, {
+          'shaderc_lib_name' : 'libshaderc_combined.a',
+        }],
+        [ 'skia_os == "win"', {
+          'conditions': [
+            [ 'MSVS_VERSION == "2013"', {
+              'shaderc_project_type' : 'MSVS2013',
+            }],
+            [ 'MSVS_VERSION == "2015"', {
+              'shaderc_project_type' : 'MSVS2015',
+            }],
+          ],
+        }, {
+          'shaderc_project_type' : 'ninja',
+        }],
+      ],
+      'shaderc_out_path': '../out/<(CONFIGURATION_NAME)/shaderc_out_<(skia_arch_type)',
+    },
+    # Export out of nested variables.
+    'shaderc_build_configuration': '<(shaderc_build_configuration)',
+    'shaderc_project_type': '<(shaderc_project_type)',
+    'shaderc_out_path': '<(shaderc_out_path)',
+    'shaderc_lib_name': '<(shaderc_lib_name)',
+    
+    # On Windows the library winds up inside a 'Debug' or 'Release' dir, not so
+    # with ninja project build.
     'conditions': [
-      [ 'CONFIGURATION_NAME == "Release_Developer"', {
-        'shaderc_build_type' : 'Release',
-      }, {
-        'shaderc_build_type' : '<(CONFIGURATION_NAME)',
-      }],
       [ 'skia_os == "win"', {
-        'shaderc_lib_name' : 'shaderc_combined.lib',
+        'shaderc_lib_full_path': '<(shaderc_out_path)/libshaderc/<(shaderc_build_configuration)/<(shaderc_lib_name)',
       }, {
-        'shaderc_lib_name' : 'libshaderc_combined.a',
-      }],
-      [ 'MSVS_VERSION == "2013"', {
-        'shaderc_project_type' : 'MSVS2013',
-      }],
-      [ 'MSVS_VERSION == "2015"', {
-        'shaderc_project_type' : 'MSVS2015',
+        'shaderc_lib_full_path': '<(shaderc_out_path)/libshaderc/<(shaderc_lib_name)',
       }],
-    ],
-    'skia_build_type' : '<(CONFIGURATION_NAME)',
+    ]
   },  
   'targets': [  
     {
             '../tools/build_shaderc.py',
           ],
           'outputs': [
-             '../out/<(skia_build_type)/shaderc_out_<(skia_arch_type)/libshaderc/<(shaderc_build_type)/<(shaderc_lib_name)',
+             '<(shaderc_lib_full_path)',
           ],
-          'action': ['python', '../tools/build_shaderc.py', '-s', '../third_party/externals/shaderc2', '-o', '../out/<(skia_build_type)/shaderc_out_<(skia_arch_type)', '-a', '<(skia_arch_type)', '-t', '<(shaderc_build_type)', '-p', '<(shaderc_project_type)'],
+          'action': ['python', '../tools/build_shaderc.py', '-s', '../third_party/externals/shaderc2', '-o', '<(shaderc_out_path)', '-a', '<(skia_arch_type)', '-t', '<(shaderc_build_configuration)', '-p', '<(shaderc_project_type)'],
         },
       ],     
       'copies': [
         {
-          'destination': '../out/<(skia_build_type)',
-          'files': ['../out/<(skia_build_type)/shaderc_out_<(skia_arch_type)/libshaderc/<(shaderc_build_type)/<(shaderc_lib_name)'],
+          'destination': '../out/<(CONFIGURATION_NAME)',
+          'files': ['<(shaderc_lib_full_path)'],
         },
       ],
       'all_dependent_settings': {
         'link_settings': {
           'libraries': [
-            '-lshaderc_combined',
+            '<(shaderc_lib_name)',
           ],
         },
       },