From d7bae1a9fc99f40221234c6eb90493ddebd2ced8 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 30 Nov 2023 12:10:27 +0100 Subject: [PATCH] Add step serialization --- pkgs/native_assets_cli/lib/src/model/asset.dart | 9 +++++++-- pkgs/native_assets_cli/lib/src/model/build_type.dart | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/native_assets_cli/lib/src/model/asset.dart b/pkgs/native_assets_cli/lib/src/model/asset.dart index 0e79ea1e4..1f191dcc6 100644 --- a/pkgs/native_assets_cli/lib/src/model/asset.dart +++ b/pkgs/native_assets_cli/lib/src/model/asset.dart @@ -237,12 +237,14 @@ class Asset { String? id, Target? target, AssetPath? path, + RunStep? step, }) => Asset( id: id ?? this.id, linkMode: linkMode ?? this.linkMode, target: target ?? this.target, path: path ?? this.path, + step: step ?? this.step, ); @override @@ -253,17 +255,19 @@ class Asset { return other.id == id && other.linkMode == linkMode && other.target == target && - other.path == path; + other.path == path && + other.step == step; } @override - int get hashCode => Object.hash(id, linkMode, target, path); + int get hashCode => Object.hash(id, linkMode, target, path, step); Map toYaml() => { _idKey: id, _linkModeKey: linkMode.name, _pathKey: path.toYaml(), _targetKey: target.toString(), + _step: step.toYaml(), }; Map> toDartConst() => { @@ -276,6 +280,7 @@ class Asset { static const _linkModeKey = 'link_mode'; static const _pathKey = 'path'; static const _targetKey = 'target'; + static const _step = 'step'; Future exists() => path.exists(); diff --git a/pkgs/native_assets_cli/lib/src/model/build_type.dart b/pkgs/native_assets_cli/lib/src/model/build_type.dart index 3a3ceec95..f3e101a3a 100644 --- a/pkgs/native_assets_cli/lib/src/model/build_type.dart +++ b/pkgs/native_assets_cli/lib/src/model/build_type.dart @@ -10,6 +10,11 @@ sealed class RunStep { List args(Uri configFile, Uri buildOutput, Uri? resources); const RunStep(); + + Map toYaml() => { + 'script': scriptName, + 'output': outputName, + }; } final class LinkStep extends RunStep {