Skip to content

Commit

Permalink
Label global
Browse files Browse the repository at this point in the history
Summary: Can be used as type.

Reviewed By: ndmitchell

Differential Revision: D47163560

fbshipit-source-id: 73562cd6107af679cdbefca19bc818495c4baa1b
  • Loading branch information
stepancheg authored and facebook-github-bot committed Jul 11, 2023
1 parent bd37f47 commit 3014479
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/buck2_interpreter/src/types/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ use starlark::any::ProvidesStaticType;
use starlark::coerce::Coerce;
use starlark::collections::StarlarkHasher;
use starlark::docs::StarlarkDocs;
use starlark::environment::GlobalsBuilder;
use starlark::environment::Methods;
use starlark::environment::MethodsBuilder;
use starlark::environment::MethodsStatic;
use starlark::values::starlark_value;
use starlark::values::starlark_value_as_type::StarlarkValueAsType;
use starlark::values::AllocValue;
use starlark::values::Freeze;
use starlark::values::Heap;
Expand Down Expand Up @@ -269,6 +271,11 @@ fn label_methods(builder: &mut MethodsBuilder) {
}
}

#[starlark_module]
pub fn register_label(globals: &mut GlobalsBuilder) {
const Label: StarlarkValueAsType<Label> = StarlarkValueAsType::new();
}

#[cfg(test)]
mod tests {
// Tests live in `buck2_build_api` crate because tests depend on `Tester` type
Expand Down
2 changes: 2 additions & 0 deletions app/buck2_interpreter_for_build/src/interpreter/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use buck2_interpreter::bxl::BXL_FUNCTIONS;
use buck2_interpreter::functions::more::MORE_FUNCTIONS;
use buck2_interpreter::functions::transition::REGISTER_TRANSITION;
use buck2_interpreter::types::label::register_label;
use starlark::environment::GlobalsBuilder;

use crate::attrs::attrs_global::register_attrs;
Expand Down Expand Up @@ -88,4 +89,5 @@ pub fn configure_extension_file_globals(globals_builder: &mut GlobalsBuilder) {
.unwrap()
.register_command_executor_config)(globals_builder);
register_package_natives(globals_builder);
register_label(globals_builder);
}

0 comments on commit 3014479

Please sign in to comment.