2019-10-17 01:25:37 +02:00
|
|
|
// Copyright 2016 Google Inc. Use of this source code is governed by an
|
|
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
2019-10-30 01:21:52 +01:00
|
|
|
import 'package:cli_pkg/cli_pkg.dart' as pkg;
|
2019-10-17 01:25:37 +02:00
|
|
|
import 'package:grinder/grinder.dart';
|
2021-06-14 21:51:01 +02:00
|
|
|
import 'package:yaml/yaml.dart';
|
2019-10-17 01:25:37 +02:00
|
|
|
|
|
|
|
import 'utils.dart';
|
|
|
|
|
2022-01-26 02:16:17 +01:00
|
|
|
void main(List<String> args) {
|
2021-05-18 05:57:37 +02:00
|
|
|
pkg.githubBearerToken.fn = () => Platform.environment["GH_BEARER_TOKEN"]!;
|
2021-01-21 01:32:18 +01:00
|
|
|
|
2021-06-14 21:51:01 +02:00
|
|
|
pkg.environmentConstants.fn = () => {
|
|
|
|
...pkg.environmentConstants.defaultValue,
|
|
|
|
"protocol-version":
|
|
|
|
File('build/embedded-protocol/VERSION').readAsStringSync().trim(),
|
|
|
|
"compiler-version": pkg.pubspec.version!.toString(),
|
|
|
|
"implementation-version": _implementationVersion
|
|
|
|
};
|
|
|
|
|
2019-10-30 01:21:52 +01:00
|
|
|
pkg.addGithubTasks();
|
|
|
|
grind(args);
|
|
|
|
}
|
2019-10-17 01:25:37 +02:00
|
|
|
|
2021-06-14 21:51:01 +02:00
|
|
|
/// Returns the version of Dart Sass that this package uses.
|
|
|
|
String get _implementationVersion {
|
|
|
|
var lockfile = loadYaml(File('pubspec.lock').readAsStringSync(),
|
|
|
|
sourceUrl: Uri(path: 'pubspec.lock'));
|
2022-01-26 02:16:17 +01:00
|
|
|
return lockfile['packages']['sass']['version'] as String;
|
2021-06-14 21:51:01 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 01:25:37 +02:00
|
|
|
@Task('Compile the protocol buffer definition to a Dart library.')
|
2022-01-26 02:16:17 +01:00
|
|
|
Future<void> protobuf() async {
|
2019-10-17 01:25:37 +02:00
|
|
|
Directory('build').createSync(recursive: true);
|
|
|
|
|
|
|
|
// Make sure we use the version of protoc_plugin defined by our pubspec,
|
|
|
|
// rather than whatever version the developer might have globally installed.
|
|
|
|
log("Writing protoc-gen-dart");
|
|
|
|
if (Platform.isWindows) {
|
|
|
|
File('build/protoc-gen-dart.bat').writeAsStringSync('''
|
|
|
|
@echo off
|
2021-01-13 22:44:41 +01:00
|
|
|
dart pub run protoc_plugin %*
|
2019-10-17 01:25:37 +02:00
|
|
|
''');
|
|
|
|
} else {
|
|
|
|
File('build/protoc-gen-dart')
|
2021-01-13 22:44:41 +01:00
|
|
|
.writeAsStringSync('dart pub run protoc_plugin "\$@"');
|
2019-11-05 04:50:50 +01:00
|
|
|
run('chmod', arguments: ['a+x', 'build/protoc-gen-dart']);
|
2019-10-17 01:25:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
await cloneOrPull("git://github.com/sass/embedded-protocol");
|
|
|
|
await runAsync("protoc",
|
|
|
|
arguments: [
|
|
|
|
"-Ibuild/embedded-protocol",
|
|
|
|
"embedded_sass.proto",
|
|
|
|
"--dart_out=lib/src/"
|
|
|
|
],
|
|
|
|
runOptions: RunOptions(environment: {
|
|
|
|
"PATH": 'build' +
|
|
|
|
(Platform.isWindows ? ";" : ":") +
|
2021-05-18 05:57:37 +02:00
|
|
|
Platform.environment["PATH"]!
|
2019-10-17 01:25:37 +02:00
|
|
|
}));
|
|
|
|
}
|