Skip to content

[native_assets_builder] Keep outputDirectory if LinkConfig.assets changes #1746

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

Merged
merged 1 commit into from
Nov 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,15 @@ class NativeAssetsBuildRunner {
buildMode: buildMode,
packageName: package.name,
packageRoot: packageLayout.packageRoot(package.name),
)
..setupLinkConfig(
assets: buildResult.encodedAssetsForLinking[package.name] ?? []);
);

final (buildDirUri, outDirUri, outDirSharedUri) = await _setupDirectories(
Hook.link, packageLayout, configBuilder, package);

configBuilder.setupLinkConfig(
assets: buildResult.encodedAssetsForLinking[package.name] ?? [],
);

File? resourcesFile;
if (resourceIdentifiers != null) {
resourcesFile = File.fromUri(buildDirUri.resolve('resources.json'));
Expand Down
5 changes: 4 additions & 1 deletion pkgs/native_assets_cli/lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ sealed class HookConfigBuilder {
/// assumed the output directory has not been set yet.
String computeChecksum() {
if (json.containsKey(_outDirConfigKey) ||
json.containsKey(_outDirSharedConfigKey)) {
json.containsKey(_outDirSharedConfigKey) ||
json.containsKey(_assetsKey)) {
// The bundling tools would first calculate the checksum, create an output
// directory and then call [BuildConfigBuilder.setupBuildRunConfig] &
// [LinkConfigBuilder.setupLinkRunConfig].
// The output directory should not depend on the assets passed in for
// linking.
throw StateError('The checksum should be generated before setting '
'up the run configuration');
}
Expand Down