@@ -4,64 +4,16 @@ use std::env;
4
4
5
5
fn main ( ) {
6
6
let embed_path = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) . join ( "embed" ) ;
7
- let out_path = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
8
7
9
8
println ! ( "cargo:rustc-env=VSLANG=1033" ) ;
10
9
println ! ( "cargo:rerun-if-changed=embed" ) ;
11
10
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
12
11
13
- let code_dir = out_path. join ( "quickjs" ) ;
14
- if code_dir. exists ( ) {
15
- std:: fs:: remove_dir_all ( & code_dir) . unwrap ( ) ;
16
- }
17
- copy_dir:: copy_dir ( embed_path. join ( "quickjs" ) , & code_dir)
18
- . expect ( "Could not copy quickjs directory" ) ;
19
-
20
- std:: fs:: copy (
21
- embed_path. join ( "extensions.c" ) ,
22
- code_dir. join ( "extensions.c" ) ,
23
- )
24
- . expect ( "Could not copy extensions.c" ) ;
25
-
26
- std:: fs:: copy (
27
- embed_path. join ( "extensions.h" ) ,
28
- code_dir. join ( "extensions.h" ) ,
29
- )
30
- . expect ( "Could not copy extensions.h" ) ;
31
-
32
- eprintln ! ( "Applying patches..." ) ;
33
- apply_patches ( & code_dir) ;
34
-
35
12
eprintln ! ( "Generating bindings..." ) ;
36
13
do_bindgen ( ) ;
37
14
38
15
eprintln ! ( "Compiling quickjs..." ) ;
39
- compile_lib ( & code_dir) ;
40
- }
41
-
42
- fn apply_patches ( code_dir : & PathBuf ) {
43
- use std:: fs;
44
-
45
- eprintln ! ( "Applying patches..." ) ;
46
- let embed_path = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) . join ( "embed" ) ;
47
- let patches_path = embed_path. join ( "patches" ) ;
48
- for patch in fs:: read_dir ( patches_path) . expect ( "Could not open patches directory" ) {
49
- let patch = patch. expect ( "Could not open patch" ) ;
50
- eprintln ! ( "Applying {:?}..." , patch. file_name( ) ) ;
51
- let status = std:: process:: Command :: new ( "patch" )
52
- . current_dir ( code_dir)
53
- . arg ( "-i" )
54
- . arg ( patch. path ( ) )
55
- . arg ( "--binary" )
56
- . spawn ( )
57
- . expect ( "Could not apply patches" )
58
- . wait ( )
59
- . expect ( "Could not apply patches" ) ;
60
- assert ! (
61
- status. success( ) ,
62
- "Patch command returned non-zero exit code"
63
- ) ;
64
- }
16
+ compile_lib ( & embed_path) ;
65
17
}
66
18
67
19
fn compile_lib ( code_dir : & Path ) {
@@ -77,10 +29,10 @@ fn compile_lib(code_dir: &Path) {
77
29
[
78
30
// extensions.c has included quickjs.c
79
31
"extensions.c" ,
80
- "cutils.c" ,
81
- "libbf.c" ,
82
- "libregexp.c" ,
83
- "libunicode.c" ,
32
+ "./quickjs/ cutils.c" ,
33
+ "./quickjs/ libbf.c" ,
34
+ "./quickjs/ libregexp.c" ,
35
+ "./quickjs/ libunicode.c" ,
84
36
]
85
37
. iter ( )
86
38
. map ( |f| code_dir. join ( f) ) ,
0 commit comments