feat: add metadata resolve in module

This commit is contained in:
2026-08-03 16:05:08 +08:00
parent 52bd89ad6e
commit 6f1c5312e0
3 changed files with 161 additions and 33 deletions
+34 -24
View File
@@ -1,45 +1,55 @@
# sarasacw-omrf-packer
## Metadata
All packer used properties are stored in target Rust manifest file as metadata style.
There is an example about how to define them in `Cargo.toml`.
```toml
[package.metadata.omrf]
# Configures the minimum required sarasacw-omrf-packer version.
# Trying to run with an older version causes an error.
# This property is optional. If there is no specification, no version constraint is applied.
# Minimum required version of sarasacw-omrf-packer.
# Running with an older version fails with an error.
# This property is optional; when omitted, no version constraint is enforced.
min_version = "1.0.0"
[package.metadata.omrf.headers]
assets = [
# `from` is the relative path to directory where this Cargo.toml is.
# `to` is the relative path to `include` directory which is the subdirectory of installation directory.
# Blank `to` means that put it directly in `include` directory.
# Header files to distribute. Each entry installs one file (or, with glob
# expansion, a set of files) into the `include` directory of the installation.
# Each entry carries a `from` source path and a `to` destination path.
# This property is required. If you really want to distribute nothing header files,
# leave empty list here.
headers = [
# `from` is a path relative to the directory that contains this `Cargo.toml`.
# `to` is a path relative to the `include` directory (a subdirectory of the install directory).
# An empty `to` places the file directly under the `include` directory.
{ from = "cbindgen/my_crate.h", to = "" },
{ from = "cbindgen/our_crate.h", to = "SomePrefix" },
# `from` support UNIX style pathname pattern expansion.
# It will find the toppest immutable component of given pattern.
# In this exmaple, this toppest immutable component is `pattern/with`.
# And use that as the root directory and put found files to `to` directory
# with preserving directory hierarchy.
{ from = "pattern/with/**/*", to = "" }
{ from = "pattern/with/**/*", to = "AllInOne" }
# `from` also supports UNIX-style glob (pathname) expansion.
# The matcher uses the leading literal portion of the pattern (`pattern/with`
# here) as the root directory and copies every matched file into the `to`
# directory, preserving the directory hierarchy beneath that root.
{ from = "pattern/with/**/*", to = "" },
# The same pattern, but nested under an `AllInOne` prefix.
{ from = "pattern/with/**/*", to = "AllInOne" },
]
[package.metadata.omrf.cmake]
# Configures the namespace part of CMake target.
# This property is optional. The default value is extracted from the name of target Rust project.
# Namespace part of the generated CMake target.
# This property is optional; it defaults to the name of the target Rust project.
namespace_name = "foobar"
# Configures the target part of CMake target.
# This property is optional. The default value is extracted from the name of target Rust project.
# Target-name part of the generated CMake target.
# This property is optional; it defaults to the name of the target Rust project.
target_name = "foobar"
[package.metadata.omrf.pkgconfig]
# Configures the human-readable name of this package.
# This property is optional. The default value is extracted from the name of target Rust project.
# Human-readable name of the package.
# This property is optional; it defaults to the name of the target Rust project.
name = "Foo Bar"
# Configures the brief description of this package.
# This property is optional. The default value is extracted from the description of target Rust project.
name = "a brown fox jumps over a lazy dog."
# Brief description of the package.
# This property is optional; it defaults to the description of the target Rust project.
description = "a brown fox jumps over a lazy dog."
```
## Environment Variables
- `OMRF_PACKER_CARGO`: Path to the `cargo` executable used to collect project metadata. When unset, the packer invokes `cargo` as resolved from `PATH`.