]> git.proxmox.com Git - cargo.git/commitdiff
Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc
authorDan Aloni <dan@kernelim.com>
Thu, 26 Sep 2019 18:21:55 +0000 (21:21 +0300)
committerDan Aloni <dan@kernelim.com>
Thu, 26 Sep 2019 18:24:34 +0000 (21:24 +0300)
12 files changed:
1  2 
src/cargo/core/compiler/build_config.rs
src/cargo/core/compiler/context/mod.rs
src/cargo/core/compiler/custom_build.rs
src/cargo/core/compiler/job_queue.rs
src/cargo/core/compiler/mod.rs
src/cargo/core/compiler/standard_lib.rs
src/cargo/core/compiler/timings.rs
src/cargo/core/compiler/unit_dependencies.rs
src/cargo/ops/cargo_clean.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/common_for_install_and_uninstall.rs
src/cargo/util/toml/mod.rs

index 77f90fa3ca016e728a023f057b58eb07b5c11440,d39294660ce6358312a36208ecc295415667606e..0ba59ecc947bd7f9ebca2834c6b6c180a64464f2
@@@ -2,37 -2,19 +2,36 @@@ use std::cell::RefCell
  
  use serde::ser;
  
+ use crate::core::compiler::{CompileKind, CompileTarget};
  use crate::util::ProcessBuilder;
