-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native_*] Hooks with
DataAsset
s read from disk (#1345)
While working on #1208, I released that most likely you'd want to report all files from the `assets/` directory as `DataAsset`s in a hook. (This also means that there's implicitly a `dependency` on the directory itself.) This PR also cleans up the remaining dart files listed in `dependencies`.
- Loading branch information
Showing
22 changed files
with
159 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 25 additions & 8 deletions
33
pkgs/native_assets_builder/test_data/simple_data_asset/hook/build.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
import 'dart:io'; | ||
|
||
import 'package:native_assets_cli/native_assets_cli.dart'; | ||
|
||
void main(List<String> args) => build( | ||
args, | ||
(config, output) async { | ||
void main(List<String> args) async { | ||
await build( | ||
args, | ||
(config, output) async { | ||
final assetDirectory = | ||
Directory.fromUri(config.packageRoot.resolve('assets/')); | ||
// If assets are added, rerun hook. | ||
output.addDependency(assetDirectory.uri); | ||
|
||
await for (final dataAsset in assetDirectory.list()) { | ||
if (dataAsset is! File) { | ||
continue; | ||
} | ||
final name = dataAsset.uri.pathSegments.last; | ||
output.addAsset( | ||
DataAsset( | ||
package: config.packageName, | ||
name: 'assetId', | ||
file: config.packageRoot.resolve('asset/test_asset.txt'), | ||
name: name, | ||
file: dataAsset.uri, | ||
), | ||
); | ||
output.addDependency(config.packageRoot.resolve('hook/build.dart')); | ||
}, | ||
); | ||
// TODO(https://github.com/dart-lang/native/issues/1208): Report | ||
// dependency on asset. | ||
output.addDependency(dataAsset.uri); | ||
} | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.