Compare commits
2
Commits
0b4ecccb71
...
f9333c72be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9333c72be | ||
|
|
bf0837e4a6 |
+51
-2
@@ -1,5 +1,52 @@
|
||||
# sarasacw-omrf-packer
|
||||
|
||||
`sarasacw-omrf-packer` is the distribution packer of the Sarasas Chip Workshop Oh My Rust FFI (OMRF) toolset.
|
||||
Given a Rust project that exposes a C-friendly FFI as a `cdylib`, it assembles a CMake-style redistributable tree.
|
||||
It involves header files, the built dynamic library, and generated CMake and pkg-config package files,
|
||||
and it can additionally bundle the result into a zip archive.
|
||||
|
||||
It targets Rust FFI projects that need to be distributed and consumed like ordinary CMake/pkg-config packages,
|
||||
including on MSVC-only Windows toolchains where pkg-config alone is not enough.
|
||||
|
||||
## Status
|
||||
|
||||
Barely works for the specific workflow of Sarasas Chip Workshop.
|
||||
And will be improved by new requirement coming from Sarasas Chip Workshop devlopment.
|
||||
|
||||
Projects declare the minimum required packer version through the `min_version` field in their `[package.metadata.omrf]` table;
|
||||
running an older packer than requested fails fast with a clear error.
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the MIT License.
|
||||
|
||||
## Usage
|
||||
|
||||
Install from PyPI (the project is built with `uv`, but `pipx install` or `pip install` work just as well on the published wheel):
|
||||
|
||||
```console
|
||||
uv tool install sarasacw-omrf-packer
|
||||
```
|
||||
|
||||
The packer does not build the project itself. Build it first -- `cargo build --release`, adding `--target <triple>` for cross-compilation -- then run:
|
||||
|
||||
```console
|
||||
sarasacw-omrf-packer -m path/to/Cargo.toml
|
||||
```
|
||||
|
||||
`cargo` and `rustc` are resolved from `PATH`; override them with the environment variables listed in the [Environment Variables](#environment-variables) section.
|
||||
|
||||
### Command-line options
|
||||
|
||||
| Option | Required | Description |
|
||||
|---|---|---|
|
||||
| `-m`, `--manifest <CARGO.TOML>` | yes | Path to the `Cargo.toml` of the project to pack. |
|
||||
| `-d`, `--dist-dir <DIR>` | no | Directory where the redistributable tree is materialized (`bin/`, `include/`, `lib/`, ...). |
|
||||
| `-z`, `--dist-zip <ZIP>` | no | Path of the zip archive produced from the redistributable tree. |
|
||||
| `-t`, `--target <TRIPLE>` | no | Target triple to pack for (e.g. `x86_64-pc-windows-msvc`). Defaults to the host toolchain triple. |
|
||||
|
||||
`--dist-dir` and `--dist-zip` are independent: pass either, both, or neither. Omitting both performs a dry run that validates the configuration without writing any output. Run `sarasacw-omrf-packer --help` for the authoritative list.
|
||||
|
||||
## Metadata
|
||||
|
||||
All packer used properties are stored in target Rust manifest file as metadata style.
|
||||
@@ -77,5 +124,7 @@ requires = ["libfoo >= 1.0", "libbar"]
|
||||
|
||||
## 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`.
|
||||
- `OMRF_PACKER_RUSTC`: Path to the `rustc` executable used to resolve the host toolchain triple. When unset, the packer invokes `rustc` as resolved from `PATH`.
|
||||
- `OMRF_PACKER_CARGO`: Path to the `cargo` executable used to collect project metadata.
|
||||
When unset, the packer invokes `cargo` as resolved from `PATH`.
|
||||
- `OMRF_PACKER_RUSTC`: Path to the `rustc` executable used to resolve the host toolchain triple.
|
||||
When unset, the packer invokes `rustc` as resolved from `PATH`.
|
||||
|
||||
+20
-1
@@ -1,12 +1,26 @@
|
||||
[project]
|
||||
name = "sarasacw-omrf-packer"
|
||||
version = "1.0.0"
|
||||
description = "Add your description here"
|
||||
description = "The packer for Rust, specifically designed for the SarasaCW OMRF project, to distribute C-friendly FFI dynamic library as CMake package."
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{ name = "yyc12345", email = "yyc12321@outlook.com" }
|
||||
]
|
||||
requires-python = ">=3.13"
|
||||
license = { text = "MIT" }
|
||||
keywords = ["rust", "ffi", "cmake", "pkg-config", "packaging", "omrf"]
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"Topic :: Software Development :: Build Tools",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: Microsoft :: Windows",
|
||||
"Operating System :: POSIX",
|
||||
"Operating System :: MacOS",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
]
|
||||
dependencies = [
|
||||
"jinja2==3.1.6",
|
||||
"semver>=3.0.4",
|
||||
@@ -15,6 +29,11 @@ dependencies = [
|
||||
[project.scripts]
|
||||
sarasacw-omrf-packer = "sarasacw_omrf_packer:main"
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/SarasasChipWorkshop/sarasacw-omrf"
|
||||
Repository = "https://github.com/SarasasChipWorkshop/sarasacw-omrf"
|
||||
Issues = "https://github.com/SarasasChipWorkshop/sarasacw-omrf/issues"
|
||||
|
||||
[build-system]
|
||||
requires = ["uv_build>=0.8.0,<0.9"]
|
||||
build-backend = "uv_build"
|
||||
|
||||
@@ -89,6 +89,7 @@ class PkgConfigRender:
|
||||
payload: dict[str, Any] = {
|
||||
"name": self.__properties.name,
|
||||
"description": self.__properties.description,
|
||||
"version": str(self.__properties.version),
|
||||
"artifact": self.__properties.artifact,
|
||||
"requires": self.__properties.requires,
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ includedir=${prefix}/include
|
||||
Name: {{ name }}
|
||||
Description: {{ description }}
|
||||
Version: {{ version }}
|
||||
{% if len(requires) != 0 -%}
|
||||
{%- if requires | length != 0 %}
|
||||
Requires: {{ requires | join(", ") }}
|
||||
{%- endif %}
|
||||
Libs: -L${libdir} -l{{ artifact }}
|
||||
|
||||
@@ -32,7 +32,7 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
{% if len(dependencies) != 0 -%}
|
||||
{% if dependencies | length != 0 -%}
|
||||
{# Pull in declared dependencies and wire them into the imported target -#}
|
||||
include(CMakeFindDependencyMacro)
|
||||
{% for dep in dependencies -%}
|
||||
|
||||
Reference in New Issue
Block a user