1
1
use std:: env;
2
- use std:: process;
3
2
4
3
fn main ( ) {
5
4
if env:: var ( "CARGO_FEATURE_RE_PCRE2" ) . is_ok ( ) {
6
5
pkg_config:: probe_library ( "libpcre2-8" ) . unwrap ( ) ;
7
6
}
8
- if env:: var ( "CARGO_FEATURE_RE_STDCPP" ) . is_ok ( ) {
9
- // stdcpp is a C++ library, so we need to compile our shim layer.
10
- if !env:: var ( "CARGO_FEATURE_LIBCXX" ) . is_ok ( ) {
11
- // use default stdlib
12
- cc:: Build :: new ( )
13
- . cpp ( true )
14
- . file ( "src/ffi/stdcpp.cpp" )
15
- . compile ( "libcstdcpp.a" ) ;
16
- } else {
17
- // use libc++ stdlib
18
- cc:: Build :: new ( )
19
- . cpp ( true )
20
- . file ( "src/ffi/stdcpp.cpp" )
21
- . compiler ( "clang++" )
22
- . cpp_link_stdlib ( "c++" )
23
- . cpp_set_stdlib ( "c++" )
24
- . compile ( "libcstdcpp.a" ) ;
25
- }
26
- }
27
- if env:: var ( "CARGO_FEATURE_RE_BOOST" ) . is_ok ( ) {
28
- // stdcpp is a C++ library, so we need to compile our shim layer.
29
- cc:: Build :: new ( )
30
- . cpp ( true )
31
- . file ( "src/ffi/stdcpp.cpp" )
32
- . define ( "USE_BOOST" , None )
33
- . compile ( "libcboost.a" ) ;
34
- println ! ( "cargo:rustc-link-lib=boost_regex" ) ;
35
- }
36
7
if env:: var ( "CARGO_FEATURE_RE_RE2" ) . is_ok ( ) {
37
8
// RE2 is a C++ library, so we need to compile our shim layer.
38
9
cc:: Build :: new ( )
@@ -46,84 +17,4 @@ fn main() {
46
17
if env:: var ( "CARGO_FEATURE_RE_TCL" ) . is_ok ( ) {
47
18
pkg_config:: probe_library ( "tcl" ) . unwrap ( ) ;
48
19
}
49
-
50
- if env:: var ( "CARGO_FEATURE_RE_DPHOBOS_DMD" ) . is_ok ( ) {
51
- process:: Command :: new ( "dmd" )
52
- . arg ( "--version" )
53
- . stdout ( process:: Stdio :: null ( ) )
54
- . stderr ( process:: Stdio :: null ( ) )
55
- . spawn ( )
56
- . unwrap ( ) ;
57
-
58
- let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
59
- let out_file = & format ! ( "-of={}/libdphobos-dmd.a" , out_dir) ;
60
- let is_compile_time =
61
- env:: var ( "CARGO_FEATURE_RE_DPHOBOS_DMD_CT" ) . is_ok ( ) ;
62
- let extra_args =
63
- if is_compile_time { vec ! [ "-version=CtRegex" ] } else { vec ! [ ] } ;
64
-
65
- let res = process:: Command :: new ( "dmd" )
66
- . arg ( "-w" )
67
- . arg ( "-lib" )
68
- . arg ( "-O" )
69
- . arg ( "-release" )
70
- . arg ( "-inline" )
71
- . arg ( "-Isrc/ffi" )
72
- . args ( extra_args)
73
- . arg ( "src/ffi/d_phobos.d" )
74
- . arg ( "src/ffi/d_phobos_ct.d" )
75
- . arg ( out_file)
76
- . output ( )
77
- . expect ( "unable to compile dphobos-regex (dmd)" ) ;
78
-
79
- if !res. status . success ( ) {
80
- println ! ( "{}" , String :: from_utf8_lossy( & res. stderr) ) ;
81
- }
82
- assert ! ( res. status. success( ) ) ;
83
-
84
- println ! ( "cargo:rustc-link-search=native={}" , out_dir) ;
85
- println ! ( "cargo:rustc-link-lib=dphobos-dmd" ) ;
86
- println ! ( "cargo:rustc-link-lib=phobos2" ) ;
87
- }
88
-
89
- if env:: var ( "CARGO_FEATURE_RE_DPHOBOS_LDC" ) . is_ok ( ) {
90
- process:: Command :: new ( "ldc" )
91
- . arg ( "--version" )
92
- . stdout ( process:: Stdio :: null ( ) )
93
- . stderr ( process:: Stdio :: null ( ) )
94
- . spawn ( )
95
- . unwrap ( ) ;
96
-
97
- let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
98
- let out_file = & format ! ( "-of={}/libdphobos-ldc.a" , out_dir) ;
99
-
100
- let is_compile_time =
101
- env:: var ( "CARGO_FEATURE_RE_DPHOBOS_LDC_CT" ) . is_ok ( ) ;
102
- let extra_args =
103
- if is_compile_time { vec ! [ "-d-version=CtRegex" ] } else { vec ! [ ] } ;
104
-
105
- let res = process:: Command :: new ( "ldc" )
106
- . arg ( "-w" )
107
- . arg ( "-lib" )
108
- . arg ( "-O3" )
109
- . arg ( "-release" )
110
- . arg ( "-mcpu=native" )
111
- . arg ( "-Isrc/ffi" )
112
- . args ( extra_args)
113
- . arg ( "src/ffi/d_phobos.d" )
114
- . arg ( "src/ffi/d_phobos_ct.d" )
115
- . arg ( out_file)
116
- . output ( )
117
- . expect ( "unable to compile dphobos-regex (ldc)" ) ;
118
-
119
- if !res. status . success ( ) {
120
- println ! ( "{}" , String :: from_utf8_lossy( & res. stderr) ) ;
121
- }
122
- assert ! ( res. status. success( ) ) ;
123
-
124
- println ! ( "cargo:rustc-link-search=native={}" , out_dir) ;
125
- println ! ( "cargo:rustc-link-lib=dphobos-ldc" ) ;
126
- println ! ( "cargo:rustc-link-lib=druntime-ldc" ) ;
127
- println ! ( "cargo:rustc-link-lib=phobos2-ldc" ) ;
128
- }
129
20
}
0 commit comments