-
Notifications
You must be signed in to change notification settings - Fork 920
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
Sync hook for downloading rust-toolchain-aux
.
#27749
base: master
Are you sure you want to change the base?
Sync hook for downloading rust-toolchain-aux
.
#27749
Conversation
A Storybook has been deployed to preview UI for the latest push |
372c951
to
3ddbebf
Compare
3ddbebf
to
37daed8
Compare
37daed8
to
868486d
Compare
f25ddea
to
7ca0bae
Compare
|
||
with tempfile.TemporaryFile() as temp_file: | ||
try: | ||
deps.DownloadUrl( |
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.
npm run sync
should not download this if the required version is already unpacked.
Will this be a no-op if the required version is already downloaded and unpacked?
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.
Currently, we don't store the version of these artifacts — they are always in sync with whatever Rust and Clang revisions Chromium has in tools/rust/update_rust.py
and tools/clang/scripts/update.py
, respectively. We can also bundle src/third_party/rust-toolchain/VERSION
with them, which will make it possible to only perform the download when necessary.
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'm okay with any approach, just make sure this is no-op if the required file is already downloaded. You can use sha256 or git commit or something else. You can look into existing deps and how they handle this.
"to build the required Rust aux package.") | ||
raise | ||
|
||
with temporary_directory() as temp_dir: |
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 can be replaced with with tempfile.TemporaryDirectory() as temp_dir:
make sure to unpack the content into the source tree, NOT into TMP as TMP most likely will have AV protection enabled (on Windows at least), which may trigger it randomly.
but you should just use deps.DownloadAndUnpack
.
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.
The AV thing is a good point, but the same applies to the tempfile.NamedTemporaryFile()
call in deps.DownloadAndUnpack()
, no?
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.
The AV thing is a good point, but the same applies to the
tempfile.NamedTemporaryFile()
call indeps.DownloadAndUnpack()
, no?
that is true, but for some reason Chromium is fine with that (in their deps downloader impl they download to tmp).
My guess is the risk of AV triggering on an archive access is much lower rather than writing a real executable on disk when unpacking.
raise | ||
|
||
with temporary_directory() as temp_dir: | ||
file.seek(0) |
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.
pls consider handling *.tar.xz
in deps.DownloadAndUnpack
instead of this file juggling here.
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.
The main concern with DownloadAndUnpack()
is not that it doesn't handle XZ files, but that it gets rid of the temp file it downloads the archive into after extracting it (which we want to keep). It's an outdated version of Chromium's DownloadAndUnpack()
in tools/clang/scripts/update.py
by the way.
Also, a minimal file juggling is necessary, as the files in the package go to different places.
1041cb1
to
7f7159c
Compare
7f7159c
to
c0d6cac
Compare
deps.DownloadAndUnpack( | ||
f'{deps_config.DEPS_PACKAGES_URL}/rust-toolchain-aux/{build_rust_toolchain_aux.package_name()}', | ||
temp_dir, | ||
output_file=PACKAGE) |
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.
sure, you can keep the whole archive and make some changes to DownloadAndUnpack
, but consider storing a simple text file like ${RUST_TOOLCHAIN}/.brave_toolchain_aux_package
with the downloaded/unpacked package and read/write it from you script to detect if you need the update.
script/deps.py
Outdated
else: | ||
t = tarfile.open(tmp_file.name, mode='r:gz') | ||
t = tarfile.open(file.name, mode='r:*') |
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 is cool, I didn't know about this mode.
a85b4ae
to
d6a2653
Compare
print(f'Skipping {Path(__file__).stem}') | ||
return | ||
|
||
with tempfile.TemporaryDirectory(dir=RUST_TOOLCHAIN) as temp_dir: |
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.
nit: this may left temp directories in a tree if the script was aborted via Ctrl+C.
but it's fine for now.
Resolves brave/brave-browser#44132.
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: