rdmd problem

Andre Pany andre at s-e-a-p.de
Fri Apr 5 12:46:18 UTC 2019


On Friday, 5 April 2019 at 12:27:25 UTC, Comrad wrote:
> On Monday, 1 April 2019 at 11:23:43 UTC, Andre Pany wrote:
>> On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
>>> [...]
>>
>> I am not sure wheter compiler arguments works at the shebang 
>> line. If it works there might be the issue, that the file is 
>> passed first to rdmd and then the compiler argument. Arguments 
>> after the file name are handled as application arguments and 
>> passed to the application.
>>
>> What definitely works is using dub and single package file
>> https://dub.pm/advanced_usage
>> You can define the versions in the json/sdl section.
>>
>> Kind regards
>> Andre
>
> Sorry,
> the documentation doesn't allow me to understand easily, how to 
> use it without additional pain. The link you gave doesn't 
> describe a clear method for those, who never used dub before.
> Anyway... I was able to solve my problem in a convenient for me 
> way (using #!/usr/bin/rdmd --shebang -version=test -O)
>
> Thank you anyhow!

No problem:)

Create a file sample.d with following content

#!/usr/bin/env dub
/+ dub.sdl:
   name "sample"
   versions "test"
+/
void main() {
	import std.stdio : writeln;
	writeln("Hello, World!");
}

You can start it with "dub sample" or if you add the executable 
flag with "./sample.d".

With recent dub version you can name the file even without the .d 
extension and just start it with "./sample".

Kind regards
Andre


More information about the Digitalmars-d mailing list