Skip to content
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
2 changes: 1 addition & 1 deletion flutter/cpp/flutter/dart_backend_match.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extern "C" struct dart_ffi_backend_match_result *dart_ffi_backend_match(
result->pbdata = new char[result->pbdata_size];
memcpy(result->pbdata, res.data(), result->pbdata_size);

LOG(INFO) << "backend matches";
LOG(INFO) << "backend matches '" << lib_path << "'";

return result;
}
Expand Down
24 changes: 22 additions & 2 deletions flutter/lib/backend/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,33 @@ part 'list.gen.dart';

class BackendInfoHelper {
BackendInfo findMatching() {
const fallbackBackend = 'libtflitebackend';
final matches = <BackendInfo>[];
// Try to match all backends except the fallback
for (var name in getBackendsList()) {
if (name == fallbackBackend) continue;
print('Checking $name');
final backendSettings = match(name);
if (backendSettings != null) {
return BackendInfo._(backendSettings, name);
matches.add(BackendInfo._(backendSettings, name));
}
}
throw 'no matching backend found';

if (matches.isEmpty) {
// No specific backend matched, use fallback
print('Checking $fallbackBackend');
final backendSettings = match(fallbackBackend);
if (backendSettings != null) {
return BackendInfo._(backendSettings, fallbackBackend);
}
throw 'no matching backend found';
}
if (matches.length > 1) {
final names = matches.map((m) => m.libName).join(', ');
throw 'multiple matching backends found: $names';
}
print('Using backend: ${matches.single.libName}');
return matches.single;
}

pb.BackendSetting? match(String libName) {
Expand Down
Loading