pod-builder 5.1.1 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,123 @@
1
+ require "pod_builder/core"
2
+ require "json"
3
+
4
+ module PodBuilder
5
+ module Command
6
+ class CompileSwiftModules
7
+ def self.call
8
+ Configuration.check_inited
9
+
10
+ Podfile.sanity_check()
11
+
12
+ puts "Loading Podfile".yellow
13
+
14
+ quiet = OPTIONS.fetch(:quiet, false)
15
+
16
+ install_update_repo = OPTIONS.fetch(:update_repos, true)
17
+ installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
18
+
19
+ all_buildable_items = Analyze.podfile_items(installer, analyzer)
20
+
21
+ iphoneos_sdk_path = `xcrun --sdk iphoneos --show-sdk-path`.strip
22
+ sim_sdk_path = `xcrun --sdk iphonesimulator --show-sdk-path`.strip
23
+
24
+ swiftinterfaces_paths = Dir.glob("#{PodBuilder::git_rootpath}/**/*.framework/**/*.swiftinterface").reject { |t| t.include?(".private.") }
25
+ frameworks_paths = Dir.glob("#{PodBuilder::git_rootpath}/**/*.framework")
26
+ swiftinterfaces_paths = filter_unexpected_pods_locations(swiftinterfaces_paths)
27
+ frameworks_paths = filter_unexpected_pods_locations(frameworks_paths)
28
+
29
+ all_buildable_items.uniq(&:root_name).map(&:root_name).each do |name|
30
+ items = all_buildable_items.select { |t| t.root_name == name }
31
+ module_name = items.first.module_name
32
+
33
+ vendored_frameworks = items.map(&:vendored_frameworks).flatten
34
+
35
+ deps = items.map { |t| t.recursive_dependencies(all_buildable_items) }.flatten
36
+ vendored_frameworks += deps.map(&:vendored_frameworks).flatten
37
+ deps.uniq! { |t| t.root_name }
38
+
39
+ swiftinterfaces_and_arch_for_module(module_name, swiftinterfaces_paths).each do |dep_swiftinterface_path, arch|
40
+ swiftmodule_dest = "#{File.dirname(dep_swiftinterface_path)}/#{arch}.swiftmodule"
41
+ if File.exist?(swiftmodule_dest) && !OPTIONS.has_key?(:force_rebuild)
42
+ puts "Swiftmodule exists, skipping #{dep_swiftinterface_path}".magenta if !quiet
43
+ next
44
+ end
45
+
46
+ puts "Processing #{dep_swiftinterface_path}".yellow if !quiet
47
+
48
+ frameworks_search_paths = []
49
+ deps.each do |dep|
50
+ frameworks_search_paths << framework_path_for_module_name(dep.module_name, arch, swiftinterfaces_paths, frameworks_paths)
51
+ end
52
+ vendored_frameworks.each do |vendored_framework|
53
+ frameworks_search_paths << framework_path_for_module_name(File.basename(vendored_framework, ".*"), arch, swiftinterfaces_paths, frameworks_paths)
54
+ end
55
+ frameworks_search_paths_arg = frameworks_search_paths.compact.map { |t| "-F '#{File.dirname(t)}'" }.join(" ")
56
+
57
+ sdk_path = arch.include?("simulator") ? sim_sdk_path : iphoneos_sdk_path
58
+ cmd = "" "swiftc -frontend \
59
+ -compile-module-from-interface \
60
+ -enable-library-evolution \
61
+ -import-underlying-module \
62
+ -sdk '#{sdk_path}' \
63
+ -Fsystem '#{sdk_path}/System/Library/Frameworks/' \
64
+ -module-name #{module_name} \
65
+ #{frameworks_search_paths_arg} \
66
+ -o '#{swiftmodule_dest}' \
67
+ '#{dep_swiftinterface_path}'
68
+ " ""
69
+
70
+ unless system(cmd)
71
+ puts "Failed generating swiftmodules for #{module_name} and arch #{arch}".red
72
+ end
73
+ end
74
+ end
75
+
76
+ puts "\n\nšŸŽ‰ done!\n".green
77
+ return 0
78
+ end
79
+
80
+ def self.swiftinterfaces_and_arch_for_module(module_name, swiftinterfaces_paths)
81
+ swiftinterfaces_paths.select { |t| t.include?("/#{module_name}.xcframework") }.map { |t| [t, File.basename(t, ".*")] }
82
+ end
83
+
84
+ def self.framework_path_for_module_name(module_name, arch, swiftinterfaces_paths, frameworks_paths)
85
+ quiet = OPTIONS.fetch(:quiet, false)
86
+
87
+ if (path = swiftinterfaces_paths.detect { |t| t.include?("/#{module_name}.framework/Modules/#{module_name}.swiftmodule/#{arch}") }) &&
88
+ (match = path.match(/(.*#{module_name}.framework)/)) && match&.size == 2
89
+ return match[1]
90
+ end
91
+
92
+ archs = arch.split("-").reject { |t| ["apple", "ios"].include?(t) }
93
+ frameworks_paths = frameworks_paths.select { |t| t.include?("#{module_name}.framework") }
94
+
95
+ frameworks_paths.select! { |t| t.include?("-simulator/") == arch.include?("simulator") }
96
+ frameworks_paths.select! { |t| t.include?("/ios-") } # currently we support only iOS xcframeworks
97
+ frameworks_paths.reject! { |t| t.include?("maccatalyst/") } # currently we do not support catalyst xcframeworks
98
+
99
+ frameworks_paths.select! { |t| archs.any? { |u| t.include?(u) } }
100
+
101
+ if frameworks_paths.count == 1
102
+ return frameworks_paths[0]
103
+ end
104
+
105
+ puts "Failed determining framework for #{module_name}" unless quiet
106
+ return nil
107
+ end
108
+
109
+ def self.filter_unexpected_pods_locations(paths)
110
+ # A project might contain multiple /Pods/ folders in subprojects. We should extract only those related to the PodBuilder project
111
+ paths.reject { |t| t.include?("/Pods/") && !t.include?(PodBuilder::project_path) }
112
+ end
113
+ end
114
+ end
115
+ end
116
+
117
+ class Pod::Specification
118
+ public
119
+
120
+ def defined_in_folder
121
+ File.dirname(defined_in_file)
122
+ end
123
+ end
@@ -1,4 +1,4 @@
1
- require 'pod_builder/core'
1
+ require "pod_builder/core"
2
2
 
3
3
  module PodBuilder
4
4
  module Command
@@ -11,7 +11,7 @@ module PodBuilder
11
11
  raise "\n\nToo many xcworkspaces found in current folder\n#{xcworkspace}\n".red if xcworkspace.count > 1
12
12
 
13
13
  Configuration.project_name = File.basename(xcworkspace.first, ".*")
14
-
14
+
15
15
  OPTIONS[:prebuild_path] ||= Configuration.base_path
16
16
 
17
17
  if File.expand_path(OPTIONS[:prebuild_path]) != OPTIONS[:prebuild_path] # if not absolute
@@ -30,8 +30,8 @@ module PodBuilder
30
30
  FileUtils.cp(project_podfile_path, prebuilt_podfile_path)
31
31
 
32
32
  podfile_content = File.read(prebuilt_podfile_path)
33
-
34
- podfile_content = Podfile.add_configuration_load_block(podfile_content)
33
+
34
+ podfile_content = Podfile.add_configuration_load_block(podfile_content)
35
35
  podfile_content = Podfile.add_install_block(podfile_content)
36
36
  podfile_content = Podfile.update_path_entries(podfile_content, Init.method(:podfile_path_transform))
37
37
  podfile_content = Podfile.update_project_entries(podfile_content, Init.method(:podfile_path_transform))
@@ -52,7 +52,7 @@ module PodBuilder
52
52
  return 0
53
53
  end
54
54
 
55
- private
55
+ private
56
56
 
57
57
  def self.write_gitignore
58
58
  source_path_rel_path = "Sources"
@@ -65,17 +65,17 @@ module PodBuilder
65
65
  Configuration.lldbinit_name,
66
66
  source_path_rel_path,
67
67
  development_pods_config_rel_path]
68
-
68
+
69
69
  if Configuration.react_native_project
70
70
  git_ignores.push("build/")
71
71
  end
72
-
72
+
73
73
  File.write("#{OPTIONS[:prebuild_path]}/.gitignore", git_ignores.join("\n"))
74
74
  end
75
75
 
76
76
  def self.write_gitattributes
77
77
  git_attributes = ["#{Configuration.prebuilt_info_filename} binary"]
78
-
78
+
79
79
  File.write("#{OPTIONS[:prebuild_path]}/.gitattributes", git_attributes.join("\n"))
80
80
  end
81
81
 
@@ -85,15 +85,15 @@ module PodBuilder
85
85
  original_basepath = PodBuilder::project_path
86
86
 
87
87
  podfile_base_path = Pathname.new(File.dirname(podfile_path))
88
-
88
+
89
89
  original_path = Pathname.new(File.join(original_basepath, path))
90
90
  replace_path = original_path.relative_path_from(podfile_base_path)
91
91
  if use_absolute_paths
92
92
  replace_path = replace_path.expand_path(podfile_base_path)
93
93
  end
94
-
94
+
95
95
  return replace_path
96
- end
96
+ end
97
97
 
98
98
  def self.update_gemfile
99
99
  gemfile_path = File.join(PodBuilder::home, "Gemfile")
@@ -112,10 +112,10 @@ module PodBuilder
112
112
 
113
113
  gemfile_lines.insert(0, source_line)
114
114
  gemfile_lines.push(podbuilder_line)
115
-
115
+
116
116
  File.write(gemfile_path, gemfile_lines.join("\n"))
117
117
 
118
- Dir.chdir(PodBuilder::home) do
118
+ Dir.chdir(PodBuilder::home) do
119
119
  system("bundle")
120
120
  end
121
121
  end
@@ -131,11 +131,11 @@ module PodBuilder
131
131
  raise "\n\nUnexpected number of #{file} found\n".red if paths.count != 1
132
132
 
133
133
  content = File.read(paths[0])
134
- expected_header_search_path_prefix = "s.pod_target_xcconfig = { \"HEADER_SEARCH_PATHS\" => \""
134
+ expected_header_search_path_prefix = "header_search_paths = ["
135
135
  raise "\n\nExpected header search path entry not found\n".red unless content.include?(expected_header_search_path_prefix)
136
136
 
137
- content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\\\"$(PODS_ROOT)/Headers/Public/Flipper-Folly\\\" ")
138
- File.write(paths[0], content)
137
+ content.sub!(expected_header_search_path_prefix, "#{expected_header_search_path_prefix}\n \"$(PODS_ROOT)/Headers/Public/Flipper-Folly\",")
138
+ File.write(paths[0], content)
139
139
 
140
140
  # React-CoreModules.podspec
141
141
  file = "React-CoreModules.podspec"
@@ -1,15 +1,16 @@
1
- require 'pod_builder/command/none'
2
- require 'pod_builder/command/build'
3
- require 'pod_builder/command/build_all'
4
- require 'pod_builder/command/update'
5
- require 'pod_builder/command/restore_all'
6
- require 'pod_builder/command/init'
7
- require 'pod_builder/command/clean'
8
- require 'pod_builder/command/deintegrate'
9
- require 'pod_builder/command/generate_podspec'
10
- require 'pod_builder/command/install_sources'
11
- require 'pod_builder/command/switch'
12
- require 'pod_builder/command/switch_all'
13
- require 'pod_builder/command/sync_podfile'
14
- require 'pod_builder/command/info'
15
- require 'pod_builder/command/generate_lldbinit'
1
+ require "pod_builder/command/none"
2
+ require "pod_builder/command/build"
3
+ require "pod_builder/command/build_all"
4
+ require "pod_builder/command/update"
5
+ require "pod_builder/command/restore_all"
6
+ require "pod_builder/command/init"
7
+ require "pod_builder/command/clean"
8
+ require "pod_builder/command/deintegrate"
9
+ require "pod_builder/command/generate_podspec"
10
+ require "pod_builder/command/install_sources"
11
+ require "pod_builder/command/switch"
12
+ require "pod_builder/command/switch_all"
13
+ require "pod_builder/command/sync_podfile"
14
+ require "pod_builder/command/info"
15
+ require "pod_builder/command/generate_lldbinit"
16
+ require "pod_builder/command/build_swiftmodules"
@@ -1,8 +1,8 @@
1
- require 'json'
2
- require 'tmpdir'
1
+ require "json"
2
+ require "tmpdir"
3
3
 
4
- module PodBuilder
5
- class Configuration
4
+ module PodBuilder
5
+ class Configuration
6
6
  # Remember to update README.md accordingly
7
7
  DEFAULT_BUILD_SETTINGS = {
8
8
  "ENABLE_BITCODE" => "NO",
@@ -12,46 +12,46 @@ module PodBuilder
12
12
  "CODE_SIGN_IDENTITY" => "",
13
13
  "CODE_SIGNING_REQUIRED" => "NO",
14
14
  "CODE_SIGN_ENTITLEMENTS" => "",
15
- "CODE_SIGNING_ALLOWED" => "NO"
15
+ "CODE_SIGNING_ALLOWED" => "NO",
16
16
  }.freeze
17
17
  DEFAULT_SPEC_OVERRIDE = {
18
18
  "Google-Mobile-Ads-SDK" => {
19
- "module_name": "GoogleMobileAds"
19
+ "module_name": "GoogleMobileAds",
20
20
  },
21
21
  "glog" => {
22
- "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
22
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" },
23
23
  },
24
24
  "DoubleConversion" => {
25
- "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
25
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" },
26
26
  },
27
27
  "Folly" => {
28
- "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
28
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" },
29
29
  },
30
30
  "Flipper-DoubleConversion" => {
31
- "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
31
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" },
32
32
  },
33
33
  "Flipper-Folly" => {
34
- "pod_target_xcconfig": { "DEFINES_MODULE": "NO" }
35
- }
34
+ "pod_target_xcconfig": { "DEFINES_MODULE": "NO" },
35
+ },
36
36
  }.freeze
