Skip to content

Commit

Permalink
[pigeon] Remove support for non-NNBD (#1524)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stuartmorgan authored Apr 15, 2022
1 parent c29083d commit 3f8a502
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 235 deletions.
7 changes: 6 additions & 1 deletion packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.0.0

* **BREAKING CHANGE**: Removes the `--dart_null_safety` flag. Generated Dart
now always uses nullability annotations, and thus requires Dart 2.12 or later.

## 2.0.4

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

* Fixes Java crash for nullable nested type.

* ## 2.0.1

* Adds support for TaskQueues for serial background execution.
Expand Down
141 changes: 61 additions & 80 deletions packages/pigeon/lib/dart_generator.dart

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:mirrors';
import 'ast.dart';

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

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
6 changes: 0 additions & 6 deletions packages/pigeon/lib/pigeon_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,6 @@ options:
..addOption('java_out', help: 'Path to generated Java file (.java).')
..addOption('java_package',
help: 'The package that generated Java code will be in.')
..addFlag('dart_null_safety',
help: 'Makes generated Dart code have null safety annotations',
defaultsTo: true)
..addOption('objc_header_out',
help: 'Path to generated Objective-C header file (.h).')
..addOption('objc_prefix',
Expand Down Expand Up @@ -1082,9 +1079,6 @@ options:
javaOptions: JavaOptions(
package: results['java_package'],
),
dartOptions: DartOptions(
isNullSafe: results['dart_null_safety'],
),
copyrightHeader: results['copyright_header'],
oneLanguage: results['one_language'],
astOut: results['ast_out'],
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: pigeon
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
version: 2.0.4 # This must match the version in lib/generator_tools.dart
version: 3.0.0 # This must match the version in lib/generator_tools.dart

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
36 changes: 12 additions & 24 deletions packages/pigeon/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,26 @@ test_pigeon_android() {
# test_null_safe_dart(<path to pigeon file>)
#
# Compiles the pigeon file to a temp directory and attempts to run the dart
# analyzer on it with and without null safety turned on.
# analyzer on it.
test_pigeon_dart() {
echo "test_pigeon_dart($1)"
temp_dir_1=$(mktmpdir)
temp_dir_2=$(mktmpdir)

$run_pigeon \
--input $1 \
--dart_out $temp_dir_1/pigeon.dart &
null_safe_gen_pid=$!
temp_dir=$(mktmpdir)

$run_pigeon \
--no-dart_null_safety \
--input $1 \
--dart_out $temp_dir_2/pigeon.dart &
non_null_safe_gen_pid=$!
--dart_out $temp_dir/pigeon.dart &
gen_pid=$!

wait $null_safe_gen_pid
wait $non_null_safe_gen_pid
wait $gen_pid

# `./e2e_tests/test_objc/.packages` is used to get access to Flutter since
# Pigeon doesn't depend on Flutter.
dartanalyzer $temp_dir_1/pigeon.dart --fatal-infos --fatal-warnings --packages ./e2e_tests/test_objc/.packages &
null_safe_analyze_pid=$!
dartanalyzer $temp_dir_2/pigeon.dart --fatal-infos --fatal-warnings --packages ./e2e_tests/test_objc/.packages &
non_null_safe_analyze_pid=$!
dart analyze $temp_dir/pigeon.dart --fatal-infos --fatal-warnings --packages ./e2e_tests/test_objc/.packages &
analyze_pid=$!

wait $null_safe_analyze_pid
wait $non_null_safe_analyze_pid
wait $analyze_pid

rm -rf $temp_dir_1
rm -rf $temp_dir_2
rm -rf $temp_dir
}

print_usage() {
Expand Down Expand Up @@ -184,7 +172,7 @@ get_java_linter_formatter() {
}

run_dart_unittests() {
dart pub run pigeon:run_tests -t dart_unittests
dart run pigeon:run_tests -t dart_unittests
}

test_command_line() {
Expand All @@ -204,11 +192,11 @@ test_command_line() {
}

run_flutter_unittests() {
dart pub run pigeon:run_tests -t flutter_unittests
dart run pigeon:run_tests -t flutter_unittests
}

run_mock_handler_tests() {
dart pub run pigeon:run_tests -t mock_handler_tests
dart run pigeon:run_tests -t mock_handler_tests
}

run_dart_compilation_tests() {
Expand Down
Loading

0 comments on commit 3f8a502

Please sign in to comment.