Skip to content

Commit 13c4d14

Browse files
committed
refactor: Remove patch operation; Remove unnecessary source code copy to simplify build process
1 parent 783e691 commit 13c4d14

File tree

4 files changed

+7
-102
lines changed

4 files changed

+7
-102
lines changed

libquickjs-sys/build.rs

+5-53
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,16 @@ use std::env;
44

55
fn main() {
66
let embed_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("embed");
7-
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
87

98
println!("cargo:rustc-env=VSLANG=1033");
109
println!("cargo:rerun-if-changed=embed");
1110
println!("cargo:rerun-if-changed=build.rs");
1211

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-
3512
eprintln!("Generating bindings...");
3613
do_bindgen();
3714

3815
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);
6517
}
6618

6719
fn compile_lib(code_dir: &Path) {
@@ -77,10 +29,10 @@ fn compile_lib(code_dir: &Path) {
7729
[
7830
// extensions.c has included quickjs.c
7931
"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",
8436
]
8537
.iter()
8638
.map(|f| code_dir.join(f)),

libquickjs-sys/embed/extensions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "extensions.h"
2-
#include "quickjs.c"
2+
#include "./quickjs/quickjs.c"
33

44
// These are static inline functions in quickjs.h so bindgen does not pick
55
// them up.

libquickjs-sys/embed/extensions.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define WIN32_LEAN_AND_MEAN
55
#define _WIN32_WINNT 0x0602
66

7-
#include "quickjs.h"
7+
#include "./quickjs/quickjs.h"
88

99
#ifndef RUSTY_EXTENSION_H
1010
#define RUSTY_EXTENSION_H

libquickjs-sys/embed/patches/js-tobigint64-overflow.patch

-47
This file was deleted.

0 commit comments

Comments
 (0)