Sublime Forum

Build Systems

#36

Make.sublime-build will only be picked up in the presence of a ‘Makefile’, and not a ‘makefile’. I’ll look at addressing this in the future.

0 Likes

#37

@jps thanks for the latest changes in 3074. really nice.
Now are we going to have a project setting to force the default build system? I kind of hate to have to select it again on every project opening / ST restart.

Thanks

0 Likes

#38

I’m totally lost with the new update :frowning:
all build systems are gone, build command says “no build system”, build with command says “no build system”, creating a new build system doesn’t change anything…how am I supposed to build now? the lessc plugin doesn’t seem to work anymore. do I have to compile my less files now manually from cmd??

0 Likes

#39

@doumer: if you remove the selector from the build system, it’ll appear as a candidate

0 Likes

#40

wohoo, it works, thanks a lot! sorry for my dumbness. :wink:

0 Likes

#41

I just upgraded to the linux 3080 version, and the build stuff changes seems like a terrible regression for me.

I used to be able to do ctrl-B to build and ctrl-shift-b to upload and run the results (it flashes to a uC).

Now with ctrl-shift-b I have to select the build sub-type from a popup, and then when I want to do a regular build again I have to do ctrl-shift-b first to select the build as with ctrl-B it will just try to upload again. (I thought I read that the selected build was not supposed to set the last sub-build type).

This is a real pain and really upsets my workflow.

Is there a workaround?

Thanks

0 Likes

#42

As someone who has been writing custom build systems, this frustrates me greatly… If the build system are going to stay this way it could be great to be able override and define keystrokes for specific build variants in our sublime-build files…

0 Likes

#43

You can do that. Just define a key binding like follows:

{ "keys": "ctrl+shift+b"], "command": "build", "args": {"variant": "Run"} }

I’m not sure if this shows a panel with all build systems that have a Run variant and if it prioritizes the Run variant of the “currently selected” build system, but you can even provide the exact path to a build system to the build command:

{ "keys": "ctrl+shift+b"], "command": "build", "args": {"build_system": "Packages/ALanguage/ALanguage.sublime-build", variant": "Run"} }
0 Likes

#44

Thank you ,

that was the workaround I needed :smile:

0 Likes

#45

As I understand, “make” build system is only shown if there is a makefile in the folder open in sidebar. At least that is how it works for me. Wouldn’t it be more reasonable to check the directory of the current file first? And only if there is no makefile in the directory of current file, then check the sidebar. This would work even if there is nothing in the sidebar. Or is there a way to enable such behavior?

0 Likes

#46

Does anyone know how it works in 2083 right now? Because I am struggling to get it to do the right thing. (p.s. I am not an expert st3 customizer so I am probably just doing it wrong.)

  • My TypeScript.sublime-build file lives in …/Packages/User and contains:
    {
    “cmd”: “/usr/local/bin/tsc”],
    “file_regex”: “^(.+?) \((\d+),(\d+)\): (.+)$”,
    “selector”: “source.TypeScript”
    }

  • When I edit a .ts file the syntax highlighting is for TypeScript and that is also what is displayed in the bottom right corner.

  • When I choose the TypeScript build system by hand it does the right thing, however

  • When I have “automatic” it doesn’t change when I open a .ts file or change to a .ts window.

Any suggestions?

0 Likes

#47

You must use the scope name for the selector argument.
To get it, open a TypeScript file, open the console and type:

>>> view.scope_name(0) 'source.python keyword.control.import.python '
this example show a Python file. You must use the global scope (“source.python” here).

0 Likes

#48

Unfortunately, none of this makes any sense to me. Well, I mean it does, but nothing I’ve tried seems to work properly [1], and this thread is both incomplete and confusing at best. Are there any good, complete, real-world examples I can look at?

Specifically, I need something with mixed filetypes (e.g. .java and .py [2]), but where I don’t have a recognizable build system (e.g. make).

My use case is that I don’t want to have to constantly flip back to the “main” file tab in a project in order to be able to build; I’d like to just hit CTRL+B regardless of which file I’m editing, and get The Right Thing for that project.

I’m on Build 3094, Win7 x64.

P.S. I could probably use make, or even just a specifically-named script, but that’s friction I don’t want. My “projects” are very small, usually only 2-5 files, but I’m frequently switching projects, and creating new ones, and having to include another file in each project is unwanted overhead, particularly when it would only be used for the custom build system (same for custom build commands in a .sublime-project file).

