digitalmars.D.learn - Compiling D inside of a D program
- Mineko (9/9) Dec 21 2013 This is a fairly basic question but I can't find any good
- thedeemon (5/9) Dec 21 2013 D runtime doesn't include any compilation abilities, it's not a
- Andrea Fontana (3/12) Dec 21 2013 I still hope they make DMD available as shared/static library
- Kelet (21/30) Dec 21 2013 Hi, I was also interested in this topic. My research suggests
- Mineko (4/37) Dec 21 2013 Would it be legal to have my program automatically download some
- John Colvin (4/48) Dec 21 2013 To the best of my knowledge it's totally ok to have your program
- Mineko (6/9) Dec 21 2013 Sounds good to me, I more or less know what to do now, I'll be
- John Colvin (2/13) Dec 21 2013 How fast do you actually need it to be?
- Mineko (4/18) Dec 21 2013 Fast enough to where the engine is not spending 5 minutes
- John Colvin (6/26) Dec 21 2013 -Ofast means fast code, not fast compilation.
This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside of a D program, so I can say, compile a D script on-the-fly in some game, it's just an idea though. To be even more to the point, how can I invoke the D compiler inside of a D program, also, do I need to bundle said D compiler with my program or does D have some compilation feature inside of an already compiled program (Which I doubt)?
Dec 21 2013
On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote:To be even more to the point, how can I invoke the D compiler inside of a D program, also, do I need to bundle said D compiler with my program or does D have some compilation feature inside of an already compiled program (Which I doubt)?D runtime doesn't include any compilation abilities, it's not a Lisp. You'll need to invoke the compiler as a separate process. Look at this example:
Dec 21 2013
I still hope they make DMD available as shared/static library just like tinyc compiler! On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote:This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside of a D program, so I can say, compile a D script on-the-fly in some game, it's just an idea though. To be even more to the point, how can I invoke the D compiler inside of a D program, also, do I need to bundle said D compiler with my program or does D have some compilation feature inside of an already compiled program (Which I doubt)?
Dec 21 2013
On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote:This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside of a D program, so I can say, compile a D script on-the-fly in some game, it's just an idea though. To be even more to the point, how can I invoke the D compiler inside of a D program, also, do I need to bundle said D compiler with my program or does D have some compilation feature inside of an already compiled program (Which I doubt)?Hi, I was also interested in this topic. My research suggests that there is no easy or safe way to do this at the moment, as thedeemon suggests. Although I think it's worth offering a possible alternative: using a scripting language binding like LuaD[1], DerelictLua[2], or pyd[3]. From here, you can expose some functions/variables between them, and solve a lot of the same problems. That being said, I think it would be useful to have something like JavaCompiler[4]. It's not an optimal solution, but combined with a minimal compiler package it could help a lot. As far as I know, you need to ask permission to distribute DMD with your application, so it may be safer to include GDC or LDC if you want to go this route. Or ask Walter, of course. [1]: https://github.com/JakobOvrum/LuaD [2]: https://github.com/DerelictOrg/DerelictLua [3]: https://bitbucket.org/ariovistus/pyd [4]: http://docs.oracle.com/javase/7/docs/api/javax/tools/JavaCompiler.html Regards, Kelet
Dec 21 2013
On Saturday, 21 December 2013 at 10:00:10 UTC, Kelet wrote:On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote:Would it be legal to have my program automatically download some dmd binary, that way I could always keep it up to date? Given Walter here doesn't absolutely forbid my program does that.This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside of a D program, so I can say, compile a D script on-the-fly in some game, it's just an idea though. To be even more to the point, how can I invoke the D compiler inside of a D program, also, do I need to bundle said D compiler with my program or does D have some compilation feature inside of an already compiled program (Which I doubt)?Hi, I was also interested in this topic. My research suggests that there is no easy or safe way to do this at the moment, as thedeemon suggests. Although I think it's worth offering a possible alternative: using a scripting language binding like LuaD[1], DerelictLua[2], or pyd[3]. From here, you can expose some functions/variables between them, and solve a lot of the same problems. That being said, I think it would be useful to have something like JavaCompiler[4]. It's not an optimal solution, but combined with a minimal compiler package it could help a lot. As far as I know, you need to ask permission to distribute DMD with your application, so it may be safer to include GDC or LDC if you want to go this route. Or ask Walter, of course. [1]: https://github.com/JakobOvrum/LuaD [2]: https://github.com/DerelictOrg/DerelictLua [3]: https://bitbucket.org/ariovistus/pyd [4]: http://docs.oracle.com/javase/7/docs/api/javax/tools/JavaCompiler.html Regards, Kelet
Dec 21 2013
On Saturday, 21 December 2013 at 21:58:16 UTC, Mineko wrote:On Saturday, 21 December 2013 at 10:00:10 UTC, Kelet wrote:To the best of my knowledge it's totally ok to have your program download the latest zip from dlang.org on the client machine and use that.On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote:Would it be legal to have my program automatically download some dmd binary, that way I could always keep it up to date? Given Walter here doesn't absolutely forbid my program does that.This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside of a D program, so I can say, compile a D script on-the-fly in some game, it's just an idea though. To be even more to the point, how can I invoke the D compiler inside of a D program, also, do I need to bundle said D compiler with my program or does D have some compilation feature inside of an already compiled program (Which I doubt)?Hi, I was also interested in this topic. My research suggests that there is no easy or safe way to do this at the moment, as thedeemon suggests. Although I think it's worth offering a possible alternative: using a scripting language binding like LuaD[1], DerelictLua[2], or pyd[3]. From here, you can expose some functions/variables between them, and solve a lot of the same problems. That being said, I think it would be useful to have something like JavaCompiler[4]. It's not an optimal solution, but combined with a minimal compiler package it could help a lot. As far as I know, you need to ask permission to distribute DMD with your application, so it may be safer to include GDC or LDC if you want to go this route. Or ask Walter, of course. [1]: https://github.com/JakobOvrum/LuaD [2]: https://github.com/DerelictOrg/DerelictLua [3]: https://bitbucket.org/ariovistus/pyd [4]: http://docs.oracle.com/javase/7/docs/api/javax/tools/JavaCompiler.html Regards, Kelet
Dec 21 2013
On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote:To the best of my knowledge it's totally ok to have your program download the latest zip from dlang.org on the client machine and use that.Sounds good to me, I more or less know what to do now, I'll be using DMD because of it's fast code compilation which is going to be KEY especially to multiplayer games, I would have LIKED to use GDC, but like I said, fast compilation times. (Or perhaps someone has an idea there..?)
Dec 21 2013
On Saturday, 21 December 2013 at 22:18:58 UTC, Mineko wrote:On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote:How fast do you actually need it to be?To the best of my knowledge it's totally ok to have your program download the latest zip from dlang.org on the client machine and use that.Sounds good to me, I more or less know what to do now, I'll be using DMD because of it's fast code compilation which is going to be KEY especially to multiplayer games, I would have LIKED to use GDC, but like I said, fast compilation times. (Or perhaps someone has an idea there..?)
Dec 21 2013
On Saturday, 21 December 2013 at 22:51:53 UTC, John Colvin wrote:On Saturday, 21 December 2013 at 22:18:58 UTC, Mineko wrote:Fast enough to where the engine is not spending 5 minutes compiling a heavily scripted (multiplayer usually) game, perhaps gdc -0fast would do it?On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote:How fast do you actually need it to be?To the best of my knowledge it's totally ok to have your program download the latest zip from dlang.org on the client machine and use that.Sounds good to me, I more or less know what to do now, I'll be using DMD because of it's fast code compilation which is going to be KEY especially to multiplayer games, I would have LIKED to use GDC, but like I said, fast compilation times. (Or perhaps someone has an idea there..?)
Dec 21 2013
On Saturday, 21 December 2013 at 23:00:20 UTC, Mineko wrote:On Saturday, 21 December 2013 at 22:51:53 UTC, John Colvin wrote:-Ofast means fast code, not fast compilation. For a scripting layer, dmd is probably the best choice. If the scripts get really big you might still run in to some problems. If they remain small (or at least the bit that neds recompiling is small) then gdc/ldc would still be viable.On Saturday, 21 December 2013 at 22:18:58 UTC, Mineko wrote:Fast enough to where the engine is not spending 5 minutes compiling a heavily scripted (multiplayer usually) game, perhaps gdc -0fast would do it?On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote:How fast do you actually need it to be?To the best of my knowledge it's totally ok to have your program download the latest zip from dlang.org on the client machine and use that.Sounds good to me, I more or less know what to do now, I'll be using DMD because of it's fast code compilation which is going to be KEY especially to multiplayer games, I would have LIKED to use GDC, but like I said, fast compilation times. (Or perhaps someone has an idea there..?)
Dec 21 2013