Move frontend utility functions from the DUB package to dmd.frontend#7485
Move frontend utility functions from the DUB package to dmd.frontend#7485dlang-bot merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
|
What's the idea here, just move common functionality from the test package or to come up new a proper API? |
src/dmd/frontend.d
Outdated
| foreach (p; path) | ||
| { | ||
| import std.string : toStringz; | ||
| Strings* a = new Strings(); |
There was a problem hiding this comment.
Why is an array created for each path, why not added the path directly to res?
Both, but (B) is definitely the goal. I just moved the bits from the test package over to bootstrap a discussion and avoid this topic sinking in the abyss. |
| .array | ||
| .sort | ||
| .uniq | ||
| .map!buildNormalizedPath; |
There was a problem hiding this comment.
This whole expression doesn't look very nice. Perhaps split it up with some helper functions/aliases. It's not very clear of what the code is actually doing.
src/dmd/frontend.d
Outdated
| shared static this() | ||
| { | ||
| initDMD(); | ||
| } |
There was a problem hiding this comment.
I'm not sure if this is the best idea if we want to allow multiple instances of the compiler in the future.
src/dmd/frontend.d
Outdated
| import dmd.dinifile : findConfFile; | ||
| import dmd.errors : fatal; | ||
| import std.algorithm, std.range, std.regex; | ||
| import std.stdio : File, stderr; |
There was a problem hiding this comment.
There's an extra space after the comma.
src/dmd/frontend.d
Outdated
| import std.algorithm, std.range, std.regex; | ||
| import std.stdio : File, stderr; | ||
|
|
||
| auto dmdEnv = env.get("DMD", "dmd"); |
There was a problem hiding this comment.
I think this function needs to be split into several layers building on top of each other. One where it's possible to give a direct path to the config and another which tries to infer it.
src/dmd/frontend.d
Outdated
| Params: | ||
| path = range of imports to add | ||
| */ | ||
| void addImports(T)(T path) |
There was a problem hiding this comment.
This should have constraints.
src/dmd/frontend.d
Outdated
| Returns: the parsed module object | ||
| */ | ||
| // TODO: allow files? | ||
| auto parseModule(string fileName, string code) |
There was a problem hiding this comment.
I don't think auto should be used here. It returns a simple class and not a template, so I don't think it's necessary.
src/dmd/frontend.d
Outdated
| Returns: | ||
| Pretty printed module as string. | ||
| */ | ||
| auto prettyPrint(Module m) |
There was a problem hiding this comment.
Same here, write out the actual return type instead of auto.
I'm don't think that's necessary. I do think the version of the first releases should be |
src/dmd/frontend.d
Outdated
|
|
||
| if (global.path is null) | ||
| { | ||
| Strings* res = new Strings(); |
There was a problem hiding this comment.
This variable doesn't seem to add any value.
src/dmd/frontend.d
Outdated
|
|
||
| return File(iniFile, "r") | ||
| .byLineCopy | ||
| // search for all -I imports in this file |
There was a problem hiding this comment.
I still prefer separate functions/lambdas instead of comments.
16bb798 to
4e0bae1
Compare
|
Shouldn't this module be named something like |
4e0bae1 to
13bdd35
Compare
It's not intended to be used by any library. It's only intended to be used for the DMD as a library builds - most likely via DUB. Regarding the name, see: #7425 (comment) |
13bdd35 to
f102704
Compare
| * the `CRuntime` used). | ||
| */ | ||
| private void addDefaultVersionIdentifiers() | ||
| void addDefaultVersionIdentifiers() |
f102704 to
7bc3dcc
Compare
1ff3d42 to
6794c43
Compare
| Initializes the DMD compiler | ||
| import dmd.dmodule : Module; | ||
| import std.range.primitives : isInputRange, ElementType; | ||
| import std.traits : isNarrowString; |
There was a problem hiding this comment.
Thought Phobos is DMD was a no-no ?
There was a problem hiding this comment.
This file isn't used by dmd at all - only by the DMD as a library project.
Should we rename the file or move it to somwhere else, s.t. this gets clearer?
I don't see any reason not to use Phobos here, it allows to write the high-level wrappers and stops us from re-inventing the wheel and blowing up the code with inferior, probably buggy implementations of Phobos.
6794c43 to
d464620
Compare
|
BTW anything else blocking this PR except for the name of this module? Everything is still marked as |
d464620 to
2af57e8
Compare
| if ("DMD" in environment) | ||
| compilers = environment.get("DMD") ~ compilers; | ||
| auto paths = environment.get("PATH", "").splitter(sep); | ||
| auto res = compilers.map!(c => paths.map!(p => p.buildPath(c~exe))).joiner.filter!exists; |
There was a problem hiding this comment.
The indentation is wrong.
2af57e8 to
1fcdbde
Compare
|
Closing & reopening for Semaphore to learn about this PR. |
1fcdbde to
502ad98
Compare
502ad98 to
ff6df1c
Compare
|
Anything else blocking this? |
|
CC @RazvanN7 are you okay with this too? |
|
LGTM |
Following to #7425, this just move these bits to
dmd.frontend. Of course, further work is needed to define the API, but I thought having an open PR is the best place to facilitate this discussion.This is far from perfect, but I won't have time to work much on it until I chat with @RazvanN7.
Anyhow if you have already have an API idea/requirement and want to drop it or just want to subscribe to the discussion, this is the place to be ;-)