Skip to content

Commit

Permalink
Address remaining comments (use >=3.5.0, remove remaining <=v1.3 vers…
Browse files Browse the repository at this point in the history
…ion-specific branching code)
  • Loading branch information
mkustermann committed Sep 25, 2024
1 parent 3bbdcb2 commit 7ae2003
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 51 deletions.
4 changes: 1 addition & 3 deletions pkgs/native_assets_builder/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_bui
publish_to: none

environment:
# Allow any pre-release version of 3.5.0 and onwards
# (i.e. 3.5.0-edge*, 3.5.0-dev*, 3.5.0-beta*, ...)
sdk: '>=3.5.0-0 <4.0.0'
sdk: '>=3.5.0 <4.0.0'

dependencies:
collection: ^1.18.0
Expand Down
3 changes: 0 additions & 3 deletions pkgs/native_assets_cli/lib/src/model/build_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ final class BuildConfigImpl extends HookConfigImpl implements BuildConfig {

@override
bool get linkingEnabled {
if (version <= Version(1, 2, 0)) {
return false;
}
if (version == Version(1, 3, 0)) {
return true;
}
Expand Down
57 changes: 15 additions & 42 deletions pkgs/native_assets_cli/lib/src/model/hook_output.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,48 +93,21 @@ final class HookOutputImpl implements BuildOutput, LinkOutput {
);
}

Map<String, Object> toJson(Version version) {
final assets = <AssetImpl>[];
for (final asset in _assets) {
switch (asset) {
case NativeCodeAssetImpl _:
if (version <= Version(1, 0, 0) && asset.architecture == null) {
// Dry run does not report architecture. But old Dart and Flutter
// expect architecture to be populated. So, populate assets for all
// architectures.
for (final architecture in asset.os.architectures) {
assets.add(asset.copyWith(
architecture: architecture,
));
}
} else {
assets.add(asset);
}
default:
assets.add(asset);
}
}
final linkMinVersion = Version(1, 3, 0);
if (_assetsForLinking.isNotEmpty && version < linkMinVersion) {
throw UnsupportedError('Please update your Dart or Flutter SDK to link '
'assets in `link.dart` scripts. Your current version is $version, '
'but this feature requires $linkMinVersion');
}
return {
_timestampKey: timestamp.toString(),
if (assets.isNotEmpty) _assetsKey: AssetImpl.listToJson(assets, version),
if (version >= linkMinVersion && _assetsForLinking.isNotEmpty)
_assetsForLinkingKey:
_assetsForLinking.map((packageName, assets) => MapEntry(
packageName,
AssetImpl.listToJson(assets, version),
)),
if (_dependencies.dependencies.isNotEmpty)
_dependenciesKey: _dependencies.toJson(),
if (metadata.metadata.isNotEmpty) _metadataKey: metadata.toJson(),
_versionKey: version.toString(),
}..sortOnKey();
}
Map<String, Object> toJson(Version version) => {
_timestampKey: timestamp.toString(),
if (_assets.isNotEmpty)
_assetsKey: AssetImpl.listToJson(_assets, version),
if (_assetsForLinking.isNotEmpty)
_assetsForLinkingKey:
_assetsForLinking.map((packageName, assets) => MapEntry(
packageName,
AssetImpl.listToJson(assets, version),
)),
if (_dependencies.dependencies.isNotEmpty)
_dependenciesKey: _dependencies.toJson(),
if (metadata.metadata.isNotEmpty) _metadataKey: metadata.toJson(),
_versionKey: version.toString(),
}..sortOnKey();

String toJsonString(Version version) =>
const JsonEncoder.withIndent(' ').convert(toJson(version));
Expand Down
4 changes: 1 addition & 3 deletions pkgs/native_assets_cli/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ topics:
- native-assets

environment:
# Allow any pre-release version of 3.5.0 and onwards
# (i.e. 3.5.0-edge*, 3.5.0-dev*, 3.5.0-beta*, ...)
sdk: '>=3.5.0-0 <4.0.0'
sdk: '>=3.5.0 <4.0.0'

dependencies:
args: ^2.4.2
Expand Down

0 comments on commit 7ae2003

Please sign in to comment.