cocoapods-binary 0.2.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 124b30e7d2396c946acac5d0d13be9417321c8bd9550c704b05776762d661032
4
- data.tar.gz: f791fa67bb61110dfb114fd68d99c59fb08e07abe39aa449df53eb3b67a6fa43
3
+ metadata.gz: 726b79f4d6dda6d56259941979e11a641fa8ae096e17755b944047241e6ab651
4
+ data.tar.gz: 9831cc28732e70613d33764dfe8d7922dc8243c23d6cddab352ad3af77b70ddd
5
5
  SHA512:
6
- metadata.gz: c8778c58520990ff47b5d8250659204ed66ef604070daec52bf03c224a1447fc176666f647dde0ebbbef1dbd8cb73c7aec25583b9ba383c9e26b8760aa3ef580
7
- data.tar.gz: d9d8080c368d815cd153173e3e64d2efcfdfa1750adfe6f46b2fe4d639363428ace2d02b57bd201070d7608f5eed718c20e3eb950903f04592e579674fb54781
6
+ metadata.gz: 1bbf02596b0c1a8aa68eea1b5d400692b451f6c6e5327826e7a06433e53dbfe8ca6efced755016b3f0080abad283cf2bd3a9704d0f75fc0920d08f1a8c1b5fe2
7
+ data.tar.gz: c9293566acff041a6f5b12229e990a3b5f1dcf4d836e059bce014d6b470cfa222b047295b06ed1a4e90d74b77e26fc99b4d21a8b6af2d7ece65f139bab80ea22
data/.gitignore CHANGED
@@ -1,3 +1,32 @@
1
1
  .DS_Store
2
2
  pkg
3
3
  .idea/
