Giter Site home page Giter Site logo

nacardin / cargo-build-deps Goto Github PK

View Code? Open in Web Editor NEW
72.0 72.0 19.0 23 KB

A cargo subcommand to build dependencies, helps speed up docker builds by allowing dependencies to be built earlier and cached.

License: Apache License 2.0

Rust 100.00%

cargo-build-deps's People

Contributors

dependabot-preview[bot] avatar nacardin avatar rodoufu avatar rpsrosario avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cargo-build-deps's Issues

Support nightly

error: Found argument '+nightly' which wasn't expected, or isn't valid in this context

USAGE:
    cargo-build-deps [FLAGS] [build-deps]

Fails with cross-compilation conditional dependency

If I do cargo new cargo-build-deps-fail-example and then change the Cargo.toml to:

[package]
name = "cargo-build-deps-fail-example"
version = "0.1.0"
edition = "2021"

[target.'cfg(target_env = "musl")'.dependencies]
tikv-jemallocator = "0.4.1"

these all work:

cargo run
cargo run --target=x86_64-unknown-linux-gnu
cargo run --target=x86_64-unknown-linux-musl

but these all fail:

cargo build-deps
cargo build-deps --target=x86_64-unknown-linux-gnu
cargo build-deps --target=x86_64-unknown-linux-musl

Adding --release has no effect.

Changing [target.'cfg(target_env = "musl")'.dependencies] to [target.'cfg(target_env = "gnu")'.dependencies] causes all commands above to work. I'm executing this from Ubuntu (target_env = "gnu") so it seems to be affected not by the target but by the environment you're running it from.

Error with RUST_BACKTRACE=1:

    Updating crates.io index
building packages: ["tikv-jemallocator:0.4.1"]
building package: "tikv-jemallocator:0.4.1"
thread 'main' panicked at 'activated_features for invalid package: features did not find PackageId { name: "tikv-jemallocator", version: "0.4.1", source: "registry `crates-io`" } false

Stack backtrace:
   0: <anyhow::Error>::msg::<alloc::string::String>
   1: <cargo::core::resolver::features::ResolvedFeatures>::activated_features_int
   2: cargo::ops::cargo_compile::generate_targets
   3: cargo::ops::cargo_compile::create_bcx
   4: cargo::ops::cargo_compile::compile_ws
   5: cargo::ops::cargo_compile::compile
   6: cargo::commands::build::exec
   7: cargo::cli::execute_subcommand
   8: cargo::cli::main
   9: cargo::main
  10: std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  11: std::rt::lang_start::<()>::{closure#0}
  12: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/core/src/ops/function.rs:259:13
  13: std::panicking::try::do_call
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/panicking.rs:485:40
  14: std::panicking::try
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/panicking.rs:449:19
  15: std::panic::catch_unwind
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/panic.rs:136:14
  16: std::rt::lang_start_internal::{{closure}}
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/rt.rs:128:48
  17: std::panicking::try::do_call
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/panicking.rs:485:40
  18: std::panicking::try
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/panicking.rs:449:19
  19: std::panic::catch_unwind
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/panic.rs:136:14
  20: std::rt::lang_start_internal
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/rt.rs:128:20
  21: main
  22: __libc_start_main
  23: <unknown>', src/tools/cargo/src/cargo/core/resolver/features.rs:266:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/core/src/panicking.rs:135:14
   2: core::result::unwrap_failed
             at /rustc/08df8b81d6e723c66fee579d57d61dc60bc21fc1/library/core/src/result.rs:1737:5
   3: cargo::ops::cargo_compile::generate_targets
   4: cargo::ops::cargo_compile::create_bcx
   5: cargo::ops::cargo_compile::compile_ws
   6: cargo::ops::cargo_compile::compile
   7: cargo::commands::build::exec
   8: cargo::cli::execute_subcommand
   9: cargo::cli::main
  10: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Error: "Exited with status code: 101"

Support features

error: Found argument '--features' which wasn't expected, or isn't valid in this context

USAGE:
    cargo-build-deps --release

For more information try --help

Cargo build-deps crashes on execution

Hello,

I tried to use build-deps on a project I just cloned, and encountered the following error:

Updating webpki v0.21.3 -> v0.21.4
    Removing webpki-roots v0.18.0
    Removing webpki-roots v0.19.0
      Adding webpki-roots v0.20.0
      Adding webpki-roots v0.21.0
    Updating wfd v0.1.4 -> v0.1.7
      Adding which v3.1.1
    Updating window_clipboard v0.1.2 -> v0.1.3
    Updating xcursor v0.3.2 -> v0.3.3
    Updating xkbcommon-sys v0.7.4 -> v0.7.5
thread 'main' panicked at 'failed to parse package', /home/noe/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-build-deps-0.1.5/src/main.rs:59:22

Useful Information

  • OS => Arch Linux
  • rustup version => 1.23.1 (3df2264a9 2020-11-30)
  • rustc active version => rustc 1.51.0-nightly (44e3daf5e 2020-12-31)
  • cargo version => cargo 1.50.0-nightly (75d5d8cff 2020-12-22)
  • build-deps version => cargo-build-deps-0.1.5

Steps to reproduce

git clone [email protected]:veloren/veloren.git
cd veloren && cargo build-deps

Is there something I'm doing wrong? Running a cargo build will work just fine.

Have a good day!

May there be a way to opt out cargo update

In main.rs, there is a line

 execute_command(Command::new("cargo").arg("update"))?;

this line forces a dependency update. The update may cause a lot of compilation and the user have no option to opt out if a reproducible build is desire. In a docker build process, this may invalidate cache.

Getting a panic while building deps

This is the backtrace I got after running RUST_BACKTRACE=1 cargo-build-deps --release

    Updating crates.io index
thread 'main' panicked at 'failed to parse version from depencency string', src/libcore/option.rs:1188:5
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1025
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:193
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:471
  11: rust_begin_unwind
             at src/libstd/panicking.rs:375
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:84
  13: core::option::expect_failed
             at src/libcore/option.rs:1188
  14: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  15: cargo_build_deps::main
  16: std::rt::lang_start::{{closure}}
  17: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  18: std::panicking::try::do_call
             at src/libstd/panicking.rs:292
  19: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  20: std::panicking::try
             at src/libstd/panicking.rs:270
  21: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  22: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  23: main
  24: __libc_start_main
  25: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This is my Cargo.toml file

[package]
name = "junks"
version = "0.1.0"
authors = ["Palash Nigam <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
num = "0.2.1"
rand = "0.7.3"
regex = "1.3.4"
rustc-serialize = "0.3.24"
serde = "1.0.104"

Updated Cargo.lock

I don't think build-deps should update the Cargo.lock file. After I ran it I saw a diff in my Cargo.lock:

It should just install the set version in Cargo.lock

add option to ignore local dependencies

this is useful for larger projects that have nested crates.
i think this will look something like the following:

  • have an optional flag for ignoring local dependencies
  • if that flag is set, when you are parsing dependencies and come across a dependency with a 'path' specification, recurse to the dependent Cargo.toml and return the filtered dependencies from there, recursing further if necessary

i'll try and tackle this soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.