1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! # feature-scope Macros
//!
//! Procedural macros for the `feature-scope` library that enables workspace crates to
//! independently control their required features without cross-package interference.
//!
//! ## Overview
//!
//! This crate provides the `#[feature_scope]` and `#[feature_scope_default]` attribute macros
//! that allow you to conditionally compile code based on feature flags defined in your `Cargo.toml`.
//!
//! ## Configuration
//!
//! This library uses a two-step configuration approach:
//!
//! 1. **Declare features** in library crates using `package.metadata.feature-scope-decl`:
//!
//! ```toml
//! # In your library crate's Cargo.toml
//! [package.metadata.feature-scope-decl]
//! default = ["a"]
//! a = []
//! b = []
//! c = []
//! ```
//!
//! 2. **Configure feature usage** in consumer crates using `package.metadata.feature-scope`:
//!
//! ```toml
//! # In your binary/consumer crate's Cargo.toml
//! [[package.metadata.feature-scope]]
//! package = "your-library-name"
//! features = ["b"]
//! default-features = false
//! ```
//!
//! ## Usage
//!
//! Use the macros in your library code:
//!
//! ```rust
//! use feature_scope::{feature_scope, feature_scope_default};
//!
//! #[feature_scope_default(a)]
//! pub fn feature_a_function() {
//! println!("This compiles when feature 'a' is enabled or by default");
//! }
//!
//! #[feature_scope(b)]
//! pub fn feature_b_function() {
//! println!("This only compiles when feature 'b' is enabled");
//! }
//!
//! #[feature_scope_default]
//! pub fn default_function() {
//! println!("This compiles by default");
//! }
//! ```
//!
//! ## Build Commands
//!
//! Use `cargo feature-scope` commands instead of regular `cargo` commands to build your project:
//!
//! ```bash
//! cargo feature-scope build
//! cargo feature-scope run
//! cargo feature-scope test
//! ```
use TokenStream;
use quote;
use parse_macro_input;