pub use clap::{AppSettings, Arg, ArgMatches};
pub use cargo::{CliError, CliResult, Config};
-pub use cargo::ops::CompileMode;
+pub use cargo::core::compiler::CompileMode;
pub type App = clap::App<'static, 'static>;
use core::{Package, PackageId, Resolve, Target};
use core::profiles::Profile;
-use ops::CompileMode;
use util::errors::{CargoResult, CargoResultExt};
use util::{internal, profile, Config};
use super::fingerprint::Fingerprint;
use super::job_queue::JobQueue;
use super::layout::Layout;
-use super::{BuildContext, Compilation, Executor, FileFlavor, Kind};
+use super::{BuildContext, Compilation, CompileMode, Executor, FileFlavor, Kind};
mod unit_dependencies;
use self::unit_dependencies::build_unit_dependencies;
//! (for example, with and without tests), so we actually build a dependency
//! graph of `Unit`s, which capture these properties.
-use super::{BuildContext, Kind, Unit};
+use super::{BuildContext, CompileMode, Kind, Unit};
use core::dependency::Kind as DepKind;
use core::profiles::ProfileFor;
use core::{Package, Target};
-use ops::CompileMode;
use std::collections::HashMap;
use CargoResult;
// cleared, and avoid building the lib thrice (once with `panic`, once
// without, once for --test). In particular, the lib included for
// doctests and examples are `Build` mode here.
- let profile_for = if unit.mode.is_any_test() || bcx.build_config.test {
+ let profile_for = if unit.mode.is_any_test() || bcx.build_config.test() {
ProfileFor::TestDependency
} else {
ProfileFor::Any
use core::profiles::Profile;
use core::{PackageId, Target};
use handle_error;
-use ops::CompileMode;
use util::{internal, profile, CargoResult, CargoResultExt, ProcessBuilder};
use util::{Config, DependencyQueue, Dirty, Fresh, Freshness};
use super::job::Job;
-use super::{BuildContext, Context, Kind, Unit};
+use super::{BuildContext, CompileMode, Context, Kind, Unit};
/// A management structure of the entire dependency graph to compile.
///
use core::profiles::{Lto, Profile};
use core::shell::ColorChoice;
use core::{Feature, PackageId, Target};
-use ops::CompileMode;
use util::errors::{CargoResult, CargoResultExt, Internal};
use util::paths;
use util::{self, machine_message, Config, Freshness, ProcessBuilder, Rustc};
pub jobs: u32,
/// Whether we are building for release
pub release: bool,
- /// Whether we are running tests
- pub test: bool,
+ /// In what mode we are compiling
+ pub mode: CompileMode,
/// Whether to print std output in json format (for machine reading)
pub message_format: MessageFormat,
}
jobs: Option<u32>,
requested_target: &Option<String>,
rustc_info_cache: Option<PathBuf>,
+ mode: CompileMode,
) -> CargoResult<BuildConfig> {
if let &Some(ref s) = requested_target {
if s.trim().is_empty() {
host: host_config,
target: target_config,
release: false,
- test: false,
+ mode,
message_format: MessageFormat::Human,
})
}
pub fn json_messages(&self) -> bool {
self.message_format == MessageFormat::Json
}
+
+ pub fn test(&self) -> bool {
+ self.mode == CompileMode::Test || self.mode == CompileMode::Bench
+ }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Json,
}
+/// The general "mode" of what to do.
+/// This is used for two purposes. The commands themselves pass this in to
+/// `compile_ws` to tell it the general execution strategy. This influences
+/// the default targets selected. The other use is in the `Unit` struct
+/// to indicate what is being done with a specific target.
+#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash)]
+pub enum CompileMode {
+ /// A target being built for a test.
+ Test,
+ /// Building a target with `rustc` (lib or bin).
+ Build,
+ /// Building a target with `rustc` to emit `rmeta` metadata only. If
+ /// `test` is true, then it is also compiled with `--test` to check it like
+ /// a test.
+ Check { test: bool },
+ /// Used to indicate benchmarks should be built. This is not used in
+ /// `Target` because it is essentially the same as `Test` (indicating
+ /// `--test` should be passed to rustc) and by using `Test` instead it
+ /// allows some de-duping of Units to occur.
+ Bench,
+ /// A target that will be documented with `rustdoc`.
+ /// If `deps` is true, then it will also document all dependencies.
+ Doc { deps: bool },
+ /// A target that will be tested with `rustdoc`.
+ Doctest,
+ /// A marker for Units that represent the execution of a `build.rs`
+ /// script.
+ RunCustomBuild,
+}
+
+impl CompileMode {
+ /// Returns true if the unit is being checked.
+ pub fn is_check(&self) -> bool {
+ match *self {
+ CompileMode::Check { .. } => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this is a doc or doctest. Be careful using this.
+ /// Although both run rustdoc, the dependencies for those two modes are
+ /// very different.
+ pub fn is_doc(&self) -> bool {
+ match *self {
+ CompileMode::Doc { .. } | CompileMode::Doctest => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this is any type of test (test, benchmark, doctest, or
+ /// check-test).
+ pub fn is_any_test(&self) -> bool {
+ match *self {
+ CompileMode::Test
+ | CompileMode::Bench
+ | CompileMode::Check { test: true }
+ | CompileMode::Doctest => true,
+ _ => false,
+ }
+ }
+
+ /// Returns true if this is the *execution* of a `build.rs` script.
+ pub fn is_run_custom_build(&self) -> bool {
+ *self == CompileMode::RunCustomBuild
+ }
+
+ /// List of all modes (currently used by `cargo clean -p` for computing
+ /// all possible outputs).
+ pub fn all_modes() -> &'static [CompileMode] {
+ static ALL: [CompileMode; 9] = [
+ CompileMode::Test,
+ CompileMode::Build,
+ CompileMode::Check { test: true },
+ CompileMode::Check { test: false },
+ CompileMode::Bench,
+ CompileMode::Doc { deps: true },
+ CompileMode::Doc { deps: false },
+ CompileMode::Doctest,
+ CompileMode::RunCustomBuild,
+ ];
+ &ALL
+ }
+}
+
/// Information required to build for a target
#[derive(Clone, Default)]
pub struct TargetConfig {
use std::collections::HashSet;
use std::{cmp, fmt, hash};
+use core::compiler::CompileMode;
use core::interning::InternedString;
use core::Shell;
-use ops::CompileMode;
use util::lev_distance::lev_distance;
use util::toml::{StringOrBool, TomlProfile, U32OrBool};
use util::CargoResult;
use std::fs;
use std::path::Path;
-use core::compiler::{BuildConfig, BuildContext, Context, Kind, Unit};
+use core::compiler::{BuildConfig, BuildContext, CompileMode, Context, Kind, Unit};
use core::profiles::ProfileFor;
use core::Workspace;
-use ops::{self, CompileMode};
+use ops;
use util::errors::{CargoResult, CargoResultExt};
use util::paths;
use util::Config;
}
}
- let mut build_config = BuildConfig::new(config, Some(1), &opts.target, None)?;
+ let mut build_config =
+ BuildConfig::new(config, Some(1), &opts.target, None, CompileMode::Build)?;
build_config.release = opts.release;
let bcx = BuildContext::new(
ws,
use std::sync::Arc;
use core::compiler::{BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor};
-use core::compiler::{Kind, MessageFormat, Unit};
+use core::compiler::{CompileMode, Kind, MessageFormat, Unit};
use core::profiles::{ProfileFor, Profiles};
use core::resolver::{Method, Resolve};
use core::{Package, Source, Target};
}
}
-/// The general "mode" of what to do.
-/// This is used for two purposes. The commands themselves pass this in to
-/// `compile_ws` to tell it the general execution strategy. This influences
-/// the default targets selected. The other use is in the `Unit` struct
-/// to indicate what is being done with a specific target.
-#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash)]
-pub enum CompileMode {
- /// A target being built for a test.
- Test,
- /// Building a target with `rustc` (lib or bin).
- Build,
- /// Building a target with `rustc` to emit `rmeta` metadata only. If
- /// `test` is true, then it is also compiled with `--test` to check it like
- /// a test.
- Check { test: bool },
- /// Used to indicate benchmarks should be built. This is not used in
- /// `Target` because it is essentially the same as `Test` (indicating
- /// `--test` should be passed to rustc) and by using `Test` instead it
- /// allows some de-duping of Units to occur.
- Bench,
- /// A target that will be documented with `rustdoc`.
- /// If `deps` is true, then it will also document all dependencies.
- Doc { deps: bool },
- /// A target that will be tested with `rustdoc`.
- Doctest,
- /// A marker for Units that represent the execution of a `build.rs`
- /// script.
- RunCustomBuild,
-}
-
-impl CompileMode {
- /// Returns true if the unit is being checked.
- pub fn is_check(&self) -> bool {
- match *self {
- CompileMode::Check { .. } => true,
- _ => false,
- }
- }
-
- /// Returns true if this is a doc or doctest. Be careful using this.
- /// Although both run rustdoc, the dependencies for those two modes are
- /// very different.
- pub fn is_doc(&self) -> bool {
- match *self {
- CompileMode::Doc { .. } | CompileMode::Doctest => true,
- _ => false,
- }
- }
-
- /// Returns true if this is any type of test (test, benchmark, doctest, or
- /// check-test).
- pub fn is_any_test(&self) -> bool {
- match *self {
- CompileMode::Test
- | CompileMode::Bench
- | CompileMode::Check { test: true }
- | CompileMode::Doctest => true,
- _ => false,
- }
- }
-
- /// Returns true if this is the *execution* of a `build.rs` script.
- pub fn is_run_custom_build(&self) -> bool {
- *self == CompileMode::RunCustomBuild
- }
-
- /// List of all modes (currently used by `cargo clean -p` for computing
- /// all possible outputs).
- pub fn all_modes() -> &'static [CompileMode] {
- static ALL: [CompileMode; 9] = [
- CompileMode::Test,
- CompileMode::Build,
- CompileMode::Check { test: true },
- CompileMode::Check { test: false },
- CompileMode::Bench,
- CompileMode::Doc { deps: true },
- CompileMode::Doc { deps: false },
- CompileMode::Doctest,
- CompileMode::RunCustomBuild,
- ];
- &ALL
- }
-}
-
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Packages {
Default,
let rustc_info_cache = ws.target_dir()
.join(".rustc_info.json")
.into_path_unlocked();
- let mut build_config = BuildConfig::new(config, jobs, &target, Some(rustc_info_cache))?;
+ let mut build_config = BuildConfig::new(config, jobs, &target, Some(rustc_info_cache), mode)?;
build_config.release = release;
- build_config.test = mode == CompileMode::Test || mode == CompileMode::Bench;
build_config.message_format = message_format;
let default_arch_kind = if build_config.requested_target.is_some() {
Kind::Target
-use core::compiler::{BuildConfig, Kind, TargetInfo};
+use core::compiler::{BuildConfig, CompileMode, Kind, TargetInfo};
use core::{PackageSet, Resolve, Workspace};
use ops;
use std::collections::HashSet;
let (packages, resolve) = ops::resolve_ws(ws)?;
let jobs = Some(1);
- let build_config = BuildConfig::new(ws.config(), jobs, &options.target, None)?;
+ let build_config =
+ BuildConfig::new(ws.config(), jobs, &options.target, None, CompileMode::Build)?;
let target_info = TargetInfo::new(ws.config(), &build_config, Kind::Target)?;
{
let mut fetched_packages = HashSet::new();
use tar::{Archive, Builder, EntryType, Header};
use core::{Package, Source, SourceId, Workspace};
-use core::compiler::{DefaultExecutor, MessageFormat};
+use core::compiler::{CompileMode, DefaultExecutor, MessageFormat};
use sources::PathSource;
use util::{self, internal, Config, FileLock};
use util::paths;
},
release: false,
message_format: MessageFormat::Human,
- mode: ops::CompileMode::Build,
+ mode: CompileMode::Build,
target_rustdoc_args: None,
target_rustc_args: None,
export_dir: None,
pub use self::cargo_clean::{clean, CleanOptions};
pub use self::cargo_compile::{compile, compile_with_exec, compile_ws, CompileOptions};
-pub use self::cargo_compile::{CompileFilter, CompileMode, FilterRule, Packages};
+pub use self::cargo_compile::{CompileFilter, FilterRule, Packages};
pub use self::cargo_read_manifest::{read_package, read_packages};
pub use self::cargo_run::run;
pub use self::cargo_install::{install, install_list, uninstall};