Sublime Forum

Conditional build and linting

#1

Assume the following changes to a package’s build file:

-    "windows":
-    {
-        "cmd":
-        [
-            "${packages}/my_package/bin/linter/windows/linter",
-            "-p",
-            "${file}"
-        ]
-    }
+    "variants":
+    [
+        {
+            "name": "linter (x32)",
+            "cmd":
+            [
+                "${packages}\\my_package\\bin\\linter\\windows32\\linter.exe",
+                "-p",
+                "${file}"
+            ]
+        },
+        {
+            "name": "linter (x64)",
+            "cmd":
+            [
+                "${packages}\\my_package\\bin\\linter\\windows64\\linter.exe",
+                "-p",
+                "${file}"
+            ]
+        },
+        {
+            "name": "linter (Windows XP)",
+            "cmd":
+            [
+                "${packages}\\my_package\\bin\\linter\\windows\\linter.exe",
+                "-p",
+                "${file}"
+            ]
+        }
+    ]

Could someone provide me with (a reference to) a working example of using a build "target" for "windows" instead with args as above?

As a follow up question, how do I replace cmd: 'linter' in a SublimeLinter-contrib-linter settings file for ST3 to get the same effect? Reading http://sublimelinter.readthedocs.io/en/latest/linter_methods.html would I use which?

0 Likes

#2

2.) works via:

import sublime
from SublimeLinter.lint import Linter, util
import os


class Xxxlinter(Linter):

    syntax = ('xxx')
    cmd = 'xxx'
    # ...

    @classmethod
    def which(cls, cmd):
        if sublime.platform() == 'linux':
            return os.path.join(sublime.packages_path(), 'XXX', 'bin', 'xxxlint', 'linux', 'xxxint')
        elif sublime.platform() == 'osx':
            return os.path.join(sublime.packages_path(), 'XXX', 'bin', 'xxxlint', 'osx', 'xxxlint')
        else:
            return os.path.join(sublime.packages_path(), 'XXX', 'bin', 'xxxlint', 'windows', 'xxxlint.exe')
0 Likes