From c639c93f11347243291cd55ecd1fc952becd6e94 Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Tue, 30 Jun 2020 15:55:53 -0400 Subject: [PATCH] Update platform files and gitignore (#60407) --- dev/benchmarks/macrobenchmarks/.gitignore | 1 + .../ios/Flutter/Debug.xcconfig | 1 + .../ios/Flutter/Release.xcconfig | 1 + dev/benchmarks/macrobenchmarks/ios/Podfile | 38 +++++++++ dev/benchmarks/macrobenchmarks/macos/Podfile | 82 +++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 dev/benchmarks/macrobenchmarks/.gitignore create mode 100644 dev/benchmarks/macrobenchmarks/ios/Podfile create mode 100644 dev/benchmarks/macrobenchmarks/macos/Podfile diff --git a/dev/benchmarks/macrobenchmarks/.gitignore b/dev/benchmarks/macrobenchmarks/.gitignore new file mode 100644 index 00000000000..d3e68fd01e5 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/.gitignore @@ -0,0 +1 @@ +lib/generated_plugin_registrant.dart diff --git a/dev/benchmarks/macrobenchmarks/ios/Flutter/Debug.xcconfig b/dev/benchmarks/macrobenchmarks/ios/Flutter/Debug.xcconfig index 592ceee85b8..e8efba11468 100644 --- a/dev/benchmarks/macrobenchmarks/ios/Flutter/Debug.xcconfig +++ b/dev/benchmarks/macrobenchmarks/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/dev/benchmarks/macrobenchmarks/ios/Flutter/Release.xcconfig b/dev/benchmarks/macrobenchmarks/ios/Flutter/Release.xcconfig index 592ceee85b8..399e9340e6f 100644 --- a/dev/benchmarks/macrobenchmarks/ios/Flutter/Release.xcconfig +++ b/dev/benchmarks/macrobenchmarks/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/dev/benchmarks/macrobenchmarks/ios/Podfile b/dev/benchmarks/macrobenchmarks/ios/Podfile new file mode 100644 index 00000000000..f7d6a5e68c3 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/ios/Podfile @@ -0,0 +1,38 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +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 + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + 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_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/dev/benchmarks/macrobenchmarks/macos/Podfile b/dev/benchmarks/macrobenchmarks/macos/Podfile new file mode 100644 index 00000000000..d60ec710284 --- /dev/null +++ b/dev/benchmarks/macrobenchmarks/macos/Podfile @@ -0,0 +1,82 @@ +platform :osx, '10.11' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def parse_KV_file(file, separator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + pods_ary = [] + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) { |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) + pods_ary.push({:name => podname, :path => podpath}); + else + puts "Invalid plugin specification: #{line}" + end + } + return pods_ary +end + +def pubspec_supports_macos(file) + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return false; + end + File.foreach(file_abs_path) { |line| + return true if line =~ /^\s*macos:/ + } + return false +end + +target 'Runner' do + use_frameworks! + use_modular_headers! + + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock + # referring to absolute paths on developers' machines. + ephemeral_dir = File.join('Flutter', 'ephemeral') + symlink_dir = File.join(ephemeral_dir, '.symlinks') + symlink_plugins_dir = File.join(symlink_dir, 'plugins') + system("rm -rf #{symlink_dir}") + system("mkdir -p #{symlink_plugins_dir}") + + # Flutter Pods + generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig')) + if generated_xcconfig.empty? + puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." + end + generated_xcconfig.map { |p| + if p[:name] == 'FLUTTER_FRAMEWORK_DIR' + symlink = File.join(symlink_dir, 'flutter') + File.symlink(File.dirname(p[:path]), symlink) + pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path])) + end + } + + # Plugin Pods + plugin_pods = parse_KV_file('../.flutter-plugins') + plugin_pods.map { |p| + symlink = File.join(symlink_plugins_dir, p[:name]) + File.symlink(p[:path], symlink) + if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml')) + pod p[:name], :path => File.join(symlink, 'macos') + end + } +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