pub struct EnvironmentContext {
pub default_build_script_target: Option<String>,
pub build_script_mode: bool,
/* private fields */
}
Expand description
Holds execution context for a Starlark environment.
Fields§
§default_build_script_target: Option<String>
Name of default target to resolve in build script mode.
build_script_mode: bool
Whether we are operating in Rust build script mode.
This will change the default target to resolve.
Implementations§
source§impl EnvironmentContext
impl EnvironmentContext
pub fn new(cwd: PathBuf) -> Self
sourcepub fn build_path(&self) -> &Path
pub fn build_path(&self) -> &Path
Directory to use for the build path.
sourcepub fn set_build_path(&mut self, path: &Path) -> Result<()>
pub fn set_build_path(&mut self, path: &Path) -> Result<()>
Update the directory to use for the build path.
sourcepub fn resolve_path(&self, path: impl AsRef<Path>) -> PathBuf
pub fn resolve_path(&self, path: impl AsRef<Path>) -> PathBuf
Resolve an absolute filesystem path from a path input.
If the incoming path is absolute, it is returned. Otherwise relative paths are joined with the current build path.
sourcepub fn set_target_build_path_prefix<P: AsRef<Path>>(&mut self, prefix: Option<P>)
pub fn set_target_build_path_prefix<P: AsRef<Path>>(&mut self, prefix: Option<P>)
Set the path prefix to use for per-target build paths.
If defined, target build paths are of the form <build_path>/<prefix>/<target>
.
Otherwise they are <build_path>/<target>
.
sourcepub fn target_build_path(&self, target: &str) -> PathBuf
pub fn target_build_path(&self, target: &str) -> PathBuf
Obtain the directory to use to build a named target.
sourcepub fn default_target(&self) -> Option<&str>
pub fn default_target(&self) -> Option<&str>
Obtain the default target to resolve.
sourcepub fn get_target(&self, target: &str) -> Option<&Target>
pub fn get_target(&self, target: &str) -> Option<&Target>
Obtain a named target.
sourcepub fn get_target_mut(&mut self, target: &str) -> Option<&mut Target>
pub fn get_target_mut(&mut self, target: &str) -> Option<&mut Target>
Obtain a mutable named target.
sourcepub fn set_resolve_targets(&mut self, targets: Vec<String>)
pub fn set_resolve_targets(&mut self, targets: Vec<String>)
Set the list of targets to resolve.
sourcepub fn targets_order(&self) -> &Vec<String>
pub fn targets_order(&self) -> &Vec<String>
Obtain the order that targets were registered in.
sourcepub fn register_target(
&mut self,
target: String,
callable: Value,
depends: Vec<String>,
default: bool,
default_build_script: bool
)
pub fn register_target(
&mut self,
target: String,
callable: Value,
depends: Vec<String>,
default: bool,
default_build_script: bool
)
Register a named target.
sourcepub fn targets_to_resolve(&self) -> Vec<String>
pub fn targets_to_resolve(&self) -> Vec<String>
Determine what targets should be resolved.
This isn’t the full list of targets that will be resolved, only the main targets that we will instruct the resolver to resolve.
Trait Implementations§
source§impl Debug for EnvironmentContext
impl Debug for EnvironmentContext
source§impl TypedValue for EnvironmentContext
impl TypedValue for EnvironmentContext
§type Holder = Mutable<EnvironmentContext>
type Holder = Mutable<EnvironmentContext>
MutableHolder<Self>
or ImmutableHolder<Self>
source§const TYPE: &'static str = "EnvironmentContext"
const TYPE: &'static str = "EnvironmentContext"
source§fn values_for_descendant_check_and_freeze(
&self
) -> Box<dyn Iterator<Item = Value>>
fn values_for_descendant_check_and_freeze(
&self
) -> Box<dyn Iterator<Item = Value>>
source§fn function_id(&self) -> Option<FunctionId>
fn function_id(&self) -> Option<FunctionId>
source§fn to_str(&self) -> String
fn to_str(&self) -> String
source§fn to_str_impl(&self, buf: &mut String) -> Result<(), Error>
fn to_str_impl(&self, buf: &mut String) -> Result<(), Error>
to_str
, more efficient for nested objectssource§fn to_repr(&self) -> String
fn to_repr(&self) -> String
source§fn to_repr_impl(&self, buf: &mut String) -> Result<(), Error>
fn to_repr_impl(&self, buf: &mut String) -> Result<(), Error>
to_repr
, more efficient for nested objectssource§fn to_bool(&self) -> bool
fn to_bool(&self) -> bool
source§fn to_int(&self) -> Result<i64, ValueError>
fn to_int(&self) -> Result<i64, ValueError>
source§fn get_hash(&self) -> Result<u64, ValueError>
fn get_hash(&self) -> Result<u64, ValueError>
source§fn call(
&self,
_call_stack: &mut CallStack,
_type_values: &TypeValues,
_positional: Vec<Value, Global>,
_named: LinkedHashMap<RcString, Value, RandomState>,
_args: Option<Value>,
_kwargs: Option<Value>
) -> Result<Value, ValueError>
fn call(
&self,
_call_stack: &mut CallStack,
_type_values: &TypeValues,
_positional: Vec<Value, Global>,
_named: LinkedHashMap<RcString, Value, RandomState>,
_args: Option<Value>,
_kwargs: Option<Value>
) -> Result<Value, ValueError>
source§fn at(&self, index: Value) -> Result<Value, ValueError>
fn at(&self, index: Value) -> Result<Value, ValueError>
source§fn slice(
&self,
_start: Option<Value>,
_stop: Option<Value>,
_stride: Option<Value>
) -> Result<Value, ValueError>
fn slice(
&self,
_start: Option<Value>,
_stop: Option<Value>,
_stride: Option<Value>
) -> Result<Value, ValueError>
start
and stop
(both of them are added length() if negative and then
clamped between 0 and length()). stride
indicates the direction. Read moresource§fn iter(&self) -> Result<&(dyn TypedIterable + 'static), ValueError>
fn iter(&self) -> Result<&(dyn TypedIterable + 'static), ValueError>
source§fn length(&self) -> Result<i64, ValueError>
fn length(&self) -> Result<i64, ValueError>
source§fn get_attr(&self, attribute: &str) -> Result<Value, ValueError>
fn get_attr(&self, attribute: &str) -> Result<Value, ValueError>
a.attribute
). Read moresource§fn has_attr(&self, _attribute: &str) -> Result<bool, ValueError>
fn has_attr(&self, _attribute: &str) -> Result<bool, ValueError>
attribute
exists for the current value. Read moresource§fn set_attr(
&mut self,
attribute: &str,
_new_value: Value
) -> Result<(), ValueError>
fn set_attr(
&mut self,
attribute: &str,
_new_value: Value
) -> Result<(), ValueError>
attribute
of the current value to new_value
(e.g.
a.attribute = new_value
). Read moresource§fn dir_attr(&self) -> Result<Vec<RcString, Global>, ValueError>
fn dir_attr(&self) -> Result<Vec<RcString, Global>, ValueError>
source§fn contains(&self, other: &Value) -> Result<bool, ValueError>
fn contains(&self, other: &Value) -> Result<bool, ValueError>
other
is in the current value, if it is a container. Read moresource§fn plus(&self) -> Result<Self, ValueError>
fn plus(&self) -> Result<Self, ValueError>
+
unary operator to the current value. Read moresource§fn minus(&self) -> Result<Self, ValueError>
fn minus(&self) -> Result<Self, ValueError>
-
unary operator to the current value. Read moresource§fn add(&self, _other: &Self) -> Result<Self, ValueError>
fn add(&self, _other: &Self) -> Result<Self, ValueError>
other
to the current value. Read moresource§fn sub(&self, _other: &Self) -> Result<Self, ValueError>
fn sub(&self, _other: &Self) -> Result<Self, ValueError>
other
from the current value. Read moresource§fn mul(&self, other: Value) -> Result<Value, ValueError>
fn mul(&self, other: Value) -> Result<Value, ValueError>
other
. Read moresource§fn percent(&self, other: Value) -> Result<Value, ValueError>
fn percent(&self, other: Value) -> Result<Value, ValueError>
other
. Read moresource§fn div(&self, other: Value) -> Result<Value, ValueError>
fn div(&self, other: Value) -> Result<Value, ValueError>
other
. division. Read more