Skip to content

Commit 130dfc8

Browse files
authored
Make Podfiles use symlinks to local pods (flutter#14748)
1 parent 54bf773 commit 130dfc8

File tree

4 files changed

+66
-25
lines changed

4 files changed

+66
-25
lines changed

bin/internal/engine.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e5b72e5f87cae358b457b6c1cb55c4560ce3c46c
1+
13cf22c284c24f81357aec6a89074a536efbf4d1

packages/flutter_tools/lib/src/cache.dart

+20
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ class FlutterEngine extends CachedArtifact {
402402
<String>['windows-x64', 'dart-sdk-windows-x64.zip'],
403403
];
404404

405+
// A list of cache directory paths to which the LICENSE file should be copied.
406+
List<String> _getLicenseDirs() {
407+
if (cache.includeAllPlatforms || platform.isMacOS) {
408+
return const <String>['ios', 'ios-profile', 'ios-release'];
409+
}
410+
return const <String>[];
411+
}
412+
405413
@override
406414
bool isUpToDateInner() {
407415
final Directory pkgDir = cache.getCacheDir('pkg');
@@ -416,6 +424,12 @@ class FlutterEngine extends CachedArtifact {
416424
if (!dir.existsSync())
417425
return false;
418426
}
427+
428+
for (String licenseDir in _getLicenseDirs()) {
429+
final File file = fs.file(fs.path.join(location.path, licenseDir, 'LICENSE'));
430+
if (!file.existsSync())
431+
return false;
432+
}
419433
return true;
420434
}
421435

@@ -447,6 +461,12 @@ class FlutterEngine extends CachedArtifact {
447461
os.unzip(frameworkZip, framework);
448462
}
449463
}
464+
465+
final File licenseSource = fs.file(fs.path.join(Cache.flutterRoot, 'LICENSE'));
466+
for (String licenseDir in _getLicenseDirs()) {
467+
final String licenseDestinationPath = fs.path.join(location.path, licenseDir, 'LICENSE');
468+
await licenseSource.copy(licenseDestinationPath);
469+
}
450470
}
451471

