[pigeon] Null safe requires Dart 2.12 (#252)

This commit is contained in:
Emmanuel Garcia
2021-02-02 10:29:51 -08:00
committed by GitHub
parent 0e3e175beb
commit 6740a21320
7 changed files with 44 additions and 71 deletions

View File

@ -73,11 +73,19 @@ task:
image: catalina-flutter
env:
PATH: $PATH:/usr/local/bin
matrix:
CHANNEL: "master"
CHANNEL: "stable"
setup_script:
- pod repo update
- git clone https://github.com/flutter/flutter.git
- git fetch origin master
- flutter doctor
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
- pub global activate flutter_plugin_tools
- brew install clang-format
upgrade_script:
- flutter channel $CHANNEL
- flutter upgrade
- flutter doctor
build_script:
- ./script/local_tests.sh

View File

@ -1,3 +1,7 @@
## 0.1.18
* Null safe requires Dart 2.12.
## 0.1.17
* Split out test code generation for Dart into a separate file via the

View File

@ -10,79 +10,33 @@ project 'Runner', {
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
generated_key_values
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
# Flutter Pod
use_frameworks!
use_modular_headers!
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
flutter_additional_ios_build_settings(target)
end
end

View File

@ -7,7 +7,7 @@ import 'generator_tools.dart';
/// Options that control how Dart code will be generated.
class DartOptions {
/// Determines if the generated code has null safety annotations (Dart >2.10 required).
/// Determines if the generated code has null safety annotations (Dart >=2.12 required).
bool isNullSafe = false;
}
@ -194,7 +194,7 @@ void generateDart(DartOptions opt, Root root, StringSink sink) {
indent.writeln(
'// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import',
);
indent.writeln('// @dart = ${opt.isNullSafe ? '2.10' : '2.8'}');
indent.writeln('// @dart = ${opt.isNullSafe ? '2.12' : '2.8'}');
indent.writeln('import \'dart:async\';');
indent.writeln(
'import \'dart:typed_data\' show Uint8List, Int32List, Int64List, Float64List;',
@ -284,7 +284,7 @@ void generateTestDart(
indent.writeln(
'// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import',
);
indent.writeln('// @dart = ${opt.isNullSafe ? '2.10' : '2.8'}');
indent.writeln('// @dart = ${opt.isNullSafe ? '2.12' : '2.8'}');
indent.writeln('import \'dart:async\';');
indent.writeln(
'import \'dart:typed_data\' show Uint8List, Int32List, Int64List, Float64List;',

View File

@ -8,7 +8,7 @@ import 'dart:mirrors';
import 'ast.dart';
/// The current version of pigeon.
const String pigeonVersion = '0.1.17';
const String pigeonVersion = '0.1.18';
/// Read all the content from [stdin] to a String.
String readStdin() {

View File

@ -1,5 +1,5 @@
name: pigeon
version: 0.1.17
version: 0.1.18
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
homepage: https://github.com/flutter/packages/tree/master/packages/pigeon
dependencies:

View File

@ -1,13 +1,19 @@
###############################################################################
# run_tests.sh
#
# This runs all the different types of tests for pigeon. It should be run from
# This runs all the different types of tests for pigeon. It should be run from
# the directory that contains the script.
###############################################################################
# exit when any command fails
set -ex
# TODO(blasten): Enable on stable when possible.
# https://github.com/flutter/flutter/issues/75187
if [[ "$CHANNEL" == "stable" ]]; then
exit 0
fi
###############################################################################
# Variables
###############################################################################
@ -43,6 +49,7 @@ test_pigeon_ios() {
-arch arm64 \
-isysroot $(xcrun --sdk iphoneos --show-sdk-path) \
-F $framework_path \
-F $framework_path/Flutter.xcframework/ios-armv7_arm64 \
-Werror \
-fobjc-arc \
-c $temp_dir/pigeon.m \
@ -194,7 +201,7 @@ xcodebuild \
-scheme RunnerTests \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 8' \
test | xcpretty
test
popd
###############################################################################