Sebastien Rousseau

LIBMAKE

LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust

Ṣẹ̀dá production-ready Rust library scaffold pẹ̀lú CI, tests àti docs ní kéré ju aaya 60

4 min read
Banner for: LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust

Àkótán alákóso / àwọn kókó pàtàkì

  • LibMake ⧉ jẹ́ open-source Rust CLI tool tí a install nípasẹ̀ cargo install libmake, tó ń generate complete library scaffold láti CLI flags tàbí config file (TOML, YAML, JSON, tàbí CSV), pẹ̀lú output tó bo Cargo.toml, source, tests, benchmarks, documentation àti CI nínú invocation kan.
  • Generated project ń tẹ̀lé Rust API Guidelines: module-level àti item-level doc comments nínú src/lib.rs, #![deny(missing_docs)] ní crate root, àti README tí a so mọ́ crate documentation nípasẹ̀ #![doc = include_str!("../README.md")].
  • Config-file mode (--config libmake.toml) ń jẹ́ kí teams commit single file tó ṣàlàyé library template wọn patapata — author, licence, categories, Rust edition, MSRV, repository URL — ó ń jẹ́ kí scaffold generation repeatable àti diffable ní Git.
  • GitHub Actions workflow tí LibMake generate ń test lórí stable, beta àti nightly Rust toolchains, ń enforce clippy -D warnings, ń check rustfmt, ó sì ń run cargo-audit fún known CVEs nínú dependency tree.
  • Tera templates ni ń drive code generation: LibMake wá pẹ̀lú default template set ṣùgbọ́n ó gba custom template directory nípasẹ̀ --template, nítorí náà non-standard project layouts àti additional generated files ni support láì fork tool náà.

LibMake ⧉ jẹ́ open-source Rust CLI àti library tó ń generate complete library project scaffold láti invocation kan. Ó dojú kọ gap láàárín cargo new --lib (tó ń ṣẹ̀dá minimal Cargo.toml àti src/lib.rs nìkan) àti production-ready library setup (tó ń bẹ̀rẹ̀ kí a fi doc comments, CI, test harnesses, benchmark structure, CONTRIBUTING.md, àti licence files kún un manually).

Àpilẹ̀kọ yìí ṣàlàyé ohun tí LibMake ń generate, bí config-file àti CLI modes ṣe ń ṣiṣẹ́, generated CI structure, àti templating system.

Installation àti basic usage

LibMake wà lórí crates.io, a sì ń install rẹ̀ nípasẹ̀ Cargo:

cargo install libmake

Minimal CLI invocation ń generate named library nínú current directory:

libmake \
  --author "Jane Smith" \
  --email "jane@example.com" \
  --name "my_library" \
  --description "A Rust library for doing useful things" \
  --version "0.1.0" \
  --licence "MIT OR Apache-2.0" \
  --repository "https://github.com/example/my_library" \
  --rustversion "1.70.0" \
  --edition "2021" \
  --output "my_library"

Additional optional flags ni --categories, --keywords, --homepage, --documentation, --readme, àti --build.

Config-file mode

Fún team use, gbogbo CLI flags lè wà nínú TOML config file:

# libmake.toml
author      = "Jane Smith"
email       = "jane@example.com"
name        = "my_library"
description = "A Rust library for doing useful things"
version     = "0.1.0"
licence     = "MIT OR Apache-2.0"
repository  = "https://github.com/example/my_library"
rustversion = "1.70.0"
edition     = "2021"
output      = "my_library"
categories  = ["algorithms", "data-structures"]
keywords    = ["rust", "library"]

A ń pe e báyìí:

libmake --config libmake.toml

LibMake tún gba JSON, YAML, àti CSV config formats nípasẹ̀ --config-json, --config-yaml, àti --config-csv flags. Commit libmake.toml sí repository root ń fún contributor kọọkan ní reproducible scaffold baseline, àti changes sí template configuration máa hàn nínú Git diffs.

Generated project structure

LibMake invocation ń ṣẹ̀dá layout yìí:

my_library/
├── .github/
│   └── workflows/
│       └── release.yml     # full CI matrix
├── benches/
│   └── lib_benchmarks.rs   # Criterion benchmark stub
├── src/
│   └── lib.rs              # doc-commented, deny(missing_docs)
├── tests/
│   └── lib_tests.rs        # integration test stub
├── CONTRIBUTING.md
├── Cargo.toml              # complete metadata
├── LICENSE-APACHE
├── LICENSE-MIT
└── README.md

