pub fn Process(Argument: &Argument) -> Result<(), Error>Expand description
Main orchestration logic for preparing and executing the build.
This function is the core of the build system, coordinating all aspects of preparing, building, and restoring project configurations. It:
- Validates the project directory and configuration files
- Creates guards to backup and restore configuration files
- Generates a unique product name and bundle identifier based on build flags
- Modifies Cargo.toml and Tauri configuration files
- Optionally stages a Node.js sidecar binary
- Executes the provided build command
- Cleans up temporary files after successful build
§Parameters
Argument- Parsed command-line arguments and environment variables
§Returns
Returns Ok(()) on successful build completion or a BuildError if
any step fails.
§Errors
BuildError::Missing- If the project directory doesn’t existBuildError::Config- If Tauri configuration file not foundBuildError::Exists- If a backup file already existsBuildError::Io- For file operation failuresBuildError::Edit- For TOML editing failuresBuildError::Json/BuildError::Jsonfive- For JSON/JSON5 parsing failuresBuildError::Parse- For TOML parsing failuresBuildError::Shell- If the build command fails
§Build Flavor Generation
The product name and bundle identifier are generated by combining:
- Environment: Node.js environment (development, production, etc.)
- Dependency: Dependency information (org/repo or generic)
- Node Version: Node.js version if bundling a sidecar
- Build Flags: Bundle, Clean, Browser, Compile, Debug
Example product name: Development_GenDependency_22NodeVersion_Debug_Mountain
Example bundle identifier: land.editor.binary.development.generic.node.22.debug.mountain
§Node.js Sidecar Bundling
If NodeVersion is specified:
- The Node.js binary is copied from
Element/SideCar/{triple}/NODE/{version}/ - The binary is staged in the project’s
Binary/directory - The Tauri configuration is updated to include the sidecar
- The binary is given appropriate permissions on Unix-like systems
- The temporary directory is cleaned up after successful build
§File Safety
All configuration file modifications are protected by the Guard pattern:
- Files are backed up before modification
- Files are automatically restored on error or when the guard drops
- This ensures the original state is preserved regardless of build outcome
§Example
use crate::Maintain::Source::Build::Process;
use crate::Maintain::Source::Build::Argument;
let argument = Argument::parse();
Process(&argument)?;