]>
Commit | Line | Data |
---|---|---|
0a29b90c FG |
1 | use crate::sources::CRATES_IO_DOMAIN; |
2 | ||
3 | pub use self::cargo_clean::{clean, CleanOptions}; | |
4 | pub use self::cargo_compile::{ | |
5 | compile, compile_with_exec, compile_ws, create_bcx, print, resolve_all_features, CompileOptions, | |
6 | }; | |
7 | pub use self::cargo_compile::{CompileFilter, FilterRule, LibRule, Packages}; | |
8 | pub use self::cargo_doc::{doc, DocOptions}; | |
9 | pub use self::cargo_fetch::{fetch, FetchOptions}; | |
10 | pub use self::cargo_generate_lockfile::generate_lockfile; | |
11 | pub use self::cargo_generate_lockfile::update_lockfile; | |
12 | pub use self::cargo_generate_lockfile::UpdateOptions; | |
13 | pub use self::cargo_install::{install, install_list}; | |
14 | pub use self::cargo_new::{init, new, NewOptions, NewProjectKind, VersionControl}; | |
15 | pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions}; | |
16 | pub use self::cargo_package::{check_yanked, package, package_one, PackageOpts}; | |
17 | pub use self::cargo_pkgid::pkgid; | |
18 | pub use self::cargo_read_manifest::{read_package, read_packages}; | |
19 | pub use self::cargo_run::run; | |
20 | pub use self::cargo_test::{run_benches, run_tests, TestOptions}; | |
21 | pub use self::cargo_uninstall::uninstall; | |
22 | pub use self::fix::{fix, fix_exec_rustc, fix_get_proxy_lock_addr, FixOptions}; | |
23 | pub use self::lockfile::{load_pkg_lockfile, resolve_to_string, write_pkg_lockfile}; | |
24 | pub use self::registry::HttpTimeout; | |
25 | pub use self::registry::{configure_http_handle, http_handle, http_handle_and_timeout}; | |
26 | pub use self::registry::{modify_owners, yank, OwnersOptions, PublishOpts}; | |
27 | pub use self::registry::{needs_custom_http_transport, registry_login, registry_logout, search}; | |
28 | pub use self::registry::{publish, RegistryCredentialConfig}; | |
29 | pub use self::resolve::{ | |
30 | add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws, resolve_ws_with_opts, | |
31 | WorkspaceResolve, | |
32 | }; | |
33 | pub use self::vendor::{vendor, VendorOptions}; | |
34 | ||
35 | pub mod cargo_add; | |
36 | mod cargo_clean; | |
37 | pub(crate) mod cargo_compile; | |
38 | pub mod cargo_config; | |
39 | mod cargo_doc; | |
40 | mod cargo_fetch; | |
41 | mod cargo_generate_lockfile; | |
42 | mod cargo_install; | |
43 | mod cargo_new; | |
44 | mod cargo_output_metadata; | |
45 | mod cargo_package; | |
46 | mod cargo_pkgid; | |
47 | mod cargo_read_manifest; | |
48 | pub mod cargo_remove; | |
49 | mod cargo_run; | |
50 | mod cargo_test; | |
51 | mod cargo_uninstall; | |
52 | mod common_for_install_and_uninstall; | |
53 | mod fix; | |
54 | pub(crate) mod lockfile; | |
55 | pub(crate) mod registry; | |
56 | pub(crate) mod resolve; | |
57 | pub mod tree; | |
58 | mod vendor; | |
59 | ||
60 | /// Returns true if the dependency is either git or path, false otherwise | |
61 | /// Error if a git/path dep is transitive, but has no version (registry source). | |
62 | /// This check is performed on dependencies before publishing or packaging | |
63 | fn check_dep_has_version(dep: &crate::core::Dependency, publish: bool) -> crate::CargoResult<bool> { | |
64 | let which = if dep.source_id().is_path() { | |
65 | "path" | |
66 | } else if dep.source_id().is_git() { | |
67 | "git" | |
68 | } else { | |
69 | return Ok(false); | |
70 | }; | |
71 | ||
72 | if !dep.specified_req() && dep.is_transitive() { | |
73 | let dep_version_source = dep.registry_id().map_or_else( | |
74 | || CRATES_IO_DOMAIN.to_string(), | |
75 | |registry_id| registry_id.display_registry_name(), | |
76 | ); | |
77 | anyhow::bail!( | |
78 | "all dependencies must have a version specified when {}.\n\ | |
79 | dependency `{}` does not specify a version\n\ | |
80 | Note: The {} dependency will use the version from {},\n\ | |
81 | the `{}` specification will be removed from the dependency declaration.", | |
82 | if publish { "publishing" } else { "packaging" }, | |
83 | dep.package_name(), | |
84 | if publish { "published" } else { "packaged" }, | |
85 | dep_version_source, | |
86 | which, | |
87 | ) | |
88 | } | |
89 | Ok(true) | |
90 | } |