@@ -8,8 +8,14 @@ use serde::Deserialize;
88use serde_yml:: Value ;
99
1010use crate :: {
11- comments:: Comments , description:: Description , distro_pkg:: DistroPkg , get_pkg_id,
12- resource:: Resource , xexec:: XExec , BuildAsset ,
11+ comments:: Comments ,
12+ description:: Description ,
13+ distro_pkg:: DistroPkg ,
14+ get_pkg_id,
15+ license:: { License , LicenseComplex } ,
16+ resource:: Resource ,
17+ xexec:: XExec ,
18+ BuildAsset ,
1319} ;
1420
1521pub mod visitor;
@@ -32,7 +38,7 @@ pub struct BuildConfig {
3238 pub maintainer : Option < Vec < String > > ,
3339 pub icon : Option < Resource > ,
3440 pub desktop : Option < Resource > ,
35- pub license : Option < Vec < String > > ,
41+ pub license : Option < Vec < License > > ,
3642 pub note : Option < Vec < String > > ,
3743 pub provides : Option < Vec < String > > ,
3844 pub repology : Option < Vec < String > > ,
@@ -140,7 +146,33 @@ impl BuildConfig {
140146 config. desktop = to_resource ( val) ;
141147 }
142148 if let Some ( val) = values. get ( "license" ) {
143- config. license = to_string_vec ( val) ;
149+ config. license = val. as_sequence ( ) . map ( |seq| {
150+ seq. iter ( )
151+ . filter_map ( |lc| {
152+ if let Some ( lc) = lc. as_str ( ) {
153+ Some ( License :: Simple ( lc. to_string ( ) ) )
154+ } else {
155+ lc. as_mapping ( ) . map ( |map| {
156+ License :: Complex ( LicenseComplex {
157+ id : map
158+ . get ( Value :: String ( "id" . to_string ( ) ) )
159+ . and_then ( |v| v. as_str ( ) )
160+ . map ( String :: from)
161+ . unwrap_or_default ( ) ,
162+ file : map
163+ . get ( Value :: String ( "file" . to_string ( ) ) )
164+ . and_then ( |v| v. as_str ( ) )
165+ . map ( String :: from) ,
166+ url : map
167+ . get ( Value :: String ( "url" . to_string ( ) ) )
168+ . and_then ( |v| v. as_str ( ) )
169+ . map ( String :: from) ,
170+ } )
171+ } )
172+ }
173+ } )
174+ . collect ( )
175+ } ) ;
144176 }
145177 if let Some ( val) = values. get ( "maintainer" ) {
146178 config. maintainer = to_string_vec ( val) ;
@@ -279,8 +311,16 @@ impl BuildConfig {
279311 write_field_comments ( writer, "license" ) ?;
280312 if let Some ( ref license) = self . license {
281313 writeln ! ( writer, "{}license:" , indent_str) ?;
282- for l in license {
283- writeln ! ( writer, "{} - \" {}\" " , indent_str, l) ?;
314+ for lc in license {
315+ lc. write_yaml ( writer, indent) ?;
316+ }
317+ }
318+
319+ if let Some ( ref build_asset) = self . build_asset {
320+ writeln ! ( writer, "{}build_asset:" , indent_str) ?;
321+ for asset in build_asset {
322+ writeln ! ( writer, "{} - url: \" {}\" " , indent_str, asset. url) ?;
323+ writeln ! ( writer, "{} out: \" {}\" " , indent_str, asset. out) ?;
284324 }
285325 }
286326
0 commit comments