37
37
  DEFAULT_BUILD_SETTINGS_OVERRIDES = {
38
38
  "SBTUITestTunnelClient" => {
39
- "ENABLE_BITCODE": "NO"
40
- }
39
+ "ENABLE_BITCODE": "NO",
40
+ },
41
41
  }.freeze
42
-
42
+
43
43
  private_constant :DEFAULT_BUILD_SETTINGS
44
44
  private_constant :DEFAULT_BUILD_SETTINGS_OVERRIDES
45
45
  private_constant :DEFAULT_SPEC_OVERRIDE
46
-
47
- class <<self
46
+
47
+ class << self
48
48
  attr_accessor :allow_building_development_pods
49
49
  attr_accessor :build_settings
50
50
  attr_accessor :build_settings_overrides
51
51
  attr_accessor :build_system
52
52
  attr_accessor :library_evolution_support
53
53
  attr_accessor :base_path
54
- attr_accessor :spec_overrides
54
+ attr_accessor :spec_overrides
55
55
  attr_accessor :skip_licenses
56
56
  attr_accessor :skip_pods
57
57
  attr_accessor :force_prebuild_pods
@@ -75,6 +75,7 @@ module PodBuilder
75
75
  attr_accessor :build_xcframeworks_all
76
76
  attr_accessor :build_xcframeworks_include
