Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
February 20, 2015 Reloaded for dub | ||||
---|---|---|---|---|
| ||||
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 |
February 20, 2015 Re: Reloaded for dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kingsley | 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 |
February 20, 2015 Re: Reloaded for dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kingsley | 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).
|
February 21, 2015 Re: Reloaded for dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kingsley | 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 |
February 22, 2015 Re: Reloaded for dub | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kingsley | 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.
|
Copyright © 1999-2021 by the D Language Foundation