-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
build: calculate BuildTarget.link_langauge if it's not set in the DSL #15509
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: master
Are you sure you want to change the base?
build: calculate BuildTarget.link_langauge if it's not set in the DSL #15509
Conversation
9c95570 to
644a28c
Compare
| self.builddir, name, self.type_suffix()) | ||
|
|
||
| def _calculcate_link_language(self) -> Language: | ||
| def calculate() -> Language: |
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.
Why is this logic defined as a function? It looks like it could be simply executed inline.
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.
Because doing it inline requires a lot of null checking, while using a closure makes it much cleaner, the closure can just return when language is found instead.
lang: T.Optional[Language] = None
if self.uses_rust():
...
lang = 'rust'
if lang is None and not languages:
...
if lang is None:
lang = languages[0]
if lang not in self.all_compilers:
...
return lang|
Is #15450 still going to be needed after this? |
|
@sp1ritCS: I think it still is. This mainly is optimizing the situation where we basically do the same calculation multiple times in multiple places, and what you're doing is orthogonal to that, and what you're doing will help make some of the work I want to do as follow up to this much easier. So, I will go review that. |
We more-or-less calculate the link_language several times if the user doesn't pass it, so let's calculate it ourselves.
644a28c to
37bbb9e
Compare
We effectively do this multiple times otherwise, even though we have all of the information to do it up front once. This simplifies a bunch of code later, and should allow us to do more cleanups later on.