@@ -6,12 +6,27 @@ use db::{connect_db, add_package_into_database, add_build_into_database, add_pat
6
6
use cargo:: core:: Package ;
7
7
use std:: process:: { Command , Output } ;
8
8
use std:: path:: PathBuf ;
9
+ use std:: fs:: remove_dir_all;
9
10
use postgres:: Connection ;
10
11
use rustc_serialize:: json:: Json ;
11
12
use error:: Result ;
12
13
use regex:: Regex ;
13
14
14
15
16
+ /// List of targets supported by docs.rs
17
+ const TARGETS : [ & ' static str ; 8 ] = [
18
+ "i686-apple-darwin" ,
19
+ "i686-pc-windows-gnu" ,
20
+ "i686-pc-windows-msvc" ,
21
+ "i686-unknown-linux-gnu" ,
22
+ "x86_64-apple-darwin" ,
23
+ "x86_64-pc-windows-gnu" ,
24
+ "x86_64-pc-windows-msvc" ,
25
+ "x86_64-unknown-linux-gnu"
26
+ ] ;
27
+
28
+
29
+
15
30
#[ derive( Debug ) ]
16
31
pub struct ChrootBuilderResult {
17
32
pub output : String ,
@@ -57,6 +72,8 @@ impl DocBuilder {
57
72
58
73
info ! ( "Building package {}-{}" , name, version) ;
59
74
75
+ // Start with clean documentation directory
76
+ try!( self . remove_build_dir ( ) ) ;
60
77
61
78
// Database connection
62
79
let conn = try!( connect_db ( ) ) ;
@@ -132,46 +149,9 @@ impl DocBuilder {
132
149
133
150
/// Builds documentation of crate for every target and returns Vec of successfully targets
134
151
fn build_package_for_all_targets ( & self , package : & Package ) -> Vec < String > {
135
- // Temporary skip tier 2 and tier 3 platforms
136
- let targets = [ // "aarch64-apple-ios",
137
- // "aarch64-linux-android",
138
- // "aarch64-unknown-linux-gnu",
139
- // "arm-linux-androideabi",
140
- // "arm-unknown-linux-gnueabi",
141
- // "arm-unknown-linux-gnueabihf",
142
- // "armv7-apple-ios",
143
- // "armv7-linux-androideabi",
144
- // "armv7-unknown-linux-gnueabihf",
145
- // "armv7s-apple-ios",
146
- // "i386-apple-ios",
147
- // "i586-pc-windows-msvc",
148
- // "i586-unknown-linux-gnu",
149
- "i686-apple-darwin" ,
150
- // "i686-linux-android",
151
- "i686-pc-windows-gnu" ,
152
- "i686-pc-windows-msvc" ,
153
- // "i686-unknown-freebsd",
154
- "i686-unknown-linux-gnu" ,
155
- // "i686-unknown-linux-musl",
156
- // "mips-unknown-linux-gnu",
157
- // "mips-unknown-linux-musl",
158
- // "mipsel-unknown-linux-gnu",
159
- // "mipsel-unknown-linux-musl",
160
- // "powerpc-unknown-linux-gnu",
161
- // "powerpc64-unknown-linux-gnu",
162
- // "powerpc64le-unknown-linux-gnu",
163
- "x86_64-apple-darwin" ,
164
- // "x86_64-apple-ios",
165
- "x86_64-pc-windows-gnu" ,
166
- "x86_64-pc-windows-msvc" ,
167
- // "x86_64-rumprun-netbsd",
168
- // "x86_64-unknown-freebsd",
169
- "x86_64-unknown-linux-gnu" /* "x86_64-unknown-linux-musl",
170
- * "x86_64-unknown-netbsd", */ ] ;
171
-
172
152
let mut successfuly_targets = Vec :: new ( ) ;
173
153
174
- for target in targets . iter ( ) {
154
+ for target in TARGETS . iter ( ) {
175
155
debug ! ( "Building {} for {}" , canonical_name( & package) , target) ;
176
156
let cmd = format ! ( "cratesfyi doc {} ={} {}" ,
177
157
package. manifest( ) . name( ) ,
@@ -185,7 +165,7 @@ impl DocBuilder {
185
165
let target_doc_path = PathBuf :: from ( & self . options . chroot_path )
186
166
. join ( "home" )
187
167
. join ( & self . options . chroot_user )
188
- . join ( canonical_name ( & package ) )
168
+ . join ( "cratesfyi" )
189
169
. join ( & target)
190
170
. join ( "doc" ) ;
191
171
if target_doc_path. exists ( ) {
@@ -219,7 +199,7 @@ impl DocBuilder {
219
199
let crate_doc_path = PathBuf :: from ( & self . options . chroot_path )
220
200
. join ( "home" )
221
201
. join ( & self . options . chroot_user )
222
- . join ( canonical_name ( & package ) )
202
+ . join ( "cratesfyi" )
223
203
. join ( target. unwrap_or ( "" ) ) ;
224
204
let destination = PathBuf :: from ( & self . options . destination )
225
205
. join ( format ! ( "{}/{}" ,
@@ -234,8 +214,22 @@ impl DocBuilder {
234
214
235
215
236
216
/// Removes build directory of a package in chroot
237
- fn remove_build_dir ( & self , package : & Package ) -> Result < ( ) > {
238
- let _ = self . chroot_command ( format ! ( "rm -rf {}" , canonical_name( & package) ) ) ;
217
+ fn remove_build_dir ( & self ) -> Result < ( ) > {
218
+ let crate_doc_path = PathBuf :: from ( & self . options . chroot_path )
219
+ . join ( "home" )
220
+ . join ( & self . options . chroot_user )
221
+ . join ( "cratesfyi" )
222
+ . join ( "doc" ) ;
223
+ let _ = remove_dir_all ( crate_doc_path) ;
224
+ for target in TARGETS . iter ( ) {
225
+ let crate_doc_path = PathBuf :: from ( & self . options . chroot_path )
226
+ . join ( "home" )
227
+ . join ( & self . options . chroot_user )
228
+ . join ( "cratesfyi" )
229
+ . join ( target)
230
+ . join ( "doc" ) ;
231
+ let _ = remove_dir_all ( crate_doc_path) ;
232
+ }
239
233
Ok ( ( ) )
240
234
}
241
235
@@ -248,7 +242,7 @@ impl DocBuilder {
248
242
. join ( package. manifest ( ) . name ( ) ) ;
249
243
let source_path = source_path ( & package) . unwrap ( ) ;
250
244
// Some crates don't have documentation, so we don't care if removing_dir_all fails
251
- let _ = self . remove_build_dir ( & package ) ;
245
+ let _ = self . remove_build_dir ( ) ;
252
246
let _ = remove_dir_all ( documentation_path) ;
253
247
let _ = remove_dir_all ( source_path) ;
254
248
Ok ( ( ) )
@@ -280,7 +274,7 @@ impl DocBuilder {
280
274
let crate_doc_path = PathBuf :: from ( & self . options . chroot_path )
281
275
. join ( "home" )
282
276
. join ( & self . options . chroot_user )
283
- . join ( canonical_name ( & package ) )
277
+ . join ( "cratesfyi" )
284
278
. join ( "doc" )
285
279
. join ( package. targets ( ) [ 0 ] . name ( ) . replace ( "-" , "_" ) . to_string ( ) ) ;
286
280
crate_doc_path. exists ( )
@@ -381,7 +375,7 @@ impl DocBuilder {
381
375
let source = PathBuf :: from ( & self . options . chroot_path )
382
376
. join ( "home" )
383
377
. join ( & self . options . chroot_user )
384
- . join ( canonical_name ( & pkg ) )
378
+ . join ( "cratesfyi" )
385
379
. join ( "doc" ) ;
386
380
387
381
// use copy_documentation destination directory so self.clean can remove it when
0 commit comments