[1] Custom variant with a specific keybind (“No build system”); Use file_patterns keyword (“init() got an unexpected keyword argument ‘file_patterns’”); Custom variant with CTRL+SHIFT+B (trouble with scope/file selector, I guess - simply doesn’t work).

[2] Think jython

0 Likes

#49

I am new to Sublime. I am on a Mac and coming from TextMate because of multiple platform support. I would prefer the selector could have the option to be by file extension instead of a system defined application. I have a lot of special file extensions that I use for different purposes. I am also a mainframe developer so a little different I guess.

Some of my file extensions are JCL, COB, ASM, ACM, ASR, and about 5 or so more. But I also have some common ones such as C and SH

“selector”: “source.plsql.oracle”,

Maybe like:
“selector”: “source.ext=JCL”,

0 Likes

#50

Build systems may define “file_patterns”, which is a list of wildcard patterns, to do this. e.g., “file_patterns”: ["*.txt"]

0 Likes

#51

Build results panel gives me this output:

__init__() got an unexpected keyword argument 'file_patterns'

  • Build 3113, Win x64 portable
0 Likes

#52

That’s a bug, sorry about that - will fix for the next build

1 Like

#53

I’m probably misunderstood something.
I declared my build systems as part of sublime-project file:
{ "build_systems": [ { "name": "build", "working_dir": "${project_path:${folder}}/v8", "shell_cmd": "gn gen out/Release && ninja -C out/Release -j1000", "file_regex": "^(?:\\.\\.\\/)*(.*):([0-9]*):([0-9]*): error", } ] }
Before Sublime update around one month ago it worked awesome but currently it just doesn’t add any output into build output without any error. When I run default C++ build system it add output correctly. What I am doing wrong?
I found that problem is in setting working_dir, if I remove working_dir then output works good. How can I specify wroking_dir for build system?

0 Likes

#56

This is an old thread, but still I’m seem to be stuck with this.
I work with different languages all the time, and I would like to select associate an existing build system for each language. I might be completely missing something, but I cannot find how to do this (or if this is even possible).

0 Likes

#57

This is probably mentioned at some point above, but to provide some salient points as a synopsis:

  1. All files that you edit have a syntax definition of some sort that’s used to drive all of the various editing features in Sublime; the type of the file as Sublime sees it is listed in the bottom right of the window in the status bar (for example a new blank tab will say Plain Text)

  2. One of the keys that can appear in a build system (sublime-build file) is selector, which is used to tell Sublime what type of file the build generally applies to, if it should be specific to a certain type of file (which is generally the case).

  3. In the Tools > Build System menu you have the option to select an explicit build system that specifies exactly what build will be used (i.e. what tool to execute) whenever the build functionality is engaged.

  4. The first option in Tools > Build System is Automatic; if you select this then every time you execute a build, Sublime will check to see which of the builds it knows about applies to the current situation and it will use that one.

So, in the general case you just need to set Tools > Build System to Automatic and then every time you use Tools > Build or hit the associated key, the build that applies to the file you’re currently editing will be automatically selected and executed.

For this to work, the build file needs to contain a selector key that gives Sublime the hint as to the type of file it applies to, and all build systems that ship with Sublime contain such a key. If you’re making your own builds, then you need to add such a key yourself to your build.

To do so, open the type of file that the build is supposed to apply to and choose Tools > Developer > Show Scope Name ; you’ll get a popup with some number of lines in it (how many depends on where you are in the file, the type, etc); the very first line is the value you should use for the selector key.

Example: You are working with Python files and you want to create a build for them; from inside of a Python file you choose the menu item and see this:

image

The first line is source.python, so your build might look like:

{
    "shell_cmd": "python -u \"$file\"",
    "selector": "source.python"
}

All this said, it’s possible that there might be more than one build that applies to the current type of file. For example, the Python build that ships with Sublime can work two ways; also any builds that don’t have an explicit selector in them can conceivably work for all types of files.

In such a case, the first time you run the build you’ll be presented with a list of options for the build to use. Once you pick one, the build will run and then going forward Sublime will remember your choice every time you build. Thus, you only need to tell it once what build to use. If you want to change your mind, Tools > Build With will run the build and prompt you again.

I have a video series all about builds and how they work that may prove helpful for demonstration purposes:

0 Likes