www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Reloaded for dub

reply "Kingsley" <kingsley.hendrickse gmail.com> writes:
Hi

Just thought I would share this in case anyone else finds it 
useful. I wrote a tiny utility that detects changes to D files 
and then rebuilds and re-executes the main binary using dub.

I use for developing with vibe.d and other dub D project that 
have an executable binary.

The code is here:   https://github.com/kingsleyh/reloaded

essentially you just run dub in the root and it builds the 
reloaded binary. Then you just copy that binary to the root of 
your dub project and ./reloaded and then as soon as you make a 
change to a D file your code will be built and executed.

--K
Feb 20 2015
next sibling parent Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 02/20/2015 03:00 PM, Kingsley wrote:
 I use for developing with vibe.d and other dub D project that have an
 executable binary.

 The code is here:   https://github.com/kingsleyh/reloaded
Nice, want to contribute? https://github.com/D-Programming-Language/dub/issues/446
Feb 20 2015
prev sibling next sibling parent FG <home fgda.pl> writes:
On 2015-02-20 at 15:00, Kingsley wrote:
 Just thought I would share this in case anyone else finds it useful. I wrote a
tiny utility that detects changes to D files and then rebuilds and re-executes
the main binary using dub.
I see two problems: 1. It doesn't sleep for a few seconds after detecting that a file has changed, so when you upload several changed source files, recompilation may start before all of them are updated and either fail or produce something strange. 2. It works like this: if (changed) { kill(projectName); build() && run(projectName); sleep(); } As a result, if the compilation fails, no application will be running. Probably a better approach would be to have the application copied to a different place and run from there. Then the loop would look like this (I also added an extra unittest run before the running application is replaced): if (changed) { sleep(); build() && test() && kill(dest) && copy(projectName, dest) && run(dest); sleep(); } In this approach your program is almost always running. You only have to figure out how to provide `dest`. Perhaps via command line arguments where you provide a path (or just a directory).
Feb 20 2015
prev sibling next sibling parent Rikki Cattermole <alphaglosined gmail.com> writes:
On 21/02/2015 3:00 a.m., Kingsley wrote:
 Hi

 Just thought I would share this in case anyone else finds it useful. I
 wrote a tiny utility that detects changes to D files and then rebuilds
 and re-executes the main binary using dub.

 I use for developing with vibe.d and other dub D project that have an
 executable binary.

 The code is here:   https://github.com/kingsleyh/reloaded

 essentially you just run dub in the root and it builds the reloaded
 binary. Then you just copy that binary to the root of your dub project
 and ./reloaded and then as soon as you make a change to a D file your
 code will be built and executed.

 --K
*whistles* https://github.com/rikkimax/livereload
Feb 20 2015
prev sibling parent "qznc" <qznc web.de> writes:
On Friday, 20 February 2015 at 14:00:33 UTC, Kingsley wrote:
 Hi

 Just thought I would share this in case anyone else finds it 
 useful. I wrote a tiny utility that detects changes to D files 
 and then rebuilds and re-executes the main binary using dub.

 I use for developing with vibe.d and other dub D project that 
 have an executable binary.

 The code is here:   https://github.com/kingsleyh/reloaded

 essentially you just run dub in the root and it builds the 
 reloaded binary. Then you just copy that binary to the root of 
 your dub project and ./reloaded and then as soon as you make a 
 change to a D file your code will be built and executed.
You seem to especially target Vibe.d and your approach is based on *restarting* the server. It should be possible to do even better. Reload the server without stopping. Basic idea: Compile your server application as a shared library. Run a small wrapper, which uses the shared library. If a file changes, recompile the library and load it into the wrapper.
Feb 22 2015