Generated src/lib.rs ní crate-level doc comment, #![deny(missing_docs)], #![doc = include_str!("../README.md")] láti fa README wọ rustdoc, àti stub public type pẹ̀lú associated doc comment. Àwọn choices wọ̀nyí ń tẹ̀lé Rust API Guidelines requirement pé gbogbo public items gbọ́dọ̀ ní documentation.

Generated benches/lib_benchmarks.rs ń lo Criterion.rs, ó sì ń bẹ̀rẹ̀ kí criterion jẹ́ dev-dependency; LibMake ń fi i sínú Cargo.toml laifọwọyi.

GitHub Actions CI workflow

Generated .github/workflows/release.yml ń run jobs márùn-ún lórí gbogbo push àti pull request:

Job Toolchain Ohun tí ó ń check
test stable, beta, nightly (matrix) cargo test --all-features
clippy stable cargo clippy -- -D warnings
fmt stable cargo fmt --check
audit stable cargo audit (cargo-audit installed in job)
doc stable cargo doc --no-deps (fails on missing docs)

Nightly job ní continue-on-error: true, nítorí náà nightly regression kì í block merges, ṣùgbọ́n failure ṣi máa hàn nínú workflow run.

Templating pẹ̀lú Tera

LibMake ń lo Tera template engine — syntax tó dà bí Jinja2 fún Rust — láti render gbogbo generated files. Template kọọkan ń gba full config struct gẹ́gẹ́ bí context:

{{ name }}            → my_library
{{ author }}          → Jane Smith
{{ edition }}         → 2021
{{ description }}     → A Rust library for doing useful things

Custom template directories ni support nípasẹ̀ --template flag:

libmake --config libmake.toml --template ./my_templates/

Custom directory gbọ́dọ̀ mirror default template structure (filenames kan náà). Fáìlì kankan tó wà nínú custom directory máa override corresponding built-in template; fáìlì tí kò sí nínú custom directory máa fall back sí built-in version. Èyí ń gba partial overrides laaye — fún àpẹẹrẹ, rirọ́pò CI workflow template nìkan nígbà tí default src/lib.rs àti Cargo.toml templates ṣi wà.

Ìbéèrè tí a máa ń béèrè

