7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/pod_builder/command/build_swiftmodules.rb', line 7
def self.call
Configuration.check_inited
Podfile.sanity_check()
puts "Loading Podfile".yellow
quiet = OPTIONS.fetch(:quiet, false)
install_update_repo = OPTIONS.fetch(:update_repos, true)
installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
all_buildable_items = Analyze.podfile_items(installer, analyzer)
iphoneos_sdk_path = `xcrun --sdk iphoneos --show-sdk-path`.strip
sim_sdk_path = `xcrun --sdk iphonesimulator --show-sdk-path`.strip
swiftinterfaces_paths = Dir.glob("#{PodBuilder::git_rootpath}/**/*.framework/**/*.swiftinterface").reject { |t| t.include?(".private.") }
frameworks_paths = Dir.glob("#{PodBuilder::git_rootpath}/**/*.framework")
swiftinterfaces_paths = filter_unexpected_pods_locations(swiftinterfaces_paths)
frameworks_paths = filter_unexpected_pods_locations(frameworks_paths)
all_buildable_items.uniq(&:root_name).map(&:root_name).each do |name|
items = all_buildable_items.select { |t| t.root_name == name }
module_name = items.first.module_name
vendored_frameworks = items.map(&:vendored_frameworks).flatten
deps = items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten
vendored_frameworks += deps.map(&:vendored_frameworks).flatten
deps.uniq! { |t| t.root_name }
swiftinterfaces_and_arch_for_module(module_name, swiftinterfaces_paths).each do |dep_swiftinterface_path, arch|
swiftmodule_dest = "#{File.dirname(dep_swiftinterface_path)}/#{arch}.swiftmodule"
if File.exist?(swiftmodule_dest) && !OPTIONS.has_key?(:force_rebuild)
puts "Swiftmodule exists, skipping #{dep_swiftinterface_path}".magenta if !quiet
next
end
puts "Processing #{dep_swiftinterface_path}".yellow if !quiet
frameworks_search_paths = []
deps.each do |dep|
frameworks_search_paths << framework_path_for_module_name(dep.module_name, arch, swiftinterfaces_paths, frameworks_paths)
end
vendored_frameworks.each do |vendored_framework|
frameworks_search_paths << framework_path_for_module_name(File.basename(vendored_framework, ".*"), arch, swiftinterfaces_paths, frameworks_paths)
end
frameworks_search_paths_arg = frameworks_search_paths.compact.map { |t| "-F '#{File.dirname(t)}'" }.join(" ")
sdk_path = arch.include?("simulator") ? sim_sdk_path : iphoneos_sdk_path
cmd = "" "swiftc -frontend \
-compile-module-from-interface \
-enable-library-evolution \
-import-underlying-module \
-sdk '#{sdk_path}' \
-Fsystem '#{sdk_path}/System/Library/Frameworks/' \
-module-name #{module_name} \
#{frameworks_search_paths_arg} \
-o '#{swiftmodule_dest}' \
'#{dep_swiftinterface_path}'
" ""
unless system(cmd)
puts "Failed generating swiftmodules for #{module_name} and arch #{arch}".red
end
end
end
puts "\n\nš done!\n".green
return 0
end
|