digitalmars.D - Compile from stdin
- Benjamin Schulte (7/7) May 06 2008 Hi!
- Dawid Ciężarkiewicz (4/14) May 06 2008 On Linux (and probably some other unixes) you can try:
- Kevin Bealer (6/16) May 06 2008 The following works for me; it's a variation on what the other guy said ...
- BCS (4/15) May 06 2008 linux only as well but their might be some way to force the <(...) const...
- Walter Bright (2/3) May 08 2008 I don't know what you mean.
- terranium (3/7) May 08 2008 maybe doing something like
- BCS (4/10) May 08 2008 this:
- Walter Bright (5/19) May 08 2008 Are you using linux or windows? Also, dmd looks at the file extension to...
- BCS (12/34) May 08 2008 something like -iD / -iL / -iO flags would cover that. But I think that ...
Hi! Is there a way to compile a sourcecode from stdin? It would be very helpful to be able to compile a sourcecode from stdin direct into an object file, without saving it first into a temporary file. Like using type test.d |dmd dmd < test.d Or is it possible with gdc? Thanks in advance.
May 06 2008
Benjamin Schulte Wrote:Hi! Is there a way to compile a sourcecode from stdin? It would be very helpful to be able to compile a sourcecode from stdin direct into an object file, without saving it first into a temporary file. Like using type test.d |dmd dmd < test.d Or is it possible with gdc?On Linux (and probably some other unixes) you can try: cat file.d | dmd /proc/self/fd/0Thanks in advance.Hope this will works (haven't tried myself).
May 06 2008
Benjamin Schulte Wrote:Hi! Is there a way to compile a sourcecode from stdin? It would be very helpful to be able to compile a sourcecode from stdin direct into an object file, without saving it first into a temporary file. Like using type test.d |dmd dmd < test.d Or is it possible with gdc? Thanks in advance.The following works for me; it's a variation on what the other guy said but provides the ".d" ending. Also a Linux-only solution. ln -s /proc/self/fd/0 source.d cat actual_source.d | dmd -ofresult source.d Note that "source" can be used by multiple dmd processes to compile different files at the same time without conflict or synchronization, so you don't need to create per-process objects, but of course you might need to do something special if you want to compile multiple modules at once. Kevin
May 06 2008
Reply to Benjamin,Hi! Is there a way to compile a sourcecode from stdin? It would be very helpful to be able to compile a sourcecode from stdin direct into an object file, without saving it first into a temporary file. Like using type test.d |dmd dmd < test.d Or is it possible with gdc? Thanks in advance.linux only as well but their might be some way to force the <(...) construct to be usable Walter: any way we can get a "don't adjust the filename" flag?
May 06 2008
BCS wrote:Walter: any way we can get a "don't adjust the filename" flag?I don't know what you mean.
May 08 2008
Walter Bright Wrote:BCS wrote:maybe doing something like dmd CONIN -ofprog.exeWalter: any way we can get a "don't adjust the filename" flag?I don't know what you mean.
May 08 2008
Reply to Walter,BCS wrote:this: dmd foo looks for a file named "foo.d", I need to to look for "foo"Walter: any way we can get a "don't adjust the filename" flag?I don't know what you mean.
May 08 2008
BCS wrote:Reply to Walter,Are you using linux or windows? Also, dmd looks at the file extension to see what to do with the file. .o means object file, .a means library, etc. Having no extension causes problems. Why not just put an extension on it?BCS wrote:this: dmd foo looks for a file named "foo.d", I need to to look for "foo"Walter: any way we can get a "don't adjust the filename" flag?I don't know what you mean.
May 08 2008
Reply to Walter,BCS wrote:linuxReply to Walter,Are you using linux or windows?BCS wrote:this: dmd foo looks for a file named "foo.d", I need to to look for "foo"Walter: any way we can get a "don't adjust the filename" flag?I don't know what you mean.Also, dmd looks at the file extension to see what to do with the file. .o means object file, .a means library, etc. Having no extension causes problems.something like -iD / -iL / -iO flags would cover that. But I think that only source code would be used very often so making that the default would be reasonable in my book. using the unix convention of - refering to stdin would cover what the OP wanted: dmd -iD-Why not just put an extension on it?Because I can't select the filename. I was trying to use the "<(command)" construct under bash. This replaces the given with a path to a named pipe that the given command's stdout can be accessed from. The name is not something I can effect.
May 08 2008