-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
rdmd: support -of=... and -od=... flags as well as -of... and -od... #341
Conversation
|
Thanks for your pull request and interest in making D better, @WebDrake! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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. |
|
This is just a small issue that I noticed while working on some refactoring goals. It seemed better to fix it sooner rather than later. Would this be worth adding an issue and/or changelog entry over? |
969f076 to
68aabda
Compare
|
Updated the commit message & PR description with a bit more context for the reason behind the fix. |
68aabda to
6ac337f
Compare
|
Thanks. I think this is more code than necessary, how about this: // Parse the -o option (-ofmyfile or -odmydir).
void dashOh(string key, string value)
{
if (value.skipOver("f"))
{
// -ofmyfile passed
value.skipOver("=");
exe = value;
}
else if (value.skipOver("d"))
{
// -odmydir passed
value.skipOver("=");
if (!exe.ptr) // Don't let -od override -of
{
// add a trailing dir separator to clarify it's a dir
exe = value;
if (!exe.endsWith(dirSeparator))
{
exe ~= dirSeparator;
}
assert(exe.endsWith(dirSeparator));
}
}
else if (value == "-")
{
// -o- passed
enforce(false, "Option -o- currently not supported by rdmd");
}
else if (value == "p")
{
// -op passed
preserveOutputPaths = true;
}
else
{
enforce(false, "Unrecognized option: " ~ key ~ value);
}
}The above will also fix |
|
Oh, interesting thought. Yup, I can rewrite along those lines if it's convenient.
Ah, right. The whole |
6ac337f to
631490b
Compare
This fixes a discrepancy between `rdmd` and `dmd` in terms of the output flags they support: `dmd` now requests `-of=...` and `-od=...` in help output but still supports the old `-of...` and `-od...` style, while `rdmd` was still supporting only the older variant. Thanks to @CyberShadow for suggesting the `skipOver`-based solution. Extra test cases have been added to `rdmd_test` to cover this, although the way this has been done is a little bit cheeky (it turns out the only place where `-of` and `-od` are really tested rigorously is in tests for the case where the output file is a library in a subdirectory). At some point it would be a good idea to add some more rigorous test cases for the `-o...` flags, but in the short term the tests added in this patch should validate the changes to `rdmd` itself.
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.
Thanks!
|
Wait wait! I have a small tweak I want to make :-P |
By checking only `value[0]`, the `dashOh` callback used to parse `-o...` flags would give false positives (e.g. for `-o-foo` or `-opbar`). This patch fixes the discrepancy by requiring exact comparison to `value`. A few test cases have been added to `rdmd_test` to cover these failures. Thanks to @CyberShadow for spotting the bug and proposing the fix.
631490b to
348610d
Compare
|
Updated. Super picky on my part, but I wanted to tweak the commit messages slightly ;-) |
|
Alrighty :) |
|
No changelog entry needed? |
|
Subjective, but this seems minor enough that I wouldn't call it required. A linked Bugzilla issue would be OK too. |
|
Let's not worry about it, then, since auto-merge is already on. Thanks! |
|
@WebDrake Congrats! |
|
This PR fixed issue 17064. |
This fixes a discrepancy between
rdmdanddmdin terms of the output flags they support:dmdnow requests-of=...and-od=...in help output but still supports the old-of...and-od...style, whilerdmdwas still supporting only the older variant.The fix itself is a bit of a hacky tweak to the
dashOhcallback used to parse-oflags viagetopt. It seemed the simplest way to fix the issue without a more intrusive rewrite of how-oflags are parsed.Extra test cases have been added to
rdmd_testto cover this, although the way this has been done is a little bit cheeky too (it turns out the only place where-ofand-odare really tested rigorously in their behaviour is in tests for the case where the output file is a library in a subdirectory). Probably at some point it would be a good idea to add some more general/rigorous test cases for the-o...flags, but in the short term the tests added in this patch should validate the changes tordmditself.