- use crate::util::{CargoResult, CargoResultExt, Config, RustfixDiagnosticServer};
+ use crate::util::{CargoResult, Config, RustfixDiagnosticServer};
  
 +#[derive(Debug, Clone)]
 +pub enum ProfileKind {
 +    Dev,
 +    Release,
 +    Custom(String),
 +}
 +
 +impl ProfileKind {
 +    pub fn name(&self) -> &str {
 +        match self {
 +            ProfileKind::Dev => "dev",
 +            ProfileKind::Release => "release",
 +            ProfileKind::Custom(name) => &name,
 +        }
 +    }
 +}
 +
  /// Configuration information for a rustc build.
  #[derive(Debug)]
  pub struct BuildConfig {
-     /// The target arch triple.
-     /// Default: host arch.
-     pub requested_target: Option<String>,
+     /// The requested kind of compilation for this session
+     pub requested_kind: CompileKind,
      /// Number of rustc jobs to run in parallel.
      pub jobs: u32,
 -    /// `true` if we are building for release.
 -    pub release: bool,
 +    /// Build profile
 +    pub profile_kind: ProfileKind,
      /// The mode we are compiling in.
      pub mode: CompileMode,
      /// `true` to print stdout in JSON format (for machine reading).
@@@ -108,9 -75,9 +92,9 @@@ impl BuildConfig 
          let jobs = jobs.or(cfg_jobs).unwrap_or(::num_cpus::get() as u32);
  
          Ok(BuildConfig {
-             requested_target: target,
+             requested_kind,
              jobs,
 -            release: false,
 +            profile_kind: ProfileKind::Dev,
              mode,
              message_format: MessageFormat::Human,
              force_rebuild: false,
index 0d021f82a94ff64877f88eb686e8b998f1505e8b,1600644b55de6c0217843f96c91cdef49651e0a0..d7327df3cbd437ac2b973b37aea917aa71ed4d50
@@@ -298,17 -298,18 +298,15 @@@ impl<'a, 'cfg> Context<'a, 'cfg> 
          export_dir: Option<PathBuf>,
          units: &[Unit<'a>],
      ) -> CargoResult<()> {
 -        let dest = if self.bcx.build_config.release {
 -            "release"
 -        } else {
 -            "debug"
 -        };
 -        let host_layout = Layout::new(self.bcx.ws, None, dest)?;
 +        let profile_kind = &self.bcx.build_config.profile_kind;
 +        let dest = self.bcx.profiles.get_dir_name(profile_kind);
 +        let host_layout = Layout::new(self.bcx.ws, None, &dest)?;
-         let target_layout = match self.bcx.build_config.requested_target.as_ref() {
-             Some(target) => {
-                 let layout = Layout::new(self.bcx.ws, Some(target), &dest)?;
-                 standard_lib::prepare_sysroot(&layout)?;
-                 Some(layout)
-             }
-             None => None,
-         };
+         let mut targets = HashMap::new();
+         if let CompileKind::Target(target) = self.bcx.build_config.requested_kind {
 -            let layout = Layout::new(self.bcx.ws, Some(target), dest)?;
++            let layout = Layout::new(self.bcx.ws, Some(target), &dest)?;
+             standard_lib::prepare_sysroot(&layout)?;
+             targets.insert(target, layout);
+         }
          self.primary_packages
              .extend(units.iter().map(|u| u.pkg.package_id()));
  
Simple merge
index abfcd20e61fe4bb083d69808459bf17c7559980c,542427d9f805128c8ebfd78562404e4da2cdfcbc..ac1ef3f25f7bdd6b4c3e035888d292e4f6b381df
@@@ -25,9 -26,8 +26,8 @@@ use std::sync::Arc
  use failure::Error;
  use lazycell::LazyCell;
  use log::debug;
- use serde::Serialize;
  
 -pub use self::build_config::{BuildConfig, CompileMode, MessageFormat};
 +pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, ProfileKind};
  pub use self::build_context::{BuildContext, FileFlavor, TargetConfig, TargetInfo};
  use self::build_plan::BuildPlan;
  pub use self::compilation::{Compilation, Doctest};
Simple merge
index a164c0ff569f35c618bb1d2050a94daf72024324,7adc7d2fe07e74facd05d1bac89b930da787e639..c6b937f1e7b101ce3bb8cd1ddfa548fcd625ac0f
@@@ -4,7 -4,7 +4,9 @@@ use std::path::Path
  
  use crate::core::compiler::unit_dependencies;
  use crate::core::compiler::UnitInterner;
- use crate::core::compiler::{BuildConfig, BuildContext, CompileMode, Context, Kind, ProfileKind};
 -use crate::core::compiler::{BuildConfig, BuildContext, CompileKind, CompileMode, Context};
++use crate::core::compiler::{
++    BuildConfig, BuildContext, CompileKind, CompileMode, Context, ProfileKind,
++};
  use crate::core::profiles::UnitFor;
  use crate::core::Workspace;
  use crate::ops;
index 8b30b3ea8d57f29fa5a72a45e6ffaf7e6b2afabc,8233f6ceaeb5f60543391da3d0c05eb618d0915c..9895adef2cf4b2f99c57219fb18d1a193d3b3c29
@@@ -294,17 -294,8 +294,11 @@@ pub fn compile_ws<'a>
          }
      }
  
-     let default_arch_kind = if build_config.requested_target.is_some() {
-         Kind::Target
-     } else {
-         Kind::Host
-     };
      let profiles = ws.profiles();
  
 +    // Early check for whether the profile is defined.
 +    let _ = profiles.base_profile(&build_config.profile_kind)?;
 +
      let specs = spec.to_package_id_specs(ws)?;
      let dev_deps = ws.require_optional_deps() || filter.need_dev_deps(build_config.mode);
      let opts = ResolveOpts::new(dev_deps, features, all_features, !no_default_features);
index 5b964bc003b2dac433a643462292e28ea926a0bd,af79e5513113a1ccf7625a4a79e743671c40ca14..3fec1ee436c100a19fbdce247bf1c68a6526d78c
@@@ -455,9 -455,9 +455,9 @@@ impl CrateListingV2 
              info.features = feature_set(&opts.features);
              info.all_features = opts.all_features;
              info.no_default_features = opts.no_default_features;
 -            info.profile = profile_name(opts.build_config.release).to_string();
 +            info.profile = opts.build_config.profile_name().to_string();
-             info.target = Some(target);
-             info.rustc = Some(rustc);
+             info.target = Some(target.to_string());
+             info.rustc = Some(rustc.to_string());
          } else {
              self.installs.insert(
                  pkg.package_id(),
                      features: feature_set(&opts.features),
                      all_features: opts.all_features,
                      no_default_features: opts.no_default_features,
 -                    profile: profile_name(opts.build_config.release).to_string(),
 +                    profile: opts.build_config.profile_name().to_string(),
-                     target: Some(target),
-                     rustc: Some(rustc),
+                     target: Some(target.to_string()),
+                     rustc: Some(rustc.to_string()),
                      other: BTreeMap::new(),
                  },
              );
Simple merge