dlang-tour / core

D Language online tour (https://tour.dlang.org/) and online editor (https://run.dlang.io/)
Boost Software License 1.0
119 stars 47 forks source link

Support multipe modules on run.dlang.io #656

Open JinShil opened 6 years ago

JinShil commented 6 years ago

This is a feature request to add support to run.dlang.io for editing/compiling multiple modules/files.

wilzbach commented 6 years ago

Thanks a lot for the request, Mike!

However, I'm inclined to close it as a WONTFIX. Here are my thoughts

Please see my NG thread about the D boilerplate template. It can be used as a template for the awesome WebIDE Cloud9 - simply use https://github.com/wilzbach/d-bootstrap as a template (or clone it in an existing workspace), hit make and your D code runs automagically. Imho we will never be as good as Cloud9 which has an entire development team and can utilize the AWS infrastructure directly.

What is your use case?

JinShil commented 6 years ago

My use case is for sharing code and ideas with others. So, for example, I could post an example to illustrate a minimal runtime with an object.d and a main.d, and readers can try the example immediately. Or to illustrate concepts such as visibility from one module to another. This can be useful for demonstrating features and bugs on the forum or in Bugzilla. I also think there are a use cases in the documentation where it would be useful to teach concepts.

Perhaps I could make use of Cloud9 for such things; I've never tried.

I will say that this is a luxury and not a necessity. It's your call. No hard feelings if you choose not to implement it, I promise.

wilzbach commented 6 years ago

Well, I agree that's "generally useful", but not many click & run platforms I know of/have used, support this:

Actually https://godbolt.org is the online platform that supports this that comes to my mind and it's windowing framework looks rather complicated.

Perhaps I could make use of Cloud9 for such things; I've never tried.

If you use the micro instances, the first year is for free. Though I think you need to explicitly add people to the workspace

So, for example, I could post an example to illustrate a minimal runtime with an object.d and a main.d, and readers can try the example immediately.

That's actually a good use case - think ... we could "hack" that in though. We already support import from GH's gist, so in theory something similar to DUB single file format could work, e.g.

# add object.d from https://gist.github.com/anonymous/451a0fb778381b11ed80078d5e0b6653
void main() {

}

Well that would be a simple start and it's left optional whether the frontend actually needs to support multiple files.

Well if you or someone else want to take a go at this, it would require the following adjustments:

1) Allow to pass multiple files to the Docker container https://github.com/dlang-tour/core-exec (maybe simply as additional arguments). Currently STDIN can be passed as $2, but an environment variable like DOCKER_COLOR or DOCKER_FLAGS would work too. 2) Modify the ExecProviders to accept multiple sources: https://github.com/dlang-tour/core/blob/master/source/exec/iexecprovider.d 3) Modify the invocation of the docker image to pass on the additional files https://github.com/dlang-tour/core/blob/master/source/exec/docker.d#L133 4) Modify the REST API to accept multiple files: https://github.com/dlang-tour/core/blob/master/source/rest/apiv1.d

As mentioned I don't need this, so I won't work on this in the foreseeable future, but I'm happy to merge PRs.

wilzbach commented 6 years ago

Initial HAR support is now live: https://run.dlang.io/is/ZHm2Xe

It's still experimental and most of the buttons don't work, but it should be enough to judge whether it's useful in this form.

And also we can start integrating it into the DTour + dlang.org where these buttons don't exist anyways.

JinShil commented 6 years ago

Tried a minimal runtime test with this: https://run.dlang.io/is/rrhgJL

object.Exception@rdmd.d(105): Option -o- currently not supported by rdmd

I'm not sure what that means.

wilzbach commented 6 years ago

I'm not sure what that means.

I initially tried to use rdmd for multiple files because -run is terribly broken (see e.g. https://github.com/dlang/dmd/pull/7927), but well it turns out rdmd isn't a good choice for this either.

Anyhow I just pushed a fix and it should be deployed in a few minutes:

https://github.com/dlang-tour/core-exec/pull/36

wilzbach commented 6 years ago

It works now: https://run.dlang.io/is/UwoLSC

JinShil commented 6 years ago

So cool!. Thanks. I'm OK to close this issue if you consider it solved.

JinShil commented 6 years ago

Ah wait!. This gave me a strange error: https://run.dlang.io/is/gHkwbJ

/sandbox/object.d(1): Error: found `EOF` when expecting `}` following compound statement
wilzbach commented 6 years ago

Hmm it goes away if I remove the comment: https://run.dlang.io/is/7k0KLk

wilzbach commented 6 years ago

For reference, this was a bug in har. An updated version of har has been deployed: https://run.dlang.io/is/KBOVEb

WebFreak001 commented 4 years ago

the main function doesn't seem to be found when using HAR right now.

However if you add -i -run app.d to the dmd arguments, you can work around this issue