compileProtos function
Walk trhgouh protos
paths and compile them with protoc + baseArguments
.
Implementation
Future<void> compileProtos(
Set<String> protos, List<String> baseArguments) async {
int counter = 0;
void writeStatusBar(String file) {
final bar = progressBar(counter / protos.length, colorCompleted: penDone);
stdout
..moveFarLeft()
..write('$bar ($counter / ${protos.length}) - $file');
}
for (var proto in protos) {
counter++;
writeStatusBar(path.basename(proto));
final depsProcess = await Process.run(
protoc,
[
...baseArguments,
'--plugin=protoc-gen-dart=$dartPlugin',
proto,
],
stdoutEncoding: utf8,
stderrEncoding: utf8,
);
if (depsProcess.exitCode != 0) {
stderr.writeln('error compiling: $proto');
stderr.writeln(depsProcess.stderr);
throw 'error';
}
}
stdout.writeln();
}