Thread overview
Make executable archive just like Java's .jar archive?
Sep 12, 2019
BoQsc
Sep 12, 2019
BoQsc
Sep 12, 2019
Mike Parker
Sep 13, 2019
norm
September 12, 2019
Is there a way to archive multiple .d source code files and make that archive executable, or something similar?
September 12, 2019
On Thursday, 12 September 2019 at 12:52:48 UTC, BoQsc wrote:
> Is there a way to archive multiple .d source code files and make that archive executable, or something similar?

https://en.wikipedia.org/wiki/JAR_(file_format)
September 12, 2019
On Thursday, 12 September 2019 at 12:53:27 UTC, BoQsc wrote:
> On Thursday, 12 September 2019 at 12:52:48 UTC, BoQsc wrote:
>> Is there a way to archive multiple .d source code files and make that archive executable, or something similar?
>
> https://en.wikipedia.org/wiki/JAR_(file_format)

A JAR file is just a standard zip file. The Java Virtual Machine loads .class files (which are Java bytecode files, not Java source) and executes them at runtime. It doesn't matter if they're in a jar file or not. Java was designed for this from the beginning.

If you're really talking about loading .d *source* files, that means they either have to be interpreted like a scripting language, in which case you'll need a D interpreter, or they'll need to be compiled at runtime into bytecode (in which case you'll need a bytecode interpreter), or compiled at runtime into object files, in which case you'll need a mechanism for loading object files into a program (there was an object loader library around back in the D1 days).

If you want to do what Java does and compile ahead of time to a bytecode format and distribute the bytecode in an archive to be loaded at runtime, then that requires implementing a bytecode compiler, a loader, and a bytecode interpreter.

I know that LLVM can output bytecode, so with LDC that's the first step out of the way. Now all you need is for someone to implement a loader and bytecode interpreter.
September 13, 2019
On Thursday, 12 September 2019 at 12:52:48 UTC, BoQsc wrote:
> Is there a way to archive multiple .d source code files and make that archive executable, or something similar?

You can achieve something similar with rdmd and shell;

$ tar -zcvf source_files.tar.gz source1.d source2.d ... sourceN.d

$ rdmd $(tar -xvf source_files.tar.gz)


I imagine it wouldn't take much for rdmd to support ZIP or tarballs directly but I'm sure there are corner cases to consider.

Bye,
norm