cocoapods-binary-cache 0.1.11 → 0.1.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0baf85dbe90fee58da87dd415914283de859c15267e14c7562cdc631a52c74f2
4
- data.tar.gz: ffa3a8be9fe5cc5c55c502e8eb98a9963f04cb0f9076b67ed74af3f7f50d4c2e
3
+ metadata.gz: 116f1017bbeca303037ea4873ed6f6ec0b6ae8e9d976958f5f2b95109c50b252
4
+ data.tar.gz: 0dd220d2c51ddaa367cf7cca6b68f23f4c898fbbeddc53d025ab39ab67b2a9d6
5
5
  SHA512:
6
- metadata.gz: 971f985d73911276ff9dd46bc963bc67e9ffaf70f367d9398eb2573c16ef9b6f5a5d031d51bc480b044e6d3d881052a4a9a03a89f7beddc5dc1d08a58c837603
7
- data.tar.gz: 3d8f0429cb6b06e44b7231b6c484e617ff659d97685b162f4fa44d7101f8378bd5d5500b9812da3fb0e156be190ee7dc6c50b8368aa9ef3e54b68a9f7893021f
6
+ metadata.gz: 1120f16b6bba0bb97db8d61d0799aebc3a395e94d6c1a0a273fe0c2d3ba9b3ffa3bd3c573ef36c7697457fc10d3546d1c92a130c8b8a4cd64b66004f3a798b50
7
+ data.tar.gz: 0efa97b49bdc34edf8ce4ebf8762b90114a2443bce9873fbb64482d0d6ab2a6e85d68c2d48904bd391d9d2d52566850abba4b7f7d6bf1f852c41e9fb3d389054
@@ -4,26 +4,43 @@ module Pod
4
4
  cache = []
5
5
  analysis_result.specifications
6
6
  .select { |spec| should_integrate_prebuilt_pod?(spec.root.name) }
7
- .each { |spec| alter_spec(spec, cache) }
7
+ .group_by(&:root)
8
+ .each do |_, specs|
9
+ first_subspec_or_self = specs.find(&:subspec?) || specs[0]
10
+ specs.each do |spec|
11
+ alterations = {
12
+ :source_files => true,
13
+ :resources => true,
14
+ :license => true,
15
+ :vendored_framework => spec == first_subspec_or_self
16
+ }
17
+ alter_spec(spec, alterations, cache)
18
+ end
19
+ end
8
20
  end
9
21
 
10
- def alter_spec(spec, cache)
22
+ private
23
+
24
+ def alter_spec(spec, alterations, cache)
11
25
  targets = Pod.fast_get_targets_for_pod_name(spec.root.name, pod_targets, cache)
12
- targets.each do |target|
13
- # Use the prebuild framworks as vendered frameworks.
14
- # The framework_file_path rule is decided in `install_for_prebuild`,
15
- # as to compitable with older version and be less wordy.
16
- framework_file_path = target.framework_name
17
- framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
18
- framework_file_path = PodPrebuild.config.prebuilt_path(path: framework_file_path)
19
- add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
26
+ platforms = targets.map { |target| target.platform.name.to_s }.uniq
27
+
28
+ if alterations[:vendored_framework]
29
+ targets.each do |target|
30
+ # Use the prebuilt frameworks as vendered frameworks.
31
+ # The framework_file_path rule is decided in `install_for_prebuild`,
32
+ # as to compitable with older version and be less wordy.
33
+ framework_file_path = target.framework_name
34
+ framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
35
+ framework_file_path = PodPrebuild.config.prebuilt_path(path: framework_file_path)
36
+ add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
37
+ end
20
38
  end
21
39
 
22
- platforms = targets.map { |target| target.platform.name.to_s }.uniq
23
- empty_source_files(spec, platforms)
24
- tweak_resources_for_xib(spec, platforms)
25
- tweak_resources_for_resource_bundles(spec, platforms)
26
- empty_liscence(spec) # to avoid the warning of missing license
40
+ empty_source_files(spec, platforms) if alterations[:source_files]
41
+ tweak_resources_for_xib(spec, platforms) if alterations[:resources]
42
+ tweak_resources_for_resource_bundles(spec, platforms) if alterations[:resources]
43
+ empty_liscence(spec) if alterations[:license]
27
44
  end
28
45
 
29
46
  def tweak_resources_for_xib(spec, platforms)
