@@ -100,60 +100,64 @@ pub fn find(build: &Build) {
100
100
. chain ( iter:: once ( build. build ) )
101
101
. collect :: < HashSet < _ > > ( ) ;
102
102
for target in targets. into_iter ( ) {
103
- let mut cfg = new_cc_build ( build, target) ;
104
- let config = build. config . target_config . get ( & target) ;
105
- if let Some ( cc) = config. and_then ( |c| c. cc . as_ref ( ) ) {
106
- cfg. compiler ( cc) ;
107
- } else {
108
- set_compiler ( & mut cfg, Language :: C , target, config, build) ;
109
- }
103
+ find_target ( build, target) ;
104
+ }
105
+ }
110
106
111
- let compiler = cfg. get_compiler ( ) ;
112
- let ar = if let ar @ Some ( ..) = config. and_then ( |c| c. ar . clone ( ) ) {
113
- ar
114
- } else {
115
- cc2ar ( compiler. path ( ) , target)
116
- } ;
107
+ pub fn find_target ( build : & Build , target : TargetSelection ) {
108
+ let mut cfg = new_cc_build ( build, target) ;
109
+ let config = build. config . target_config . get ( & target) ;
110
+ if let Some ( cc) = config. and_then ( |c| c. cc . as_ref ( ) ) {
111
+ cfg. compiler ( cc) ;
112
+ } else {
113
+ set_compiler ( & mut cfg, Language :: C , target, config, build) ;
114
+ }
117
115
118
- build. cc . borrow_mut ( ) . insert ( target, compiler. clone ( ) ) ;
119
- let cflags = build. cflags ( target, GitRepo :: Rustc , CLang :: C ) ;
116
+ let compiler = cfg. get_compiler ( ) ;
117
+ let ar = if let ar @ Some ( ..) = config. and_then ( |c| c. ar . clone ( ) ) {
118
+ ar
119
+ } else {
120
+ cc2ar ( compiler. path ( ) , target)
121
+ } ;
120
122
121
- // If we use llvm-libunwind, we will need a C++ compiler as well for all targets
122
- // We'll need one anyways if the target triple is also a host triple
123
- let mut cfg = new_cc_build ( build, target) ;
124
- cfg. cpp ( true ) ;
125
- let cxx_configured = if let Some ( cxx) = config. and_then ( |c| c. cxx . as_ref ( ) ) {
126
- cfg. compiler ( cxx) ;
127
- true
128
- } else if build. hosts . contains ( & target) || build. build == target {
129
- set_compiler ( & mut cfg, Language :: CPlusPlus , target, config, build) ;
130
- true
131
- } else {
132
- // Use an auto-detected compiler (or one configured via `CXX_target_triple` env vars).
133
- cfg. try_get_compiler ( ) . is_ok ( )
134
- } ;
123
+ build. cc . borrow_mut ( ) . insert ( target, compiler. clone ( ) ) ;
124
+ let cflags = build. cflags ( target, GitRepo :: Rustc , CLang :: C ) ;
135
125
136
- // for VxWorks, record CXX compiler which will be used in lib.rs:linker()
137
- if cxx_configured || target. contains ( "vxworks" ) {
138
- let compiler = cfg. get_compiler ( ) ;
139
- build. cxx . borrow_mut ( ) . insert ( target, compiler) ;
140
- }
126
+ // If we use llvm-libunwind, we will need a C++ compiler as well for all targets
127
+ // We'll need one anyways if the target triple is also a host triple
128
+ let mut cfg = new_cc_build ( build, target) ;
129
+ cfg. cpp ( true ) ;
130
+ let cxx_configured = if let Some ( cxx) = config. and_then ( |c| c. cxx . as_ref ( ) ) {
131
+ cfg. compiler ( cxx) ;
132
+ true
133
+ } else if build. hosts . contains ( & target) || build. build == target {
134
+ set_compiler ( & mut cfg, Language :: CPlusPlus , target, config, build) ;
135
+ true
136
+ } else {
137
+ // Use an auto-detected compiler (or one configured via `CXX_target_triple` env vars).
138
+ cfg. try_get_compiler ( ) . is_ok ( )
139
+ } ;
141
140
142
- build. verbose ( & format ! ( "CC_{} = {:?}" , & target. triple, build. cc( target) ) ) ;
143
- build. verbose ( & format ! ( "CFLAGS_{} = {:?}" , & target. triple, cflags) ) ;
144
- if let Ok ( cxx) = build. cxx ( target) {
145
- let cxxflags = build. cflags ( target, GitRepo :: Rustc , CLang :: Cxx ) ;
146
- build. verbose ( & format ! ( "CXX_{} = {:?}" , & target. triple, cxx) ) ;
147
- build. verbose ( & format ! ( "CXXFLAGS_{} = {:?}" , & target. triple, cxxflags) ) ;
148
- }
149
- if let Some ( ar) = ar {
150
- build. verbose ( & format ! ( "AR_{} = {:?}" , & target. triple, ar) ) ;
151
- build. ar . borrow_mut ( ) . insert ( target, ar) ;
152
- }
141
+ // for VxWorks, record CXX compiler which will be used in lib.rs:linker()
142
+ if cxx_configured || target. contains ( "vxworks" ) {
143
+ let compiler = cfg. get_compiler ( ) ;
144
+ build. cxx . borrow_mut ( ) . insert ( target, compiler) ;
145
+ }
153
146
154
- if let Some ( ranlib) = config. and_then ( |c| c. ranlib . clone ( ) ) {
155
- build. ranlib . borrow_mut ( ) . insert ( target, ranlib) ;
156
- }
147
+ build. verbose ( & format ! ( "CC_{} = {:?}" , & target. triple, build. cc( target) ) ) ;
148
+ build. verbose ( & format ! ( "CFLAGS_{} = {:?}" , & target. triple, cflags) ) ;
149
+ if let Ok ( cxx) = build. cxx ( target) {
150
+ let cxxflags = build. cflags ( target, GitRepo :: Rustc , CLang :: Cxx ) ;
151
+ build. verbose ( & format ! ( "CXX_{} = {:?}" , & target. triple, cxx) ) ;
152
+ build. verbose ( & format ! ( "CXXFLAGS_{} = {:?}" , & target. triple, cxxflags) ) ;
153
+ }
154
+ if let Some ( ar) = ar {
155
+ build. verbose ( & format ! ( "AR_{} = {:?}" , & target. triple, ar) ) ;
156
+ build. ar . borrow_mut ( ) . insert ( target, ar) ;
157
+ }
158
+
159
+ if let Some ( ranlib) = config. and_then ( |c| c. ranlib . clone ( ) ) {
160
+ build. ranlib . borrow_mut ( ) . insert ( target, ranlib) ;
157
161
}
158
162
}
159
163
0 commit comments