@@ -46,22 +46,60 @@ fn clone(our_dir: impl AsRef<Path>) -> Result<()> {
46
46
47
47
#[ cfg( all( feature = "build" , not( feature = "no-build" ) ) ) ]
48
48
pub fn build ( out_dir : impl AsRef < Path > ) -> Result < ( ) > {
49
- use cmake :: Config ;
49
+ use std :: process :: Command ;
50
50
51
51
std:: env:: set_current_dir ( & out_dir) ?;
52
52
// std::fs::create_dir_all(out_dir.as_ref().join("build"))?;
53
53
54
- let libjpeg = Config :: new ( "libjpeg" )
55
- . generator ( "Unix Makefiles" )
56
- . define ( "ENABLE_SHARED" , "OFF" )
57
- . define ( "RELATIVE_PATH" , out_dir. as_ref ( ) . join ( "libjpeg" ) )
58
- . define ( "ENABLE_STATIC" , "ON" )
59
- . define ( "WITH_JPEG8" , "ON" )
60
- . define ( "WITH_JPEG7" , "ON" )
61
- . build ( ) ;
54
+ // let libjpeg = Config::new("libjpeg")
55
+ // .generator("Unix Makefiles")
56
+ // .define("ENABLE_SHARED", "OFF")
57
+ // .define("RELATIVE_PATH", out_dir.as_ref().join("libjpeg"))
58
+ // .define("ENABLE_STATIC", "ON")
59
+ // .define("WITH_JPEG8", "ON")
60
+ // .define("WITH_JPEG7", "ON")
61
+ // .build();
62
+
63
+ let libjpeg = Command :: new ( "cmake" )
64
+ . arg ( "-G" )
65
+ . arg ( "Unix Makefiles" )
66
+ . arg ( "-DENABLE_SHARED=OFF" )
67
+ . arg ( "-DENABLE_STATIC=ON" )
68
+ . arg ( "-DWITH_JPEG8=ON" )
69
+ . arg ( "-DWITH_JPEG7=ON" )
70
+ . arg ( "libjpeg" )
71
+ . arg ( "-Blibjpeg" )
72
+ . output ( ) ?;
73
+
74
+ if !libjpeg. status . success ( ) {
75
+ return Err ( format ! (
76
+ "Failed to configure libjpeg: {}" ,
77
+ String :: from_utf8_lossy( & libjpeg. stderr)
78
+ )
79
+ . into ( ) ) ;
80
+ }
81
+
82
+ let libjpeg_build = Command :: new ( "cmake" )
83
+ . arg ( "--build" )
84
+ . arg ( "." )
85
+ . arg ( "-j" )
86
+ . arg ( std:: thread:: available_parallelism ( ) ?. to_string ( ) )
87
+ . output ( ) ?;
88
+ if !libjpeg_build. status . success ( ) {
89
+ return Err ( format ! (
90
+ "Failed to build libjpeg: {}" ,
91
+ String :: from_utf8_lossy( & libjpeg_build. stderr)
92
+ )
93
+ . into ( ) ) ;
94
+ }
62
95
63
96
// let mut libjpeg = cc::Build::new();
64
97
// libjpeg.include("libjpeg");
98
+ // libjpeg.cpp(false);
99
+
100
+ // libjpeg.include("libjpeg/");
101
+ // // libjpeg.file("libjpeg/jconfigint.h");
102
+ // libjpeg.define("INLINE", "__inline__ __attribute__((always_inline))");
65
103
// libjpeg.file("libjpeg/cdjpeg.c");
66
104
// libjpeg.file("libjpeg/cjpeg.c");
67
105
// libjpeg.file("libjpeg/djpeg.c");
@@ -148,15 +186,15 @@ pub fn build(out_dir: impl AsRef<Path>) -> Result<()> {
148
186
// libjpeg.file("libjpeg/wrppm.c");
149
187
// libjpeg.file("libjpeg/wrtarga.c");
150
188
// libjpeg.compile("jpeg");
151
- // println!(
152
- // "cargo:rustc-link-search=native={}",
153
- // out_dir.as_ref().join("lib").display()
154
- // );
155
-
156
189
println ! (
157
190
"cargo:rustc-link-search=native={}" ,
158
- libjpeg . join( "build " ) . display( )
191
+ out_dir . as_ref ( ) . join( "lib " ) . display( )
159
192
) ;
193
+
194
+ // println!(
195
+ // "cargo:rustc-link-search=native={}",
196
+ // libjpeg.join("build").display()
197
+ // );
160
198
println ! ( "cargo:rustc-link-lib=static=jpeg" ) ;
161
199
162
200
Ok ( ( ) )
0 commit comments