Báwo ni LibMake ṣe yàtọ̀ sí cargo new --lib? cargo new --lib ń ṣẹ̀dá minimal project pẹ̀lú Cargo.toml àti src/lib.rs nìkan (tó ní #[cfg(test)] block kan). LibMake ń generate full structure — integration tests, benchmarks, CI, CONTRIBUTING.md, dual-licence files, àti src/lib.rs tó ní documentation dáadáa — configured pẹ̀lú actual metadata ti project dípò placeholders.

Ṣé a lè lo LibMake pẹ̀lú existing Cargo workspace? LibMake ń generate standalone crate directory. Láti fi generated crate kún existing workspace, fi output path sí workspace members array nínú root Cargo.toml. LibMake kì í modify existing workspace files.

Ṣé mo lè update scaffold templates lẹ́yìn initial generation? LibMake ń generate files lẹ́ẹ̀kan; kò track tàbí update projects tí a ti generate tẹ́lẹ̀. Láti adopt updated templates, ọ̀nà tí a ṣeduro ni láti run LibMake sí temporary directory, kí o sì diff result náà sí existing crate, kí o apply changes tí o fẹ́ selectively.

Rust editions àti MSRV values wo ni LibMake support? LibMake ń gba string kankan fún --edition àti --rustversion, ó sì ń kọ values náà taara sí Cargo.toml. Kò validate bóyá edition tàbí MSRV tí a sọ jẹ́ real Rust version, nítorí náà caller ló ní responsibility láti fi correct values sílẹ̀.

Àwọn ìtọ́kasí

  1. Rousseau, S. LibMake — code generator fún dín repetitive tasks kù àti kíkọ high-quality Rust libraries. GitHub, 2023. https://github.com/sebastienrousseau/libmake
  2. The Rust Programming Language. Rust API Guidelines. GitHub, 2023. https://rust-lang.github.io/api-guidelines/
  3. The Cargo Book. Package Layout. The Rust Programming Language, 2023. https://doc.rust-lang.org/cargo/guide/project-layout.html
  4. Keats, V. et al. Tera — template engine tí Jinja2 àti Django templates ní ìmísí sí. GitHub, 2023. https://keats.github.io/tera/

A ṣe àtúnyẹ̀wò kẹ́yìn .

Àyẹ̀wò àkọ́kọ́ .

Tẹ àpilẹ̀kọ yìí jáde lẹ́ẹ̀kan sí i

Daakọ ọ̀nà fún Medium

# LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau

> Originally published at [https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/](https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/)

LibMake jẹ́ Rust CLI tool tó ń dá complete library scaffold — Cargo.toml, src/lib.rs pẹ̀lú doc templates, test àti benchmark harnesses, àti GitHub Actions CI — láti command kan tàbí versioned TOML/YAML config file.

Read the full article on sebastienrousseau.com: https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/

Daakọ ọ̀nà fún Mastodon

LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau

LibMake jẹ́ Rust CLI tool tó ń dá complete library scaffold — Cargo.toml, src/lib.rs pẹ̀lú doc templates, test àti benchmark harnesses, àti GitHub Actions CI — láti command kan tàbí versioned TOML/YAML config file.

https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/

Daakọ tí a ṣe ìtọ́nà fún LinkedIn

LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau

LibMake jẹ́ Rust CLI tool tó ń dá complete library scaffold - Cargo.toml, src/lib.rs pẹ̀lú doc templates, test àti benchmark harnesses, àti GitHub Actions CI - láti command kan tàbí versioned TOML/YAML config file.

Èyí ni àwọn èrò àgbékalẹ̀ pàtàkì:

- Installation àti basic usage. LibMake wà lórí crates.io, a sì ń install rẹ̀ nípasẹ̀ Cargo:.
- Config-file mode. Fún team use, gbogbo CLI flags lè wà nínú TOML config file:.
- Generated project structure. LibMake invocation ń ṣẹ̀dá layout yìí:.
- GitHub Actions CI workflow. Generated .github/workflows/release.yml ń run jobs márùn-ún lórí gbogbo push àti pull request:.

Kí ni ọ̀nà àgbékalẹ̀ ilé-iṣẹ́ yín sí àwọn ìpèníjà tí a sọ nínú àpilẹ̀kọ yìí?

→ https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/

#Libmake #RustCodeGenerator #CargoScaffold #RustLibraryTemplate #TeraTemplating

Sebastien Rousseau | CC-BY-4.0
Tọka àpilẹkọ yìí

LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau

LibMake jẹ́ Rust CLI tool tó ń dá complete library scaffold — Cargo.toml, src/lib.rs pẹ̀lú doc templates, test àti benchmark harnesses, àti GitHub Actions CI — láti command kan tàbí versioned TOML/YAML config file.

BibTeX

@online{rousseau2023libmake,
  author  = {Rousseau, Sebastien},
  title   = {{LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau}},
  year    = {2023},
  url     = {https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/},
  urldate = {2023}
}

RIS

TY  - GEN
AU  - Rousseau, Sebastien
TI  - LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau
PY  - 2023
UR  - https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/
ER  -

Vancouver

Rousseau S. LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau. sebastienrousseau.com. 2023 Oct 26. Available from: https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/

Chicago

Rousseau, Sebastien. "LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau." sebastienrousseau.com. October 26, 2023. https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/.

APA

Rousseau, S. (2023, October 26). LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau. sebastienrousseau.com. https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/

Tun àpilẹkọ yìí jade

LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau

LibMake jẹ́ Rust CLI tool tó ń dá complete library scaffold — Cargo.toml, src/lib.rs pẹ̀lú doc templates, test àti benchmark harnesses, àti GitHub Actions CI — láti command kan tàbí versioned TOML/YAML config file.

A ti fun àpilẹkọ yìí ni iwe-ẹri labẹ Creative Commons Attribution 4.0 International. Atunjade nilo idanimọ si URL akọkọ.

LibMake: Olùpilẹ̀ṣẹ̀ Àtẹ-ìpìlẹ̀ Ìkójọ-kóòdù Rust — Sebastien Rousseau

LibMake jẹ́ Rust CLI tool tó ń dá complete library scaffold — Cargo.toml, src/lib.rs pẹ̀lú doc templates, test àti benchmark harnesses, àti GitHub Actions CI — láti command kan tàbí versioned TOML/YAML config file.

Originally published at https://sebastienrousseau.com/yo/2023-10-26-libmake-a-code-generator-to-reduce-repetitive-tasks-and-build-high-quality-rust-libraries/ by Sebastien Rousseau.
Licensed under CC-BY-4.0.