sourcesStamp method

String sourcesStamp()

A hash of the runner's Swift sources, so a glint update with a changed runner rebuilds it.

Implementation

String sourcesStamp() {
  var h = 0x811c9dc5;
  final root = Directory(projectPath).parent;
  if (!root.existsSync()) return '';
  final files = root
      .listSync(recursive: true)
      .whereType<File>()
      .where((f) => f.path.endsWith('.swift') || f.path.endsWith('.pbxproj'))
      .toList()
    ..sort((a, b) => a.path.compareTo(b.path));
  for (final f in files) {
    for (final b in f.readAsBytesSync()) {
      h = ((h ^ b) * 0x01000193) & 0xffffffff;
    }
  }
  return h.toRadixString(16);
}