4
+
5
+ test/Pods
6
+
7
+ ## Various settings
8
+ *.pbxuser
9
+ !default.pbxuser
10
+ *.mode1v3
11
+ !default.mode1v3
12
+ *.mode2v3
13
+ !default.mode2v3
14
+ *.perspectivev3
15
+ !default.perspectivev3
16
+ xcuserdata/
17
+
18
+ ## Other
19
+ *.moved-aside
20
+ *.xccheckout
21
+ *.xcscmblueprint
22
+
23
+ ### Xcode Patch ###
24
+ *.xcodeproj/*
25
+ !*.xcodeproj/project.pbxproj
26
+ !*.xcodeproj/xcshareddata/
27
+ !*.xcworkspace/contents.xcworkspacedata
28
+ /*.gcno
29
+ test/Binary.xcworkspace/contents.xcworkspacedata
30
+ test/Binary.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
31
+ test/Podfile
32
+ test/Podfile.lock
@@ -0,0 +1,22 @@
1
+ osx_image: xcode9.3
2
+ language: objective-c
3
+ cache:
4
+ - cocoapods
5
+ - bundler
6
+ before_install:
7
+ - gem install cocoapods
8
+ script:
9
+ - rake install
10
+ - cd test
11
+ - sh test.sh
12
+
13
+ # auto deploy on tagging
14
+ # automatically set by `travis setup rubygems`
15
+ deploy:
16
+ provider: rubygems
17
+ api_key:
18
+ secure: HglQwElI8cEeKc5oXzoVbBBprgb8k7RUr0YOH1N1fhpNW7HJpJtSLzUBPC5T+Sv5RPSicaxY/oXeYE6x4E7Oadf7Gy2tmM9iwwJQh6YgZ/foh9G9obHZtTerhB4wY2cjguBXDmLqiMRiJzNTZRvoUnESBKakPbK/ODY0mHT+LDdMwZk2QsMjD3fRc5M7JRR29jr56jzVuUdy0lR4TRoc2+yIRqp2vFNtcbKdzKuYgzcdE9xzPh0FQzgiImA5uGDruyAgoNeOlGxDPZdnm7fw/epLmq8fUIZanReI30QnJeIErFwMCVeN1zVqQiWRgv8qGi8Z0ZKOzvcu7oKuaeXo5xSkTfkAc9I0LbcRd3UHCluAr9JHuERNwkn1qx5W0DdngTKrPM65ZABQxk4KUHt+5yd6Dv7lR9GrGD3teNZDga/X8u0tQIkoPIl76ZjXRh0bmCDQM/zWaTKkh7eX/YXQKgrjrEecZMeZfsLds789MK2QO17QlbHTVno+HBr0Rah6nHI0/vl1xqHthHCb/Y9SBXmLQ7+ySNXmj7YxPjpD6m8kEEUDTQQdgjS7vMInqJiSekGBImu2VQA/qZP1+WEBha5nX2ADfvsAWfUdsdQfuTbv07RnIG+3quzSl5U1UPVR9f7EsqpTtxflLJCqVdaz2ndQBO6NXAnRhA90cfAFd9s=
19
+ gem: cocoapods-binary
20
+ on:
21
+ tags: true
22
+ repo: leavez/cocoapods-binary
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/EXAMPLE/cocoapods-binary'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($/).reject{|f| f.start_with? "test/"}
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
@@ -1,6 +1,8 @@
1
- require_relative 'podfile_options'
2
- require_relative 'feature_switches'
3
- require_relative 'prebuild_sandbox'
1
+ require_relative 'helper/podfile_options'
2
+ require_relative 'helper/feature_switches'
3
+ require_relative 'helper/prebuild_sandbox'
4
+ require_relative 'helper/passer'
5
+
4
6
 
5
7
  # NOTE:
6
8
  # This file will only be loaded on normal pod install step
@@ -18,21 +20,24 @@ module Pod
18
20
  class PodSourceInstaller
19
21
 
20
22
  def install_for_prebuild!(standard_sanbox)
23
+ return if standard_sanbox.local? self.name
24
+
21
25
  # make a symlink to target folder
22
26
  prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
23
- source = prebuild_sandbox.framework_path_for_pod_name self.name
27
+ folder = prebuild_sandbox.framework_folder_path_for_pod_name(self.name)
24
28
 
25
29
  target_folder = standard_sanbox.pod_dir(self.name)
26
- return if standard_sanbox.local? self.name
27
-
28
30
  target_folder.rmtree if target_folder.exist?
29
- target_folder.mkdir unless target_folder.exist?
30
- target = target_folder + "#{self.name}.framework"
31
-
32
-
33
- # make a relatvie symbol link
34
- relative_source = source.relative_path_from(target_folder)
35
- FileUtils.ln_sf(relative_source, target)
31
+ target_folder.mkdir
32
+
33
+ # make a relatvie symbol link for all children
34
+ folder.children.each do |child|
35
+ source = child
36
+ target = target_folder + File.basename(source)
37
+
38
+ relative_source = source.relative_path_from(target.parent)
39
+ FileUtils.ln_sf(relative_source, target)
40
+ end
36
41
  end
37
42
 
38
43
  end
@@ -47,17 +52,18 @@ end
47
52
  module Pod
48
53
  class Installer
49
54
 
55
+
50
56
  # Remove the old target files if prebuild frameworks changed
51
57
  def remove_target_files_if_needed
52
58
 
53
- changes = Pod::Prebuild.framework_changes
59
+ changes = Pod::Prebuild::Passer.prebuild_pods_changes
54
60
  updated_names = []
55
61
  if changes == nil
56
62
  updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_names
57
63
  else
58
- added = changes[:added] || []
59
- changed = changes[:changed] || []
60
- deleted = changes[:removed] || []
64
+ added = changes.added
65
+ changed = changes.changed
66
+ deleted = changes.deleted
61
67
  updated_names = added + changed + deleted
62
68
  end
63
69
 
@@ -82,11 +88,45 @@ module Pod
82
88
 
83
89
  # Remove the old target files, else it will not notice file changes
84
90
  self.remove_target_files_if_needed
91
+
92
+ # call original
85
93
  old_method2.bind(self).()
86
94
 
87
- self.analysis_result.specifications.each do |spec|
88
- next unless self.prebuild_pod_names.include? spec.name
89
- spec.attributes_hash["vendored_frameworks"] = "#{spec.name}.framework"
95
+
96
+ # check the prebuilt targets
97
+ targets = self.prebuild_pod_targets
98
+ targets_have_different_platforms = targets.select {|t| t.pod_name != t.name }
99
+
100
+ if targets_have_different_platforms.count > 0
101
+ names = targets_have_different_platforms.map(&:pod_name)
102
+ STDERR.puts "[!] Binary doesn't support pods who integrate in 2 or more platforms simultaneously: #{names}".red
103
+ exit
104
+ end
105
+
106
+
107
+ specs = self.analysis_result.specifications
108
+ prebuilt_specs = (specs.select do |spec|
109
+ self.prebuild_pod_names.include? spec.root.name
110
+ end)
111
+
112
+ # make sturcture to fast get target by name
113
+ name_to_target_hash = self.pod_targets.reduce({}) do |sum, target|
114
+ sum[target.name] = target
115
+ sum
116
+ end
117
+
118
+ prebuilt_specs.each do |spec|
119
+ # `spec` may be a subspec, so we use the root's name
120
+ root_name = spec.root.name
121
+
122
+ # use the prebuilt framework
123
+ target = name_to_target_hash[root_name]
124
+ original_vendored_frameworks = spec.attributes_hash["vendored_frameworks"] || []
125
+ if original_vendored_frameworks.kind_of?(String)
126
+ original_vendored_frameworks = [original_vendored_frameworks]
127
+ end
128
+ original_vendored_frameworks += [target.framework_name]
129
+ spec.attributes_hash["vendored_frameworks"] = original_vendored_frameworks
90
130
  spec.attributes_hash["source_files"] = []
91
131
 
92
132
  # to avoid the warning of missing license
@@ -119,3 +159,38 @@ module Pod
119
159
  end
120
160
  end
121
161
 
162
+ # A fix in embeded frameworks script.
163
+ #
164
+ # The framework file in pod target folder is a symblink. The EmbedFrameworksScript use `readlink`
165
+ # to read the read path. As the symlink is a relative symlink, readlink cannot handle it well. So
166
+ # we override the `readlink` to a fixed version.
167
+ #
168
+ module Pod
169
+ module Generator
170
+ class EmbedFrameworksScript
171
+
172
+ old_method = instance_method(:script)
173
+ define_method(:script) do
174
+
175
+ script = old_method.bind(self).()
176
+ patch = <<-SH.strip_heredoc
177
+ #!/bin/sh
178
+
179
+ # ---- this is added by cocoapods-binary ---
180
+ # Readlink cannot handle relative symlink well, so we override it to a new one
181
+ # If the path isn't an absolute path, we add a realtive prefix.
182
+ readlink () {
183
+ path=`/usr/bin/readlink $1`;
184
+ if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
185
+ echo $path;
186
+ else
187
+ echo "`dirname $1`/$path";
188
+ fi
189
+ }
190
+ # ---
191
+ SH
192
+ patch + script
193
+ end
194
+ end
195
+ end
196
+ end
@@ -1,28 +1,35 @@
1
1
  # encoding: UTF-8
2
-
3
- require_relative 'podfile_options'
2
+ require_relative 'helper/podfile_options'
3
+ require_relative 'tool/tool'
4
4
 
5
5
  module Pod
6
6
  class Podfile
7
7
  module DSL
8
8
 
9
- # enable bitcode for prebuilt frameworks
9
+ # Enable prebuiding for all pods
10
+ # it has a lower priority to other binary settings
11
+ def all_binary!
12
+ DSL.prebuild_all = true
13
+ end
14
+
15
+ # Enable bitcode for prebuilt frameworks
10
16
  def enable_bitcode_for_prebuilt_frameworks!
11
- @@bitcode_enabled = true
17
+ DSL.bitcode_enabled = true
12
18
  end
13
19
 
14
20
  private
15
- @@bitcode_enabled = false
16
- def self.is_bitcode_enabled
17
- @@bitcode_enabled
18
- end
21
+ class_attr_accessor :prebuild_all
22
+ prebuild_all = false
23
+
24
+ class_attr_accessor :bitcode_enabled
25
+ bitcode_enabled = false
19
26
  end
20
27
  end
21
28
  end
22
29
 
23
30
  Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_context|
24
-
25
- require_relative 'feature_switches'
31
+
32
+ require_relative 'helper/feature_switches'
26
33
  if Pod.is_prebuild_stage
27
34
  next
28
35
  end
@@ -42,7 +49,7 @@ Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_conte
42
49
  # -- step 1: prebuild framework ---
43
50
  # Execute a sperated pod install, to generate targets for building framework,
44
51
  # then compile them to framework files.
45
- require_relative 'prebuild_sandbox'
52
+ require_relative 'helper/prebuild_sandbox'
46
53
  require_relative 'Prebuild'
47
54
 
48
55
  Pod::UI.puts "🚀 Prebuild frameworks"
@@ -82,7 +89,7 @@ Pod::HooksManager.register('cocoapods-binary', :pre_install) do |installer_conte
82
89
  Pod::Installer.disable_install_complete_message false
83
90
 
84
91
 
85
- # -- step 2: prebuild framework ---
92
+ # -- step 2: pod install ---
86
93
  # install
87
94
  Pod::UI.puts "\n"
88
95
  Pod::UI.puts "🤖 Pod Install"
@@ -1,16 +1,13 @@
1
1
  require_relative 'rome/build_framework'
2
-
3
- module Pod
4
- class Prebuild
5
- class_attr_accessor :framework_changes
6
- end
7
- end
8
-
2
+ require_relative 'helper/passer'
9
3
 
10
4
  # patch prebuild ability
11
5
  module Pod
12
6
  class Installer
13
7
 
8
+
9
+ private
10
+
14
11
  def local_manifest
15
12
  if not @local_manifest_inited
16
13
  @local_manifest_inited = true
@@ -20,20 +17,34 @@ module Pod
20
17
  @local_manifest
21
18
  end
22
19
 
20
+ # @return [Analyzer::SpecsState]
21
+ def prebuild_pods_changes
22
+ return nil if local_manifest.nil?
23
+ if @prebuild_pods_changes.nil?
24
+ changes = local_manifest.detect_changes_with_podfile(podfile)
25
+ @prebuild_pods_changes = Analyzer::SpecsState.new(changes)
26
+ # save the chagnes info for later stage
27
+ Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes
28
+ end
29
+ @prebuild_pods_changes
30
+ end
31
+
23
32
 
33
+ public
34
+
24
35
  # check if need to prebuild
25
36
  def have_exact_prebuild_cache?
26
37
  # check if need build frameworks
27
38
  return false if local_manifest == nil
28
39
 
29
- changes = local_manifest.detect_changes_with_podfile(podfile)
30
- Pod::Prebuild.framework_changes = changes # save the chagnes info for later stage
31
- added = changes[:added] || []
32
- changed = changes[:changed] || []
33
- unchanged = changes[:unchanged] || []
34
- deleted = changes[:removed] || []
40
+ changes = prebuild_pods_changes
41
+ added = changes.added
42
+ changed = changes.changed
43
+ unchanged = changes.unchanged
44
+ deleted = changes.deleted
35
45
 
36
- unchange_framework_names = added + unchanged
46
+ unchange_framework_names = (added + unchanged)
47
+
37
48
  exsited_framework_names = sandbox.exsited_framework_names
38
49
  missing = unchanged.select do |pod_name|
39
50
  not exsited_framework_names.include?(pod_name)
@@ -54,32 +65,33 @@ module Pod
54
65
 
55
66
 
56
67
  # Build the needed framework files
57
- def prebuild_frameworks
68
+ def prebuild_frameworks!
58
69
 
59
- local_manifest = self.local_manifest
70
+ # build options
60
71
  sandbox_path = sandbox.root
61
72
  existed_framework_folder = sandbox.generate_framework_path
62
- bitcode_enabled = Pod::Podfile::DSL.is_bitcode_enabled
63
-
73
+ bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled
74
+ targets = []
75
+
64
76
  if local_manifest != nil
65
77
 
66
- changes = local_manifest.detect_changes_with_podfile(podfile)
67
- added = changes[:added] || []
68
- changed = changes[:changed] || []
69
- unchanged = changes[:unchanged] || []
70
- deleted = changes[:removed] || []
78
+ changes = prebuild_pods_changes
79
+ added = changes.added
80
+ changed = changes.changed
81
+ unchanged = changes.unchanged
82
+ deleted = changes.deleted
71
83
 
72
84
  existed_framework_folder.mkdir unless existed_framework_folder.exist?
73
85
  exsited_framework_names = sandbox.exsited_framework_names
74
86
 
75
87
  # deletions
76
88
  # remove all frameworks except ones to remain
77
- unchange_framework_names = added + unchanged
89
+ unchange_framework_names = (added + unchanged)
78
90
  to_delete = exsited_framework_names.select do |framework_name|
79
91
  not unchange_framework_names.include?(framework_name)
80
92
  end
81
93
  to_delete.each do |framework_name|
82
- path = sandbox.framework_path_for_pod_name framework_name
94
+ path = sandbox.framework_folder_path_for_pod_name(framework_name)
83
95
  path.rmtree if path.exist?
84
96
  end
85
97
 
@@ -88,17 +100,58 @@ module Pod
88
100
  not exsited_framework_names.include?(pod_name)
89
101
  end
90
102
 
91
- targets = (added + changed + missing).map do |pod_name|
92
- self.pod_targets.find do |pod_target|
93
- pod_target.root_spec.name == pod_name
94
- end
103
+
104
+ root_names_to_update = (added + changed + missing)
105
+
106
+ # transform names to targets
107
+ name_to_target_hash = self.pod_targets.reduce({}) do |sum, target|
108
+ sum[target.name] = target
109
+ sum
95
110
  end
96
- Pod::Prebuild.build(sandbox_path, existed_framework_folder, targets, bitcode_enabled)
97
-
111
+ targets = root_names_to_update.map do |root_name|
112
+ name_to_target_hash[root_name]
113
+ end || []
114
+
115
+ # add the dendencies
116
+ dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
117
+ targets = (targets + dependency_targets).uniq
98
118
  else
99
- Pod::Prebuild.build(sandbox_path, existed_framework_folder, self.pod_targets, bitcode_enabled)
119
+ targets = self.pod_targets
100
120
  end
101
121
 
122
+ targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
123
+
124
+
125
+
126
+ # build!
127
+ Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
128
+ Pod::Prebuild.remove_build_dir(sandbox_path)
129
+ targets.each do |target|
130
+ next unless target.should_build?
131
+ output_path = sandbox.framework_folder_path_for_pod_name(target.name)
132
+ output_path.mkpath unless output_path.exist?
133
+ Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled)
134
+ end
135
+ Pod::Prebuild.remove_build_dir(sandbox_path)
136
+
137
+
138
+ # copy vendored libraries and frameworks
139
+ targets.each do |target|
140
+ root_path = self.sandbox.pod_dir(target.name)
141
+ target.spec_consumers.each do |consumer|
142
+ file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
143
+ lib_paths = file_accessor.vendored_frameworks || []
144
+ lib_paths += file_accessor.vendored_libraries
145
+ # @TODO dSYM files
146
+ lib_paths.each do |lib_path|
147
+ relative = lib_path.relative_path_from(root_path)
148
+ destination = sandbox.framework_folder_path_for_pod_name(target.name) + relative
149
+ destination.dirname.mkpath unless destination.dirname.exist?
150
+ FileUtils.cp_r(lib_path, destination, :remove_destination => true)
151
+ end
152
+ end
153
+ end
154
+
102
155
  # Remove useless files
103
156
  # only keep manifest.lock and framework folder
104
157
  to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
@@ -111,14 +164,14 @@ module Pod
111
164
  end
112
165
 
113
166
  end
114
-
115
-
167
+
168
+
116
169
  # patch the post install hook
117
170
  old_method2 = instance_method(:run_plugins_post_install_hooks)
118
171
  define_method(:run_plugins_post_install_hooks) do
119
172
  old_method2.bind(self).()
120
173
  if Pod::is_prebuild_stage
121
- self.prebuild_frameworks
174
+ self.prebuild_frameworks!
122
175
  end
123
176
  end
124
177
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBinary
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3"
3
3
  end
@@ -1,4 +1,4 @@
1
- require_relative 'tool/tool'
1
+ require_relative '../tool/tool'
2
2
  require_relative 'prebuild_sandbox'
3
3
 
4
4
  module Pod
@@ -26,10 +26,23 @@ module Pod
26
26
  old_method.bind(self).(name, *args)
27
27
  return
28
28
  end
29
+
30
+ # patched content
31
+ should_prebuild = Pod::Podfile::DSL.prebuild_all
32
+ local = false
33
+
29
34
  options = args.last
30
- return unless options.is_a?(Hash)
31
- prebuild = options[Pod::Prebuild.keyword]
32
- if prebuild
35
+ if options.is_a?(Hash) and options[Pod::Prebuild.keyword] != nil
36
+ should_prebuild = options[Pod::Prebuild.keyword]
37
+ local = (options[:path] != nil)
38
+ end
39
+
40
+ if should_prebuild and (not local)
41
+ if current_target_definition.platform.name == :watchos
42
+ # watchos isn't supported currently
43
+ Pod::UI.warn "Binary doesn't support watchos currently: #{name}. You can manually set `binary => false` for this pod to suppress this warning."
44
+ return
45
+ end
33
46
  old_method.bind(self).(name, *args)
34
47
  end
35
48
  end
@@ -0,0 +1,20 @@
1
+ require_relative '../tool/tool'
2
+
3
+ module Pod
4
+ class Prebuild
5
+
6
+ # Pass the data between the 2 steps
7
+ #
8
+ # At step 2, the normal pod install, it needs some info of the
9
+ # prebuilt step. So we store it here.
10
+ #
11
+ class Passer
12
+
13
+ # indicate the add/remove/update of prebuit pods
14
+ # @return [Analyzer::SpecsState]
15
+ #
16
+ class_attr_accessor :prebuild_pods_changes
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,107 @@
1
+ module Pod
2
+
3
+ class Prebuild
4
+ def self.keyword
5
+ :binary
6
+ end
7
+ end
8
+
9
+ class Podfile
10
+ class TargetDefinition
11
+
12
+ ## --- option for setting using prebuild framework ---
13
+ def parse_prebuild_framework(name, requirements)
14
+ options = requirements.last
15
+ return requirements unless options.is_a?(Hash)
16
+
17
+ should_prebuild_framework = options.delete(Pod::Prebuild.keyword)
18
+ pod_name = Specification.root_name(name)
19
+ set_prebuild_for_pod(pod_name, should_prebuild_framework)
20
+ requirements.pop if options.empty?
21
+ end
22
+
23
+ def set_prebuild_for_pod(pod_name, should_prebuild)
24
+
25
+ if should_prebuild == true
26
+ # watchos isn't supported currently
27
+ return if self.platform.name == :watchos
28
+
29
+ @prebuild_framework_names ||= []
30
+ @prebuild_framework_names.push pod_name
31
+ else
32
+ @should_not_prebuild_framework_names ||= []
33
+ @should_not_prebuild_framework_names.push pod_name
34
+ end
35
+ end
36
+
37
+ def prebuild_framework_names
38
+ names = @prebuild_framework_names || []
39
+ if parent != nil and parent.kind_of? TargetDefinition
40
+ names += parent.prebuild_framework_names
41
+ end
42
+ names
43
+ end
44
+ def should_not_prebuild_framework_names
45
+ names = @should_not_prebuild_framework_names || []
46
+ if parent != nil and parent.kind_of? TargetDefinition
47
+ names += parent.should_not_prebuild_framework_names
48
+ end
49
+ names
50
+ end
51
+
52
+ # ---- patch method ----
53
+ # We want modify `store_pod` method, but it's hard to insert a line in the
54
+ # implementation. So we patch a method called in `store_pod`.
55
+ old_method = instance_method(:parse_inhibit_warnings)
56
+
57
+ define_method(:parse_inhibit_warnings) do |name, requirements|
58
+ parse_prebuild_framework(name, requirements)
59
+ old_method.bind(self).(name, requirements)
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+
66
+
67
+ module Pod
68
+ class Installer
69
+
70
+ def prebuild_pod_targets
71
+
72
+ all = []
73
+
74
+ aggregate_targets = self.aggregate_targets.select { |a| a.platform.name != :watchos }
75
+ aggregate_targets.each do |aggregate_target|
76
+ target_definition = aggregate_target.target_definition
77
+ targets = aggregate_target.pod_targets || []
78
+
79
+ # filter prebuild
80
+ prebuild_names = target_definition.prebuild_framework_names
81
+ if not Podfile::DSL.prebuild_all
82
+ targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
83
+ end
84
+ dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
85
+ targets = (targets + dependency_targets).uniq
86
+
87
+ # filter should not prebuild
88
+ explict_should_not_names = target_definition.should_not_prebuild_framework_names
89
+ targets = targets.reject { |pod_target| explict_should_not_names.include?(pod_target.pod_name) }
90
+
91
+ all += targets
92
+ end
93
+
94
+ all = all.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
95
+ all.uniq
96
+ end
97
+
98
+ # the root names who needs prebuild, including dependency pods.
99
+ def prebuild_pod_names
100
+ @prebuild_pod_names ||= self.prebuild_pod_targets.map(&:pod_name)
101
+ end
102
+
103
+ end
104
+ end
105
+
106
+
107
+
@@ -12,23 +12,27 @@ module Pod
12
12
  end
13
13
 
14
14
  def generate_framework_path
15
- self.root + "Frameworks"
15
+ self.root + "GeneratedFrameworks"
16
16
  end
17
17
 
18
- def framework_path_for_pod_name(name)
19
- self.generate_framework_path + "#{name}.framework"
18
+ def framework_folder_path_for_pod_name(name)
19
+ self.generate_framework_path + name
20
20
  end
21
21
 
22
22
  def exsited_framework_names
23
23
  return [] unless generate_framework_path.exist?
24
- generate_framework_path.children.map do |framework_name|
25
- extension = File.extname(framework_name)
26
- if extension == ".framework"
27
- File.basename(framework_name, extension)
24
+ generate_framework_path.children().map do |framework_name|
25
+ if framework_name.directory?
26
+ if not framework_name.children.empty?
27
+ File.basename(framework_name)
28
+ else
29
+ nil
30
+ end
28
31
  else
29
32
  nil
30
33
  end
31
34
  end.reject(&:nil?)
32
35
  end
36
+
33
37
  end
34
38
  end
@@ -1,6 +1,4 @@
1
1
  require 'fourflusher'
2
- require_relative '../feature_switches'
3
-
4
2
 
5
3
  CONFIGURATION = "Release"
6
4
  PLATFORMS = { 'iphonesimulator' => 'iOS',
@@ -11,7 +9,14 @@ PLATFORMS = { 'iphonesimulator' => 'iOS',
11
9
  # @param [PodTarget] target
12
10
  # a specific pod target
13
11
  #
14
- def build_for_iosish_platform(sandbox, build_dir, target, device, simulator, bitcode_enabled)
12
+ def build_for_iosish_platform(sandbox,
13
+ build_dir,
14
+ output_path,
15
+ target,
16
+ device,
17
+ simulator,
18
+ bitcode_enabled)
19
+
15
20
  deployment_target = target.platform.deployment_target.to_s
16
21
 
17
22
  target_label = target.label
@@ -38,7 +43,8 @@ def build_for_iosish_platform(sandbox, build_dir, target, device, simulator, bit
38
43
  puts lipo_log unless File.exist?(executable_path)
39
44
 
40
45
  FileUtils.mv executable_path, device_lib, :force => true
41
- FileUtils.mv device_framework_lib, build_dir, :force => true
46
+ output_path.mkpath unless output_path.exist?
47
+ FileUtils.mv device_framework_lib, output_path, :force => true
42
48
  FileUtils.rm simulator_lib if File.file?(simulator_lib)
43
49
  FileUtils.rm device_lib if File.file?(device_lib)
44
50
  end
@@ -61,61 +67,59 @@ module Pod
61
67
  # @param [String] sandbox_root_path
62
68
  # The sandbox root path where the targets project place
63
69
  #
70
+ # [PodTarget] target
71
+ # The pod targets to build
72
+ #
64
73
  # [Pathname] output_path
65
74
  # output path for generated frameworks
66
75
  #
67
- # [Array<PodTarget>] targets
68
- # The pod targets to build
69
- #
70
- def self.build(sandbox_root_path, output_path, targets, bitcode_enabled = false)
76
+ def self.build(sandbox_root_path, target, output_path, bitcode_enabled = false)
71
77
 
72
- return unless not targets.empty?
78
+ return unless not target == nil
73
79
 
74
80
  sandbox_root = Pathname(sandbox_root_path)
75
81
  sandbox = Pod::Sandbox.new(sandbox_root)
76
-
77
- build_dir = sandbox_root.parent + 'build'
78
- destination = output_path
79
-
80
- build_dir.rmtree if build_dir.directory?
81
-
82
-
83
- Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
84
-
85
- targets.each do |target|
86
- case target.platform.name
87
- when :ios then build_for_iosish_platform(sandbox, build_dir, target, 'iphoneos', 'iphonesimulator', bitcode_enabled)
88
- when :osx then xcodebuild(sandbox, target.label)
89
- when :tvos then nil
90
- when :watchos then nil
91
- # when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
92
- # when :watchos then build_for_iosish_platform(sandbox, build_dir, target, 'watchos', 'watchsimulator')
93
- else raise "Unknown platform '#{target.platform.name}'" end
94
- end
82
+ build_dir = self.build_dir(sandbox_root)
83
+
84
+ # -- build the framework
85
+ case target.platform.name
86
+ when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'iphoneos', 'iphonesimulator', bitcode_enabled)
87
+ when :osx then xcodebuild(sandbox, target.label)
88
+ # when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
89
+ # when :watchos then build_for_iosish_platform(sandbox, build_dir, target, 'watchos', 'watchsimulator')
90
+ else raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'" end
95
91
 
96
92
  raise Pod::Informative, 'The build directory was not found in the expected location.' unless build_dir.directory?
93
+
94
+ # # --- copy the vendored libraries and framework
95
+ # frameworks = build_dir.children.select{ |path| File.extname(path) == ".framework" }
96
+ # Pod::UI.puts "Built #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)}"
97
97
 
98
- # Make sure the device target overwrites anything in the simulator build, otherwise iTunesConnect
99
- # can get upset about Info.plist containing references to the simulator SDK
100
- frameworks = build_dir.children.select{ |path| File.extname(path) == ".framework" }
101
- Pod::UI.puts "Built #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)}"
98
+ # pod_target = target
99
+ # consumer = pod_target.root_spec.consumer(pod_target.platform.name)
100
+ # file_accessor = Pod::Sandbox::FileAccessor.new(sandbox.pod_dir(pod_target.pod_name), consumer)
101
+ # frameworks += file_accessor.vendored_libraries
102
+ # frameworks += file_accessor.vendored_frameworks
103
+
104
+ # frameworks.uniq!
102
105
 
103
- targets.each do |pod_target|
104
- consumer = pod_target.root_spec.consumer(pod_target.platform.name)
105
- file_accessor = Pod::Sandbox::FileAccessor.new(sandbox.pod_dir(pod_target.pod_name), consumer)
106
- frameworks += file_accessor.vendored_libraries
107
- frameworks += file_accessor.vendored_frameworks
108
- end
109
- frameworks.uniq!
106
+ # frameworks.each do |framework|
107
+ # FileUtils.mkdir_p destination
108
+ # FileUtils.cp_r framework, destination, :remove_destination => true
109
+ # end
110
+ # build_dir.rmtree if build_dir.directory?
111
+ end
110
112
 
111
- Pod::UI.puts "Copying #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)} " \
112
- "to `#{destination.relative_path_from Pathname.pwd}`"
113
+ def self.remove_build_dir(sandbox_root)
114
+ path = build_dir(sandbox_root)
115
+ path.rmtree if path.exist?
116
+ end
117
+
118
+ private
113
119
 
114
- frameworks.each do |framework|
115
- FileUtils.mkdir_p destination
116
- FileUtils.cp_r framework, destination, :remove_destination => true
117
- end
118
- build_dir.rmtree if build_dir.directory?
120
+ def self.build_dir(sandbox_root)
121
+ # don't know why xcode chose this folder
122
+ sandbox_root.parent + 'build'
119
123
  end
120
124
 
121
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-binary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - leavez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -80,6 +80,7 @@ extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
82
  - ".gitignore"
83
+ - ".travis.yml"
83
84
  - Gemfile
84
85
  - LICENSE.txt
85
86
  - README.md
@@ -89,10 +90,11 @@ files:
89
90
  - lib/cocoapods-binary/Integration.rb
90
91
  - lib/cocoapods-binary/Main.rb
91
92
  - lib/cocoapods-binary/Prebuild.rb
92
- - lib/cocoapods-binary/feature_switches.rb
93
93
  - lib/cocoapods-binary/gem_version.rb
94
- - lib/cocoapods-binary/podfile_options.rb
95
- - lib/cocoapods-binary/prebuild_sandbox.rb
94
+ - lib/cocoapods-binary/helper/feature_switches.rb
95
+ - lib/cocoapods-binary/helper/passer.rb
96
+ - lib/cocoapods-binary/helper/podfile_options.rb
97
+ - lib/cocoapods-binary/helper/prebuild_sandbox.rb
96
98
  - lib/cocoapods-binary/rome/build_framework.rb
97
99
  - lib/cocoapods-binary/tool/tool.rb
98
100
  - lib/cocoapods_plugin.rb
@@ -1,71 +0,0 @@
1
- module Pod
2
-
3
- class Prebuild
4
- def self.keyword
5
- :binary
6
- end
7
- end
8
-
9
- class Podfile
10
- class TargetDefinition
11
-
12
- ## --- option for setting using prebuild framework ---
13
- def parse_prebuild_framework(name, requirements)
14
- options = requirements.last
15
- return requirements unless options.is_a?(Hash)
16
-
17
- should_prebuild_framework = options.delete(Pod::Prebuild.keyword)
18
- pod_name = Specification.root_name(name)
19
- set_prebuild_for_pod(pod_name, should_prebuild_framework)
20
- requirements.pop if options.empty?
21
- end
22
-
23
- def set_prebuild_for_pod(pod_name, should_prebuild)
24
- return unless should_prebuild == true
25
- @prebuild_framework_names ||= []
26
- @prebuild_framework_names.push pod_name
27
- end
28
-
29
- def prebuild_framework_names
30
- @prebuild_framework_names || []
31
- end
32
-
33
- # ---- patch method ----
34
- # We want modify `store_pod` method, but it's hard to insert a line in the
35
- # implementation. So we patch a method called in `store_pod`.
36
- old_method = instance_method(:parse_inhibit_warnings)
37
-
38
- define_method(:parse_inhibit_warnings) do |name, requirements|
39
- parse_prebuild_framework(name, requirements)
40
- old_method.bind(self).(name, requirements)
41
- end
42
-
43
- end
44
- end
45
- end
46
-
47
-
48
- module Pod
49
- class Installer
50
- def prebuild_pod_names
51
- @prebuild_pod_names ||= self.podfile.target_definition_list.map(&:prebuild_framework_names).flatten.uniq
52
- end
53
- end
54
- end
55
-
56
- module Pod
57
- class AggregateTarget
58
-
59
- def have_prebuild_pod_targets?
60
- prebuild_framework_names = self.target_definition.prebuild_framework_names
61
- return (prebuild_framework_names != nil and !prebuild_framework_names.empty?)
62
- end
63
-
64
- def prebuild_pod_targets
65
- prebuild_framework_names = self.target_definition.prebuild_framework_names
66
- pod_targets = self.pod_targets.select { |pod_target| prebuild_framework_names.include?(pod_target.pod_name) }
67
- return pod_targets
68
- end
69
- end
70
- end
71
-