Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharkes committed Nov 29, 2024
1 parent 3f79866 commit 82666be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
20 changes: 3 additions & 17 deletions pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,6 @@ ${e.message}
Uri workingDirectory,
bool includeParentEnvironment,
) async {
final dartPathFile = File.fromUri(
outputDirectory.resolve('../hook.dill.dart_path.txt'),
);

final kernelFile = File.fromUri(
outputDirectory.resolve('../hook.dill'),
);
Expand All @@ -698,18 +694,9 @@ ${e.message}
final dependenciesHashes = DependenciesHashFile(file: dependenciesHashFile);
final lastModifiedCutoffTime = DateTime.now();
var mustCompile = false;
if (!await dependenciesHashFile.exists() || !await dartPathFile.exists()) {
if (!await dependenciesHashFile.exists()) {
mustCompile = true;
} else {
final previousDartExecutable =
Uri.file(await dartPathFile.readAsString());
if (previousDartExecutable != dartExecutable) {
mustCompile = true;
logger.info(
'Recompiling ${scriptUri.toFilePath()}, Dart executable changed.',
);
}

final outdatedFile =
await dependenciesHashes.findOutdatedFileSystemEntity();
if (outdatedFile != null) {
Expand Down Expand Up @@ -744,12 +731,11 @@ ${e.message}
await dependenciesHashes.hashFilesAndDirectories(
[
...dartSources,
// If the Dart executable is replaced in-place, recompile.
dartExecutable,
// If the Dart version changed, recompile.
dartExecutable.resolve('../version'),
],
validBeforeLastModified: lastModifiedCutoffTime,
);
await dartPathFile.writeAsString(dartExecutable.toFilePath());
if (modifiedDuringBuild != null) {
logger.severe('File modified during build. Build must be rerun.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ void main() async {
buildValidator: validateCodeAssetBuildOutput,
applicationAssetValidator: validateCodeAssetInApplication,
))!;
final hookUri = packageUri.resolve('hook/build.dart');
print(logMessages.join('\n'));
expect(
logMessages.join('\n'),
isNot(contains('Recompiling ${hookUri.toFilePath()}')),
);
expect(
logMessages.join('\n'),
contains('Skipping build for native_add'),
Expand Down Expand Up @@ -199,7 +205,7 @@ void main() async {
applicationAssetValidator: validateCodeAssetInApplication,
))!;

final hookUri = packageUri.resolve('hook/').resolve('build.dart');
final hookUri = packageUri.resolve('hook/build.dart');
expect(
logMessages.join('\n'),
contains('Recompiling ${hookUri.toFilePath()}'),
Expand Down

0 comments on commit 82666be

Please sign in to comment.