digitalmars.D.learn - Using dub and rdmd together?
- Matthew OConnor (14/14) Jul 11 2018 Hi, I'm new to D and trying to make some command line tools that
Hi, I'm new to D and trying to make some command line tools that reference external packages from dub. I know I can do this with: /+ dub.sdl: name "get" dependency "requests" version="~>0.3.2" +/ But when I run it (with `dub get.d` on Windows), it rebuilds every time. Is there a way to integrate the two so that `rdmd` is used for the builds, but `dub` is used to download the necessary packages? Thanks, Matthew
Jul 11 2018
On Wednesday, 11 July 2018 at 16:13:56 UTC, Matthew OConnor wrote:Hi, I'm new to D and trying to make some command line tools to reference external packages from dub. I know I can do this with: /+ dub.sdl: name "get" dependency "requests" version="~>0.3.2" +/ But when I run it (with `dub get.d` on Windows), it rebuilds every time. Is there a way to integrate the two so that `rdmd` is used for the builds, but `dub` is used to download the necessary packages? Thanks, MatthewI don't know of an easy way to do out of the box. However, with dmd's new -i option, it could be as easy as: --- dub fetch requests cat > test.d << EOF import std.stdio; import requests; void main() { auto content = postContent("http://httpbin.org/post", queryParams("name", "any name", "age", 42)); writeln(content); } EOF dub fetch requests dmd -I~/.dub/packages/requests-0.8.2/requests/source -i -run tests.d --- However, dmd itself doesn't do any caching (though it would work similarly with rdmd). But, of course, this won't work for more complex dub packages. There's `dub describe` (and a backend generator) for which they might be used.
Jul 11 2018
On Wednesday, 11 July 2018 at 16:43:24 UTC, Seb wrote:I don't know of an easy way to do out of the box. However, with dmd's new -i option, it could be as easy as: --- dub fetch requests cat > test.d << EOF import std.stdio; import requests; void main() { auto content = postContent("http://httpbin.org/post", queryParams("name", "any name", "age", 42)); writeln(content); } EOF dub fetch requests dmd -I~/.dub/packages/requests-0.8.2/requests/source -i -run tests.d --- However, dmd itself doesn't do any caching (though it would work similarly with rdmd). But, of course, this won't work for more complex dub packages. There's `dub describe` (and a backend generator) for which they might be used.So this is kind of similar to what dub does already? Would be nice if dub could cache such compiled scripts somewhere. I mean dub already caches inside .dub folder in a dub project. Why not also cache compiled scripts somewhere?
Jul 11 2018