@@ -106,6 +106,8 @@ impl MultiSolMacroGen {
106
106
& mut self ,
107
107
name : & str ,
108
108
version : & str ,
109
+ description : & str ,
110
+ license : & str ,
109
111
bindings_path : & Path ,
110
112
single_file : bool ,
111
113
alloy_version : Option < String > ,
@@ -115,7 +117,6 @@ impl MultiSolMacroGen {
115
117
self . generate_bindings ( all_derives) ?;
116
118
117
119
let src = bindings_path. join ( "src" ) ;
118
-
119
120
let _ = fs:: create_dir_all ( & src) ;
120
121
121
122
// Write Cargo.toml
@@ -125,11 +126,23 @@ impl MultiSolMacroGen {
125
126
name = "{name}"
126
127
version = "{version}"
127
128
edition = "2021"
128
-
129
- [dependencies]
130
129
"#
131
130
) ;
132
131
132
+ if !description. is_empty ( ) {
133
+ toml_contents. push_str ( & format ! ( "description = \" {description}\" \n " ) ) ;
134
+ }
135
+
136
+ if !license. is_empty ( ) {
137
+ let formatted_licenses: Vec < String > =
138
+ license. split ( ',' ) . map ( Self :: parse_license_alias) . collect ( ) ;
139
+
140
+ let formatted_license = formatted_licenses. join ( " OR " ) ;
141
+ toml_contents. push_str ( & format ! ( "license = \" {formatted_license}\" \n " ) ) ;
142
+ }
143
+
144
+ toml_contents. push_str ( "\n [dependencies]\n " ) ;
145
+
133
146
let alloy_dep = Self :: get_alloy_dep ( alloy_version, alloy_rev) ;
134
147
write ! ( toml_contents, "{alloy_dep}" ) ?;
135
148
@@ -174,6 +187,23 @@ edition = "2021"
174
187
Ok ( ( ) )
175
188
}
176
189
190
+ /// Attempts to detect the appropriate license.
191
+ pub fn parse_license_alias ( license : & str ) -> String {
192
+ match license. trim ( ) . to_lowercase ( ) . as_str ( ) {
193
+ "mit" => "MIT" . to_string ( ) ,
194
+ "apache" | "apache2" | "apache20" | "apache2.0" => "Apache-2.0" . to_string ( ) ,
195
+ "gpl" | "gpl3" => "GPL-3.0" . to_string ( ) ,
196
+ "lgpl" | "lgpl3" => "LGPL-3.0" . to_string ( ) ,
197
+ "agpl" | "agpl3" => "AGPL-3.0" . to_string ( ) ,
198
+ "bsd" | "bsd3" => "BSD-3-Clause" . to_string ( ) ,
199
+ "bsd2" => "BSD-2-Clause" . to_string ( ) ,
200
+ "mpl" | "mpl2" => "MPL-2.0" . to_string ( ) ,
201
+ "isc" => "ISC" . to_string ( ) ,
202
+ "unlicense" => "Unlicense" . to_string ( ) ,
203
+ _ => license. trim ( ) . to_string ( ) ,
204
+ }
205
+ }
206
+
177
207
pub fn write_to_module (
178
208
& mut self ,
179
209
bindings_path : & Path ,
0 commit comments