Skip to content

Commit

Permalink
tools: read dart version from flutter sdk dir (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
fertrig authored Oct 7, 2023
1 parent bb7fdab commit 7cd233e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions tools/build_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ Building Monarch Controller using these arguments:
out_controller_dir.deleteSync(recursive: true);
out_controller_dir.createSync(recursive: true);

var flutterVersion = pub.Version.parse(get_flutter_version(flutter_sdk));
var flutterVersionWithDart3 = pub.Version(3, 8, 0, pre: '10.1.pre');
var dartVersion = pub.Version.parse(get_dart_version(flutter_sdk));
var dart3 = pub.Version(3, 0, 0);

var useGrpc310 = flutterVersion < flutterVersionWithDart3;
var useGrpc310 = dartVersion < dart3;
if (useGrpc310) {
print('Running `git apply grpc_310.patch`\n');
utils.gitApplyPatch(repo_paths.controller, 'grpc_310.patch');
Expand Down
14 changes: 7 additions & 7 deletions tools/build_preview_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import 'utils_local.dart' as local_utils;
/// - Path to the root of the Monarch repo
/// - Path to the Flutter SDK to use
/// - Path to the monarch_ui/{flutter_id} output directory
void buildPreviewApi(String repo_root, String flutter_sdk, String out_ui_flutter_id) {
void buildPreviewApi(
String repo_root, String flutter_sdk, String out_ui_flutter_id) {
var repo_paths = RepoPaths(repo_root);

print('''
Expand All @@ -32,11 +33,10 @@ Building Monarch Preview API using these arguments:
out_preview_api_dir.deleteSync(recursive: true);
out_preview_api_dir.createSync(recursive: true);

var dartVersion = pub.Version.parse(get_dart_version(flutter_sdk));
var dart3 = pub.Version(3, 0, 0);

var flutterVersion = pub.Version.parse(get_flutter_version(flutter_sdk));
var flutterVersionWithDart3 = pub.Version(3, 8, 0, pre: '10.1.pre');

var useGrpc310 = flutterVersion < flutterVersionWithDart3;
var useGrpc310 = dartVersion < dart3;
if (useGrpc310) {
print('Running `git apply grpc_310.patch`\n');
utils.gitApplyPatch(repo_paths.preview_api, 'grpc_310.patch');
Expand Down Expand Up @@ -81,7 +81,8 @@ Building monarch preview_api flutter bundle. Will output to:
}

{
var icudtl_dat_ = icudtl_dat(flutter_sdk, local_utils.read_target_platform());
var icudtl_dat_ =
icudtl_dat(flutter_sdk, local_utils.read_target_platform());

if (Platform.isWindows) {
var result = Process.runSync(
Expand Down Expand Up @@ -109,4 +110,3 @@ Building monarch preview_api flutter bundle. Will output to:
===============================================================================
''');
}

6 changes: 6 additions & 0 deletions tools/paths.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,9 @@ String gen_seed_flutter_id(String platform_gen_seed, String flutter_sdk) =>

String build_flutter_id(String build, String flutter_sdk) =>
p.join(build, flutter_id(flutter_sdk));

String get_dart_version(String flutter_sdk) {
var version = File(p.join(flutter_sdk, 'bin', 'cache', 'dart-sdk', 'version'))
.readAsStringSync();
return version.trim();
}

0 comments on commit 7cd233e

Please sign in to comment.