77
77
  attr_accessor :build_xcframeworks_exclude
78
+ attr_accessor :keep_swiftmodules
78
79
  attr_accessor :pre_actions
79
80
  attr_accessor :post_actions
80
81
  attr_accessor :development_team
@@ -116,27 +117,29 @@ module PodBuilder
116
117
  @build_xcframeworks_include = []
117
118
  @build_xcframeworks_exclude = []
118
119
 
120
+ @keep_swiftmodules = false
121
+
119
122
  @pre_actions = {}
120
123
  @post_actions = {}
121
124
 
122
125
  @development_team = ""
123
126
  @development_language = nil
124
-
127
+
125
128
  def self.check_inited
126
129
  raise "\n\nNot inited, run `pod_builder init`\n".red if podbuilder_path.nil?
127
130
  end
128
-
131
+
129
132
  def self.exists
130
133
  return !config_path.nil? && File.exist?(config_path)
131
134
  end
132
-
135
+
133
136
  def self.load
134
137
  unless podbuilder_path
135
138
  return
136
139
  end
137
-
140
+
138
141
  Configuration.base_path = podbuilder_path
139
-
142
+
140
143
  if exists
141
144
  begin
142
145
  json = JSON.parse(File.read(config_path))
@@ -239,6 +242,11 @@ module PodBuilder
239
242
  Configuration.build_xcframeworks_exclude = value
