You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-16 14:17:34 +02:00
Make install-tools command work from any directory in the workspace. (#2725)
This fixes #2708 by creating a CARGO_WORKSPACE_DIR env variable to act as an anchor path, allowing the installation of mdbook-exerciser and mdbook-course to succeed from any directory within the repository. Based on the approach mentioned here: https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993 --------- Co-authored-by: Eric Githinji <egithinji@google.com>
This commit is contained in:
@ -2,3 +2,8 @@
|
|||||||
# We use this alias for task automation in the project.
|
# We use this alias for task automation in the project.
|
||||||
# See README in xtask directory.
|
# See README in xtask directory.
|
||||||
xtask = "run --package xtask --"
|
xtask = "run --package xtask --"
|
||||||
|
|
||||||
|
[env]
|
||||||
|
# To provide an anchor to the root of the workspace when working with paths.
|
||||||
|
# See https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993
|
||||||
|
CARGO_WORKSPACE_DIR = { value = "", relative = true }
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
use anyhow::{anyhow, Ok, Result};
|
use anyhow::{anyhow, Ok, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use std::path::Path;
|
||||||
use std::{env, process::Command};
|
use std::{env, process::Command};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
@ -54,6 +55,11 @@ fn execute_task() -> Result<()> {
|
|||||||
fn install_tools() -> Result<()> {
|
fn install_tools() -> Result<()> {
|
||||||
println!("Installing project tools...");
|
println!("Installing project tools...");
|
||||||
|
|
||||||
|
let path_to_mdbook_exerciser =
|
||||||
|
Path::new(env!("CARGO_WORKSPACE_DIR")).join("mdbook-exerciser");
|
||||||
|
let path_to_mdbook_course =
|
||||||
|
Path::new(env!("CARGO_WORKSPACE_DIR")).join("mdbook-course");
|
||||||
|
|
||||||
let install_args = vec![
|
let install_args = vec![
|
||||||
// The --locked flag is important for reproducible builds. It also
|
// The --locked flag is important for reproducible builds. It also
|
||||||
// avoids breakage due to skews between mdbook and mdbook-svgbob.
|
// avoids breakage due to skews between mdbook and mdbook-svgbob.
|
||||||
@ -62,9 +68,11 @@ fn install_tools() -> Result<()> {
|
|||||||
vec!["mdbook-pandoc", "--locked", "--version", "0.9.3"],
|
vec!["mdbook-pandoc", "--locked", "--version", "0.9.3"],
|
||||||
vec!["mdbook-i18n-helpers", "--locked", "--version", "0.3.5"],
|
vec!["mdbook-i18n-helpers", "--locked", "--version", "0.3.5"],
|
||||||
vec!["i18n-report", "--locked", "--version", "0.2.0"],
|
vec!["i18n-report", "--locked", "--version", "0.2.0"],
|
||||||
// These packages are located in this repository
|
// Mdbook-exerciser and mdbook-course are located in this repository.
|
||||||
vec!["--path", "mdbook-exerciser", "--locked"],
|
// To make it possible to install them from any directory we need to
|
||||||
vec!["--path", "mdbook-course", "--locked"],
|
// specify their path from the workspace root.
|
||||||
|
vec!["--path", path_to_mdbook_exerciser.to_str().unwrap(), "--locked"],
|
||||||
|
vec!["--path", path_to_mdbook_course.to_str().unwrap(), "--locked"],
|
||||||
];
|
];
|
||||||
|
|
||||||
for args in &install_args {
|
for args in &install_args {
|
||||||
|
Reference in New Issue
Block a user