Skip to content

Commit 231a532

Browse files
committed
updates in response to code review
1 parent c81cfb1 commit 231a532

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ test: generate_text test_text generate_core test_core
1111
# Runs `ffigen` for all packages and all tests for all packages
1212
test_only: test_core test_text
1313

14+
# Runs `sdks_finder` to update manifest files
15+
sdks:
16+
dart tool/builder/bin/main.dart sdks
17+
1418
# Core ---
1519

1620
# Runs `ffigen` for `mediapipe_core`

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
# Flutter-MediaPipe
22

33
This repository will be home to the source code for the mediapipe_task_vision, mediapipe_task_audio, and mediapipe_task_text plugins for Flutter.
4+
5+
## Releasing
6+
7+
### Updating MediaPipe SDKs
8+
9+
Anytime MediaPipe releases new versions of their SDKs, this package will need to be updated to incorporate those latest builds. SDK versions are pinned in the `sdk_downloads.json` files in each package, which are updated by running the following command from the root of the repository:
10+
11+
```
12+
$ make sdks
13+
```
14+
15+
The Google Cloud Storage bucket in question only gives read-list access to a specific list of Googlers' accounts, so this command must be run from such a Googler's corp machines.
16+
17+
After this, create and merge a PR with the changes and then proceed to `Releasing to pub.dev`.
18+
19+
### Releasing to pub.dev
20+
21+
TODO

tool/builder/lib/sdks_finder.dart

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:convert';
22
import 'dart:io';
3+
import 'dart:io' as io;
34

45
import 'package:args/command_runner.dart';
56
import 'package:builder/extensions.dart';
@@ -47,9 +48,12 @@ enum MediaPipeSdk {
4748
/// command helps by automating a portion of the task.
4849
///
4950
/// The cache-busting mechanism of Flutter's native assets feature is a hash
50-
/// of the contents of any build dependencies, so if this command leads to any
51-
/// new build state, this must be reflected by *some change* to the associated
52-
/// library's `build.dart` script.
51+
/// of the contents of any build dependencies. The output files of this command
52+
/// are included in the build dependencies (as specified by the contents of each
53+
/// package's `build.dart` file), so if this command generates new SDK locations
54+
/// in those files, Flutter's CLI will have a cache miss, will re-run
55+
/// `build.dart` during the build phase, and in turn will download the newest
56+
/// versions of the MediaPipe SDKs onto the developer's machine.
5357
///
5458
/// Operationally, [SdksFinderCommand]'s implementation involves orchestrating
5559
/// one [_OsFinder] instance for each supported [OS] value, which in turn
@@ -67,7 +71,7 @@ class SdksFinderCommand extends Command with RepoFinderMixin {
6771
}
6872
@override
6973
String description =
70-
'Downloads the appropriate MediaPipe SDKs for the current build target';
74+
'Updates MediaPipe SDK manifest files for the current build target';
7175

7276
@override
7377
String name = 'sdks';
@@ -120,8 +124,24 @@ final Map<String, Map<String, String>> sdkDownloadUrls = ${encoder.convert(resul
120124
}
121125

122126
void _checkGsUtil() async {
127+
if (!io.Platform.isMacOS && !io.Platform.isLinux) {
128+
// `which` is not available on Windows, so allow the command to attempt
129+
// to run on Windows
130+
// TODO: possibly add Windows-specific support
131+
return;
132+
}
123133
final process = await Process.start('which', ['gsutil']);
124-
await process.exitCode;
134+
final exitCode = await process.exitCode;
135+
if (exitCode != 0) {
136+
stderr.writeln(
137+
wrapWith(
138+
'Warning: Unexpected exit code $exitCode checking for gsutil. Output:'
139+
'${(await process.processedStdOut).join('\n')}',
140+
[yellow],
141+
),
142+
);
143+
// Not exiting here, since this could be a false-negative.
144+
}
125145
if ((await process.processedStdOut).isEmpty) {
126146
stderr.writeln(
127147
wrapWith(
@@ -297,7 +317,21 @@ Future<List<String>> _gsUtil(String path, {bool recursive = false}) async {
297317
];
298318
_log.finest('Running: `gsutil ${cmd.join(' ')}`');
299319
final process = await Process.start('gsutil', cmd);
300-
await process.exitCode;
320+
final exitCode = await process.exitCode;
321+
if (exitCode > 1) {
322+
// Exit codes of 1 appear when `gsutil` checks for a file that does not
323+
// exist, which for our purposes does not constitute an actual error, and is
324+
// handled later when `process.processedStdOut` is empty.
325+
stderr.writeln(
326+
wrapWith(
327+
'Warning: Unexpected exit code $exitCode running '
328+
'`gsutil ${cmd.join(' ')}`. Output: '
329+
'${(await process.processedStdOut).join('\n')}',
330+
[red],
331+
),
332+
);
333+
exit(exitCode);
334+
}
301335
final processStdout = await process.processedStdOut;
302336
final filtered = (processStdout).where((String line) => line != '').toList();
303337
return filtered;

0 commit comments

Comments
 (0)