240
243
  end
241
244
  end
245
+ if value = json["keep_swiftmodules"]
246
+ if [TrueClass, FalseClass].include?(value.class)
247
+ Configuration.keep_swiftmodules = value
248
+ end
249
+ end
242
250
  if value = json["pre_actions"]
243
251
  if value.is_a?(Hash)
244
252
  Configuration.pre_actions = PodBuilder::Actions.load(value)
@@ -263,12 +271,12 @@ module PodBuilder
263
271
 
264
272
  sanity_check()
265
273
  end
266
-
274
+
267
275
  dev_pods_configuration_path = File.join(Configuration.base_path, Configuration.dev_pods_configuration_filename)
268
-
276
+
269
277
  if File.exist?(dev_pods_configuration_path)
270
278
  begin
271
- json = JSON.parse(File.read(dev_pods_configuration_path))
279
+ json = JSON.parse(File.read(dev_pods_configuration_path))
272
280
  rescue => exception
273
281
  raise "\n\n#{File.basename(dev_pods_configuration_path)} is an invalid JSON\n".red
274
282
  end
@@ -282,10 +290,10 @@ module PodBuilder
282
290
  lockfile_path = File.join(PodBuilder::home, lockfile_name)
283
291
  end
284
292
  end
285
-
293
+
286
294
  def self.write
