Skip to content

Commit 6740a21

Browse files
author
Emmanuel Garcia
authored
[pigeon] Null safe requires Dart 2.12 (#252)
1 parent 0e3e175 commit 6740a21

File tree

7 files changed

+44
-71
lines changed

7 files changed

+44
-71
lines changed

.cirrus.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,19 @@ task:
7373
image: catalina-flutter
7474
env:
7575
PATH: $PATH:/usr/local/bin
76+
matrix:
77+
CHANNEL: "master"
78+
CHANNEL: "stable"
7679
setup_script:
7780
- pod repo update
81+
- git clone https://github.com/flutter/flutter.git
7882
- git fetch origin master
79-
- flutter doctor
83+
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
8084
- pub global activate flutter_plugin_tools
8185
- brew install clang-format
86+
upgrade_script:
87+
- flutter channel $CHANNEL
88+
- flutter upgrade
89+
- flutter doctor
8290
build_script:
8391
- ./script/local_tests.sh

packages/pigeon/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.18
2+
3+
* Null safe requires Dart 2.12.
4+
15
## 0.1.17
26

37
* Split out test code generation for Dart into a separate file via the

packages/pigeon/e2e_tests/test_objc/ios/Podfile

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,79 +10,33 @@ project 'Runner', {
1010
'Release' => :release,
1111
}
1212

13-
def parse_KV_file(file, separator='=')
14-
file_abs_path = File.expand_path(file)
15-
if !File.exists? file_abs_path
16-
return [];
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
1717
end
18-
generated_key_values = {}
19-
skip_line_start_symbols = ["#", "/"]
20-
File.foreach(file_abs_path) do |line|
21-
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22-
plugin = line.split(pattern=separator)
23-
if plugin.length == 2
24-
podname = plugin[0].strip()
25-
path = plugin[1].strip()
26-
podpath = File.expand_path("#{path}", file_abs_path)
27-
generated_key_values[podname] = podpath
28-
else
29-
puts "Invalid plugin specification: #{line}"
30-
end
18+
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
3122
end
32-
generated_key_values
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
3324
end
3425

35-
target 'Runner' do
36-
# Flutter Pod
37-
use_frameworks!
38-
39-
copied_flutter_dir = File.join(__dir__, 'Flutter')
40-
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
41-
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
42-
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
43-
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
44-
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
45-
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
46-
47-
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
48-
unless File.exist?(generated_xcode_build_settings_path)
49-
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
50-
end
51-
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
52-
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
53-
54-
unless File.exist?(copied_framework_path)
55-
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
56-
end
57-
unless File.exist?(copied_podspec_path)
58-
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
59-
end
60-
end
26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
6127

62-
# Keep pod path relative so it can be checked into Podfile.lock.
63-
pod 'Flutter', :path => 'Flutter'
28+
flutter_ios_podfile_setup
6429

65-
# Plugin Pods
30+
target 'Runner' do
31+
use_frameworks!
32+
use_modular_headers!
6633

67-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
68-
# referring to absolute paths on developers' machines.
69-
system('rm -rf .symlinks')
70-
system('mkdir -p .symlinks/plugins')
71-
plugin_pods = parse_KV_file('../.flutter-plugins')
72-
plugin_pods.each do |name, path|
73-
symlink = File.join('.symlinks', 'plugins', name)
74-
File.symlink(path, symlink)
75-
pod name, :path => File.join(symlink, 'ios')
76-
end
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
7735
end
7836

79-
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
80-
install! 'cocoapods', :disable_input_output_paths => true
81-
8237
post_install do |installer|
8338
installer.pods_project.targets.each do |target|
84-
target.build_configurations.each do |config|
85-
config.build_settings['ENABLE_BITCODE'] = 'NO'
86-
end
39+
flutter_additional_ios_build_settings(target)
8740
end
8841
end
42+

packages/pigeon/lib/dart_generator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'generator_tools.dart';
77

88
/// Options that control how Dart code will be generated.
99
class DartOptions {
10-
/// Determines if the generated code has null safety annotations (Dart >2.10 required).
10+
/// Determines if the generated code has null safety annotations (Dart >=2.12 required).
1111
bool isNullSafe = false;
1212
}
1313

@@ -194,7 +194,7 @@ void generateDart(DartOptions opt, Root root, StringSink sink) {
194194
indent.writeln(
195195
'// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import',
196196
);
197-
indent.writeln('// @dart = ${opt.isNullSafe ? '2.10' : '2.8'}');
197+
indent.writeln('// @dart = ${opt.isNullSafe ? '2.12' : '2.8'}');
198198
indent.writeln('import \'dart:async\';');
199199
indent.writeln(
200200
'import \'dart:typed_data\' show Uint8List, Int32List, Int64List, Float64List;',
@@ -284,7 +284,7 @@ void generateTestDart(
284284
indent.writeln(
285285
'// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import',
286286
);
287-
indent.writeln('// @dart = ${opt.isNullSafe ? '2.10' : '2.8'}');
287+
indent.writeln('// @dart = ${opt.isNullSafe ? '2.12' : '2.8'}');
288288
indent.writeln('import \'dart:async\';');
289289
indent.writeln(
290290
'import \'dart:typed_data\' show Uint8List, Int32List, Int64List, Float64List;',

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.
11-
const String pigeonVersion = '0.1.17';
11+
const String pigeonVersion = '0.1.18';
1212

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

packages/pigeon/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: pigeon
2-
version: 0.1.17
2+
version: 0.1.18
33
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
44
homepage: https://github.com/flutter/packages/tree/master/packages/pigeon
55
dependencies:

packages/pigeon/run_tests.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
###############################################################################
22
# run_tests.sh
33
#
4-
# This runs all the different types of tests for pigeon. It should be run from
4+
# This runs all the different types of tests for pigeon. It should be run from
55
# the directory that contains the script.
66
###############################################################################
77

88
# exit when any command fails
99
set -ex
1010

11+
# TODO(blasten): Enable on stable when possible.
12+
# https://github.com/flutter/flutter/issues/75187
13+
if [[ "$CHANNEL" == "stable" ]]; then
14+
exit 0
15+
fi
16+
1117
###############################################################################
1218
# Variables
1319
###############################################################################
@@ -43,6 +49,7 @@ test_pigeon_ios() {
4349
-arch arm64 \
4450
-isysroot $(xcrun --sdk iphoneos --show-sdk-path) \
4551
-F $framework_path \
52+
-F $framework_path/Flutter.xcframework/ios-armv7_arm64 \
4653
-Werror \
4754
-fobjc-arc \
4855
-c $temp_dir/pigeon.m \
@@ -194,7 +201,7 @@ xcodebuild \
194201
-scheme RunnerTests \
195202
-sdk iphonesimulator \
196203
-destination 'platform=iOS Simulator,name=iPhone 8' \
197-
test | xcpretty
204+
test
198205
popd
199206

200207
###############################################################################

0 commit comments

Comments
 (0)