Skip to content

Commit a3d4452

Browse files
authored
Logging (#92)
* foo-bindings should not be dependent on the library * add tracing logging to the various build phases! * tweaks to logging
1 parent 1692024 commit a3d4452

File tree

14 files changed

+373
-16
lines changed

14 files changed

+373
-16
lines changed

Cargo.lock

Lines changed: 307 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci-script/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ dotnet-oo-bindgen = { path = "../generators/dotnet-oo-bindgen" }
1111
java-oo-bindgen = { path = "../generators/java-oo-bindgen" }
1212
clap = "3.2.17"
1313
pathdiff = "0.2"
14+
tracing = "^0.1"

ci-script/src/lib.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,33 @@ trait BindingBuilder {
127127

128128
/// run the builder
129129
fn run(&mut self, run_tests: bool, package: bool, generate_doxygen: bool) {
130-
self.generate(package, generate_doxygen);
130+
let span = tracing::info_span!("generate()", lang = Self::name());
131+
span.in_scope(|| {
132+
tracing::info!("begin");
133+
self.generate(package, generate_doxygen);
134+
tracing::info!("end");
135+
});
131136

132137
if package {
133-
self.package();
138+
let span = tracing::info_span!("package()", lang = Self::name());
139+
span.in_scope(|| {
140+
tracing::info!("begin");
141+
self.package();
142+
tracing::info!("end");
143+
});
134144
} else if run_tests {
135-
self.build();
136-
self.test();
145+
let span = tracing::info_span!("build()", lang = Self::name());
146+
span.in_scope(|| {
147+
tracing::info!("begin");
148+
self.build();
149+
tracing::info!("end");
150+
});
151+
let span = tracing::info_span!("test()", lang = Self::name());
152+
span.in_scope(|| {
153+
tracing::info!("begin");
154+
self.test();
155+
tracing::info!("end");
156+
});
137157
}
138158
}
139159
}

generators/c-oo-bindgen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ authors = ["Émile Grégoire <[email protected]>"]
55
edition = "2021"
66

77
[dependencies]
8+
tracing = "^0.1"
89
oo-bindgen = { path = "../../oo-bindgen" }

generators/c-oo-bindgen/src/cpp/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::formatting::print_license;
1515

1616
pub(crate) fn generate_header(lib: &Library, path: &Path) -> FormattingResult<()> {
1717
// Open the file
18-
std::fs::create_dir_all(&path)?;
18+
logged::create_dir_all(&path)?;
1919
let filename = path.join(format!("{}.hpp", lib.settings.name));
2020
let mut f = FilePrinter::new(filename)?;
2121

generators/c-oo-bindgen/src/cpp/implementation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::ctype::CType;
99

1010
pub(crate) fn generate_cpp_file(lib: &Library, path: &Path) -> FormattingResult<()> {
1111
// Open the file
12-
std::fs::create_dir_all(&path)?;
12+
logged::create_dir_all(&path)?;
1313
let filename = path.join(format!("{}.cpp", lib.settings.name));
1414
let mut f = FilePrinter::new(filename)?;
1515

generators/c-oo-bindgen/src/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) fn generate_c_header(lib: &Library, path: &Path) -> FormattingResult<
1111
let uppercase_name = lib.settings.c_ffi_prefix.to_uppercase();
1212

1313
// Open file
14-
std::fs::create_dir_all(&path)?;
14+
logged::create_dir_all(&path)?;
1515
let filename = path.join(format!("{}.h", lib.settings.name));
1616
let mut f = FilePrinter::new(filename)?;
1717

generators/c-oo-bindgen/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ pub fn generate_c_package(lib: &Library, config: &CBindgenConfig) -> FormattingR
8989
let lib_path = output_dir
9090
.join("lib")
9191
.join(config.platform_location.platform.target_triple);
92-
fs::create_dir_all(&lib_path)?;
92+
logged::create_dir_all(&lib_path)?;
9393

9494
let lib_filename = config
9595
.platform_location
9696
.platform
9797
.static_lib_filename(&config.ffi_name);
98-
fs::copy(
98+
logged::copy(
9999
config.platform_location.location.join(&lib_filename),
100100
lib_path.join(&lib_filename),
101101
)?;
@@ -104,7 +104,7 @@ pub fn generate_c_package(lib: &Library, config: &CBindgenConfig) -> FormattingR
104104
.platform_location
105105
.platform
106106
.dyn_lib_filename(&config.ffi_name);
107-
fs::copy(
107+
logged::copy(
108108
config.platform_location.location.join(&lib_filename),
109109
lib_path.join(&lib_filename),
110110
)?;
@@ -114,7 +114,7 @@ pub fn generate_c_package(lib: &Library, config: &CBindgenConfig) -> FormattingR
114114
.platform_location
115115
.platform
116116
.bin_filename(&config.ffi_name);
117-
fs::copy(
117+
logged::copy(
118118
config.platform_location.location.join(&bin_filename),
119119
lib_path.join(&bin_filename),
120120
)?;
@@ -125,7 +125,7 @@ pub fn generate_c_package(lib: &Library, config: &CBindgenConfig) -> FormattingR
125125
output_dir.join(lib.info.license_path.file_name().unwrap()),
126126
)?;
127127
for path in &config.extra_files {
128-
fs::copy(path, output_dir.join(path.file_name().unwrap()))?;
128+
logged::copy(path, output_dir.join(path.file_name().unwrap()))?;
129129
}
130130

131131
// Generate doxygen (if asked)
@@ -236,7 +236,7 @@ fn generate_cmake_config(
236236
.output_dir
237237
.join(platform_location.platform.target_triple)
238238
.join("cmake");
239-
fs::create_dir_all(&cmake_path)?;
239+
logged::create_dir_all(&cmake_path)?;
240240
let filename = cmake_path.join(format!("{}-config.cmake", lib.settings.name));
241241
let mut f = FilePrinter::new(filename)?;
242242

oo-bindgen/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ regex = "1.3"
1111
lazy_static = "1.4"
1212
backtrace = "0.3"
1313
heck = "0.3"
14-
platforms = "2.0"
14+
platforms = "2.0"
15+
tracing = "^0.1"

oo-bindgen/src/backend/formatting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct FilePrinter {
2121

2222
impl FilePrinter {
2323
pub fn new<T: AsRef<Path>>(filepath: T) -> FormattingResult<Self> {
24+
tracing::info!("Create file: {}", filepath.as_ref().display());
2425
let file = File::create(filepath)?;
2526
let writer = BufWriter::new(file);
2627
Ok(Self {

0 commit comments

Comments
 (0)