287
295
  config = {}
288
-
296
+
289
297
  config["project_name"] = Configuration.project_name
290
298
  config["spec_overrides"] = Configuration.spec_overrides
291
299
  config["skip_licenses"] = Configuration.skip_licenses
@@ -304,11 +312,11 @@ module PodBuilder
304
312
  config["react_native_project"] = Configuration.react_native_project
305
313
  config["development_team"] = Configuration.development_team
306
314
  config["development_language"] = Configuration.development_language || "en"
307
-
315
+
308
316
  File.write(config_path, JSON.pretty_generate(config))
309
317
  end
310
-
311
- private
318
+
319
+ private
312
320
 
313
321
  def self.sanity_check
314
322
  Configuration.skip_pods.each do |pod|
@@ -322,12 +330,12 @@ module PodBuilder
322
330
  raise "\n\nInvalid PodBuilder.json configuration: 'build_xcframeworks_all' is false and 'build_xcframeworks_exclude' is not empty\n".red if Configuration.build_xcframeworks_exclude.count > 0
323
331
  end
324
332
  end
325
-
333
+
326
334
  def self.config_path
327
335
  unless path = podbuilder_path
328
336
  return nil
329
337
  end
330
-
338
+
331
339
  return File.join(path, Configuration.configuration_filename)
332
340
  end
333
341
 
@@ -346,5 +354,5 @@ module PodBuilder
346
354
 
347
355
  return path
348
356
  end
349
- end
357
+ end
350
358
  end