Skip to content

Commit

Permalink
bxl: Move stuff to BxlContextCoreData
Browse files Browse the repository at this point in the history
Summary: And impl `Deref`. Was going to use this for a diff which didn't work out, but good as is

Reviewed By: stepancheg

Differential Revision: D61436899

fbshipit-source-id: ee5e9d7e84e8d081dbda40ca7729c4d6e914c00c
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Aug 18, 2024
1 parent 2d34199 commit 72a80a5
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions app/buck2_bxl/src/bxl/starlark_defs/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ pub(crate) struct BxlContextNoDice<'v> {
core: BxlContextCoreData,
}

impl Deref for BxlContextNoDice<'_> {
type Target = BxlContextCoreData;

fn deref(&self) -> &Self::Target {
&self.core
}
}

#[derive(Derivative, Display, Trace, Allocative)]
#[derivative(Debug)]
#[display(fmt = "{:?}", self)]
Expand Down Expand Up @@ -295,14 +303,6 @@ impl BxlContextCoreData {
pub(crate) fn key(&self) -> &BxlKey {
&self.current_bxl
}

pub(crate) fn artifact_fs(&self) -> &ArtifactFs {
&self.artifact_fs
}

pub(crate) fn project_fs(&self) -> &ProjectRoot {
&self.project_fs
}
}

impl<'v> BxlContext<'v> {
Expand Down Expand Up @@ -466,45 +466,47 @@ impl<'v> BxlContextNoDice<'v> {
}
Ok(())
}
}

impl BxlContextCoreData {
pub(crate) fn project_root(&self) -> &ProjectRoot {
&self.core.project_fs
&self.project_fs
}

pub(crate) fn global_cfg_options(&self) -> &GlobalCfgOptions {
self.core.current_bxl.global_cfg_options()
self.current_bxl.global_cfg_options()
}

pub(crate) fn target_alias_resolver(&self) -> &BuckConfigTargetAliasResolver {
&self.core.target_alias_resolver
&self.target_alias_resolver
}

pub(crate) fn cell_resolver(&self) -> &CellResolver {
&self.core.cell_resolver
&self.cell_resolver
}

pub(crate) fn cell_name(&self) -> CellName {
self.core.cell_name
self.cell_name
}

pub(crate) fn cell_root_abs(&self) -> &AbsNormPathBuf {
&self.core.cell_root_abs
&self.cell_root_abs
}

pub(crate) fn cell_alias_resolver(&self) -> &CellAliasResolver {
&self.core.cell_alias_resolver
&self.cell_alias_resolver
}

pub(crate) fn current_bxl(&self) -> &BxlKey {
&self.core.current_bxl
&self.current_bxl
}

pub(crate) fn project_fs(&self) -> &ProjectRoot {
&self.core.project_fs
&self.project_fs
}

pub(crate) fn artifact_fs(&self) -> &ArtifactFs {
&self.core.artifact_fs
&self.artifact_fs
}

/// Working dir for resolving literals.
Expand Down

0 comments on commit 72a80a5

Please sign in to comment.