From dd17b03c487b64212fae77a406075fc83514a369 Mon Sep 17 00:00:00 2001
From: Rutger Helling <address@hidden>
Date: Fri, 8 Dec 2017 15:56:34 +0100
Subject: [PATCH] gnu: vulkan: Add glslang.

* gnu/packages/vulkan.scm (glslang): New variable.
---
 gnu/packages/vulkan.scm | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/vulkan.scm b/gnu/packages/vulkan.scm
index 248dc206c..03562e45d 100644
--- a/gnu/packages/vulkan.scm
+++ b/gnu/packages/vulkan.scm
@@ -23,6 +23,7 @@
   #:use-module (guix git-download)
   #:use-module (guix build-system cmake)
   #:use-module (gnu packages)
+  #:use-module (gnu packages bison)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python))
 
@@ -90,3 +91,41 @@ files from the SPIR-V Registry.")
    (description "The SPIR-V Tools project provides an API and commands for
 processing SPIR-V modules.")
    (license license:asl2.0)))
+
+(define-public glslang
+  ;; Version 3.0 is too old for vulkan-icd-loader. Use a recent git commit
+  ;; until the next stable version.
+  (let ((commit "471bfed0621162a7513fc24a51e8a1ccc2e640ff")
+        (revision "1"))
+    (package
+     (name "glslang")
+     (version (string-append "0.0-" revision "." (string-take commit 9)))
+     (source
+      (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/KhronosGroup/glslang")
+             (commit commit)))
+       (sha256
+        (base32
+         "0m2vljmrqppp80ghbbwfnayqw2canxlcjhgy6jw9xjdssln0d3pd"))
+       (file-name (string-append name "-" version "-checkout"))))
+     (build-system cmake-build-system)
+     (arguments
+      `(#:tests? #f ;; No tests
+        ;; glslang tries to set CMAKE_INSTALL_PREFIX manually. Remove the
+        ;; offending line.
+        #:phases (modify-phases %standard-phases
+                   (add-after 'patch-source-shebangs 'fix-cmakelists
+                     (lambda _
+                       (substitute* "CMakeLists.txt"
+                                    (("set.*CMAKE_INSTALL_PREFIX.*") "")))))))
+   (inputs `(("bison" ,bison)))
+   (native-inputs `(("pkg-config" ,pkg-config)))
+   (home-page "https://github.com/KhronosGroup/glslang")
+   (synopsis "OpenGL and OpenGL ES shader front end and validator")
+   (description "glslang is a OpenGL and OpenGL ES shader front end and
+validator.")
+   ;; Modified BSD license. See "copyright" section of
+   ;; https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
+   (license license:bsd-3))))
-- 
2.15.1