@@ -11,7 +11,7 @@ module Pod
11
11
  end
12
12
 
13
13
  def install!
14
- @source_installer.install! if PodPrebuild.config.still_download_sources?(name)
14
+ @source_installer.install!
15
15
  install_prebuilt_framework!
16
16
  end
17
17
 
@@ -39,8 +39,10 @@ module Pod
39
39
  walk(real_file_folder) do |child|
40
40
  source = child
41
41
  # only make symlink to file and `.framework` folder
42
- if child.directory? && [".framework", ".dSYM"].include?(child.extname)
43
- mirror_with_symlink(source, real_file_folder, target_folder) if child.extname == ".framework"
42
+ if child.directory? && [".framework", ".xcframework", ".dSYM"].include?(child.extname)
43
+ if [".framework", ".xcframework"].include?(child.extname)
44
+ mirror_with_symlink(source, real_file_folder, target_folder)
45
+ end
44
46
  # Ignore dsym here to avoid cocoapods from adding install_dsym to buildphase-script
45
47
  # That can cause duplicated output files error in Xcode 11 (warning in Xcode 10)
46
48
  # We need more setup to support local debuging with prebuilt dSYM
@@ -58,10 +60,15 @@ module Pod
58
60
  next unless metadata.static_framework?
59
61
 
60
62
  metadata.resources.each do |path|
61
- target_file_path = path
63
+ target_file_path = Pathname(path)
62
64
  .sub("${PODS_ROOT}", sandbox.root.to_path)
63
65
  .sub("${PODS_CONFIGURATION_BUILD_DIR}", sandbox.root.to_path)
66
+ next if target_file_path.exist?
67
+
64
68
  real_file_path = real_file_folder + metadata.framework_name + File.basename(path)
69
+
70
+ # TODO (thuyen): Fix https://github.com/grab/cocoapods-binary-cache/issues/45
71
+
65
72
  case File.extname(path)
66
73
  when ".xib"
67
74
  # https://github.com/grab/cocoapods-binary-cache/issues/7
@@ -19,26 +19,30 @@ module PodPrebuild
19
19
  end
20
20
 
21
21
  def run
22
- build_for_sdk(simulator) if build_types.include?(:simulator)
23
- build_for_sdk(device) if build_types.include?(:device)
22
+ sdks.each { |sdk| build_for_sdk(sdk) }
24
23
 
25
24
  targets.each do |target|
26
- case build_types
27
- when [:simulator]
28
- collect_output(target, Dir[target_products_dir_of(target, simulator) + "/*"])
29
- when [:device]
30
- collect_output(target, Dir[target_products_dir_of(target, device) + "/*"])
25
+ if PodPrebuild.config.xcframework?
26
+ create_xcframework(target)
27
+ elsif sdks.count > 1
28
+ create_fat_framework(target)
31
29
  else
32
- # When merging contents of `simulator` & `device`, prefer contents of `device` over `simulator`
33
- # https://github.com/grab/cocoapods-binary-cache/issues/25
34
- collect_output(target, Dir[target_products_dir_of(target, device) + "/*"])
35
- create_universal_framework(target)
30
+ collect_output(target, Dir[target_products_dir_of(target, sdks[0]) + "/*"])
36
31
  end
37
32
  end
38
33
  end
39
34
 
40
35
  private
41
36
 
37
+ def sdks
38
+ @sdks ||= begin
39
+ sdks_ = []
40
+ sdks_ << simulator if build_types.include?(:simulator)
41
+ sdks_ << device if build_types.include?(:device)
42
+ sdks_
43
+ end
44
+ end
45
+
42
46
  def build_types
43
47
  @build_types ||= begin
44
48
  # TODO (thuyen): Add DSL options `build_for_types` to specify build types
@@ -49,15 +53,19 @@ module PodPrebuild
49
53
  end
50
54
 
51
55
  def make_up_build_args(args)
56
+ # Note: The build arguments explicitly passed from config_cocoapods_binary_cache
57
+ # should be preceded by the default arguments so that they could take higher priority
58
+ # when there are argument collisions in the xcodebuild command.
59
+ # For ex. `xcodebuild AN_ARG=1 AN_ARG=2` should use `AN_ARG=2` instead.
52
60
  args_ = args.clone
53
61
  args_[:default] ||= []
54
62
  args_[:simulator] ||= []
55
63
  args_[:device] ||= []
