tryBuild static method
Attempts to build the given file if it is not already being built.
Prevents duplicate builds for the same file by using _buildingFiles map.
Implementation
static void tryBuild(File file, PrepareBuilder builder) async {
if (_buildingFiles[file.path] == true) return;
// Load the source file.
final source = SourceFileManager.load(file, builder.extensions);
if (source == null) return;
// Mark the file as building.
_buildingFiles[file.path] = true;
try {
await PrepareBuildCommand.tryBuild(source, builder);
} catch (error) {
log("${builder.name} Error: $error", color: red);
} finally {
// Reset the build flag after a short delay to allow subsequent builds.
Future.delayed(delayDuration, () {
_buildingFiles[file.path] = false;
});
}
}