452472
void _makeFilesExecutable(Directory dir) {

packages/flutter_tools/templates/cocoapods/Podfile-objc

+22-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
66

7-
def parse_KV_file(file,seperator='=')
7+
def parse_KV_file(file, separator='=')
88
file_abs_path = File.expand_path(file)
99
if !File.exists? file_abs_path
1010
return [];
@@ -13,12 +13,12 @@ def parse_KV_file(file,seperator='=')
1313
skip_line_start_symbols = ["#", "/"]
1414
File.foreach(file_abs_path) { |line|
1515
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
16-
plugin = line.split(pattern=seperator)
16+
plugin = line.split(pattern=separator)
1717
if plugin.length == 2
1818
podname = plugin[0].strip()
1919
path = plugin[1].strip()
2020
podpath = File.expand_path("#{path}", file_abs_path)
21-
pods_ary.push({:name => podname,:path=>podpath});
21+
pods_ary.push({:name => podname, :path => podpath});
2222
else
2323
puts "Invalid plugin specification: #{line}"
2424
end
@@ -27,21 +27,31 @@ def parse_KV_file(file,seperator='=')
2727
end
2828

2929
target 'Runner' do
30+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
31+
# referring to absolute paths on developers' machines.
32+
system('rm -rf Pods/.symlinks')
33+
system('mkdir -p Pods/.symlinks/flutter')
34+
system('mkdir -p Pods/.symlinks/plugins')
35+
3036
# Flutter Pods
31-
generated_xcode_build_settings = parse_KV_file("./Flutter/Generated.xcconfig")
37+
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
3238
if generated_xcode_build_settings.empty?
33-
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter build or flutter run is executed once first."
39+
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
3440
end
35-
generated_xcode_build_settings.map{ |p|
36-
if p[:name]=='FLUTTER_FRAMEWORK_DIR'
37-
pod 'Flutter', :path => p[:path]
41+
generated_xcode_build_settings.map { |p|
42+
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
43+
symlink = File.join('Pods', '.symlinks', 'flutter', File.basename(p[:path]))
44+
File.symlink(p[:path], symlink)
45+
pod 'Flutter', :path => symlink
3846
end
3947
}
4048

4149
# Plugin Pods
42-
plugin_pods = parse_KV_file("../.flutter-plugins")
43-
plugin_pods.map{ |p|
44-
pod p[:name], :path => File.expand_path("ios",p[:path])
50+
plugin_pods = parse_KV_file('../.flutter-plugins')
51+
plugin_pods.map { |p|
52+
symlink = File.join('Pods', '.symlinks', 'plugins', File.basename(p[:path]))
53+
File.symlink(p[:path], symlink)
54+
pod p[:name], :path => File.join(symlink, 'ios')
4555
}
4656
end
4757

@@ -51,4 +61,4 @@ post_install do |installer|
5161
config.build_settings['ENABLE_BITCODE'] = 'NO'
5262
end
5363
end
54-
end
64+
end

packages/flutter_tools/templates/cocoapods/Podfile-swift

+23-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
66

7-
def parse_KV_file(file,seperator='=')
7+
def parse_KV_file(file, separator='=')
88
file_abs_path = File.expand_path(file)
99
if !File.exists? file_abs_path
1010
return [];
@@ -13,12 +13,12 @@ def parse_KV_file(file,seperator='=')
1313
skip_line_start_symbols = ["#", "/"]
1414
File.foreach(file_abs_path) { |line|
1515
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
16-
plugin = line.split(pattern=seperator)
16+
plugin = line.split(pattern=separator)
1717
if plugin.length == 2
1818
podname = plugin[0].strip()
1919
path = plugin[1].strip()
2020
podpath = File.expand_path("#{path}", file_abs_path)
21-
pods_ary.push({:name => podname,:path=>podpath});
21+
pods_ary.push({:name => podname, :path => podpath});
2222
else
2323
puts "Invalid plugin specification: #{line}"
2424
end
@@ -28,21 +28,32 @@ end
2828

2929
target 'Runner' do
3030
use_frameworks!
31+
32+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
33+
# referring to absolute paths on developers' machines.
34+
system('rm -rf Pods/.symlinks')
35+
system('mkdir -p Pods/.symlinks/flutter')
36+
system('mkdir -p Pods/.symlinks/plugins')
37+
3138
# Flutter Pods
32-
generated_xcode_build_settings = parse_KV_file("./Flutter/Generated.xcconfig")
39+
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
3340
if generated_xcode_build_settings.empty?
34-
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter build or flutter run is executed once first."
41+
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
3542
end
36-
generated_xcode_build_settings.map{ |p|
37-
if p[:name]=='FLUTTER_FRAMEWORK_DIR'
38-
pod 'Flutter', :path => p[:path]
43+
generated_xcode_build_settings.map { |p|
44+
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
45+
symlink = File.join('Pods', '.symlinks', 'flutter', File.basename(p[:path]))
46+
File.symlink(p[:path], symlink)
47+
pod 'Flutter', :path => symlink
3948
end
4049
}
4150

4251
# Plugin Pods
43-
plugin_pods = parse_KV_file("../.flutter-plugins")
44-
plugin_pods.map{ |p|
45-
pod p[:name], :path => File.expand_path("ios",p[:path])
52+
plugin_pods = parse_KV_file('../.flutter-plugins')
53+
plugin_pods.map { |p|
54+
symlink = File.join('Pods', '.symlinks', 'plugins', File.basename(p[:path]))
55+
File.symlink(p[:path], symlink)
56+
pod p[:name], :path => File.join(symlink, 'ios')
4657
}
4758
end
4859

@@ -57,4 +68,4 @@ post_install do |installer|
5768
config.build_settings['ENABLE_BITCODE'] = 'NO'
5869
end
5970
end
60-
end
71+
end

0 commit comments

Comments
 (0)