@@ -8,6 +8,7 @@ use msix::AppxManifest;
88use serde:: Deserialize ;
99use std:: collections:: HashMap ;
1010use std:: path:: { Path , PathBuf } ;
11+ use xcommon:: ZipFileOptions ;
1112
1213#[ derive( Clone , Debug , Default ) ]
1314pub struct Config {
@@ -313,7 +314,84 @@ impl Config {
313314 }
314315}
315316
317+ #[ derive( Clone , Copy , Debug , Default , Deserialize ) ]
318+ #[ serde( rename_all = "snake_case" ) ]
319+ pub enum UnalignedCompressed {
320+ /// Don't align this file
321+ Unaligned ,
322+ /// Compressed files do not need to be aligned, as they have to be unpacked and decompressed anyway
323+ #[ default]
324+ Compressed ,
325+ }
326+
327+ #[ derive( Clone , Copy , Debug , Deserialize ) ]
328+ #[ serde( untagged) ]
329+ pub enum ZipAlignmentOptions {
330+ /// Align this file to the given number of bytes
331+ Aligned ( u16 ) ,
332+ /// Used to wrap a tagged enum with an untagged alignment value
333+ UnalignedCompressed ( UnalignedCompressed ) ,
334+ }
335+
336+ impl Default for ZipAlignmentOptions {
337+ fn default ( ) -> Self {
338+ Self :: UnalignedCompressed ( UnalignedCompressed :: Compressed )
339+ }
340+ }
341+
342+ impl ZipAlignmentOptions {
343+ pub fn to_zip_file_options ( self ) -> ZipFileOptions {
344+ match self {
345+ Self :: Aligned ( a) => ZipFileOptions :: Aligned ( a) ,
346+ Self :: UnalignedCompressed ( UnalignedCompressed :: Unaligned ) => ZipFileOptions :: Unaligned ,
347+ Self :: UnalignedCompressed ( UnalignedCompressed :: Compressed ) => {
348+ ZipFileOptions :: Compressed
349+ }
350+ }
351+ }
352+ }
353+
354+ #[ derive( Clone , Debug , Deserialize ) ]
355+ #[ serde( untagged, deny_unknown_fields) ]
356+ pub enum AssetPath {
357+ Path ( PathBuf ) ,
358+ Extended {
359+ path : PathBuf ,
360+ #[ serde( default ) ]
361+ optional : bool ,
362+ #[ serde( default ) ]
363+ alignment : ZipAlignmentOptions ,
364+ } ,
365+ }
366+
367+ impl AssetPath {
368+ #[ inline]
369+ pub fn path ( & self ) -> & Path {
370+ match self {
371+ AssetPath :: Path ( path) => path,
372+ AssetPath :: Extended { path, .. } => path,
373+ }
374+ }
375+
376+ #[ inline]
377+ pub fn optional ( & self ) -> bool {
378+ match self {
379+ AssetPath :: Path ( _) => false ,
380+ AssetPath :: Extended { optional, .. } => * optional,
381+ }
382+ }
383+
384+ #[ inline]
385+ pub fn alignment ( & self ) -> ZipAlignmentOptions {
386+ match self {
387+ AssetPath :: Path ( _) => Default :: default ( ) ,
388+ AssetPath :: Extended { alignment, .. } => * alignment,
389+ }
390+ }
391+ }
392+
316393#[ derive( Deserialize ) ]
394+ #[ serde( deny_unknown_fields) ]
317395struct RawConfig {
318396 #[ serde( flatten) ]
319397 generic : Option < GenericConfig > ,
@@ -325,13 +403,15 @@ struct RawConfig {
325403}
326404
327405#[ derive( Clone , Debug , Default , Deserialize ) ]
406+ #[ serde( deny_unknown_fields) ]
328407pub struct GenericConfig {
329408 icon : Option < PathBuf > ,
330409 #[ serde( default ) ]
331410 runtime_libs : Vec < PathBuf > ,
332411}
333412
334413#[ derive( Clone , Debug , Default , Deserialize ) ]
414+ #[ serde( deny_unknown_fields) ]
335415pub struct AndroidDebugConfig {
336416 /// Forward remote (phone) socket connection to local (host)
337417 #[ serde( default ) ]
@@ -342,6 +422,7 @@ pub struct AndroidDebugConfig {
342422}
343423
344424#[ derive( Clone , Debug , Default , Deserialize ) ]
425+ #[ serde( deny_unknown_fields) ]
345426pub struct AndroidConfig {
346427 #[ serde( flatten) ]
347428 generic : GenericConfig ,
@@ -353,12 +434,15 @@ pub struct AndroidConfig {
353434 pub gradle : bool ,
354435 #[ serde( default ) ]
355436 pub wry : bool ,
437+ #[ serde( default ) ]
438+ pub assets : Vec < AssetPath > ,
356439 /// Debug configuration for `x run`
357440 #[ serde( default ) ]
358441 pub debug : AndroidDebugConfig ,
359442}
360443
361444#[ derive( Clone , Debug , Default , Deserialize ) ]
445+ #[ serde( deny_unknown_fields) ]
362446pub struct IosConfig {
363447 #[ serde( flatten) ]
364448 generic : GenericConfig ,
@@ -367,19 +451,22 @@ pub struct IosConfig {
367451}
368452
369453#[ derive( Clone , Debug , Default , Deserialize ) ]
454+ #[ serde( deny_unknown_fields) ]
370455pub struct MacosConfig {
371456 #[ serde( flatten) ]
372457 generic : GenericConfig ,
373458 pub info : InfoPlist ,
374459}
375460
376461#[ derive( Clone , Debug , Default , Deserialize ) ]
462+ #[ serde( deny_unknown_fields) ]
377463pub struct LinuxConfig {
378464 #[ serde( flatten) ]
379465 generic : GenericConfig ,
380466}
381467
382468#[ derive( Clone , Debug , Default , Deserialize ) ]
469+ #[ serde( deny_unknown_fields) ]
383470pub struct WindowsConfig {
384471 #[ serde( flatten) ]
385472 generic : GenericConfig ,
0 commit comments