aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/docs/build.md
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/docs/build.md')
-rw-r--r--mingling_core/src/docs/build.md57
1 files changed, 57 insertions, 0 deletions
diff --git a/mingling_core/src/docs/build.md b/mingling_core/src/docs/build.md
new file mode 100644
index 0000000..6f9285a
--- /dev/null
+++ b/mingling_core/src/docs/build.md
@@ -0,0 +1,57 @@
+Provide Mingling's build script module for build-time behavior of specific features in `build.rs`.
+
+To use it, add a dependency on mingling under `[build-dependencies]` in `Cargo.toml`, and enable the relevant features:
+
+## Build-Time Related Features
+
+| Name | Purpose |
+| ---------------- | ------------------------------------------------------------------------------------------------- |
+| `build` | Master switch for build-time features |
+| `build_advanced` | Master switch for build-time features, paired with the `advanced` feature |
+| `build_full` | Master switch for build-time features, paired with the `full` feature |
+| `comp` | Completion script builder; both sides must enable it, generates cross-platform completion scripts |
+| `pathf` | Type path analyzer; both sides must enable it, generates type mapping tables |
+| `dispatch_tree` | Compile-time dispatch tree; when `pathf` is a build-time dependency, |
+| | and `dispatch_tree` (included in `advanced` or `full`) is enabled, both sides should enable it |
+
+```toml
+# Cargo.toml
+[dependencies.mingling]
+features = [
+ "advanced", # Enable `advanced` if using it
+]
+
+[build-dependencies.mingling]
+features = [
+ "build_advanced" # This side should enable `build_advanced`
+]
+```
+
+## `build.rs` Templates
+
+You can use the following template to write `build.rs` to quickly gain the build-time capabilities of `comp` and `pathf`:
+
+```rust,ignore
+// build.rs
+fn main() {
+ build_scripts();
+ build_pathf_mapping();
+}
+
+/// Generate completion scripts
+fn build_scripts() {
+ // `env!("CARGO_PKG_NAME")` equals the crate name, which matches the binary name.
+ // If your binary name differs from the crate name, specify it explicitly.
+ mingling::build::build_comp_scripts(
+ // Your binary name:
+ env!("CARGO_PKG_NAME"),
+ )
+ .unwrap();
+}
+
+fn build_pathf_mapping() {
+ // Build pathf type mapping to ensure that the enabled `pathf` feature
+ // can correctly scan macros in the project
+ mingling::build::analyze_and_build_type_mapping().unwrap();
+}
+```