From 9c7706f595abaf12b34b83559817e885787eae85 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Wed, 21 Oct 2026 10:43:15 +0200 Subject: [PATCH] Make clap optional behind a default cli feature Only the webnn-graph binary uses clap, but it was an unconditional dependency, so library consumers compiled it. Add a default `cli` feature enabling clap and gate the binary on it with `required-features`. Default builds are unchanged; `--no-default-features` now builds the library without clap. --- CHANGELOG.md | 6 ++++++ Cargo.toml | 6 ++++-- README.md | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a7bb5..5d80c84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project follows Semantic Versioning. +## [Unreleased] + +### Changed +- `clap` is optional, behind a new default `cli` feature that also gates the `webnn-graph` binary; + `--no-default-features` builds the library without it. + ## [0.4.0] - 2026-10-15 ### Added diff --git a/Cargo.toml b/Cargo.toml index cc21fdb..eb11406 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,9 +16,11 @@ path = "src/lib.rs" [[bin]] name = "webnn-graph" path = "src/main.rs" +required-features = ["cli"] [features] -default = ["onnx"] +default = ["onnx", "cli"] +cli = ["dep:clap"] onnx = ["dep:webnn-onnx-utils", "dep:prost"] [dependencies] @@ -30,7 +32,7 @@ half = "2.7.1" thiserror = "1.0" pest = "2.7" pest_derive = "2.7" -clap = { version = "4.5", features = ["derive"] } +clap = { version = "4.5", features = ["derive"], optional = true } base64 = "0.22" prost = { version = "0.12", optional = true } webnn-onnx-utils = { version = "0.1.1", optional = true } diff --git a/README.md b/README.md index 29a92dd..71a6904 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,9 @@ cargo build cargo test ``` -ONNX conversion is enabled by the default `onnx` feature. Build only the parser, serializer, validators, -emitters, and weight utilities with: +ONNX conversion is enabled by the default `onnx` feature, and the `webnn-graph` binary by the default `cli` +feature (which pulls in `clap`). Build only the parser, serializer, validators, emitters, and weight utilities +with: ```bash cargo build --no-default-features