-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix #14334: Support more msbuild conditional constructs #8039
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
base: main
Are you sure you want to change the base?
Conversation
a8ea143 to
dade829
Compare
|
Thanks for your contribution. Please avoid adding test-only code in the production code. See e04019c for an approach. If you inherit from |
lib/importproject.cpp
Outdated
| catch (const std::runtime_error& r) | ||
| { | ||
| return false; | ||
| } |
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.
We should report the exception as a debug or verbose message.
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.
Should this use the ErrorLogger infrastructure?
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.
Yes. reportErr() for a debug message or reportOut() for a verbose message. Not sure which would be more appropriate.
| tokenlist.createAst(); | ||
| for (const Token *tok = tokenlist.front(); tok; tok = tok->next()) { | ||
| if (tok->str() == "(" && tok->astOperand1() && tok->astOperand2()) { | ||
| // TODO: this is wrong - it is Contains() not Equals() |
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.
We should have filed a ticket for this since fixing it is a behavior change. Are you able to do that or should I file one?
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.
Could you do that? :)
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.
Will do later. I want to have a reproducer first.
Currently |
Sorry that I missed that.
Let's get the CI to pass first and the other stuff addressed and then I will have another look. It won't be merged before we made the 2.19 release anyways. |
a327364 to
e674fb6
Compare
0818e64 to
f0810d5
Compare
lib/importproject.cpp
Outdated
|
|
||
| static bool evalExpression(std::string expr /* should be a std::string_view */, const ProjectConfiguration& p) | ||
| { | ||
| const auto startsHere = [&](size_t& i, std::string string) |
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.
I have the feeling this could be simplified using string::compare
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.
Ok will it change to
if (expr.compare(i, string.length(), string) == 0)
{
i += string.length();
return true;
}
return false;| } | ||
| return false; | ||
| }; | ||
| const auto skipSpaces = [&](size_t& i) |
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.
I think i = expr.find_first_not_of(' ',i); can be used instead.
| throw std::runtime_error("Expecting a start of a string!"); | ||
| } | ||
| auto start = ++i; | ||
| while (i < expr.length() && expr[i] != '\'') ++i; |
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.
can there be some escape sequences we should handle i.e. if expr is 'a\'b' ?
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.
No it seems that is not possible
lib/importproject.cpp
Outdated
| if (startsHere(i, "$(Configuration.")) | ||
| { | ||
| initialized = true; | ||
| if (startsHere(i, "Contains(")) |
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.
is it possible to have spaces.. Contains ( ?
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.
Never have seen this, but it seems to be possible.
| { | ||
| return !evalExpression(expr.substr(i + 1), p); | ||
| } | ||
| if (startsHere(i, "And")) |
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 will be true if expr contains AndXY.
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.
Hm that is true. Otherwise this is then also an invalid msbuild project that does not build...
|



No description provided.