This repository was archived by the owner on Jul 10, 2023. It is now read-only.
File tree 2 files changed +18
-24
lines changed
2 files changed +18
-24
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,7 @@ repository = "https://github.com/servo/heapsize"
8
8
build = " build.rs"
9
9
10
10
[build-dependencies ]
11
- semver = " 0.2"
12
- chrono = " 0.2"
11
+ regex = " 0.1"
13
12
14
13
[features ]
15
14
unstable = []
Original file line number Diff line number Diff line change 1
- extern crate semver;
2
- extern crate chrono;
1
+ extern crate regex;
3
2
4
3
use std:: env:: var;
5
4
use std:: process:: Command ;
6
- use semver:: Version ;
7
- use chrono:: NaiveDate ;
5
+ use std:: str;
8
6
9
7
fn main ( ) {
10
- let unprefixed_jemalloc_version: Version = "1.8.0-dev" . parse ( ) . unwrap ( ) ;
11
- let unprefixed_jemalloc_day: NaiveDate = "2016-02-16" . parse ( ) . unwrap ( ) ;
12
-
13
- let rustc_version_string = Command :: new ( var ( "RUSTC" ) . unwrap_or ( "rustc" . into ( ) ) )
14
- . arg ( "--version" ) . output ( ) . ok ( )
15
- . and_then ( |o| String :: from_utf8 ( o. stdout ) . ok ( ) )
16
- . unwrap ( ) ;
17
- let rustc_version: Version = rustc_version_string. split_whitespace ( )
18
- . skip ( 1 ) . next ( )
19
- . and_then ( |r| r. parse ( ) . ok ( ) )
8
+ let version_line = Command :: new ( var ( "RUSTC" ) . unwrap_or ( "rustc" . into ( ) ) )
9
+ . arg ( "--version" )
10
+ . output ( )
11
+ . unwrap ( )
12
+ . stdout ;
13
+ let captures = regex:: Regex :: new ( r"rustc (\d+)\.(\d+)\.(\d+).+(\d{4}-\d{2}-\d{2})\)" )
14
+ . unwrap ( )
15
+ . captures ( str:: from_utf8 ( & version_line) . unwrap ( ) )
20
16
. unwrap ( ) ;
21
- let rustc_day: NaiveDate = rustc_version_string. split_whitespace ( )
22
- . last ( )
23
- . and_then ( |r| r[ ..r. len ( ) -1 ] . parse ( ) . ok ( ) )
24
- . unwrap ( ) ;
25
-
26
- if rustc_day < unprefixed_jemalloc_day
27
- || rustc_version < unprefixed_jemalloc_version
28
- {
17
+ let version = (
18
+ captures[ 1 ] . parse :: < u32 > ( ) . unwrap ( ) ,
19
+ captures[ 2 ] . parse :: < u32 > ( ) . unwrap ( ) ,
20
+ captures[ 3 ] . parse :: < u32 > ( ) . unwrap ( ) ,
21
+ & captures[ 4 ] ,
22
+ ) ;
23
+ if version < ( 1 , 8 , 0 , "2016-02-14" ) {
29
24
println ! ( "cargo:rustc-cfg=prefixed_jemalloc" ) ;
30
25
}
31
26
}
You can’t perform that action at this time.
0 commit comments