Sublime Forum

'Multi-Step' Build Scripts

#1

Hi there!

I wonder, if its possible to do multi-step build scripts? For example, I wrote one to compile coffescript and an other one to run javascript with node. Is there any chance to do this in one step? Ihad similar issue with action script, where I can build .as files to .swf but cant automatically open the .swf once its compiled.

I`ve seen sime build script improvements in the 2.0 relese notes but not sure what are those.

Any help would appreciated!

Cheers!

p.s.

there is a similat topic here:


but no answer yet…

0 Likes

#2

I was only able to find one way to do multiple builds cleanly (although I use Java), and it was by making a plugin. I can’t find the tutorial I used, so here’s the code I ended up with. You need something a little different, but hopefully this’ll help.

This goes in RunBuild.py located in folder RunBuild under packages

[code]import sublime, sublime_plugin

class RunBuildCommand(sublime_plugin.WindowCommand):
def run(self, build_system):
self.window.run_command( “set_build_system”, {“file”: build_system } )
self.window.run_command( “build” )[/code]

This goes in the user key bindings file:

	{ "keys": "ctrl+1"], "command": "run_build", "args": { "build_system": "Packages/RunBuild/JavaC.sublime-build" } },
	{ "keys": "ctrl+2"], "command": "run_build", "args": { "build_system": "Packages/RunBuild/JavaR.sublime-build" } },
	{ "keys": "ctrl+3"], "command": "run_build", "args": { "build_system": "Packages/RunBuild/JavaA.sublime-build" } }
][/code]

And the final step is to add build configurations, located in the RunBuild folder (This is JavaA.sublime-build, located in the RunBuild folder):
[code]{
   "cmd": "appletviewer", "applet.html" ],
   "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
   "working_dir": "${file_path}",
   "selector": "source.java"
}

You’ll need to modify it a bit to suit your needs, but at least it should point you in the right direction.

0 Likes

#3

Thanx!

Although I have something different in mind, when I say multi-step. Perhaps ‘chaining’ would be a better word. So I want one buildscript that compiles my cofeescript(just example) to javascript and when it`s done runs the next command or even a third one.

something like this:

{
   "cmd": "coffee","--compile" ,"$file" ],
   "selector": "source.coffee"
},
{
 "cmd": "node", "$file_name.js" ],
 "selector": "source.js"
}

These two are working indivdually but I`d love to have them in one.

0 Likes

#4

Okay, have you tried making the build system run a batch file that does both operations?

(like in this thread)
https://forum.sublimetext.com/t/compiling-and-running-java/4004/1

0 Likes

#5

Yepp, I tried and it`s working that way. On the other hand it is rather a ‘makeshift’ solution. I mean this is going to be windows only, which is fine right now but I was hoping for a ‘native’ solution, so I can specify for all three platforms if necessary.

Thank You anyway!

0 Likes

#6

UPDATE:

This plugin seems to solve my issue

0 Likes