Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily allow modification of a BuildOutput's raw dependencies #169

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkgs/native_assets_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.2

- Fixed an issue where `Depenendencies.dependencies` could not be
modified when expected to.

## 0.3.1

- Added `Target.androidRiscv64`.
Expand Down
6 changes: 4 additions & 2 deletions pkgs/native_assets_cli/lib/src/model/build_output.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ class BuildOutput {
Metadata? metadata,
}) : timestamp = (timestamp ?? DateTime.now()).roundDownToSeconds(),
assets = assets ?? [],
dependencies = dependencies ?? const Dependencies([]),
metadata = metadata ?? const Metadata({});
// ignore: prefer_const_constructors
dependencies = dependencies ?? Dependencies([]),
// ignore: prefer_const_constructors
metadata = metadata ?? Metadata({});

static const _assetsKey = 'assets';
static const _dependenciesKey = 'dependencies';
Expand Down
4 changes: 3 additions & 1 deletion pkgs/native_assets_cli/lib/src/model/dependencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../utils/uri.dart';
import '../utils/yaml.dart';

class Dependencies {
/// The dependencies a build relied on.
final List<Uri> dependencies;

const Dependencies(this.dependencies);
Expand All @@ -19,7 +20,8 @@ class Dependencies {
if (yaml is YamlList) {
return Dependencies.fromYaml(yaml);
}
return const Dependencies([]);
// ignore: prefer_const_constructors
return Dependencies([]);
}

factory Dependencies.fromYaml(YamlList? yamlList) => Dependencies([
Expand Down
2 changes: 1 addition & 1 deletion pkgs/native_assets_cli/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: native_assets_cli
description: >-
A library that contains the argument and file formats for implementing a
native assets CLI.
version: 0.3.1
version: 0.3.2
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_cli

topics:
Expand Down
11 changes: 11 additions & 0 deletions pkgs/native_assets_cli/test/model/build_output_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,15 @@ version: ${BuildOutput.version}'''),
throwsFormatException,
);
});

test('BuildOutput dependencies can be modified', () {
// TODO(https://github.com/dart-lang/native/issues/25):
// Remove once dependencies are made immutable.
final buildOutput = BuildOutput();
expect(
() => buildOutput.dependencies.dependencies
.add(Uri.file('path/to/file.ext')),
returnsNormally,
);
});
}