56
- args_[:default] += ["BITCODE_GENERATION_MODE=bitcode"] if bitcode_enabled?
57
- args_[:default] += ["DEBUG_INFORMATION_FORMAT=dwarf"] if disable_dsym?
58
- args_[:simulator] += ["ARCHS=x86_64", "ONLY_ACTIVE_ARCH=NO"] if simulator == "iphonesimulator"
64
+ args_[:default].prepend("BITCODE_GENERATION_MODE=bitcode") if bitcode_enabled?
65
+ args_[:default].prepend("DEBUG_INFORMATION_FORMAT=dwarf") if disable_dsym?
66
+ args_[:simulator].prepend("ARCHS=x86_64", "ONLY_ACTIVE_ARCH=NO") if simulator == "iphonesimulator"
59
67
  args_[:simulator] += args_[:default]
60
- args_[:device] += ["ONLY_ACTIVE_ARCH=NO"]
68
+ args_[:device].prepend("ONLY_ACTIVE_ARCH=NO")
61
69
  args_[:device] += args_[:default]
62
70
  args_
63
71
  end
@@ -74,7 +82,47 @@ module PodPrebuild
74
82
  )
75
83
  end
76
84
 
77
- def create_universal_framework(target)
85
+ def create_xcframework(target)
86
+ non_framework_paths = Dir[target_products_dir_of(target, sdks[0]) + "/*"] \
87
+ - [framework_path_of(target, sdks[0])] \
88
+ - dsym_paths_of(target, sdks[0]) \
89
+ - bcsymbolmap_paths_of(target, sdks[0])
90
+ collect_output(target, non_framework_paths)
91
+
92
+ output = "#{output_path(target)}/#{target.product_module_name}.xcframework"
93
+ FileUtils.rm_rf(output)
94
+
95
+ cmd = ["xcodebuild", "-create-xcframework", "-allow-internal-distribution"]
96
+
97
+ # for each sdk, the order of params must be -framework then -debug-symbols
98
+ # to prevent duplicated file error when copying dSYMs
99
+ sdks.each do |sdk|
100
+ cmd << "-framework" << framework_path_of(target, sdk)
101
+
102
+ unless disable_dsym?
103
+ dsyms = dsym_paths_of(target, sdk)
104
+ cmd += dsyms.map { |dsym| "-debug-symbols #{dsym}" }
105
+ end
106
+
107
+ if bitcode_enabled?
108
+ bcsymbolmaps = bcsymbolmap_paths_of(target, sdk)
109
+ cmd += bcsymbolmaps.map { |bcsymbolmap| "-debug-symbols #{bcsymbolmap}" }
110
+ end
111
+ end
112
+
113
+ cmd << "-output" << output
114
+
115
+ Pod::UI.puts "- Create xcframework: #{target}".magenta
116
+ Pod::UI.puts_indented "$ #{cmd.join(' ')}" unless PodPrebuild.config.silent_build?
117
+
118
+ `#{cmd.join(" ")}`
119
+ end
120
+
121
+ def create_fat_framework(target)
122
+ # When merging contents of `simulator` & `device`, prefer contents of `device` over `simulator`
123
+ # https://github.com/grab/cocoapods-binary-cache/issues/25
124
+ collect_output(target, Dir[target_products_dir_of(target, device) + "/*"])
125
+
78
126
  merge_framework_binary(target)
79
127
  merge_framework_dsym(target)
80
128
  merge_swift_headers(target)
@@ -149,6 +197,14 @@ module PodPrebuild
149
197
  "#{target_products_dir_of(target, sdk)}/#{target.product_module_name}.framework"
150
198
  end
151
199
 
200
+ def dsym_paths_of(target, sdk)
201
+ Dir["#{target_products_dir_of(target, sdk)}/*.dSYM"]
202
+ end
203
+
204
+ def bcsymbolmap_paths_of(target, sdk)
205
+ Dir["#{target_products_dir_of(target, sdk)}/*.bcsymbolmap"]
206
+ end
207
+
152
208
  def sandbox
153
209
  @options[:sandbox]
154
210
  end
@@ -8,6 +8,11 @@ module PodPrebuild
8
8
  "watchsimulator" => "watchOS"
9
9
  }.freeze
10
10
 
11
+ DESTINATION_OF_SDK = {
12
+ "iphoneos" => "\"generic/platform=iOS\"",
13
+ "iphonesimulator" => "\"generic/platform=iOS Simulator\""
14
+ }.freeze
15
+
11
16
  def self.xcodebuild(options)
