diff --git a/cargo/Cargo.lock b/cargo/Cargo.lock index 92536a335..982e79cac 100644 --- a/cargo/Cargo.lock +++ b/cargo/Cargo.lock @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "coarsetime" version = "0.1.14" -source = "git+https://github.com/ankitects/rust-coarsetime.git?branch=old-mac-compat#f9e2c86216f0f4803bc75404828318fc206dab29" +source = "git+https://github.com/ankitects/rust-coarsetime.git?tag=anki-2020-11-03#f9e2c86216f0f4803bc75404828318fc206dab29" dependencies = [ "lazy_static", "libc", diff --git a/cargo/crates.bzl b/cargo/crates.bzl index d8df6339f..8479d9278 100644 --- a/cargo/crates.bzl +++ b/cargo/crates.bzl @@ -325,6 +325,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__coarsetime__0_1_14", remote = "https://github.com/ankitects/rust-coarsetime.git", + shallow_since = "1594611111 +1000", commit = "f9e2c86216f0f4803bc75404828318fc206dab29", build_file = Label("//cargo/remote:coarsetime-0.1.14.BUILD.bazel"), init_submodules = True, @@ -912,6 +913,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__hyper_timeout__0_3_1", remote = "https://github.com/ankitects/hyper-timeout.git", + shallow_since = "1604362633 +1000", commit = "f9ef687120d88744c1da50a222e19208b4553503", build_file = Label("//cargo/remote:hyper-timeout-0.3.1.BUILD.bazel"), init_submodules = True, @@ -1530,6 +1532,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__prost__0_6_1", remote = "https://github.com/danburkert/prost.git", + shallow_since = "1598739849 -0700", commit = "4ded4a98ef339da0b7babd4efee3fbe8adaf746b", build_file = Label("//cargo/remote:prost-0.6.1.BUILD.bazel"), init_submodules = True, @@ -1539,6 +1542,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__prost_build__0_6_1", remote = "https://github.com/danburkert/prost.git", + shallow_since = "1598739849 -0700", commit = "4ded4a98ef339da0b7babd4efee3fbe8adaf746b", build_file = Label("//cargo/remote:prost-build-0.6.1.BUILD.bazel"), init_submodules = True, @@ -1548,6 +1552,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__prost_derive__0_6_1", remote = "https://github.com/danburkert/prost.git", + shallow_since = "1598739849 -0700", commit = "4ded4a98ef339da0b7babd4efee3fbe8adaf746b", build_file = Label("//cargo/remote:prost-derive-0.6.1.BUILD.bazel"), init_submodules = True, @@ -1557,6 +1562,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__prost_types__0_6_1", remote = "https://github.com/danburkert/prost.git", + shallow_since = "1598739849 -0700", commit = "4ded4a98ef339da0b7babd4efee3fbe8adaf746b", build_file = Label("//cargo/remote:prost-types-0.6.1.BUILD.bazel"), init_submodules = True, @@ -1716,6 +1722,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__reqwest__0_10_8", remote = "https://github.com/ankitects/reqwest.git", + shallow_since = "1604362745 +1000", commit = "eab12efe22f370f386d99c7d90e7a964e85dd071", build_file = Label("//cargo/remote:reqwest-0.10.8.BUILD.bazel"), init_submodules = True, @@ -2195,6 +2202,7 @@ def raze_fetch_remote_crates(): new_git_repository, name = "raze__tokio_io_timeout__0_4_0", remote = "https://github.com/ankitects/tokio-io-timeout.git", + shallow_since = "1598411535 +1000", commit = "96e1358555c49905de89170f2b1102a7d8b6c4c2", build_file = Label("//cargo/remote:tokio-io-timeout-0.4.0.BUILD.bazel"), init_submodules = True, diff --git a/cargo/update.py b/cargo/update.py index e4f26b685..b3ae6fc7e 100644 --- a/cargo/update.py +++ b/cargo/update.py @@ -6,10 +6,32 @@ EXTRA_DEPS = [ 'pyo3 = { version = "0.12.3", features = ["extension-module"] }' ] +# If you get a message like the following during a build: +# +# DEBUG: Rule 'raze__reqwest__0_10_8' indicated that a canonical reproducible +# form can be obtained by modifying arguments shallow_since = "1604362745 +1000" + +# ...then the commit and shallow_since argument should be added below, as this +# will remove the debug warning, and speed up the git clone. + +COMMITS_SHALLOW_SINCE = { + # reqwest + "eab12efe22f370f386d99c7d90e7a964e85dd071": "1604362745 +1000", + # hyper-timeout + "f9ef687120d88744c1da50a222e19208b4553503": "1604362633 +1000", + # tokio-io-timeout + "96e1358555c49905de89170f2b1102a7d8b6c4c2": "1598411535 +1000", + # prost + "4ded4a98ef339da0b7babd4efee3fbe8adaf746b": "1598739849 -0700", + # coarsetime + "f9e2c86216f0f4803bc75404828318fc206dab29": "1594611111 +1000", +} + import os import sys import subprocess import shutil +import re if os.getcwd() != os.path.abspath(os.path.dirname(__file__)): print("Run this from the cargo/ folder") @@ -31,12 +53,33 @@ with open("../rslib/Cargo.toml") as file: deps.extend(EXTRA_DEPS) +# write out Cargo.toml with open("Cargo.toml", "w") as file: file.write(header) file.write("\n".join(deps)) +# update Cargo.lock subprocess.run(["cargo", "update"], check=True) + +# generate cargo-raze files if os.path.exists("remote"): shutil.rmtree("remote") subprocess.run(["cargo-raze"], check=True) os.remove("Cargo.toml") + +output_lines = [] +commit_re = re.compile('\s+commit = "([0-9a-f]+)",') +with open("crates.bzl") as file: + for line in file.readlines(): + if match := commit_re.match(line): + commit = match.group(1) + if commit in line: + if since := COMMITS_SHALLOW_SINCE.get(commit): + output_lines.append(f' shallow_since = "{since}",\n') + else: + print(f"{commit} not in COMMITS_SHALLOW_SINCE") + output_lines.append(line) + +with open("crates.bzl", "w") as file: + for line in output_lines: + file.write(line) diff --git a/rslib/Cargo.toml b/rslib/Cargo.toml index a434d1f32..29d40e13b 100644 --- a/rslib/Cargo.toml +++ b/rslib/Cargo.toml @@ -32,7 +32,7 @@ async-compression = { version = "0.3.5", features = ["stream", "gzip"] } blake3 = "0.3.5" bytes = "0.5.5" chrono = "0.4.13" -coarsetime = { git = "https://github.com/ankitects/rust-coarsetime.git", branch="old-mac-compat" } +coarsetime = { git = "https://github.com/ankitects/rust-coarsetime.git", tag="anki-2020-11-03" } failure = "0.1.8" flate2 = "1.0.16" fluent = { git = "https://github.com/ankitects/fluent-rs.git", branch="32bit-panic" }