Skip to content

Commit

Permalink
Merge pull request #1389 from google/fix-double-init
Browse files Browse the repository at this point in the history
Fix double init of EnvLogger
  • Loading branch information
adetaylor authored Sep 8, 2024
2 parents 657540f + fea2009 commit e9efdc3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions gen/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@

use autocxx_engine::{BuilderContext, RebuildDependencyRecorder};
use indexmap::set::IndexSet as HashSet;
use std::{io::Write, sync::Mutex};
use std::{
borrow::Borrow,
io::Write,
sync::{LazyLock, Mutex},
};

pub type Builder = autocxx_engine::Builder<'static, CargoBuilderContext>;

#[doc(hidden)]
pub struct CargoBuilderContext;

static ENV_LOGGER: LazyLock<()> = LazyLock::new(|| {
env_logger::builder()
.format(|buf, record| writeln!(buf, "cargo:warning=MESSAGE:{}", record.args()))
.init();
});

impl BuilderContext for CargoBuilderContext {
fn setup() {
env_logger::builder()
.format(|buf, record| writeln!(buf, "cargo:warning=MESSAGE:{}", record.args()))
.init();
ENV_LOGGER.borrow();
}
fn get_dependency_recorder() -> Option<Box<dyn RebuildDependencyRecorder>> {
Some(Box::new(CargoRebuildDependencyRecorder::new()))
Expand Down

0 comments on commit e9efdc3

Please sign in to comment.