12
17
  sdk = options[:sdk] || "iphonesimulator"
13
18
  targets = options[:targets] || [options[:target]]
@@ -18,15 +23,18 @@ module PodPrebuild
18
23
  targets.each { |target| cmd << "-target" << target }
19
24
  cmd << "-configuration" << options[:configuration]
20
25
  cmd << "-sdk" << sdk
21
- unless platform.nil?
22
- cmd << Fourflusher::SimControl.new.destination(:oldest, platform, options[:deployment_target])
26
+ if DESTINATION_OF_SDK.key?(sdk)
27
+ cmd << "-destination" << DESTINATION_OF_SDK[sdk]
28
+ else
29
+ cmd << Fourflusher::SimControl.new.destination(:oldest, platform, options[:deployment_target]) unless platform.nil?
23
30
  end
24
31
  cmd += options[:args] if options[:args]
25
32
  cmd << "build"
26
33
  cmd << "2>&1"
27
34
  cmd = cmd.join(" ")
28
35
 
29
- Pod::UI.puts_indented "$ #{cmd}"
36
+ Pod::UI.puts_indented "$ #{cmd}" unless PodPrebuild.config.silent_build?
37
+
30
38
  log = `#{cmd}`
31
39
  return if $?.exitstatus.zero? # rubocop:disable Style/SpecialGlobalVars
32
40
 
@@ -58,7 +58,9 @@ module PodPrebuild
58
58
  end
59
59
 
60
60
  def prebuilt_path(path: nil)
61
- path.nil? ? "_Prebuilt" : "_Prebuilt/#{path}"
61
+ p = Pathname.new(path.nil? ? "_Prebuilt" : "_Prebuilt/#{path}")
62
+ p = p.sub_ext(".xcframework") if xcframework? && p.extname == ".framework"
63
+ p.to_s
62
64
  end
63
65
 
64
66
  def validate_dsl_config
@@ -103,13 +105,12 @@ module PodPrebuild
103
105
  @dsl_config[:device_build_enabled]
104
106
  end
105
107
 
106
- def disable_dsym?
107
- @dsl_config[:disable_dsym]
108
+ def xcframework?
109
+ @dsl_config[:xcframework]
108
110
  end
109
111
 
110
- def still_download_sources?(name)
111
- option = @dsl_config[:still_download_sources]
112
- option.is_a?(Array) ? option.include?(name) : option
112
+ def disable_dsym?
113
+ @dsl_config[:disable_dsym]
113
114
  end
114
115
 
115
116
  def dont_remove_source_code?
@@ -136,6 +137,10 @@ module PodPrebuild
136
137
  @dsl_config[:strict_diagnosis]
137
138
  end
138
139
 
140
+ def silent_build?
141
+ @dsl_config[:silent_build]
142
+ end
143
+
139
144
  def targets_to_prebuild_from_cli
140
145
  @cli_config[:prebuild_targets] || []
141
146
  end
@@ -170,14 +175,15 @@ module PodPrebuild
170
175
  :dev_pods_enabled,
171
176
  :bitcode_enabled,
172
177
  :device_build_enabled,
178
+ :xcframework,
173
179
  :disable_dsym,
174
- :still_download_sources,
175
180
  :dont_remove_source_code,
176
181
  :build_args,
177
182
  :save_cache_validation_to,
178
183
  :validate_prebuilt_settings,
179
184
  :prebuild_code_gen,
180
- :strict_diagnosis
185
+ :strict_diagnosis,
186
+ :silent_build
181
187
  ]
182
188
  end
183
189
 
@@ -1,3 +1,4 @@
1
+ require "parallel"
1
2
  require_relative "base"
2
3
  require_relative "../helper/zip"
3
4
 
@@ -57,7 +58,8 @@ module PodPrebuild
57
58
  @config.manifest_path
58
59
  )
59
60
  end
60
- Dir[@config.generated_frameworks_dir(in_cache: true) + "/*.zip"].each do |path|
61
+ zip_paths = Dir[@config.generated_frameworks_dir(in_cache: true) + "/*.zip"]
62
+ Parallel.each(zip_paths, in_threads: 8) do |path|
61
63
  ZipUtils.unzip(path, to_dir: @config.generated_frameworks_dir)
62
64
  end
63
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-binary-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bang Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-15 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: parallel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement