@@ -25,7 +25,8 @@ fn main() {
25
25
println ! ( "cargo:root={}" , dst. display( ) ) ;
26
26
println ! ( "cargo:include={}/include" , dst. display( ) ) ;
27
27
println ! ( "cargo:rerun-if-changed=xz-5.2.2/configure" ) ;
28
-
28
+ let features = env:: var ( "CARGO_CFG_TARGET_FEATURE" )
29
+ . unwrap_or ( String :: new ( ) ) ;
29
30
if target. contains ( "msvc" ) {
30
31
println ! ( "cargo:rustc-link-lib=static=liblzma" ) ;
31
32
let mut msbuild = gcc:: windows_registry:: find ( & target, "msbuild" )
@@ -36,13 +37,20 @@ fn main() {
36
37
let _ = fs:: remove_dir_all ( dst. join ( "include" ) ) ;
37
38
cp_r ( Path :: new ( "xz-5.2.2" ) , & build) ;
38
39
40
+ let profile = if features. contains ( "crt-static" ) {
41
+ "ReleaseMT"
42
+ } else {
43
+ "Release"
44
+ } ;
45
+
39
46
run ( msbuild. current_dir ( build. join ( "windows" ) )
40
47
. arg ( "liblzma.vcxproj" )
41
- . arg ( "/p:Configuration=Release" ) ) ;
48
+ . arg ( & format ! ( "/p:Configuration={}" , profile ) ) ) ;
42
49
t ! ( fs:: create_dir( dst. join( "lib" ) ) ) ;
43
50
t ! ( fs:: create_dir( dst. join( "include" ) ) ) ;
44
51
let platform = if target. contains ( "x86_64" ) { "X64" } else { "Win32" } ;
45
- t ! ( fs:: copy( build. join( "windows/Release" )
52
+ t ! ( fs:: copy( build. join( "windows" )
53
+ . join( profile)
46
54
. join( platform)
47
55
. join( "liblzma/liblzma.lib" ) ,
48
56
dst. join( "lib/liblzma.lib" ) ) ) ;
0 commit comments