Skip to content

Commit b3109be

Browse files
committed
publish 0.6.4
1 parent 9584ff5 commit b3109be

File tree

3 files changed

+69
-16
lines changed

3 files changed

+69
-16
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ members = [
88
]
99

1010
[workspace.package]
11-
version = "0.6.0"
11+
version = "0.6.4"
1212
edition = "2021"
1313
authors = ["[email protected]"]
1414
repository = "https://github.com/acl-dev/open-coroutine"
@@ -22,6 +22,7 @@ open-coroutine-macros = { path = "macros", version = "0.6.0" }
2222

2323
tracing = { version = "0.1", default-features = false }
2424
tracing-subscriber = { version = "0.3", default-features = false }
25+
tracing-appender = { version = "0.2", default-features = false }
2526
mio = { version = "1.0", default-features = false }
2627

2728
cfg-if = "1.0.0"

open-coroutine/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ windows-sys = { workspace = true, features = [
2525
"Win32_System_Diagnostics_Debug",
2626
] }
2727

28+
[build-dependencies]
29+
tracing = { workspace = true, default-features = false }
30+
tracing-subscriber = { workspace = true, features = [
31+
"fmt",
32+
"local-time"
33+
], default-features = false }
34+
tracing-appender.workspace = true
35+
time.workspace = true
36+
2837
[dev-dependencies]
2938
tempfile.workspace = true
3039

open-coroutine/build.rs

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
11
use std::env::var;
22
use std::fs::{read_dir, rename};
33
use std::path::PathBuf;
4+
use tracing::{info, Level};
5+
use tracing_appender::rolling::{RollingFileAppender, Rotation};
46

57
fn main() {
8+
// init log
9+
let out_dir = PathBuf::from(var("OUT_DIR").expect("env not found"));
10+
let target_dir = out_dir
11+
.parent()
12+
.expect("can not find deps dir")
13+
.parent()
14+
.expect("can not find deps dir")
15+
.parent()
16+
.expect("can not find deps dir")
17+
.parent()
18+
.expect("can not find deps dir");
19+
_ = tracing_subscriber::fmt()
20+
.with_writer(RollingFileAppender::new(
21+
Rotation::NEVER,
22+
target_dir,
23+
"open-coroutine-build.log",
24+
))
25+
.with_thread_names(true)
26+
.with_line_number(true)
27+
.with_max_level(Level::INFO)
28+
.with_timer(tracing_subscriber::fmt::time::OffsetTime::new(
29+
time::UtcOffset::from_hms(8, 0, 0).expect("create UtcOffset failed !"),
30+
time::format_description::well_known::Rfc2822,
31+
))
32+
.try_init();
633
// build dylib
734
let target = var("TARGET").expect("env not found");
8-
let out_dir = PathBuf::from(var("OUT_DIR").expect("env not found"));
9-
let cargo_manifest_dir = PathBuf::from(var("CARGO_MANIFEST_DIR").expect("env not found"));
1035
let mut cargo = std::process::Command::new("cargo");
1136
let mut cmd = cargo.arg("build").arg("--target").arg(target.clone());
1237
if cfg!(not(debug_assertions)) {
@@ -15,7 +40,7 @@ fn main() {
1540
if let Err(e) = cmd
1641
.arg("--manifest-path")
1742
.arg(
18-
cargo_manifest_dir
43+
PathBuf::from(var("CARGO_MANIFEST_DIR").expect("env not found"))
1944
.parent()
2045
.expect("parent not found")
2146
.join("hook")
@@ -44,15 +69,17 @@ fn main() {
4469
.parent()
4570
.expect("can not find deps dir")
4671
.join("deps");
72+
let dir = read_dir(hook_deps.clone())
73+
.unwrap_or_else(|_| read_dir(deps.clone()).expect("can not find deps dir"));
74+
info!("deps: {deps:?}");
75+
info!("hook_deps:{hook_deps:?}");
76+
info!("dir:{dir:?}");
4777
let lib_names = [
4878
String::from("libopen_coroutine_hook.so"),
4979
String::from("libopen_coroutine_hook.dylib"),
5080
String::from("open_coroutine_hook.lib"),
5181
];
52-
for entry in read_dir(hook_deps.clone())
53-
.expect("Failed to read deps")
54-
.flatten()
55-
{
82+
for entry in dir.flatten() {
5683
let file_name = entry.file_name().to_string_lossy().to_string();
5784
if !file_name.contains("open_coroutine_hook") {
5885
continue;
@@ -63,31 +90,47 @@ fn main() {
6390
if file_name.eq("open_coroutine_hook.dll") {
6491
continue;
6592
}
93+
info!("{file_name:?}");
6694
if cfg!(target_os = "linux") && file_name.ends_with(".so") {
6795
rename(
68-
hook_deps.join(file_name),
96+
hook_deps.join(file_name.clone()),
6997
deps.join("libopen_coroutine_hook.so"),
7098
)
71-
.expect("rename to libopen_coroutine_hook.so failed!");
99+
.unwrap_or_else(|_| {
100+
rename(deps.join(file_name), deps.join("libopen_coroutine_hook.so"))
101+
.expect("rename to libopen_coroutine_hook.so failed!")
102+
});
72103
} else if cfg!(target_os = "macos") && file_name.ends_with(".dylib") {
73104
rename(
74-
hook_deps.join(file_name),
105+
hook_deps.join(file_name.clone()),
75106
deps.join("libopen_coroutine_hook.dylib"),
76107
)
77-
.expect("rename to libopen_coroutine_hook.dylib failed!");
108+
.unwrap_or_else(|_| {
109+
rename(
110+
deps.join(file_name),
111+
deps.join("libopen_coroutine_hook.dylib"),
112+
)
113+
.expect("rename to libopen_coroutine_hook.dylib failed!")
114+
});
78115
} else if cfg!(windows) {
79116
if file_name.ends_with(".dll") {
80117
rename(
81-
hook_deps.join(file_name),
118+
hook_deps.join(file_name.clone()),
82119
deps.join("open_coroutine_hook.dll"),
83120
)
84-
.expect("rename to open_coroutine_hook.dll failed!");
121+
.unwrap_or_else(|_| {
122+
rename(deps.join(file_name), deps.join("open_coroutine_hook.dll"))
123+
.expect("rename to open_coroutine_hook.dll failed!")
124+
});
85125
} else if file_name.ends_with(".lib") {
86126
rename(
87-
hook_deps.join(file_name),
127+
hook_deps.join(file_name.clone()),
88128
deps.join("open_coroutine_hook.lib"),
89129
)
90-
.expect("rename to open_coroutine_hook.lib failed!");
130+
.unwrap_or_else(|_| {
131+
rename(deps.join(file_name), deps.join("open_coroutine_hook.lib"))
132+
.expect("rename to open_coroutine_hook.lib failed!")
133+
});
91134
}
92135
}
93136
}

0 commit comments

Comments
 (0)