pub enum BuildTarget {
Hb,
Bin,
Cdylib,
Window,
}Expand description
A build target is what runs htl’s output. The htl binary runs a .hb bundle; the
OS runs a native binary; a caller written in C, Python or C# loads a cdylib. That is
the axis, and it is the only thing the entries below differ about:
| target | what runs the output | output | Rust in the project |
|---|---|---|---|
hb (the default) — plain htl new, then htl build | the htl binary, htl run app.hb | a .hb bundle | no |
bin | the OS, as a binary | a binary (library + a thin main.rs) | the user’s crate |
cdylib | a C / Python / Unity caller | cdylib + staticlib + a header | the user’s crate |
window | the OS, as a window | a binary that opens a window (library + main.rs calling htl_mq::run) | the user’s crate, plus htl-mq |
Host is the other axis: the Rust side that embeds the Lua state, what [build] host
and htl build --host name the modules of. htl.toml records the target as [build] target (absent means hb), htl new --target <name> writes it, htl init --target <name> adds the Rust side to a project that predates it, and htl build refuses a
project whose target is not hb, naming the command that does build it.
§What is in the enum, and what is derived from it
The enum is over what runs the output, and nothing else. Cargo’s [lib] crate-type
and the entry-script rule are answers derived from an entry (crate_types,
entry), not fields stored beside it, so adding a target is adding one arm and the
answers it gives rather than a row of parallel data that can disagree with itself. A
platform or a target triple is deliberately not in here: bin on Linux and bin on
Windows are the same build target, and if a platform ever has to be named it is an
attribute of one target, not a fourth entry.
§Why it is not called a host
Three of the four entries happen to be Rust crates, which is why this used to be called
a host; an output nothing Rust runs — a .love bundle, say — is the entry that makes
that word plainly wrong.
Host keeps its own meaning throughout htl and is not this: it is the Rust side that
embeds the Lua state — #[host_module], the src/host.d.tl generated from it, and
[build] host / htl build --host x,y, which name the modules that side provides at
run time. A project can have a host and the default target (htl build alone), and two
targets can share one host, so they are two axes rather than two words for one.
Variants§
Hb
A .hb bundle, run by the htl binary. What plain htl build produces, and what
every project without Rust in it is.
Bin
A native binary, run by the OS: a library crate holding the host module and the embedded scripts, with a thin binary on top.
Cdylib
A C ABI library, loaded by a caller that is not written in Rust.
Window
A native binary the OS runs as a windowed app: the same library-plus-thin-binary
shape as Bin, with the window and the frame loop coming from
htl-mq. That crate is the backend today and the target does not name it: a second
backend would be a second crate behind this entry, because what runs the output —
the OS, as a window — is what the enum is over, and that does not change with the
crate that opens the window.
Implementations§
Source§impl BuildTarget
impl BuildTarget
Sourcepub const ALL: &'static [BuildTarget]
pub const ALL: &'static [BuildTarget]
Every target there is, in the order they are offered and reported.
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
How it is spelled on the command line (--target <name>) and in htl.toml.
Sourcepub fn names() -> Vec<&'static str>
pub fn names() -> Vec<&'static str>
Every name, in ALL order: what a flag offers and what a typo
is answered with.
Sourcepub fn crate_types(&self) -> &'static [&'static str]
pub fn crate_types(&self) -> &'static [&'static str]
[lib] crate-type = [...] beyond the default rlib, which needs no section at all.
Derived rather than stored: the crate shape is a consequence of what loads the
output, so it is answered here and Cargo.toml has nothing else to know about it.
Trait Implementations§
Source§impl Clone for BuildTarget
impl Clone for BuildTarget
Source§fn clone(&self) -> BuildTarget
fn clone(&self) -> BuildTarget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BuildTarget
Source§impl Debug for BuildTarget
impl Debug for BuildTarget
Source§impl<'de> Deserialize<'de> for BuildTarget
The string form is the only form: target = "cdylib" in htl.toml goes through
FromStr, so a name that is not one is refused with the same sentence the command
line answers a typo with, rather than with serde’s list of variant spellings.
impl<'de> Deserialize<'de> for BuildTarget
The string form is the only form: target = "cdylib" in htl.toml goes through
FromStr, so a name that is not one is refused with the same sentence the command
line answers a typo with, rather than with serde’s list of variant spellings.
Source§fn deserialize<D>(d: D) -> Result<BuildTarget, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<BuildTarget, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for BuildTarget
impl Display for BuildTarget
impl Eq for BuildTarget
Source§impl FromStr for BuildTarget
impl FromStr for BuildTarget
Source§impl Hash for BuildTarget
impl Hash for BuildTarget
Source§impl PartialEq for BuildTarget
impl PartialEq for BuildTarget
impl StructuralPartialEq for BuildTarget
Auto Trait Implementations§
impl Freeze for BuildTarget
impl RefUnwindSafe for BuildTarget
impl Send for BuildTarget
impl Sync for BuildTarget
impl Unpin for BuildTarget
impl UnsafeUnpin for BuildTarget
impl UnwindSafe for BuildTarget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more