@@ -10,7 +10,7 @@ use cargo::core::{FeatureValue, Package, PackageId, Target, TargetKind, Workspac
10
10
use cargo:: ops:: { self , CompileFilter , CompileOptions , FilterRule , LibRule } ;
11
11
use cargo:: util:: command_prelude:: { ArgMatches , ArgMatchesExt , CompileMode , ProfileChecking } ;
12
12
use cargo:: util:: interning:: InternedString ;
13
- use cargo:: { CliResult , Config } ;
13
+ use cargo:: { CliResult , GlobalContext } ;
14
14
15
15
use anyhow:: Context as _;
16
16
use cargo_util:: paths:: { copy, create, create_dir_all, open, read, read_bytes, write} ;
@@ -29,7 +29,7 @@ fn build_include_file(
29
29
root_output : & Path ,
30
30
root_path : & Path ,
31
31
) -> anyhow:: Result < ( ) > {
32
- ws. config ( )
32
+ ws. gctx ( )
33
33
. shell ( )
34
34
. status ( "Building" , "header file using cbindgen" ) ?;
35
35
let mut header_name = PathBuf :: from ( name) ;
@@ -64,7 +64,7 @@ fn copy_prebuilt_include_file(
64
64
build_targets : & BuildTargets ,
65
65
root_output : & Path ,
66
66
) -> anyhow:: Result < ( ) > {
67
- let mut shell = ws. config ( ) . shell ( ) ;
67
+ let mut shell = ws. gctx ( ) . shell ( ) ;
68
68
shell. status ( "Populating" , "uninstalled header directory" ) ?;
69
69
let path = & format ! ( "PKG_CONFIG_PATH=\" {}\" " , root_output. display( ) ) ;
70
70
shell. verbose ( move |s| s. note ( path) ) ?;
@@ -90,7 +90,7 @@ fn build_pc_files(
90
90
root_output : & Path ,
91
91
pc : & PkgConfig ,
92
92
) -> anyhow:: Result < ( ) > {
93
- ws. config ( ) . shell ( ) . status ( "Building" , "pkg-config files" ) ?;
93
+ ws. gctx ( ) . shell ( ) . status ( "Building" , "pkg-config files" ) ?;
94
94
build_pc_file ( filename, root_output, pc) ?;
95
95
let pc_uninstalled = pc. uninstalled ( root_output) ;
96
96
build_pc_file (
@@ -140,7 +140,7 @@ fn build_def_file(
140
140
let env = & target. env ;
141
141
142
142
if os == "windows" && env == "msvc" {
143
- ws. config ( )
143
+ ws. gctx ( )
144
144
. shell ( )
145
145
. status ( "Building" , ".def file using dumpbin" ) ?;
146
146
@@ -213,7 +213,7 @@ fn build_implib_file(
213
213
if os == "windows" {
214
214
let arch = & target. arch ;
215
215
if env == "gnu" {
216
- ws. config ( )
216
+ ws. gctx ( )
217
217
. shell ( )
218
218
. status ( "Building" , "implib using dlltool" ) ?;
219
219
@@ -242,7 +242,7 @@ fn build_implib_file(
242
242
Err ( anyhow:: anyhow!( "Command failed {:?}" , dlltool_command) )
243
243
}
244
244
} else {
245
- ws. config ( ) . shell ( ) . status ( "Building" , "implib using lib" ) ?;
245
+ ws. gctx ( ) . shell ( ) . status ( "Building" , "implib using lib" ) ?;
246
246
let target_str = format ! ( "{}-pc-windows-msvc" , & target. arch) ;
247
247
let mut lib = match cc:: windows_registry:: find ( & target_str, "lib.exe" ) {
248
248
Some ( command) => command,
@@ -802,14 +802,14 @@ fn load_manifest_capi_config(
802
802
803
803
fn compile_options (
804
804
ws : & Workspace ,
805
- config : & Config ,
805
+ gctx : & GlobalContext ,
806
806
args : & ArgMatches ,
807
807
profile : InternedString ,
808
808
compile_mode : CompileMode ,
809
809
) -> anyhow:: Result < CompileOptions > {
810
810
use cargo:: core:: compiler:: CompileKind ;
811
811
let mut compile_opts =
812
- args. compile_options ( config , compile_mode, Some ( ws) , ProfileChecking :: Custom ) ?;
812
+ args. compile_options ( gctx , compile_mode, Some ( ws) , ProfileChecking :: Custom ) ?;
813
813
814
814
compile_opts. build_config . requested_profile = profile;
815
815
@@ -827,12 +827,12 @@ fn compile_options(
827
827
828
828
compile_opts. build_config . unit_graph = false ;
829
829
830
- let rustc = config . load_global_rustc ( Some ( ws) ) ?;
830
+ let rustc = gctx . load_global_rustc ( Some ( ws) ) ?;
831
831
832
832
// Always set the target, requested_kinds is a vec of a single element.
833
833
if compile_opts. build_config . requested_kinds [ 0 ] . is_host ( ) {
834
834
compile_opts. build_config . requested_kinds =
835
- CompileKind :: from_requested_targets ( config , & [ rustc. host . to_string ( ) ] ) ?
835
+ CompileKind :: from_requested_targets ( gctx , & [ rustc. host . to_string ( ) ] ) ?
836
836
}
837
837
838
838
Ok ( compile_opts)
@@ -893,7 +893,6 @@ impl Executor for Exec {
893
893
894
894
use cargo:: core:: compiler:: { unit_graph, UnitInterner } ;
895
895
use cargo:: ops:: create_bcx;
896
- use cargo:: util:: profile;
897
896
898
897
fn set_deps_args (
899
898
dep : & UnitDep ,
@@ -959,11 +958,10 @@ fn compile_with_exec(
959
958
}
960
959
961
960
if options. build_config . unit_graph {
962
- unit_graph:: emit_serialized_unit_graph ( & bcx. roots , & bcx. unit_graph , ws. config ( ) ) ?;
961
+ unit_graph:: emit_serialized_unit_graph ( & bcx. roots , & bcx. unit_graph , ws. gctx ( ) ) ?;
963
962
return Ok ( HashMap :: new ( ) ) ;
964
963
}
965
- let _p = profile:: start ( "compiling" ) ;
966
- let cx = cargo:: core:: compiler:: Context :: new ( & bcx) ?;
964
+ let cx = cargo:: core:: compiler:: BuildRunner :: new ( & bcx) ?;
967
965
968
966
let r = cx. compile ( exec) ?;
969
967
@@ -1039,7 +1037,7 @@ impl CPackage {
1039
1037
1040
1038
pub fn cbuild (
1041
1039
ws : & mut Workspace ,
1042
- config : & Config ,
1040
+ config : & GlobalContext ,
1043
1041
args : & ArgMatches ,
1044
1042
default_profile : & str ,
1045
1043
) -> anyhow:: Result < ( Vec < CPackage > , CompileOptions ) > {
@@ -1240,7 +1238,7 @@ pub fn cbuild(
1240
1238
1241
1239
pub fn ctest (
1242
1240
ws : & Workspace ,
1243
- config : & Config ,
1241
+ config : & GlobalContext ,
1244
1242
args : & ArgMatches ,
1245
1243
packages : & [ CPackage ] ,
1246
1244
mut compile_opts : CompileOptions ,
0 commit comments