peachsim 0.1.2412 → 0.1.2421
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.
- package/README.md +1 -1
- package/cli/catalog/content.ts +6 -3
- package/cli/catalog/meta.ts +63 -17
- package/cli/catalog/routes.ts +4 -0
- package/cli/cloud-box-artifact.ts +45 -24
- package/cli/cloud-client.ts +6 -2
- package/cli/command-registry.ts +3 -1
- package/cli/commands/control.ts +74 -55
- package/cli/commands/desktop.ts +3 -3
- package/cli/commands/electron.ts +7 -5
- package/cli/commands/kotlin.ts +8 -1
- package/cli/commands/platform.ts +5 -7
- package/cli/commands/profile.ts +2 -2
- package/cli/commands/settings.ts +90 -0
- package/cli/commands/shell-url.ts +18 -10
- package/cli/commands/swift.ts +3 -1
- package/cli/main.ts +6 -0
- package/cli/outbound-endpoints.ts +17 -15
- package/cli/settings-flags.ts +115 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +3606 -1815
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +3 -7
- package/dist-lib/config.mjs +3 -7
- package/dist-lib/detox/index.cjs +4 -4
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +17049 -15297
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +63367 -62445
- package/dist-lib/host/fetch-proxy-handler.cjs +1598 -211
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +2704 -1213
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +972 -246
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1737 -246
- package/dist-lib/native-app-identity-project.cjs +35 -203
- package/dist-lib/native-app-identity-project.mjs +35 -203
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +26 -24
- package/dist-lib/public-origins-lib.json +198 -117
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +21665 -20508
- package/dist-lib/swift-compile.cjs +48 -228
- package/dist-lib/swift-compile.mjs +48 -228
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -199
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +126 -247
- package/dist-lib/vite.cjs +5240 -3788
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/config.d.ts +1 -4
- package/kotlin/README.md +4 -3
- package/kotlin/sdk.tar.gz +0 -0
- package/kotlin/toolchain.json +3 -6
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h +1 -43
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayerContents.h +55 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +3 -3
- package/sdk/ios/usr/include/ObjectiveC.apinotes +0 -24
- package/sdk/ios/usr/include/grp.h +93 -0
- package/sdk/ios/usr/include/netinet/tcp.h +299 -0
- package/sdk/ios/wasm/include/netinet/tcp.h +6 -0
- package/sdk/ios/wasm/include/stdlib.h +1 -0
- package/sdk/ios/wasm/include/unistd.h +2 -0
- package/skills/contrast/SKILL.md +1 -0
- package/skills/peach-setup/SKILL.md +11 -1
- package/src/android-bridge-dependencies.ts +1 -1
- package/src/app-config.ts +7 -0
- package/src/binaryen.lock.json +21 -0
- package/src/cocoapods-trunk.ts +52 -0
- package/src/config.ts +21 -31
- package/src/kotlin-host.ts +1 -1
- package/src/kotlin-sdk.ts +7 -7
- package/src/kotlin-toolchain.ts +28 -24
- package/src/kotlinSdkContract.ts +2 -2
- package/src/native-bundles.ts +5 -2
- package/src/native-static-libraries.ts +38 -5
- package/src/podfile-cocoapods.ts +1473 -0
- package/src/podspec-cocoapods.ts +331 -106
- package/src/podspec-ruby-stdlib.ts +134 -19
- package/src/podspec-ruby.ts +199 -46
- package/src/settingsContract.ts +74 -0
- package/src/swift-compile.ts +1 -1
- package/src/swift-compiler-digest.ts +1 -0
- package/src/swift-host.ts +32 -7
- package/src/swift-packages.ts +35 -6
- package/src/swift-shared-sdk.ts +19 -0
- package/src/swift-toolchain.ts +2 -201
- package/src/turbo-source.ts +7 -37
- package/src/wasm-optimize.ts +4 -27
- package/src/xcode-project.ts +6 -1
|
@@ -0,0 +1,1473 @@
|
|
|
1
|
+
// evaluates an app's Podfile the way CocoaPods' Podfile.from_file does, in the
|
|
2
|
+
// same interpreter as its podspecs. the Ruby below is cocoapods-core 1.17.0's
|
|
3
|
+
// Podfile DSL, TargetDefinition and BuildType (MIT, Eloy Durán and the
|
|
4
|
+
// CocoaPods team), kept to the parts evaluation reaches.
|
|
5
|
+
import fs from 'node:fs'
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
import { trunkSpecificationFile, trunkVersions } from './cocoapods-trunk'
|
|
8
|
+
import { cocoapodsInterpreter, rubyFailures } from './podspec-cocoapods'
|
|
9
|
+
import {
|
|
10
|
+
type Frame,
|
|
11
|
+
type Interpreter,
|
|
12
|
+
RModule,
|
|
13
|
+
RObject,
|
|
14
|
+
str,
|
|
15
|
+
type Value,
|
|
16
|
+
} from './podspec-ruby'
|
|
17
|
+
import { toJson } from './podspec-ruby-stdlib'
|
|
18
|
+
|
|
19
|
+
const PODFILE = String.raw`
|
|
20
|
+
module Pod
|
|
21
|
+
class BuildType
|
|
22
|
+
KNOWN_PACKAGING_OPTIONS = { :library => [:static, :dynamic], :framework => [:static, :dynamic] }.freeze
|
|
23
|
+
attr_reader :packaging, :linkage
|
|
24
|
+
def initialize(linkage: :static, packaging: :library)
|
|
25
|
+
raise ArgumentError, "Invalid linkage option #{linkage.inspect}, valid options are #{KNOWN_PACKAGING_OPTIONS[packaging].inspect}" unless KNOWN_PACKAGING_OPTIONS[packaging].include?(linkage)
|
|
26
|
+
@packaging = packaging
|
|
27
|
+
@linkage = linkage
|
|
28
|
+
end
|
|
29
|
+
def self.dynamic_library; new(:linkage => :dynamic, :packaging => :library); end
|
|
30
|
+
def self.static_library; new(:linkage => :static, :packaging => :library); end
|
|
31
|
+
def self.dynamic_framework; new(:linkage => :dynamic, :packaging => :framework); end
|
|
32
|
+
def self.static_framework; new(:linkage => :static, :packaging => :framework); end
|
|
33
|
+
def dynamic?; linkage == :dynamic; end
|
|
34
|
+
def static?; linkage == :static; end
|
|
35
|
+
def framework?; packaging == :framework; end
|
|
36
|
+
def library?; packaging == :library; end
|
|
37
|
+
def dynamic_framework?; dynamic? && framework?; end
|
|
38
|
+
def dynamic_library?; dynamic? && library?; end
|
|
39
|
+
def static_framework?; static? && framework?; end
|
|
40
|
+
def static_library?; static? && library?; end
|
|
41
|
+
def to_s
|
|
42
|
+
"#{linkage} #{packaging}"
|
|
43
|
+
end
|
|
44
|
+
def to_hash
|
|
45
|
+
{ :linkage => linkage, :packaging => packaging }
|
|
46
|
+
end
|
|
47
|
+
def ==(other)
|
|
48
|
+
linkage == other.linkage && packaging == other.packaging
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class Sandbox
|
|
53
|
+
attr_reader :root, :stored_podspecs
|
|
54
|
+
def initialize(root)
|
|
55
|
+
@root = Pathname.new(root)
|
|
56
|
+
@stored_podspecs = {}
|
|
57
|
+
@local_paths = {}
|
|
58
|
+
end
|
|
59
|
+
def specifications_root
|
|
60
|
+
root + 'Local Podspecs'
|
|
61
|
+
end
|
|
62
|
+
def specification(name)
|
|
63
|
+
@stored_podspecs[Specification.root_name(name)]
|
|
64
|
+
end
|
|
65
|
+
def store_local_path(name, path, was_absolute = false)
|
|
66
|
+
@local_paths[Specification.root_name(name)] = [path.dirname, was_absolute]
|
|
67
|
+
end
|
|
68
|
+
def local_path(name)
|
|
69
|
+
@local_paths[Specification.root_name(name)]&.first
|
|
70
|
+
end
|
|
71
|
+
def local?(name)
|
|
72
|
+
@local_paths.key?(Specification.root_name(name))
|
|
73
|
+
end
|
|
74
|
+
def development_pods
|
|
75
|
+
@local_paths.transform_values(&:first)
|
|
76
|
+
end
|
|
77
|
+
def store_podspec(name, podspec, _external_source = false, json = false)
|
|
78
|
+
file_name = json ? "#{name}.podspec.json" : "#{name}.podspec"
|
|
79
|
+
output_path = specifications_root + file_name
|
|
80
|
+
spec = case podspec
|
|
81
|
+
when Specification
|
|
82
|
+
raise ArgumentError, 'can only store Specification objects as json' unless json
|
|
83
|
+
# the checksum of the JSON CocoaPods writes to output_path
|
|
84
|
+
podspec.dup.tap { |stored| stored.instance_variable_set(:@checksum, Digest::SHA1.hexdigest(podspec.to_pretty_json)) }
|
|
85
|
+
else
|
|
86
|
+
raise ArgumentError, "Peach stores only evaluated podspecs, not #{podspec.inspect}"
|
|
87
|
+
end
|
|
88
|
+
spec.defined_in_file = output_path
|
|
89
|
+
unless spec.name == name
|
|
90
|
+
raise Informative, "The name of the given podspec '#{spec.name}' doesn't match the expected one '#{name}'"
|
|
91
|
+
end
|
|
92
|
+
@stored_podspecs[spec.name] = spec
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class Installer
|
|
97
|
+
attr_reader :sandbox, :podfile, :lockfile
|
|
98
|
+
attr_accessor :pod_targets, :aggregate_targets
|
|
99
|
+
def initialize(sandbox, podfile, lockfile = nil)
|
|
100
|
+
@sandbox = sandbox
|
|
101
|
+
@podfile = podfile
|
|
102
|
+
@lockfile = lockfile
|
|
103
|
+
@pod_targets = []
|
|
104
|
+
@aggregate_targets = []
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
private
|
|
108
|
+
|
|
109
|
+
def run_podfile_pre_install_hooks
|
|
110
|
+
podfile.pre_install!(self)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def run_podfile_post_install_hooks
|
|
114
|
+
podfile.post_install!(self)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# upstream runs plugin hooks and prints warnings here; Peach loads no plugins
|
|
118
|
+
def perform_post_install_actions
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
class UserProjectIntegrator
|
|
122
|
+
private
|
|
123
|
+
|
|
124
|
+
def integrate_user_targets
|
|
125
|
+
[]
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
class Specification
|
|
131
|
+
SCRIPT_PHASE_REQUIRED_KEYS = [:name, :script].freeze
|
|
132
|
+
SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :input_file_lists, :output_file_lists,
|
|
133
|
+
:show_env_vars_in_log, :execution_position, :dependency_file, :always_out_of_date].freeze
|
|
134
|
+
EXECUTION_POSITION_KEYS = [:before_compile, :after_compile, :before_headers, :after_headers, :any].freeze
|
|
135
|
+
ALL_SCRIPT_PHASE_KEYS = (SCRIPT_PHASE_REQUIRED_KEYS + SCRIPT_PHASE_OPTIONAL_KEYS).freeze
|
|
136
|
+
|
|
137
|
+
def defined_in_file
|
|
138
|
+
root? ? @defined_in_file : root.defined_in_file
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def defined_in_file=(file)
|
|
142
|
+
raise StandardError, 'Defined in file can be set only for root specs.' unless root?
|
|
143
|
+
@defined_in_file = file
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def self.root_name(full_name)
|
|
147
|
+
if full_name[0] == '/'
|
|
148
|
+
full_name.split('/', 3).first(2).join('/')
|
|
149
|
+
else
|
|
150
|
+
full_name.split('/', 2).first
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def self.from_json(json, path = nil)
|
|
155
|
+
from_hash(JSON.parse(json)).tap { |spec| spec.defined_in_file = path }
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def ==(other)
|
|
159
|
+
other.is_a?(self.class) && name == other.name && version == other.version
|
|
160
|
+
end
|
|
161
|
+
alias_method :eql?, :==
|
|
162
|
+
|
|
163
|
+
def hash
|
|
164
|
+
(name.hash * 53) ^ version.hash
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def test_specs
|
|
168
|
+
subspecs.select(&:test_specification?)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def app_specs
|
|
172
|
+
subspecs.select(&:app_specification?)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def recursive_subspecs
|
|
176
|
+
mapper = lambda do |spec|
|
|
177
|
+
spec.subspecs.map do |subspec|
|
|
178
|
+
[subspec, *mapper.call(subspec)]
|
|
179
|
+
end.flatten
|
|
180
|
+
end
|
|
181
|
+
mapper.call(self)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def all_dependencies(platform = nil)
|
|
185
|
+
dependencies(platform) + subspec_dependencies(platform)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def subspec_dependencies(platform = nil)
|
|
189
|
+
specs = if default_subspecs.empty?
|
|
190
|
+
subspecs.compact.reject(&:non_library_specification?)
|
|
191
|
+
else
|
|
192
|
+
default_subspecs.map do |subspec_name|
|
|
193
|
+
root.subspec_by_name("#{name}/#{subspec_name}")
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
if platform
|
|
197
|
+
specs = specs.select { |s| s.supported_on_platform?(platform) }
|
|
198
|
+
end
|
|
199
|
+
specs.map { |s| Dependency.new(s.name, version) }
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def supported_on_platform?(platform, target = nil)
|
|
203
|
+
platform = Platform.new(platform, target) unless platform.is_a?(Platform)
|
|
204
|
+
available_platforms.any? { |available| platform.supports?(available) }
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def to_pretty_json(*a)
|
|
208
|
+
JSON.pretty_generate(to_hash, *a) << "\n"
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def checksum
|
|
212
|
+
@checksum ||= begin
|
|
213
|
+
if root?
|
|
214
|
+
unless defined_in_file.nil?
|
|
215
|
+
require 'digest'
|
|
216
|
+
checksum = Digest::SHA1.hexdigest(File.read(defined_in_file))
|
|
217
|
+
checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
|
|
218
|
+
checksum
|
|
219
|
+
end
|
|
220
|
+
else
|
|
221
|
+
root.checksum
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
class Podfile
|
|
228
|
+
class StandardError < ::StandardError; end
|
|
229
|
+
|
|
230
|
+
module DSL
|
|
231
|
+
def install!(installation_method, options = {})
|
|
232
|
+
unless current_target_definition.root?
|
|
233
|
+
raise Informative, 'The installation method can only be set at the root level of the Podfile.'
|
|
234
|
+
end
|
|
235
|
+
set_hash_value('installation_method', 'name' => installation_method, 'options' => options)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def ensure_bundler!(version = '>= 0')
|
|
239
|
+
raise Informative, "Peach does not evaluate ensure_bundler! (#{version})"
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def pod(name = nil, *requirements)
|
|
243
|
+
unless name
|
|
244
|
+
raise StandardError, 'A dependency requires a name.'
|
|
245
|
+
end
|
|
246
|
+
if block_given?
|
|
247
|
+
raise StandardError, "A block was passed to pod #{name}, which is not supported."
|
|
248
|
+
end
|
|
249
|
+
current_target_definition.store_pod(name, *requirements)
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def podspec(options = nil)
|
|
253
|
+
current_target_definition.store_podspec(options)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def target(name, options = nil)
|
|
257
|
+
if options
|
|
258
|
+
raise Informative, "Unsupported options #{options} for target #{name}."
|
|
259
|
+
end
|
|
260
|
+
parent = current_target_definition
|
|
261
|
+
definition = TargetDefinition.new(name, parent)
|
|
262
|
+
self.current_target_definition = definition
|
|
263
|
+
yield if block_given?
|
|
264
|
+
ensure
|
|
265
|
+
self.current_target_definition = parent
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def script_phase(options)
|
|
269
|
+
raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?
|
|
270
|
+
raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?
|
|
271
|
+
current_target_definition.store_script_phase(options)
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def abstract_target(name)
|
|
275
|
+
target(name) do
|
|
276
|
+
abstract!
|
|
277
|
+
yield if block_given?
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
def abstract!(abstract = true)
|
|
282
|
+
current_target_definition.abstract = abstract
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def inherit!(inheritance)
|
|
286
|
+
current_target_definition.inheritance = inheritance
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def platform(name, target = nil)
|
|
290
|
+
current_target_definition.set_platform!(name, target)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def project(path, build_configurations = {})
|
|
294
|
+
current_target_definition.user_project_path = path
|
|
295
|
+
current_target_definition.build_configurations = build_configurations
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def inhibit_all_warnings!
|
|
299
|
+
current_target_definition.inhibit_all_warnings = true
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def use_modular_headers!
|
|
303
|
+
current_target_definition.use_modular_headers_for_all_pods = true
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def use_frameworks!(option = true)
|
|
307
|
+
current_target_definition.use_frameworks!(option)
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def supports_swift_versions(*requirements)
|
|
311
|
+
current_target_definition.store_swift_version_requirements(*requirements)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def workspace(path)
|
|
315
|
+
set_hash_value('workspace', path)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def generate_bridge_support!
|
|
319
|
+
set_hash_value('generate_bridge_support', true)
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
def set_arc_compatibility_flag!
|
|
323
|
+
set_hash_value('set_arc_compatibility_flag', true)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def source(source)
|
|
327
|
+
hash_sources = get_hash_value('sources') || []
|
|
328
|
+
hash_sources << source
|
|
329
|
+
set_hash_value('sources', hash_sources.uniq)
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def plugin(name, options = {})
|
|
333
|
+
hash_plugins = get_hash_value('plugins') || {}
|
|
334
|
+
(hash_plugins[name] ||= {}).merge!(options)
|
|
335
|
+
set_hash_value('plugins', hash_plugins)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def pre_install(&block)
|
|
339
|
+
@pre_install_callback = block
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def pre_integrate(&block)
|
|
343
|
+
@pre_integrate_callback = block
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def post_install(&block)
|
|
347
|
+
@post_install_callback = block
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def post_integrate(&block)
|
|
351
|
+
@post_integrate_callback = block
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
include DSL
|
|
356
|
+
|
|
357
|
+
HASH_KEYS = %w(installation_method workspace sources plugins set_arc_compatibility_flag generate_bridge_support target_definitions).freeze
|
|
358
|
+
|
|
359
|
+
attr_accessor :defined_in_file
|
|
360
|
+
attr_accessor :current_target_definition
|
|
361
|
+
attr_reader :internal_hash
|
|
362
|
+
|
|
363
|
+
def initialize(defined_in_file = nil, internal_hash = {})
|
|
364
|
+
@defined_in_file = defined_in_file
|
|
365
|
+
@internal_hash = internal_hash
|
|
366
|
+
default_target_def = TargetDefinition.new('Pods', self)
|
|
367
|
+
default_target_def.abstract = true
|
|
368
|
+
@root_target_definitions = [default_target_def]
|
|
369
|
+
@current_target_definition = default_target_def
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
def to_s
|
|
373
|
+
'Podfile'
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def target_definitions
|
|
377
|
+
Hash[target_definition_list.map { |td| [td.name, td] }]
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
def target_definition_list
|
|
381
|
+
root_target_definitions.map { |td| [td, td.recursive_children] }.flatten
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
attr_accessor :root_target_definitions
|
|
385
|
+
|
|
386
|
+
def dependencies
|
|
387
|
+
target_definition_list.map(&:dependencies).flatten.uniq
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def checksum
|
|
391
|
+
@checksum ||= Digest::SHA1.hexdigest(File.read(defined_in_file)) unless defined_in_file.nil?
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
def workspace_path
|
|
395
|
+
path = get_hash_value('workspace')
|
|
396
|
+
if path
|
|
397
|
+
if File.extname(path) == '.xcworkspace'
|
|
398
|
+
path
|
|
399
|
+
else
|
|
400
|
+
"#{path}.xcworkspace"
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def generate_bridge_support?
|
|
406
|
+
get_hash_value('generate_bridge_support')
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
def set_arc_compatibility_flag?
|
|
410
|
+
get_hash_value('set_arc_compatibility_flag')
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
def installation_method
|
|
414
|
+
get_hash_value('installation_method', 'name' => 'cocoapods', 'options' => {}).values_at('name', 'options')
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
def sources
|
|
418
|
+
get_hash_value('sources') || []
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
def plugins
|
|
422
|
+
get_hash_value('plugins') || {}
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def to_hash
|
|
426
|
+
hash = {}
|
|
427
|
+
hash['target_definitions'] = root_target_definitions.map(&:to_hash)
|
|
428
|
+
hash.merge!(internal_hash)
|
|
429
|
+
hash
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def pre_install!(installer)
|
|
433
|
+
@pre_install_callback ? @pre_install_callback.call(installer) || true : false
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
def post_install!(installer)
|
|
437
|
+
@post_install_callback ? @post_install_callback.call(installer) || true : false
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def set_hash_value(key, value)
|
|
441
|
+
raise StandardError, "Unsupported hash key '#{key}'" unless HASH_KEYS.include?(key)
|
|
442
|
+
internal_hash[key] = value
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
def get_hash_value(key, default = nil)
|
|
446
|
+
raise StandardError, "Unsupported hash key '#{key}'" unless HASH_KEYS.include?(key)
|
|
447
|
+
internal_hash.fetch(key, default)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
class TargetDefinition
|
|
451
|
+
attr_reader :parent
|
|
452
|
+
attr_reader :internal_hash
|
|
453
|
+
attr_accessor :children
|
|
454
|
+
|
|
455
|
+
HASH_KEYS = %w(
|
|
456
|
+
name platform podspecs exclusive link_with link_with_first_target inhibit_warnings use_modular_headers
|
|
457
|
+
user_project_path build_configurations project_names dependencies script_phases children
|
|
458
|
+
configuration_pod_whitelist uses_frameworks swift_version_requirements inheritance abstract swift_version
|
|
459
|
+
).freeze
|
|
460
|
+
|
|
461
|
+
def initialize(name, parent, internal_hash = nil)
|
|
462
|
+
@internal_hash = internal_hash || {}
|
|
463
|
+
@parent = parent
|
|
464
|
+
@children = []
|
|
465
|
+
@label = nil
|
|
466
|
+
self.name ||= name
|
|
467
|
+
if parent.is_a?(TargetDefinition)
|
|
468
|
+
parent.children << self
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
def recursive_children
|
|
473
|
+
(children + children.map(&:recursive_children)).flatten
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
def root?
|
|
477
|
+
parent.is_a?(Podfile) || parent.nil?
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def root
|
|
481
|
+
if root?
|
|
482
|
+
self
|
|
483
|
+
else
|
|
484
|
+
parent.root
|
|
485
|
+
end
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
def podfile
|
|
489
|
+
root.parent
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
def dependencies
|
|
493
|
+
if exclusive?
|
|
494
|
+
non_inherited_dependencies
|
|
495
|
+
else
|
|
496
|
+
non_inherited_dependencies + parent.dependencies
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
def targets_to_inherit_search_paths
|
|
501
|
+
return [] unless inheritance == 'search_paths'
|
|
502
|
+
if root? || !matches_platform?(parent)
|
|
503
|
+
raise StandardError, "Non-root target definitions (#{label}) need a parent target definition with the same platform."
|
|
504
|
+
elsif parent.inheritance == 'search_paths'
|
|
505
|
+
parent.targets_to_inherit_search_paths << parent
|
|
506
|
+
else
|
|
507
|
+
[parent]
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
def non_inherited_dependencies
|
|
512
|
+
pod_dependencies.concat(podspec_dependencies)
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
def empty?
|
|
516
|
+
non_inherited_dependencies.empty?
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
def label
|
|
520
|
+
@label ||= if root? && name == 'Pods'
|
|
521
|
+
'Pods'
|
|
522
|
+
elsif exclusive? || parent.nil?
|
|
523
|
+
"Pods-#{name}"
|
|
524
|
+
else
|
|
525
|
+
"#{parent.label}-#{name}"
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
alias_method :to_s, :label
|
|
530
|
+
|
|
531
|
+
def inspect
|
|
532
|
+
"#<#{self.class} label=#{label}>"
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def name
|
|
536
|
+
get_hash_value('name')
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
def name=(name)
|
|
540
|
+
@label = nil
|
|
541
|
+
set_hash_value('name', name)
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
def abstract?
|
|
545
|
+
get_hash_value('abstract', root?)
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
def abstract=(abstract)
|
|
549
|
+
set_hash_value('abstract', abstract)
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
def swift_version
|
|
553
|
+
get_hash_value('swift_version')
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
def swift_version=(version)
|
|
557
|
+
set_hash_value('swift_version', version)
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
def swift_version_requirements
|
|
561
|
+
get_hash_value('swift_version_requirements')
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
def store_swift_version_requirements(*requirements)
|
|
565
|
+
set_hash_value('swift_version_requirements', requirements.flatten.map(&:to_s))
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
def inheritance
|
|
569
|
+
get_hash_value('inheritance', 'complete')
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
def inheritance=(inheritance)
|
|
573
|
+
inheritance = inheritance.to_s
|
|
574
|
+
unless %w(none search_paths complete).include?(inheritance)
|
|
575
|
+
raise Informative, "Unrecognized inheritance option '#{inheritance}' specified for target '#{name}'."
|
|
576
|
+
end
|
|
577
|
+
if root?
|
|
578
|
+
raise Informative, 'Cannot set inheritance for the root target definition.'
|
|
579
|
+
end
|
|
580
|
+
if abstract?
|
|
581
|
+
raise Informative, 'Cannot set inheritance for abstract target definition.'
|
|
582
|
+
end
|
|
583
|
+
set_hash_value('inheritance', inheritance)
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
def exclusive?
|
|
587
|
+
if root?
|
|
588
|
+
true
|
|
589
|
+
else
|
|
590
|
+
!matches_platform?(parent) || (inheritance != 'complete')
|
|
591
|
+
end
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
def matches_platform?(target_definition)
|
|
595
|
+
return false unless target_definition
|
|
596
|
+
return true if target_definition.platform == platform
|
|
597
|
+
!target_definition.platform && target_definition.abstract?
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
def user_project_path
|
|
601
|
+
path = get_hash_value('user_project_path')
|
|
602
|
+
if path
|
|
603
|
+
Pathname(path).sub_ext('.xcodeproj').to_path
|
|
604
|
+
else
|
|
605
|
+
parent.user_project_path unless root?
|
|
606
|
+
end
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
def user_project_path=(path)
|
|
610
|
+
set_hash_value('user_project_path', path)
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
def build_configurations
|
|
614
|
+
if root?
|
|
615
|
+
get_hash_value('build_configurations')
|
|
616
|
+
else
|
|
617
|
+
get_hash_value('build_configurations') || parent.build_configurations
|
|
618
|
+
end
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
def build_configurations=(hash)
|
|
622
|
+
set_hash_value('build_configurations', hash) unless hash.empty?
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
def script_phases
|
|
626
|
+
script_phases_hashes = get_hash_value('script_phases', [])
|
|
627
|
+
script_phases_hashes.map do |script_phase_hash|
|
|
628
|
+
Specification.convert_keys_to_symbol(script_phase_hash)
|
|
629
|
+
end
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
def project_name_for_pod(pod_name)
|
|
633
|
+
if root?
|
|
634
|
+
raw_project_names_hash[pod_name]
|
|
635
|
+
else
|
|
636
|
+
raw_project_names_hash[pod_name] || parent.project_name_for_pod(pod_name)
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
|
|
640
|
+
def inhibits_warnings_for_pod?(pod_name)
|
|
641
|
+
if Array(inhibit_warnings_hash['not_for_pods']).include?(pod_name)
|
|
642
|
+
false
|
|
643
|
+
elsif Array(inhibit_warnings_hash['for_pods']).include?(pod_name)
|
|
644
|
+
true
|
|
645
|
+
elsif inhibit_warnings_hash['all']
|
|
646
|
+
true
|
|
647
|
+
elsif !root? && parent.inhibits_warnings_for_pod?(pod_name)
|
|
648
|
+
true
|
|
649
|
+
else
|
|
650
|
+
false
|
|
651
|
+
end
|
|
652
|
+
end
|
|
653
|
+
|
|
654
|
+
def inhibit_all_warnings=(flag)
|
|
655
|
+
raw_inhibit_warnings_hash['all'] = flag
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
def set_inhibit_warnings_for_pod(pod_name, should_inhibit)
|
|
659
|
+
hash_key = case should_inhibit
|
|
660
|
+
when true
|
|
661
|
+
'for_pods'
|
|
662
|
+
when false
|
|
663
|
+
'not_for_pods'
|
|
664
|
+
when nil
|
|
665
|
+
return
|
|
666
|
+
else
|
|
667
|
+
raise ArgumentError, "Got '#{should_inhibit.inspect}', should be a boolean"
|
|
668
|
+
end
|
|
669
|
+
raw_inhibit_warnings_hash[hash_key] ||= []
|
|
670
|
+
raw_inhibit_warnings_hash[hash_key] << pod_name
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
def build_pod_as_module?(pod_name)
|
|
674
|
+
if Array(use_modular_headers_hash['not_for_pods']).include?(pod_name)
|
|
675
|
+
false
|
|
676
|
+
elsif Array(use_modular_headers_hash['for_pods']).include?(pod_name)
|
|
677
|
+
true
|
|
678
|
+
elsif use_modular_headers_hash['all']
|
|
679
|
+
true
|
|
680
|
+
elsif !root? && parent.build_pod_as_module?(pod_name)
|
|
681
|
+
true
|
|
682
|
+
else
|
|
683
|
+
false
|
|
684
|
+
end
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
def use_modular_headers_for_all_pods=(flag)
|
|
688
|
+
raw_use_modular_headers_hash['all'] = flag
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
def set_use_modular_headers_for_pod(pod_name, flag)
|
|
692
|
+
hash_key = case flag
|
|
693
|
+
when true
|
|
694
|
+
'for_pods'
|
|
695
|
+
when false
|
|
696
|
+
'not_for_pods'
|
|
697
|
+
when nil
|
|
698
|
+
return
|
|
699
|
+
else
|
|
700
|
+
raise ArgumentError, "Got '#{flag.inspect}', should be a boolean"
|
|
701
|
+
end
|
|
702
|
+
raw_use_modular_headers_hash[hash_key] ||= []
|
|
703
|
+
raw_use_modular_headers_hash[hash_key] << pod_name
|
|
704
|
+
end
|
|
705
|
+
|
|
706
|
+
def use_frameworks!(option = true)
|
|
707
|
+
value = case option
|
|
708
|
+
when true, false
|
|
709
|
+
option ? BuildType.dynamic_framework : BuildType.static_library
|
|
710
|
+
when Hash
|
|
711
|
+
BuildType.new(:linkage => option.fetch(:linkage), :packaging => :framework)
|
|
712
|
+
else
|
|
713
|
+
raise ArgumentError, "Got '#{option.inspect}', should be a boolean or hash."
|
|
714
|
+
end
|
|
715
|
+
set_hash_value('uses_frameworks', value.to_hash)
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
def build_type
|
|
719
|
+
value = get_hash_value('uses_frameworks', root? ? BuildType.static_library.to_hash : parent.build_type.to_hash)
|
|
720
|
+
case value
|
|
721
|
+
when true, false
|
|
722
|
+
value ? BuildType.dynamic_framework : BuildType.static_library
|
|
723
|
+
when Hash
|
|
724
|
+
BuildType.new(:linkage => value.fetch(:linkage), :packaging => value.fetch(:packaging))
|
|
725
|
+
when BuildType
|
|
726
|
+
value
|
|
727
|
+
else
|
|
728
|
+
raise ArgumentError, "Got '#{value.inspect}', should be a boolean, hash or BuildType."
|
|
729
|
+
end
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
def uses_frameworks?
|
|
733
|
+
if internal_hash['uses_frameworks'].nil?
|
|
734
|
+
root? ? false : parent.uses_frameworks?
|
|
735
|
+
else
|
|
736
|
+
build_type.framework?
|
|
737
|
+
end
|
|
738
|
+
end
|
|
739
|
+
|
|
740
|
+
def whitelist_pod_for_configuration(pod_name, configuration_name)
|
|
741
|
+
found = raw_configuration_pod_whitelist.find { |configuration, _| configuration.casecmp(configuration_name.to_s).zero? }
|
|
742
|
+
configuration_name = found.nil? ? configuration_name.to_s : found.first
|
|
743
|
+
list = raw_configuration_pod_whitelist[configuration_name] ||= []
|
|
744
|
+
list << pod_name
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
def pod_whitelisted_for_configuration?(pod_name, configuration_name)
|
|
748
|
+
found = false
|
|
749
|
+
configuration_pod_whitelist.each do |configuration, pods|
|
|
750
|
+
if pods.include?(pod_name)
|
|
751
|
+
found = true
|
|
752
|
+
if configuration.casecmp(configuration_name.to_s).zero?
|
|
753
|
+
return true
|
|
754
|
+
end
|
|
755
|
+
end
|
|
756
|
+
end
|
|
757
|
+
!found && (root? || (inheritance != 'none' && parent.pod_whitelisted_for_configuration?(pod_name, configuration_name)))
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
def all_whitelisted_configurations
|
|
761
|
+
parent_configurations = (root? || inheritance == 'none') ? [] : parent.all_whitelisted_configurations
|
|
762
|
+
(configuration_pod_whitelist.keys + parent_configurations).uniq
|
|
763
|
+
end
|
|
764
|
+
|
|
765
|
+
def platform
|
|
766
|
+
name_or_hash = get_hash_value('platform')
|
|
767
|
+
if name_or_hash
|
|
768
|
+
if name_or_hash.is_a?(Hash)
|
|
769
|
+
name = name_or_hash.keys.first.to_sym
|
|
770
|
+
target = name_or_hash.values.first
|
|
771
|
+
else
|
|
772
|
+
name = name_or_hash.to_sym
|
|
773
|
+
end
|
|
774
|
+
target ||= (name == :ios ? '4.3' : '10.6')
|
|
775
|
+
Platform.new(name, target)
|
|
776
|
+
else
|
|
777
|
+
parent.platform unless root?
|
|
778
|
+
end
|
|
779
|
+
end
|
|
780
|
+
|
|
781
|
+
def set_platform(name, target = nil)
|
|
782
|
+
name = :osx if name == :macos
|
|
783
|
+
unless [:ios, :osx, :tvos, :visionos, :watchos].include?(name)
|
|
784
|
+
raise StandardError, "Unsupported platform '#{name}'. Platform must be ':ios', ':osx', ':macos', ':tvos', :visionos, or ':watchos'."
|
|
785
|
+
end
|
|
786
|
+
if target
|
|
787
|
+
value = { name.to_s => target }
|
|
788
|
+
else
|
|
789
|
+
value = name.to_s
|
|
790
|
+
end
|
|
791
|
+
set_hash_value('platform', value)
|
|
792
|
+
end
|
|
793
|
+
|
|
794
|
+
def set_platform!(name, target = nil)
|
|
795
|
+
raise StandardError, "The target '#{label}' already has a platform set." if get_hash_value('platform')
|
|
796
|
+
set_platform(name, target)
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
def store_pod(name, *requirements)
|
|
800
|
+
return if parse_subspecs(name, requirements)
|
|
801
|
+
parse_inhibit_warnings(name, requirements)
|
|
802
|
+
parse_modular_headers(name, requirements)
|
|
803
|
+
parse_configuration_whitelist(name, requirements)
|
|
804
|
+
parse_project_name(name, requirements)
|
|
805
|
+
if requirements && !requirements.empty?
|
|
806
|
+
pod = { name => requirements }
|
|
807
|
+
else
|
|
808
|
+
pod = name
|
|
809
|
+
end
|
|
810
|
+
get_hash_value('dependencies', []) << pod
|
|
811
|
+
nil
|
|
812
|
+
end
|
|
813
|
+
|
|
814
|
+
def store_podspec(options = nil)
|
|
815
|
+
options ||= {}
|
|
816
|
+
unless options.keys.all? { |key| [:autodetect, :path, :name, :subspecs, :subspec].include?(key) }
|
|
817
|
+
raise StandardError, "Unrecognized options for the podspec method '#{options}'"
|
|
818
|
+
end
|
|
819
|
+
if subspec_name = options[:subspec]
|
|
820
|
+
options[:subspecs] = [subspec_name]
|
|
821
|
+
end
|
|
822
|
+
options[:autodetect] = true if !options.include?(:name) && !options.include?(:path)
|
|
823
|
+
get_hash_value('podspecs', []) << options
|
|
824
|
+
end
|
|
825
|
+
|
|
826
|
+
def store_script_phase(options)
|
|
827
|
+
option_keys = options.keys
|
|
828
|
+
unrecognized_keys = option_keys - Specification::ALL_SCRIPT_PHASE_KEYS
|
|
829
|
+
unless unrecognized_keys.empty?
|
|
830
|
+
raise StandardError, "Unrecognized options '#{unrecognized_keys}' in shell script '#{options[:name]}' within '#{name}' target. Available options are '#{Specification::ALL_SCRIPT_PHASE_KEYS}'."
|
|
831
|
+
end
|
|
832
|
+
missing_required_keys = Specification::SCRIPT_PHASE_REQUIRED_KEYS - option_keys
|
|
833
|
+
unless missing_required_keys.empty?
|
|
834
|
+
raise StandardError, "Missing required shell script phase options '#{missing_required_keys.join(', ')}'"
|
|
835
|
+
end
|
|
836
|
+
script_phases_hash = get_hash_value('script_phases', [])
|
|
837
|
+
if script_phases_hash.map { |script_phase_options| script_phase_options[:name] }.include?(options[:name])
|
|
838
|
+
raise StandardError, "Script phase with name '#{options[:name]}' name already present for target '#{name}'."
|
|
839
|
+
end
|
|
840
|
+
options[:execution_position] = :any unless options.key?(:execution_position)
|
|
841
|
+
unless Specification::EXECUTION_POSITION_KEYS.include?(options[:execution_position])
|
|
842
|
+
raise StandardError, "Invalid execution position value '#{options[:execution_position]}' in shell script '#{options[:name]}' within '#{name}' target. Available options are '#{Specification::EXECUTION_POSITION_KEYS}'."
|
|
843
|
+
end
|
|
844
|
+
script_phases_hash << options
|
|
845
|
+
end
|
|
846
|
+
|
|
847
|
+
def to_hash
|
|
848
|
+
hash = internal_hash.dup
|
|
849
|
+
unless children.empty?
|
|
850
|
+
hash['children'] = children.map(&:to_hash)
|
|
851
|
+
end
|
|
852
|
+
hash
|
|
853
|
+
end
|
|
854
|
+
|
|
855
|
+
private
|
|
856
|
+
|
|
857
|
+
def set_hash_value(key, value)
|
|
858
|
+
unless HASH_KEYS.include?(key)
|
|
859
|
+
raise StandardError, "Unsupported hash key '#{key}'"
|
|
860
|
+
end
|
|
861
|
+
internal_hash[key] = value
|
|
862
|
+
end
|
|
863
|
+
|
|
864
|
+
def get_hash_value(key, base_value = nil)
|
|
865
|
+
unless HASH_KEYS.include?(key)
|
|
866
|
+
raise StandardError, "Unsupported hash key '#{key}'"
|
|
867
|
+
end
|
|
868
|
+
internal_hash[key] = base_value if internal_hash[key].nil?
|
|
869
|
+
internal_hash[key]
|
|
870
|
+
end
|
|
871
|
+
|
|
872
|
+
def raw_inhibit_warnings_hash
|
|
873
|
+
get_hash_value('inhibit_warnings', {})
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
def inhibit_warnings_hash
|
|
877
|
+
inhibit_hash = raw_inhibit_warnings_hash
|
|
878
|
+
if exclusive?
|
|
879
|
+
inhibit_hash
|
|
880
|
+
else
|
|
881
|
+
parent_hash = parent.send(:inhibit_warnings_hash).dup
|
|
882
|
+
if parent_hash['not_for_pods']
|
|
883
|
+
parent_hash['not_for_pods'] -= Array(inhibit_hash['for_pods'])
|
|
884
|
+
end
|
|
885
|
+
if parent_hash['for_pods']
|
|
886
|
+
parent_hash['for_pods'] -= Array(inhibit_hash['not_for_pods'])
|
|
887
|
+
end
|
|
888
|
+
if inhibit_hash['all']
|
|
889
|
+
parent_hash['all'] = true
|
|
890
|
+
end
|
|
891
|
+
parent_hash.merge(inhibit_hash) do |_, l, r|
|
|
892
|
+
Array(l).concat(r).uniq
|
|
893
|
+
end
|
|
894
|
+
end
|
|
895
|
+
end
|
|
896
|
+
|
|
897
|
+
def raw_use_modular_headers_hash
|
|
898
|
+
get_hash_value('use_modular_headers', {})
|
|
899
|
+
end
|
|
900
|
+
|
|
901
|
+
def use_modular_headers_hash
|
|
902
|
+
raw_hash = raw_use_modular_headers_hash
|
|
903
|
+
if exclusive?
|
|
904
|
+
raw_hash
|
|
905
|
+
else
|
|
906
|
+
parent_hash = parent.send(:use_modular_headers_hash).dup
|
|
907
|
+
if parent_hash['not_for_pods']
|
|
908
|
+
parent_hash['not_for_pods'] -= Array(raw_hash['for_pods'])
|
|
909
|
+
end
|
|
910
|
+
if parent_hash['for_pods']
|
|
911
|
+
parent_hash['for_pods'] -= Array(raw_hash['not_for_pods'])
|
|
912
|
+
end
|
|
913
|
+
if raw_hash['all']
|
|
914
|
+
parent_hash['all'] = true
|
|
915
|
+
end
|
|
916
|
+
parent_hash.merge(raw_hash) do |_, l, r|
|
|
917
|
+
Array(l).concat(r).uniq
|
|
918
|
+
end
|
|
919
|
+
end
|
|
920
|
+
end
|
|
921
|
+
|
|
922
|
+
def raw_project_names_hash
|
|
923
|
+
get_hash_value('project_names', {})
|
|
924
|
+
end
|
|
925
|
+
|
|
926
|
+
def raw_configuration_pod_whitelist
|
|
927
|
+
get_hash_value('configuration_pod_whitelist', {})
|
|
928
|
+
end
|
|
929
|
+
|
|
930
|
+
def configuration_pod_whitelist
|
|
931
|
+
raw_configuration_pod_whitelist
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
def pod_dependencies
|
|
935
|
+
pods = get_hash_value('dependencies') || []
|
|
936
|
+
pods.map do |name_or_hash|
|
|
937
|
+
if name_or_hash.is_a?(Hash)
|
|
938
|
+
name = name_or_hash.keys.first
|
|
939
|
+
requirements = name_or_hash.values.first
|
|
940
|
+
else
|
|
941
|
+
name = name_or_hash
|
|
942
|
+
requirements = []
|
|
943
|
+
end
|
|
944
|
+
Dependency.new(name, *requirements)
|
|
945
|
+
end
|
|
946
|
+
end
|
|
947
|
+
|
|
948
|
+
def podspec_dependencies
|
|
949
|
+
podspecs = get_hash_value('podspecs') || []
|
|
950
|
+
podspecs.map do |options|
|
|
951
|
+
file = podspec_path_from_options(options)
|
|
952
|
+
spec = Specification.from_file(file)
|
|
953
|
+
subspec_names = options[:subspecs] || options[:subspec]
|
|
954
|
+
specs = if subspec_names.blank?
|
|
955
|
+
[spec]
|
|
956
|
+
else
|
|
957
|
+
subspec_names = [subspec_names] if subspec_names.is_a?(String)
|
|
958
|
+
subspec_names.map { |subspec_name| spec.subspec_by_name("#{spec.name}/#{subspec_name}") }
|
|
959
|
+
end
|
|
960
|
+
specs.map do |subspec|
|
|
961
|
+
all_specs = [subspec, *subspec.recursive_subspecs]
|
|
962
|
+
all_deps = all_specs.map { |s| s.dependencies(platform) }.flatten
|
|
963
|
+
all_deps.reject { |dep| dep.root_name == subspec.root.name }
|
|
964
|
+
end.flatten
|
|
965
|
+
end.flatten.uniq
|
|
966
|
+
end
|
|
967
|
+
|
|
968
|
+
def podspec_path_from_options(options)
|
|
969
|
+
if path = options[:path]
|
|
970
|
+
if File.basename(path).include?('.podspec')
|
|
971
|
+
path_with_ext = path
|
|
972
|
+
else
|
|
973
|
+
path_with_ext = "#{path}.podspec"
|
|
974
|
+
end
|
|
975
|
+
path_without_tilde = path_with_ext.gsub('~', ENV['HOME'])
|
|
976
|
+
podfile.defined_in_file.dirname + path_without_tilde
|
|
977
|
+
elsif name = options[:name]
|
|
978
|
+
name = File.basename(name).include?('.podspec') ? name : "#{name}.podspec"
|
|
979
|
+
podfile.defined_in_file.dirname + name
|
|
980
|
+
elsif options[:autodetect]
|
|
981
|
+
glob_pattern = podfile.defined_in_file.dirname + '*.podspec{,.json}'
|
|
982
|
+
path = Pathname.glob(glob_pattern).first
|
|
983
|
+
unless path
|
|
984
|
+
raise Informative, 'Could not locate a podspec in the current directory. ' \
|
|
985
|
+
'You can specify the path via the path option.'
|
|
986
|
+
end
|
|
987
|
+
path
|
|
988
|
+
end
|
|
989
|
+
end
|
|
990
|
+
|
|
991
|
+
def parse_inhibit_warnings(name, requirements)
|
|
992
|
+
options = requirements.last
|
|
993
|
+
return requirements unless options.is_a?(Hash)
|
|
994
|
+
should_inhibit = options.delete(:inhibit_warnings)
|
|
995
|
+
pod_name = Specification.root_name(name)
|
|
996
|
+
set_inhibit_warnings_for_pod(pod_name, should_inhibit)
|
|
997
|
+
requirements.pop if options.empty?
|
|
998
|
+
end
|
|
999
|
+
|
|
1000
|
+
def parse_modular_headers(name, requirements)
|
|
1001
|
+
options = requirements.last
|
|
1002
|
+
return requirements unless options.is_a?(Hash)
|
|
1003
|
+
defines_module = options.delete(:modular_headers)
|
|
1004
|
+
pod_name = Specification.root_name(name)
|
|
1005
|
+
set_use_modular_headers_for_pod(pod_name, defines_module)
|
|
1006
|
+
requirements.pop if options.empty?
|
|
1007
|
+
end
|
|
1008
|
+
|
|
1009
|
+
def parse_project_name(name, requirements)
|
|
1010
|
+
options = requirements.last
|
|
1011
|
+
return requirements unless options.is_a?(Hash)
|
|
1012
|
+
project_name = options.delete(:project_name)
|
|
1013
|
+
pod_name = Specification.root_name(name)
|
|
1014
|
+
raw_project_names_hash[pod_name] = project_name if project_name
|
|
1015
|
+
requirements.pop if options.empty?
|
|
1016
|
+
end
|
|
1017
|
+
|
|
1018
|
+
def parse_configuration_whitelist(name, requirements)
|
|
1019
|
+
options = requirements.last
|
|
1020
|
+
return requirements unless options.is_a?(Hash)
|
|
1021
|
+
configurations = options.delete(:configurations)
|
|
1022
|
+
configurations ||= options.delete(:configuration)
|
|
1023
|
+
Array(configurations).each do |configuration|
|
|
1024
|
+
whitelist_pod_for_configuration(name, configuration)
|
|
1025
|
+
end
|
|
1026
|
+
requirements.pop if options.empty?
|
|
1027
|
+
end
|
|
1028
|
+
|
|
1029
|
+
def parse_subspecs(name, requirements)
|
|
1030
|
+
options = requirements.last
|
|
1031
|
+
return false unless options.is_a?(Hash)
|
|
1032
|
+
subspecs = options.delete(:subspecs)
|
|
1033
|
+
test_specs = options.delete(:testspecs)
|
|
1034
|
+
app_specs = options.delete(:appspecs)
|
|
1035
|
+
if subspecs && subspecs.empty?
|
|
1036
|
+
raise StandardError, 'Empty subspecs list.'
|
|
1037
|
+
end
|
|
1038
|
+
subspecs.each do |ss|
|
|
1039
|
+
store_pod("#{name}/#{ss}", *requirements.dup)
|
|
1040
|
+
end if subspecs
|
|
1041
|
+
requirements.pop if options.empty?
|
|
1042
|
+
if test_specs || app_specs
|
|
1043
|
+
options[:testspecs] = test_specs.uniq if test_specs
|
|
1044
|
+
options[:appspecs] = app_specs.uniq if app_specs
|
|
1045
|
+
requirements.push(options)
|
|
1046
|
+
end
|
|
1047
|
+
!subspecs.nil?
|
|
1048
|
+
end
|
|
1049
|
+
end
|
|
1050
|
+
end
|
|
1051
|
+
end
|
|
1052
|
+
`
|
|
1053
|
+
|
|
1054
|
+
// CocoaPods 1.17's local external sources (MIT, the CocoaPods team), and its
|
|
1055
|
+
// resolver's outcome for dependency graphs without version conflicts. Molinillo
|
|
1056
|
+
// backtracks on a conflict; here each trunk pod takes the highest version every
|
|
1057
|
+
// requirement on it allows, and a conflict raises.
|
|
1058
|
+
const RESOLVER = String.raw`
|
|
1059
|
+
module Pod
|
|
1060
|
+
module ExternalSources
|
|
1061
|
+
def self.from_dependency(dependency, podfile_path)
|
|
1062
|
+
params = dependency.external_source
|
|
1063
|
+
name = dependency.root_name
|
|
1064
|
+
if params.key?(:podspec)
|
|
1065
|
+
PodspecSource.new(name, params, podfile_path)
|
|
1066
|
+
elsif params.key?(:path)
|
|
1067
|
+
PathSource.new(name, params, podfile_path)
|
|
1068
|
+
else
|
|
1069
|
+
raise Informative, "Peach does not fetch the external source of '#{name}': #{params}"
|
|
1070
|
+
end
|
|
1071
|
+
end
|
|
1072
|
+
|
|
1073
|
+
class AbstractExternalSource
|
|
1074
|
+
attr_reader :name, :params, :podfile_path
|
|
1075
|
+
def initialize(name, params, podfile_path)
|
|
1076
|
+
@name = name
|
|
1077
|
+
@params = params
|
|
1078
|
+
@podfile_path = podfile_path
|
|
1079
|
+
end
|
|
1080
|
+
|
|
1081
|
+
def normalized_podspec_path(declared_path)
|
|
1082
|
+
extension = File.extname(declared_path)
|
|
1083
|
+
if extension == '.podspec' || extension == '.json'
|
|
1084
|
+
path_with_ext = declared_path
|
|
1085
|
+
else
|
|
1086
|
+
path_with_ext = "#{declared_path}/#{name}.podspec"
|
|
1087
|
+
end
|
|
1088
|
+
podfile_dir = File.dirname(podfile_path || '')
|
|
1089
|
+
File.expand_path(path_with_ext, podfile_dir)
|
|
1090
|
+
end
|
|
1091
|
+
|
|
1092
|
+
private
|
|
1093
|
+
|
|
1094
|
+
def store_podspec(sandbox, spec, json = false)
|
|
1095
|
+
sandbox.store_podspec(name, Specification.from_file(spec), true, true)
|
|
1096
|
+
end
|
|
1097
|
+
end
|
|
1098
|
+
|
|
1099
|
+
class PathSource < AbstractExternalSource
|
|
1100
|
+
def fetch(sandbox)
|
|
1101
|
+
podspec = podspec_path
|
|
1102
|
+
raise Informative, "No podspec found for '#{name}' in '#{declared_path}'" unless podspec.exist?
|
|
1103
|
+
store_podspec(sandbox, podspec, podspec.extname == '.json')
|
|
1104
|
+
sandbox.store_local_path(name, podspec, Pathname(declared_path).absolute? || declared_path.start_with?('~'))
|
|
1105
|
+
end
|
|
1106
|
+
|
|
1107
|
+
def declared_path
|
|
1108
|
+
result = params[:path]
|
|
1109
|
+
result.to_s if result
|
|
1110
|
+
end
|
|
1111
|
+
|
|
1112
|
+
def podspec_path
|
|
1113
|
+
path = Pathname(normalized_podspec_path(declared_path))
|
|
1114
|
+
path.exist? ? path : Pathname("#{path}.json")
|
|
1115
|
+
end
|
|
1116
|
+
end
|
|
1117
|
+
|
|
1118
|
+
class PodspecSource < AbstractExternalSource
|
|
1119
|
+
def fetch(sandbox)
|
|
1120
|
+
podspec_path = Pathname(podspec_uri)
|
|
1121
|
+
raise Informative, "Peach does not download the podspec of '#{name}' from #{podspec_uri}" unless podspec_path.exist?
|
|
1122
|
+
store_podspec(sandbox, podspec_path, podspec_path.extname == '.json')
|
|
1123
|
+
end
|
|
1124
|
+
|
|
1125
|
+
def podspec_uri
|
|
1126
|
+
declared_path = params[:podspec].to_s
|
|
1127
|
+
declared_path =~ %r{^.+://} ? declared_path : normalized_podspec_path(declared_path)
|
|
1128
|
+
end
|
|
1129
|
+
end
|
|
1130
|
+
end
|
|
1131
|
+
|
|
1132
|
+
class Resolver
|
|
1133
|
+
class Vertex
|
|
1134
|
+
attr_reader :name, :requirements, :origins
|
|
1135
|
+
attr_accessor :spec, :platforms
|
|
1136
|
+
def initialize(name)
|
|
1137
|
+
@name = name
|
|
1138
|
+
@requirements = []
|
|
1139
|
+
@origins = []
|
|
1140
|
+
@platforms = []
|
|
1141
|
+
end
|
|
1142
|
+
end
|
|
1143
|
+
|
|
1144
|
+
attr_reader :vertices, :trunk_roots
|
|
1145
|
+
|
|
1146
|
+
# trunk answers versions(name) with its published version strings and
|
|
1147
|
+
# specification(name, version) with the Specification, or nil until fetched
|
|
1148
|
+
def initialize(sandbox, podfile, trunk)
|
|
1149
|
+
@sandbox = sandbox
|
|
1150
|
+
@podfile = podfile
|
|
1151
|
+
@trunk = trunk
|
|
1152
|
+
@chosen = {}
|
|
1153
|
+
@learned = Hash.new { |h, k| h[k] = [] }
|
|
1154
|
+
@excluded = Hash.new { |h, k| h[k] = [] }
|
|
1155
|
+
end
|
|
1156
|
+
|
|
1157
|
+
def fetch_external_sources
|
|
1158
|
+
@podfile.dependencies.select(&:external_source).uniq(&:root_name).sort.each do |dependency|
|
|
1159
|
+
ExternalSources.from_dependency(dependency, @podfile.defined_in_file).fetch(@sandbox)
|
|
1160
|
+
end
|
|
1161
|
+
end
|
|
1162
|
+
|
|
1163
|
+
# the trunk names and versions still to fetch, empty once resolved
|
|
1164
|
+
def resolve
|
|
1165
|
+
@platforms_by_dependency = Hash.new { |h, k| h[k] = [] }
|
|
1166
|
+
explicit = []
|
|
1167
|
+
@podfile.target_definition_list.each do |target|
|
|
1168
|
+
target.dependencies.each do |dep|
|
|
1169
|
+
explicit << dep
|
|
1170
|
+
@platforms_by_dependency[dep.to_s].push(target.platform) if target.platform
|
|
1171
|
+
end
|
|
1172
|
+
end
|
|
1173
|
+
explicit.uniq!
|
|
1174
|
+
@platforms_by_dependency.each_value(&:uniq!)
|
|
1175
|
+
@podfile_requirements = @podfile.dependencies.group_by(&:root_name)
|
|
1176
|
+
100.times do
|
|
1177
|
+
@missing = []
|
|
1178
|
+
activate(explicit)
|
|
1179
|
+
return @missing.uniq unless @missing.empty?
|
|
1180
|
+
return [] if consistent?
|
|
1181
|
+
end
|
|
1182
|
+
raise Informative, 'CocoaPods dependency resolution did not settle'
|
|
1183
|
+
end
|
|
1184
|
+
|
|
1185
|
+
def specs_by_target
|
|
1186
|
+
@podfile.target_definition_list.each_with_object({}) do |target, result|
|
|
1187
|
+
next if target.abstract? && !target.platform
|
|
1188
|
+
explicit = target.dependencies.map(&:name)
|
|
1189
|
+
used = {}
|
|
1190
|
+
loop do
|
|
1191
|
+
added = @vertices.values.select do |v|
|
|
1192
|
+
v.spec && !used[v.name] && (explicit.include?(v.name) || v.origins.any? { |origin, dep| used[origin] && edge_valid?(origin, dep, target.platform) })
|
|
1193
|
+
end
|
|
1194
|
+
break if added.empty?
|
|
1195
|
+
added.each { |v| used[v.name] = true }
|
|
1196
|
+
end
|
|
1197
|
+
aggregate = {}
|
|
1198
|
+
loop do
|
|
1199
|
+
added = used.keys.select do |name|
|
|
1200
|
+
!aggregate[name] && @vertices[name].spec.library_specification? &&
|
|
1201
|
+
(explicit.include?(name) || @vertices[name].origins.any? { |origin, _| aggregate[origin] })
|
|
1202
|
+
end
|
|
1203
|
+
break if added.empty?
|
|
1204
|
+
added.each { |name| aggregate[name] = true }
|
|
1205
|
+
end
|
|
1206
|
+
result[target] = used.keys.map { |name| [@vertices[name].spec, !aggregate[name]] }.sort_by { |spec, _| spec.name }
|
|
1207
|
+
end
|
|
1208
|
+
end
|
|
1209
|
+
|
|
1210
|
+
def specifications
|
|
1211
|
+
specs_by_target.values.flatten(1).map(&:first).uniq
|
|
1212
|
+
end
|
|
1213
|
+
|
|
1214
|
+
private
|
|
1215
|
+
|
|
1216
|
+
def activate(explicit)
|
|
1217
|
+
@vertices = {}
|
|
1218
|
+
@requirements = Hash.new { |h, k| h[k] = [] }
|
|
1219
|
+
@trunk_roots = []
|
|
1220
|
+
queue = explicit.map { |dep| [dep, nil] }
|
|
1221
|
+
until queue.empty?
|
|
1222
|
+
dep, origin = queue.shift
|
|
1223
|
+
vertex = (@vertices[dep.name] ||= Vertex.new(dep.name))
|
|
1224
|
+
vertex.requirements << dep
|
|
1225
|
+
vertex.origins << [origin, dep] if origin
|
|
1226
|
+
@requirements[dep.root_name] << dep
|
|
1227
|
+
next if vertex.requirements.size > 1
|
|
1228
|
+
root_spec = root_specification(dep)
|
|
1229
|
+
next unless root_spec
|
|
1230
|
+
spec = root_spec.subspec_by_name(dep.name, false, true)
|
|
1231
|
+
raise Informative, "Unable to find a specification for '#{dep}'" unless spec
|
|
1232
|
+
vertex.spec = spec
|
|
1233
|
+
dependencies_for(spec).each { |d| queue << [d, dep.name] }
|
|
1234
|
+
end
|
|
1235
|
+
end
|
|
1236
|
+
|
|
1237
|
+
def dependencies_for(spec)
|
|
1238
|
+
root_name = Specification.root_name(spec.name)
|
|
1239
|
+
spec.all_dependencies.map do |dependency|
|
|
1240
|
+
dependency.root_name == root_name ? dependency.dup.tap { |d| d.specific_version = spec.version } : dependency
|
|
1241
|
+
end
|
|
1242
|
+
end
|
|
1243
|
+
|
|
1244
|
+
def root_specification(dep)
|
|
1245
|
+
root = dep.root_name
|
|
1246
|
+
stored = @sandbox.specification(root)
|
|
1247
|
+
return stored if stored
|
|
1248
|
+
raise Informative, "Unable to find a specification for '#{dep}'" if dep.external_source
|
|
1249
|
+
@trunk_roots << root unless @trunk_roots.include?(root)
|
|
1250
|
+
version = (@chosen[root] ||= choose(root))
|
|
1251
|
+
return nil unless version
|
|
1252
|
+
spec = @trunk.specification(root, version.to_s)
|
|
1253
|
+
@missing << [root, version.to_s] unless spec
|
|
1254
|
+
spec
|
|
1255
|
+
end
|
|
1256
|
+
|
|
1257
|
+
def choose(root)
|
|
1258
|
+
versions = @trunk.versions(root)
|
|
1259
|
+
unless versions
|
|
1260
|
+
@missing << [root, nil]
|
|
1261
|
+
return nil
|
|
1262
|
+
end
|
|
1263
|
+
deps = @requirements[root] + Array(@podfile_requirements[root])
|
|
1264
|
+
requirements = deps.map(&:requirement) + @learned[root]
|
|
1265
|
+
prerelease = deps.any? { |d| d.prerelease? || d.external_source }
|
|
1266
|
+
candidates = versions.map { |v| Version.new(v) }.sort.reverse.reject { |v| @excluded[root].include?(v) }
|
|
1267
|
+
chosen = candidates.find { |v| requirements.all? { |r| r.satisfied_by?(v) } && (prerelease || !v.prerelease?) }
|
|
1268
|
+
raise Informative, "CocoaPods could not find compatible versions for pod '#{root}': #{requirements.map(&:to_s).uniq.join(', ')}" unless chosen
|
|
1269
|
+
chosen
|
|
1270
|
+
end
|
|
1271
|
+
|
|
1272
|
+
# the version each pod took satisfies every requirement on it and the
|
|
1273
|
+
# platforms of every target that reaches it; otherwise the pass repeats
|
|
1274
|
+
def consistent?
|
|
1275
|
+
platforms
|
|
1276
|
+
settled = true
|
|
1277
|
+
@vertices.each_value do |vertex|
|
|
1278
|
+
spec = vertex.spec
|
|
1279
|
+
root = Specification.root_name(vertex.name)
|
|
1280
|
+
unsatisfied = @requirements[root].map(&:requirement).reject { |r| r.satisfied_by?(spec.version) }
|
|
1281
|
+
unless unsatisfied.empty?
|
|
1282
|
+
raise Informative, "CocoaPods could not satisfy #{unsatisfied.map(&:to_s).join(', ')} with '#{root}' (#{spec.version})" unless @chosen.key?(root)
|
|
1283
|
+
@learned[root] |= unsatisfied
|
|
1284
|
+
@chosen.delete(root)
|
|
1285
|
+
settled = false
|
|
1286
|
+
next
|
|
1287
|
+
end
|
|
1288
|
+
next if platform_compatible?(vertex)
|
|
1289
|
+
raise Informative, "The platforms of '#{vertex.name}' (#{spec.available_platforms.map(&:to_s).join(', ')}) do not support #{vertex.platforms.map(&:to_s).join(', ')}" unless @chosen.key?(root)
|
|
1290
|
+
@excluded[root] << spec.version
|
|
1291
|
+
@chosen.delete(root)
|
|
1292
|
+
settled = false
|
|
1293
|
+
end
|
|
1294
|
+
settled
|
|
1295
|
+
end
|
|
1296
|
+
|
|
1297
|
+
def platforms
|
|
1298
|
+
@vertices.each_value do |vertex|
|
|
1299
|
+
vertex.platforms = vertex.requirements.reject { |dep| vertex.origins.any? { |_, d| d.equal?(dep) } }.flat_map { |dep| @platforms_by_dependency[dep.to_s] }.uniq
|
|
1300
|
+
end
|
|
1301
|
+
loop do
|
|
1302
|
+
grew = false
|
|
1303
|
+
@vertices.each_value do |vertex|
|
|
1304
|
+
inherited = vertex.origins.flat_map { |origin, _| @vertices[origin].platforms } - vertex.platforms
|
|
1305
|
+
next if inherited.empty?
|
|
1306
|
+
vertex.platforms |= inherited
|
|
1307
|
+
grew = true
|
|
1308
|
+
end
|
|
1309
|
+
break unless grew
|
|
1310
|
+
end
|
|
1311
|
+
end
|
|
1312
|
+
|
|
1313
|
+
def platform_compatible?(vertex)
|
|
1314
|
+
spec = vertex.spec
|
|
1315
|
+
vertex.platforms.all? do |platform|
|
|
1316
|
+
spec.available_platforms.all? do |spec_platform|
|
|
1317
|
+
spec_platform.name != platform.name || spec.non_library_specification? || platform.supports?(spec_platform)
|
|
1318
|
+
end
|
|
1319
|
+
end
|
|
1320
|
+
end
|
|
1321
|
+
|
|
1322
|
+
def edge_valid?(origin, dep, platform)
|
|
1323
|
+
@vertices[origin].spec.all_dependencies(platform).any? { |d| d.name == dep.name }
|
|
1324
|
+
end
|
|
1325
|
+
end
|
|
1326
|
+
end
|
|
1327
|
+
`
|
|
1328
|
+
|
|
1329
|
+
export interface EvaluatedPodfile {
|
|
1330
|
+
file: string
|
|
1331
|
+
interp: Interpreter
|
|
1332
|
+
podfile: RObject
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
export interface ResolvedPodfile extends EvaluatedPodfile {
|
|
1336
|
+
sandbox: RObject
|
|
1337
|
+
resolver: RObject
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
const send = (interp: Interpreter, receiver: Value, name: string, args: Value[] = []) =>
|
|
1341
|
+
interp.callMethod(receiver, name, args, null, null, null, null)
|
|
1342
|
+
|
|
1343
|
+
function podClass(interp: Interpreter, name: string): RModule {
|
|
1344
|
+
const pod = interp.object.consts.get('Pod')
|
|
1345
|
+
const found = pod instanceof RModule ? interp.constIn(pod, name, null, '-') : null
|
|
1346
|
+
if (!(found instanceof RModule)) throw new Error(`no Pod::${name}`)
|
|
1347
|
+
return found
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
// peach builds React Native's core, Hermes and their C++ dependencies from
|
|
1351
|
+
// source itself, so the Podfile takes React Native's own source route instead
|
|
1352
|
+
// of probing Maven and downloading prebuilt archives nothing here links
|
|
1353
|
+
const REACT_NATIVE_FROM_SOURCE = {
|
|
1354
|
+
RCT_USE_RN_DEP: '0',
|
|
1355
|
+
RCT_USE_PREBUILT_RNCORE: '0',
|
|
1356
|
+
RCT_BUILD_HERMES_FROM_SOURCE: 'true',
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/** the app's `ios/Podfile`, evaluated with React Native's and the app's helpers. */
|
|
1360
|
+
export function evaluatePodfile(
|
|
1361
|
+
app: string,
|
|
1362
|
+
env: Record<string, string | undefined>,
|
|
1363
|
+
): EvaluatedPodfile {
|
|
1364
|
+
const file = path.join(app, 'ios', 'Podfile')
|
|
1365
|
+
return rubyFailures(file, () => {
|
|
1366
|
+
const { interp } = cocoapodsInterpreter(app, [app], {
|
|
1367
|
+
...env,
|
|
1368
|
+
...REACT_NATIVE_FROM_SOURCE,
|
|
1369
|
+
})
|
|
1370
|
+
interp.evalString(PODFILE, 'cocoapods-core/podfile')
|
|
1371
|
+
const pathname = interp.object.consts.get('Pathname') ?? null
|
|
1372
|
+
const podfile = send(interp, podClass(interp, 'Podfile'), 'new', [
|
|
1373
|
+
send(interp, pathname, 'new', [str(file)]),
|
|
1374
|
+
])
|
|
1375
|
+
if (!(podfile instanceof RObject))
|
|
1376
|
+
throw new Error('Pod::Podfile.new returned no object')
|
|
1377
|
+
interp.host.cwd = path.dirname(file)
|
|
1378
|
+
const frame: Frame = {
|
|
1379
|
+
...interp.topFrame,
|
|
1380
|
+
self: podfile,
|
|
1381
|
+
defTarget: interp.singletonOf(podfile),
|
|
1382
|
+
cref: [interp.object],
|
|
1383
|
+
file,
|
|
1384
|
+
id: {},
|
|
1385
|
+
}
|
|
1386
|
+
interp.evalString(fs.readFileSync(file, 'utf8'), file, frame)
|
|
1387
|
+
return { file, interp, podfile }
|
|
1388
|
+
})
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/** CocoaPods' `Podfile#to_hash` for the evaluated Podfile, as JSON values. */
|
|
1392
|
+
export function podfileHash({ interp, podfile }: EvaluatedPodfile): unknown {
|
|
1393
|
+
return toJson(interp, send(interp, podfile, 'to_hash'))
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* resolves the Podfile's pods as `pod install` does before it downloads
|
|
1398
|
+
* anything: local podspecs are stored in a sandbox through any patches the
|
|
1399
|
+
* Podfile's helpers made to it, and trunk pods take versions from the CDN.
|
|
1400
|
+
*/
|
|
1401
|
+
export async function resolvePodfile(
|
|
1402
|
+
evaluated: EvaluatedPodfile,
|
|
1403
|
+
): Promise<ResolvedPodfile> {
|
|
1404
|
+
const { file, interp, podfile } = evaluated
|
|
1405
|
+
const versions = new Map<string, string[]>()
|
|
1406
|
+
const specFiles = new Map<string, string>()
|
|
1407
|
+
const specs = new Map<string, Value>()
|
|
1408
|
+
const { sandbox, resolver } = rubyFailures(file, () => {
|
|
1409
|
+
interp.evalString(RESOLVER, 'cocoapods/resolver')
|
|
1410
|
+
const pathname = interp.object.consts.get('Pathname') ?? null
|
|
1411
|
+
const specification = podClass(interp, 'Specification')
|
|
1412
|
+
const trunk = interp.defineModule('Trunk', podClass(interp, 'Resolver'))
|
|
1413
|
+
const arg = (args: Value[], at: number) => interp.toS(args[at] ?? null)
|
|
1414
|
+
interp.defineNative(
|
|
1415
|
+
trunk,
|
|
1416
|
+
'versions',
|
|
1417
|
+
(c) => versions.get(arg(c.args, 0))?.map((version) => str(version)) ?? null,
|
|
1418
|
+
true,
|
|
1419
|
+
)
|
|
1420
|
+
interp.defineNative(
|
|
1421
|
+
trunk,
|
|
1422
|
+
'specification',
|
|
1423
|
+
(c) => {
|
|
1424
|
+
const key = `${arg(c.args, 0)}/${arg(c.args, 1)}`
|
|
1425
|
+
const known = specs.get(key)
|
|
1426
|
+
if (known !== undefined) return known
|
|
1427
|
+
const json = specFiles.get(key)
|
|
1428
|
+
if (json === undefined) return null
|
|
1429
|
+
const spec = send(interp, specification, 'from_json', [
|
|
1430
|
+
str(fs.readFileSync(json, 'utf8')),
|
|
1431
|
+
send(interp, pathname, 'new', [str(json)]),
|
|
1432
|
+
])
|
|
1433
|
+
specs.set(key, spec)
|
|
1434
|
+
return spec
|
|
1435
|
+
},
|
|
1436
|
+
true,
|
|
1437
|
+
)
|
|
1438
|
+
const sandbox = send(interp, podClass(interp, 'Sandbox'), 'new', [
|
|
1439
|
+
str(path.join(path.dirname(file), 'Pods')),
|
|
1440
|
+
])
|
|
1441
|
+
const resolver = send(interp, podClass(interp, 'Resolver'), 'new', [
|
|
1442
|
+
sandbox,
|
|
1443
|
+
podfile,
|
|
1444
|
+
trunk,
|
|
1445
|
+
])
|
|
1446
|
+
if (!(sandbox instanceof RObject) || !(resolver instanceof RObject))
|
|
1447
|
+
throw new Error('Pod::Resolver.new returned no object')
|
|
1448
|
+
send(interp, resolver, 'fetch_external_sources')
|
|
1449
|
+
return { sandbox, resolver }
|
|
1450
|
+
})
|
|
1451
|
+
for (;;) {
|
|
1452
|
+
const missing = rubyFailures(file, () =>
|
|
1453
|
+
toJson(interp, send(interp, resolver, 'resolve')),
|
|
1454
|
+
)
|
|
1455
|
+
if (!Array.isArray(missing)) throw new Error('Pod::Resolver#resolve returned no list')
|
|
1456
|
+
if (missing.length === 0) return { ...evaluated, sandbox, resolver }
|
|
1457
|
+
await Promise.all(
|
|
1458
|
+
missing.map(async (entry: unknown) => {
|
|
1459
|
+
if (!Array.isArray(entry) || typeof entry[0] !== 'string')
|
|
1460
|
+
throw new Error(`Pod::Resolver#resolve listed ${JSON.stringify(entry)}`)
|
|
1461
|
+
const [name, version] = entry
|
|
1462
|
+
if (typeof version === 'string')
|
|
1463
|
+
specFiles.set(`${name}/${version}`, await trunkSpecificationFile(name, version))
|
|
1464
|
+
else {
|
|
1465
|
+
const published = await trunkVersions(name)
|
|
1466
|
+
if (!published)
|
|
1467
|
+
throw new Error(`Unable to find a specification for \`${name}\``)
|
|
1468
|
+
versions.set(name, published)
|
|
1469
|
+
}
|
|
1470
|
+
}),
|
|
1471
|
+
)
|
|
1472
|
+
}
|
|
1473
|
+
}
|