mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-11 10:43:31 +02:00
docs: improve tauri_build::build & try_build (#13001)
* docs: remove outdated `tauri_build::build` docs
The docstring has been unchanged ever since
40ac52971e (2021).
The `build()` function has grown massivly since then,
now it's not only about Windows.
* docs: `tauri_build::build`: see `try_build` for more config
`try_build` is not only about not panicing, but it also takes the
`attributes: Attributes` argument,
which is very important for controlling command permissions.
* Update crates/tauri-build/src/lib.rs
Co-authored-by: Amr Bashir <github@amrbashir.me>
* update docs
---------
Co-authored-by: Amr Bashir <github@amrbashir.me>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
@@ -419,23 +419,26 @@ pub fn is_dev() -> bool {
|
||||
|
||||
/// Run all build time helpers for your Tauri Application.
|
||||
///
|
||||
/// The current helpers include the following:
|
||||
/// * Generates a Windows Resource file when targeting Windows.
|
||||
/// To provide extra configuration, such as [`AppManifest::commands`]
|
||||
/// for fine-grained control over command permissions, see [`try_build`].
|
||||
/// See [`Attributes`] for the complete list of configuration options.
|
||||
///
|
||||
/// # Platforms
|
||||
///
|
||||
/// [`build()`] should be called inside of `build.rs` regardless of the platform:
|
||||
/// * New helpers may target more platforms in the future.
|
||||
/// * Platform specific code is handled by the helpers automatically.
|
||||
/// * A build script is required in order to activate some cargo environmental variables that are
|
||||
/// used when generating code and embedding assets - so [`build()`] may as well be called.
|
||||
/// [`build()`] should be called inside of `build.rs` regardless of the platform, so **DO NOT** use a [conditional compilation]
|
||||
/// check that prevents it from running on any of your targets.
|
||||
///
|
||||
/// In short, this is saying don't put the call to [`build()`] behind a `#[cfg(windows)]`.
|
||||
/// Platform specific code is handled by the helpers automatically.
|
||||
///
|
||||
/// A build script is required in order to activate some cargo environmental variables that are
|
||||
/// used when generating code and embedding assets.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If any of the build time helpers fail, they will [`std::panic!`] with the related error message.
|
||||
/// This is typically desirable when running inside a build script; see [`try_build`] for no panics.
|
||||
///
|
||||
/// [conditional compilation]: https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/conditional-compilation.html
|
||||
pub fn build() {
|
||||
if let Err(error) = try_build(Attributes::default()) {
|
||||
let error = format!("{error:#}");
|
||||
@@ -450,7 +453,7 @@ pub fn build() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Non-panicking [`build()`].
|
||||
/// Same as [`build()`], but takes an extra configuration argument, and does not panic.
|
||||
#[allow(unused_variables)]
|
||||
pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
use anyhow::anyhow;
|
||||
|
||||
Reference in New Issue
Block a user