-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #895, so that dub looks for a compiler next to itself first #1208
Conversation
Thanks for your pull request, @joakim-noah! |
Why not interpret relative paths in |
Possible, but then inconsistent with |
I'd go for it, as it allows more flexibility for packaging (e.g. different bin folders). |
Good idea, will add that.
dub looks for it first in the system ( |
Alright, modified this pull to check for |
@s-ludwig, let me know if this pull is okay, would be good to get this in before the next dmd/ldc releases. |
Sorry for the late reply, this slipped past me. Two notes:
|
Those are all environment variables normally though, right? I thought this should be different because it's specific to the config file. Doesn't really matter to me though, just let me know what you want.
The only changed lookup logic is to first search for a compiler name specified in the config file in the |
My idea was that we could support real environment variables, too, at some point, and this special case could then just naturally merge with that.
Okay, it's mostly just a fuzzy concern on my side right now, because I haven't really thought through the possible implications/issues. One thing that gets a bit hairy is when one explicitly wants to select the compiler in PATH instead of the one in the local directory, but maybe that's a bit superficial. Generally I'd just try to avoid changes that serve no concrete need (i.e. if a config file in the compiler distribution already works for the initial use case). |
OK, will change it.
Just specify
It is true that adding that option to use a compiler relative to dub's path to the config file, which wasn't there before this pull, is potentially redundant with checking for a compiler next to dub automatically, but only if every compiler that ships dub adds a config file that explicitly says where dub is relative to the compiler. Since most will stick dub right next to the compiler, this saves them that trouble. It's sufficiently common that I think it's worth having both. |
Having rdmd now behave like this is a good argument. It makes sense to stay consistent within the tools ecosystem. |
source/dub/dub.d
Outdated
if (m_defaultCompiler.length && m_defaultCompiler.isAbsolute) | ||
return; | ||
|
||
auto dubPrefix = m_defaultCompiler.matchFirst(ctRegex!(`^DUB_BINARY_PATH`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to DUB_BINARY_PATH
like you asked.
test/issue895-local-configuration.sh
Outdated
@@ -14,9 +15,11 @@ if [ -e ~/.dub/settings.json ]; then | |||
die $LINENO 'Found existing user wide DUB configuration. Aborting.' | |||
fi | |||
|
|||
if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF 'Unknown compiler: foo'; then | |||
if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF 'Unknown compiler: '; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should now pass, but removed the compiler name foo
because my new code passes the full path of a compiler next to dub
to the settings and this error output. I'm adding more tests for the new behavior and will update the patch soon.
Finally spent an hour and updated this pull to test all new code paths, should be ready to merge. |
Ping, @s-ludwig or @MartinNowak, PR passes most CI, except for some scenarios because of the upstream druntime headers, which are broken unrelated to this pull. |
Ping, would be good to get this in for the next release, so dub works out of the box with dmd. |
The only issue I can see is that the "$" is missing before "DUB_BINARY_PATH". Otherwise it looks good to merge, the Windows failure is unrelated (we should really clean this up at some point, so that AppVeyor can also be marked as a required check). |
OK, do you want me to add the |
Yeah, sorry for that, I was indeed writing ambiguously there. So in the path, it should be written as |
Will do, in the meantime, I rebased to get the CI to run again. Update: Added the |
put some restrictions on the defaultCompiler specified in a DUB settings.json, such that it must be a compiler name, a path relative to dub, or an absolute path, including a tilde-prefixed local path. Unqualified relative paths are no longer allowed from the settings file, as they make no sense for how dub invokes the compiler.
Is codecov broken, @wilzbach? It says I only cover 45% of my patch with the tests, when I tried to hit all of it. |
Since I didn't get a response about how checking for a compiler next to dub should interact with the one specified in a DUB config file, I went ahead and implemented what I thought makes sense. I can add some tests once the behavior is approved.
Also puts some restrictions on the defaultCompiler specified in a DUB
settings.json
, such that it must be a compiler name or an absolute path, including a tilde-prefixed local path. Relative paths are no longerallowed, as they make no sense for how dub invokes the compiler. You could argue that even a compiler name should be disallowed, as it's unlikely anyone will specify one that's not already on the default list that dub tries, but I suppose the sdc devs may want to try out dub some day. ;)
If a compiler name like
sdc
is specified in a DUBsettings.json
, I have dub check for other common compilers in thePATH
only ifsdc
isn't found next to dub or on thePATH
(Update: which is probably why the test for #895 now fails on Travis CI, though the test will be changed), though you could argue the user only wantssdc
used. However, dub always says what compiler it's using and if the user hasn't provided ansdc
, it's a convenience to search for another compiler. I could change it to only check thePATH
forsdc
in that case, if wanted, as I do when checking next to dub.Finally, all this changes nothing about specifying a compiler with
--compiler
, where none of this is used and you can specify any D compiler you want, including one with a relative path.