File: FnGlslangLinter.php

package info (click to toggle)
arcanist-clang-format-linter 0.git20161021-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 112 kB
  • sloc: php: 438; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

/**
 * Uses Glslang to verify GLSL shaders.
 */
final class FnGlslangLinter extends ArcanistExternalLinter {

  public function getInfoName() {
    return 'GLSL Validator';
  }

  public function getInfoURI() {
    return 'https://github.com/KhronosGroup/glslang';
  }

  public function getInfoDescription() {
    return pht('GLSL validator from Khronos Group');
  }

  public function getLinterName() {
    return 'GLSLANG';
  }

  public function getLinterConfigurationName() {
    return 'fn-glslang';
  }

  public function getDefaultBinary() {
    return 'glslangValidator';
  }

  public function getInstallInstructions() {
    return pht('Install CMake and Bison. Then see: '.
               'https://github.com/KhronosGroup/glslang');
  }

  protected function parseLinterOutput($path, $err, $stdout, $stderr) {
    $lines = phutil_split_lines($stdout);
    $messages = array();

    foreach ($lines as $line) {
      $matches = null;
      if (!preg_match('/^(\w+): \d+:(\d+): (.*)$/', $line, $matches)) {
        continue;
      }

      $message = id(new ArcanistLintMessage())
        ->setPath($path)
        ->setLine($matches[2])
        ->setCode($this->getLinterName())
        ->setDescription($matches[3]);

      if ($matches[1] === 'ERROR') {
        $message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR)
        ->setName('Syntax error');
      } else {
        $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING)
        ->setName('Glslang Warning');
      }
      $messages[] = $message;
    }

    return $messages;
  }
}