aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-03-21 17:05:42 -0400
committerNick Mathewson <nickm@torproject.org>2018-03-21 17:05:42 -0400
commit03e787e220a92996ecca1c9bc262f29ee37ececc (patch)
tree80d555623548c6527ae0b69c32f5c2ed504c0743
parent2c36a02bb148e7331675f65628939dec448a8db1 (diff)
parent95b78d4178a07b9b33782a2d3193aa176a88ca80 (diff)
downloadtor-03e787e220a92996ecca1c9bc262f29ee37ececc.tar.gz
tor-03e787e220a92996ecca1c9bc262f29ee37ececc.zip
Merge branch 'maint-0.3.3'
-rw-r--r--doc/HACKING/CodingStandardsRust.md36
-rwxr-xr-xscripts/maint/updateRustDependencies.sh45
m---------src/ext/rust0
-rw-r--r--src/rust/Cargo.lock29
-rw-r--r--src/rust/external/Cargo.toml2
-rw-r--r--src/rust/protover/Cargo.toml2
-rw-r--r--src/rust/smartlist/Cargo.toml2
-rw-r--r--src/rust/tor_allocate/Cargo.toml2
-rw-r--r--src/rust/tor_util/Cargo.toml2
9 files changed, 100 insertions, 20 deletions
diff --git a/doc/HACKING/CodingStandardsRust.md b/doc/HACKING/CodingStandardsRust.md
index 72b62a3f57..d9496c08f7 100644
--- a/doc/HACKING/CodingStandardsRust.md
+++ b/doc/HACKING/CodingStandardsRust.md
@@ -61,10 +61,46 @@ In general, we use modules from only the Rust standard library
whenever possible. We will review including external crates on a
case-by-case basis.
+If a crate only contains traits meant for compatibility between Rust
+crates, such as [the digest crate](https://crates.io/crates/digest) or
+[the failure crate](https://crates.io/crates/failure), it is very likely
+permissible to add it as a dependency. However, a brief review should
+be conducted as to the usefulness of implementing external traits
+(i.e. how widespread is the usage, how many other crates either
+implement the traits or have trait bounds based upon them), as well as
+the stability of the traits (i.e. if the trait is going to change, we'll
+potentially have to re-do all our implementations of it).
+
+For large external libraries, especially which implement features which
+would be labour-intensive to reproduce/maintain ourselves, such as
+cryptographic or mathematical/statistics libraries, only crates which
+have stabilised to 1.0.0 should be considered, however, again, we may
+make exceptions on a case-by-case basis.
+
Currently, Tor requires that you use the latest stable Rust version. At
some point in the future, we will freeze on a given stable Rust version,
to ensure backward compatibility with stable distributions that ship it.
+ Updating/Adding Dependencies
+------------------------------
+
+To add/remove/update dependencies, first add your dependencies,
+exactly specifying their versions, into the appropriate *crate-level*
+`Cargo.toml` in `src/rust/` (i.e. *not* `/src/rust/Cargo.toml`, but
+instead the one for your crate). Also, investigate whether your
+dependency has any optional dependencies which are unnecessary but are
+enabled by default. If so, you'll likely be able to enable/disable
+them via some feature, e.g.:
+
+```toml
+[dependencies]
+foo = { version = "1.0.0", default-features = false }
+```
+
+Next, run `/scripts/maint/updateRustDependencies.sh`. Then, go into
+`src/ext/rust` and commit the changes to the `tor-rust-dependencies`
+repo.
+
Documentation
---------------
diff --git a/scripts/maint/updateRustDependencies.sh b/scripts/maint/updateRustDependencies.sh
new file mode 100755
index 0000000000..a5a92579d3
--- /dev/null
+++ b/scripts/maint/updateRustDependencies.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2018 The Tor Project, Inc.
+# Copyright (c) 2018 isis agora lovecruft
+# See LICENSE for license information
+#
+# updateRustDependencies.sh
+# -------------------------
+# Update our vendored Rust dependencies, either adding/removing
+# dependencies and/or upgrading current dependencies to newer
+# versions.
+#
+# To use this script, first add your dependencies, exactly specifying
+# their versions, into the appropriate *crate-level* Cargo.toml in
+# src/rust/ (i.e. *not* /src/rust/Cargo.toml, but instead the one for
+# your crate).
+#
+# Next, run this script. Then, go into src/ext/rust and commit the
+# changes to the tor-rust-dependencies repo.
+
+set -e
+
+HERE=`dirname $(realpath $0)`
+TOPLEVEL=`dirname $(dirname $HERE)`
+TOML="$TOPLEVEL/src/rust/Cargo.toml"
+VENDORED="$TOPLEVEL/src/ext/rust/crates"
+CARGO=`which cargo`
+
+if ! test -f "$TOML" ; then
+ printf "Error: Couldn't find workspace Cargo.toml in expected location: %s\n" "$TOML"
+fi
+
+if ! test -d "$VENDORED" ; then
+ printf "Error: Couldn't find directory for Rust dependencies! Expected location: %s\n" "$VENDORED"
+fi
+
+if test -z "$CARGO" ; then
+ printf "Error: cargo must be installed and in your \$PATH\n"
+fi
+
+if test -z `cargo --list | grep vendor` ; then
+ printf "Error: cargo-vendor not installed\n"
+fi
+
+$CARGO vendor -v --locked --explicit-version --no-delete --sync $TOML $VENDORED
diff --git a/src/ext/rust b/src/ext/rust
-Subproject 240296800824e40b10cb8c16da0e71156335394
+Subproject 2422d7acccc44c633ea825b630ceee6777773cc
diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock
index 116ef17f1c..717add222f 100644
--- a/src/rust/Cargo.lock
+++ b/src/rust/Cargo.lock
@@ -1,22 +1,13 @@
-[root]
-name = "tor_util"
-version = "0.0.1"
-dependencies = [
- "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
- "tor_allocate 0.0.1",
- "tor_log 0.1.0",
-]
-
[[package]]
name = "external"
version = "0.0.1"
dependencies = [
- "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
-version = "0.2.22"
+version = "0.2.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -24,7 +15,7 @@ name = "protover"
version = "0.0.1"
dependencies = [
"external 0.0.1",
- "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"smartlist 0.0.1",
"tor_allocate 0.0.1",
"tor_log 0.1.0",
@@ -35,14 +26,14 @@ dependencies = [
name = "smartlist"
version = "0.0.1"
dependencies = [
- "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tor_allocate"
version = "0.0.1"
dependencies = [
- "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -61,5 +52,13 @@ dependencies = [
"tor_util 0.0.1",
]
+[[package]]
+name = "tor_util"
+version = "0.0.1"
+dependencies = [
+ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tor_allocate 0.0.1",
+]
+
[metadata]
-"checksum libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "babb8281da88cba992fa1f4ddec7d63ed96280a1a53ec9b919fd37b53d71e502"
+"checksum libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "f54263ad99207254cf58b5f701ecb432c717445ea2ee8af387334bdd1a03fdff"
diff --git a/src/rust/external/Cargo.toml b/src/rust/external/Cargo.toml
index bccd7033a7..b5957b1079 100644
--- a/src/rust/external/Cargo.toml
+++ b/src/rust/external/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.0.1"
name = "external"
[dependencies]
-libc = "0.2.22"
+libc = "=0.2.39"
[lib]
name = "external"
diff --git a/src/rust/protover/Cargo.toml b/src/rust/protover/Cargo.toml
index 3f70155ef8..af1089c914 100644
--- a/src/rust/protover/Cargo.toml
+++ b/src/rust/protover/Cargo.toml
@@ -7,7 +7,7 @@ name = "protover"
testing = ["tor_log/testing"]
[dependencies]
-libc = "0.2.22"
+libc = "=0.2.39"
[dependencies.smartlist]
path = "../smartlist"
diff --git a/src/rust/smartlist/Cargo.toml b/src/rust/smartlist/Cargo.toml
index 51f486c4d7..6ddcbee8e9 100644
--- a/src/rust/smartlist/Cargo.toml
+++ b/src/rust/smartlist/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.0.1"
name = "smartlist"
[dependencies]
-libc = "0.2.22"
+libc = "0.2.39"
[lib]
name = "smartlist"
diff --git a/src/rust/tor_allocate/Cargo.toml b/src/rust/tor_allocate/Cargo.toml
index ceb08b78ab..468425f115 100644
--- a/src/rust/tor_allocate/Cargo.toml
+++ b/src/rust/tor_allocate/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.0.1"
name = "tor_allocate"
[dependencies]
-libc = "0.2.22"
+libc = "=0.2.39"
[lib]
name = "tor_allocate"
diff --git a/src/rust/tor_util/Cargo.toml b/src/rust/tor_util/Cargo.toml
index adc3390b53..a606a280b2 100644
--- a/src/rust/tor_util/Cargo.toml
+++ b/src/rust/tor_util/Cargo.toml
@@ -15,5 +15,5 @@ path = "../tor_allocate"
path = "../tor_log"
[dependencies]
-libc = "0.2.22"
+libc = "=0.2.39"