Skip to content
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

Use the rust-src tool for fetching rust source #844

Merged
merged 1 commit into from
Jul 21, 2021
Merged

Use the rust-src tool for fetching rust source #844

merged 1 commit into from
Jul 21, 2021

Conversation

csmulhern
Copy link
Contributor

@csmulhern csmulhern commented Jul 19, 2021

This tool only includes the relevant rust source files, significantly slimming the size of the download, and significantly decreasing the number of bazel targets generated. The concept of a "host tool" is introduced, which is targetless, to accommodate this change.

This partially fixes #833.

Returns:
str: The fully qualified url path for the specified tool.
"""
url = ""
if iso_date:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no excuse for not having a unit test for this function :) I just uploaded #846.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(feel free to merge it and add a test for none in target_triple)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return "{}-{}-{}".format(tool_name, version, target_triple)
url += "{}/".format(iso_date)
if tool_name:
url += tool_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tool is not an optional argument, let'sfail() with an error message when None is passed. Same for version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if tool_name:
url += tool_name
if version:
url += "-{}".format(version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about alternative code (not tested):

result = "-".join([e for e in [tool_name, target_triple,version] if e])
if iso_date:
  return iso_date + "/" + result
else:
  return result

Combining += and format is imho confusing and cumbersome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

rust/private/repository_utils.bzl Show resolved Hide resolved
This tool only includes the relevant rust source files, significantly
slimming the size of the download, and significantly decreasing the
number of bazel targets generated. The concept of a "host tool" is
introduced, which is targetless, to accommodate this change.
Copy link
Member

@hlopko hlopko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@hlopko
Copy link
Member

hlopko commented Jul 21, 2021

CC @UebelAndre FYI.

@hlopko hlopko merged commit ac7378f into bazelbuild:main Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

include_rustc_srcs creates many configured targets
2 participants