Skip to content

Commit 3f8a502

Browse files
[pigeon] Remove support for non-NNBD (#1524)
Makes a breaking change to remove non-NNBD support, since it adds complexity to the generator and there's no compelling reason to continue supporting it going forward. Also updates some legacy Dart commands in scripts (dartanalyzer, dart pub run) to their modern versions.
1 parent c29083d commit 3f8a502

File tree

8 files changed

+121
-235
lines changed

8 files changed

+121
-235
lines changed

packages/pigeon/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.0.0
2+
3+
* **BREAKING CHANGE**: Removes the `--dart_null_safety` flag. Generated Dart
4+
now always uses nullability annotations, and thus requires Dart 2.12 or later.
5+
16
## 2.0.4
27

38
* Fixes bug where Dart `FlutterApi`s would assert that a nullable argument was nonnull.
@@ -9,7 +14,7 @@
914
## 2.0.2
1015

1116
* Fixes Java crash for nullable nested type.
12-
17+
1318
* ## 2.0.1
1419

1520
* Adds support for TaskQueues for serial background execution.

packages/pigeon/lib/dart_generator.dart

Lines changed: 61 additions & 80 deletions
Large diffs are not rendered by default.

packages/pigeon/lib/generator_tools.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:mirrors';
88
import 'ast.dart';
99

1010
/// The current version of pigeon. This must match the version in pubspec.yaml.
11-
const String pigeonVersion = '2.0.4';
11+
const String pigeonVersion = '3.0.0';
1212

1313
/// Read all the content from [stdin] to a String.
1414
String readStdin() {

packages/pigeon/lib/pigeon_lib.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,6 @@ options:
10411041
..addOption('java_out', help: 'Path to generated Java file (.java).')
10421042
..addOption('java_package',
10431043
help: 'The package that generated Java code will be in.')
1044-
..addFlag('dart_null_safety',
1045-
help: 'Makes generated Dart code have null safety annotations',
1046-
defaultsTo: true)
10471044
..addOption('objc_header_out',
10481045
help: 'Path to generated Objective-C header file (.h).')
10491046
..addOption('objc_prefix',
@@ -1082,9 +1079,6 @@ options:
10821079
javaOptions: JavaOptions(
10831080
package: results['java_package'],
10841081
),
1085-
dartOptions: DartOptions(
1086-
isNullSafe: results['dart_null_safety'],
1087-
),
10881082
copyrightHeader: results['copyright_header'],
10891083
oneLanguage: results['one_language'],
10901084
astOut: results['ast_out'],

packages/pigeon/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: pigeon
22
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
33
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
5-
version: 2.0.4 # This must match the version in lib/generator_tools.dart
5+
version: 3.0.0 # This must match the version in lib/generator_tools.dart
66

77
environment:
88
sdk: ">=2.12.0 <3.0.0"

packages/pigeon/run_tests.sh

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,38 +86,26 @@ test_pigeon_android() {
8686
# test_null_safe_dart(<path to pigeon file>)
8787
#
8888
# Compiles the pigeon file to a temp directory and attempts to run the dart
89-
# analyzer on it with and without null safety turned on.
89+
# analyzer on it.
9090
test_pigeon_dart() {
9191
echo "test_pigeon_dart($1)"
92-
temp_dir_1=$(mktmpdir)
93-
temp_dir_2=$(mktmpdir)
94-
95-
$run_pigeon \
96-
--input $1 \
97-
--dart_out $temp_dir_1/pigeon.dart &
98-
null_safe_gen_pid=$!
92+
temp_dir=$(mktmpdir)
9993

10094
$run_pigeon \
101-
--no-dart_null_safety \
10295
--input $1 \
103-
--dart_out $temp_dir_2/pigeon.dart &
104-
non_null_safe_gen_pid=$!
96+
--dart_out $temp_dir/pigeon.dart &
97+
gen_pid=$!
10598

106-
wait $null_safe_gen_pid
107-
wait $non_null_safe_gen_pid
99+
wait $gen_pid
108100

109101
# `./e2e_tests/test_objc/.packages` is used to get access to Flutter since
110102
# Pigeon doesn't depend on Flutter.
111-
dartanalyzer $temp_dir_1/pigeon.dart --fatal-infos --fatal-warnings --packages ./e2e_tests/test_objc/.packages &
112-
null_safe_analyze_pid=$!
113-
dartanalyzer $temp_dir_2/pigeon.dart --fatal-infos --fatal-warnings --packages ./e2e_tests/test_objc/.packages &
114-
non_null_safe_analyze_pid=$!
103+
dart analyze $temp_dir/pigeon.dart --fatal-infos --fatal-warnings --packages ./e2e_tests/test_objc/.packages &
104+
analyze_pid=$!
115105

116-
wait $null_safe_analyze_pid
117-
wait $non_null_safe_analyze_pid
106+
wait $analyze_pid
118107

119-
rm -rf $temp_dir_1
120-
rm -rf $temp_dir_2
108+
rm -rf $temp_dir
121109
}
122110

123111
print_usage() {
@@ -184,7 +172,7 @@ get_java_linter_formatter() {
184172
}
185173

186174
run_dart_unittests() {
187-
dart pub run pigeon:run_tests -t dart_unittests
175+
dart run pigeon:run_tests -t dart_unittests
188176
}
189177

190178
test_command_line() {
@@ -204,11 +192,11 @@ test_command_line() {
204192
}
205193

206194
run_flutter_unittests() {
207-
dart pub run pigeon:run_tests -t flutter_unittests
195+
dart run pigeon:run_tests -t flutter_unittests
208196
}
209197

210198
run_mock_handler_tests() {
211-
dart pub run pigeon:run_tests -t mock_handler_tests
199+
dart run pigeon:run_tests -t mock_handler_tests
212200
}
213201

214202
run_dart_compilation_tests() {

0 commit comments

Comments
 (0)