cocoapods-fast-install 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 78a43678654463ce4320017854ce718071e52242
4
+ data.tar.gz: d4800d0a22079111d2852b6634a19b4a37d024af
5
+ SHA512:
6
+ metadata.gz: 247736d6728ced6ae683227a9eadd89fe320c97d43ea28114486017bc1e4bf46357c77288b4d2758a6edfd237290fb4cdbddf90cbbe82dd9608f90bad69d3199
7
+ data.tar.gz: da56f01a74334abbb228ceb3f959c388471dcf13280fd01396c12903bed6dcfde7a7dc18923df3de4827375b7328cdbb955d7b2ff98c27e259230c3a56042eef
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-fast-install.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 Gao <gaoji@bytedance.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # cocoapods-fast-install
2
+
3
+ A cocoapods plugin that speed up the pod install for CI.
4
+
5
+ For the CI environment, we just pod install and build. Large mount
6
+ of files in project file will slow down the pod install. So we exclude
7
+ some files from the xcodeproject, the header files, then the pod install
8
+ speed up.
9
+
10
+ For a project containing 1700 header files in pods, it can reduce about
11
+ 13 seconds in `Generating Pods project` step.
12
+
13
+ Umbrella Header and Module are compatible with this plugin.
14
+
15
+ ## Installation
16
+
17
+ $ gem install cocoapods-fast-install
18
+
19
+ ## Usage
20
+
21
+ In the Podfile
22
+
23
+ ```ruby
24
+ plugin 'cocoapods-fast-install'
25
+ accelerate_xcproject_generating!
26
+ ```
27
+
28
+ If you want keep headers for some pods
29
+
30
+ ```ruby
31
+ plugin 'cocoapods-fast-install'
32
+ accelerate_xcproject_generating! :keeping_header_for => ['Protobuf', 'AFNetworking']
33
+ ```
34
+
35
+
36
+ ## Licence
37
+
38
+ MIT
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-fast-install/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-fast-install'
8
+ spec.version = CocoapodsFastInstall::VERSION
9
+ spec.authors = ['Gao']
10
+ spec.email = ['gaoji@bytedance.com']
11
+ spec.description = %q{A short description of cocoapods-fast-install.}
12
+ spec.summary = %q{A longer description of cocoapods-fast-install.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-fast-install'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-fast-install/gem_version'
@@ -0,0 +1,190 @@
1
+
2
+ module Pod
3
+
4
+ # -------------------------------- find the target to exclude -------------------------------
5
+ class FastProjectGenerating
6
+
7
+ class << self
8
+ attr_accessor :user_excluded_targets # Array<String>
9
+ attr_accessor :excluded_target_names # Array<String>
10
+ end
11
+
12
+ def self.should_skip_path(absolute_path)
13
+ # may not support 'one pod for multiple platform'
14
+ self.excluded_target_names.all? { |name| not (absolute_path.to_s.include? '/'+name+'/') }
15
+ end
16
+ end
17
+
18
+
19
+ class PodTarget
20
+ def uses_cpp?
21
+ return @uses_cpp if defined? @uses_cpp
22
+ @uses_cpp = begin
23
+ file_accessors.reject { |a| a.spec.test_specification? }.any? do |file_accessor|
24
+ file_accessor.source_files.any? { |sf| ['.cpp', '.mm', '.cc', '.cxx', '.c++', '.C'].include? sf.extname }
25
+ end
26
+ end
27
+ end
28
+
29
+ def uses_relative_header_importing?
30
+ return @uses_relative_header_importing if defined? @uses_relative_header_importing
31
+ @uses_relative_header_importing = begin
32
+ file_accessors.reject { |a| a.spec.test_specification? }.any? do |file_accessor|
33
+ file_accessor.public_headers.any? do |file|
34
+ file.extname == '.h' && begin
35
+ File.read(file) =~ /#import +"[\w]+\/.+\.h"/
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ class Installer
45
+
46
+ OLD_FAST_INSTALL_2_generate_pods_project = instance_method :generate_pods_project
47
+ define_method :generate_pods_project do |*args|
48
+
49
+ # check the input names
50
+ names = pod_targets.map(&:name)
51
+ wrong_input_names = FastProjectGenerating.user_excluded_targets.select { |input| not (names.include? input) }
52
+ unless wrong_input_names.empty?
53
+ puts "Wrong input for accelerate_xcodeproj_generating! #{wrong_input_names}".red
54
+ FastProjectGenerating.user_excluded_targets -= wrong_input_names
55
+ end
56
+
57
+ # find the pod that cannot support
58
+ relative_importing_target_names = []
59
+ cpp_target_names = []
60
+ $c = 0
61
+ pod_targets.map do |target|
62
+ if target.uses_cpp?
63
+ cpp_target_names << target.name
64
+ elsif target.uses_relative_header_importing?
65
+ relative_importing_target_names << target.name
66
+ end
67
+ end
68
+
69
+ FastProjectGenerating.excluded_target_names = []
70
+ FastProjectGenerating.excluded_target_names += FastProjectGenerating.user_excluded_targets
71
+ FastProjectGenerating.excluded_target_names += relative_importing_target_names
72
+
73
+
74
+ OLD_FAST_INSTALL_2_generate_pods_project.bind(self).(*args)
75
+
76
+
77
+ unless FastProjectGenerating.excluded_target_names.empty?
78
+ puts "Skip excluding headers (manually specified): #{FastProjectGenerating.user_excluded_targets}" unless FastProjectGenerating.user_excluded_targets.empty?
79
+ puts "Skip excluding headers (contain c++): #{cpp_target_names}" unless cpp_target_names.empty?
80
+ puts "Skip excluding headers (contain relative importing): #{relative_importing_target_names}" unless relative_importing_target_names.empty?
81
+ end
82
+
83
+ puts "cdddddd #{$c}"
84
+ exit
85
+ end
86
+
87
+ end
88
+
89
+
90
+ #---------------------------------- real function ------------------------------------
91
+
92
+
93
+ # Filter the Headers when adding file references (the origin)
94
+ class Project < Xcodeproj::Project
95
+
96
+ FAST_INSTALL_OLD_add_file_reference = instance_method :add_file_reference
97
+ define_method(:add_file_reference) do |absolute_path, group, reflect_file_system_structure, base_path = nil|
98
+ if absolute_path.extname == '.h'
99
+ if FastProjectGenerating.should_skip_path(absolute_path)
100
+ next
101
+ end
102
+ end
103
+
104
+ FAST_INSTALL_OLD_add_file_reference.bind(self).(absolute_path, group, false, base_path)
105
+ end
106
+
107
+ end
108
+
109
+
110
+ # Filter the Headers when adding to build phase
111
+ class Installer
112
+ class Xcode
113
+ class PodsProjectGenerator
114
+ class PodTargetInstaller
115
+
116
+ # 其实应该直接修改 def add_files_to_build_phases(native_target, test_native_targets)
117
+ # 但 hook 这个函数更方便
118
+ FAST_INSTALL_OLD_project_file_references_array = instance_method :project_file_references_array
119
+ define_method(:project_file_references_array) do |files, file_type|
120
+ $c += files.count
121
+
122
+ if file_type == 'header'
123
+ files = files.reject do |path|
124
+ FastProjectGenerating.should_skip_path(path)
125
+ end
126
+ end
127
+ next FAST_INSTALL_OLD_project_file_references_array.bind(self).(files, file_type)
128
+
129
+ end
130
+
131
+ end
132
+ end
133
+ end
134
+ end
135
+
136
+
137
+ # There's a bug when use `header_dir` in podspec.
138
+ #
139
+ # The `header search path` is set to something like
140
+ # "${PODS_ROOT}/Headers/Private/lottie-ios"
141
+ #
142
+ # But the when header_dir is set, the real headers will place in a nested folder. So we add a recursise search.
143
+ #
144
+ # Xcode cannot find the header file when it isn't added to the project AND the header file doesn't
145
+ # placed in the same directory with the source file who import it if header search path is not set.
146
+ #
147
+ #
148
+ class PodTarget
149
+
150
+
151
+ FAST_INSTALL_OLD_header_search_paths = instance_method :header_search_paths
152
+ define_method :header_search_paths do |*args|
153
+ paths = FAST_INSTALL_OLD_header_search_paths.bind(self).(*args)
154
+ paths = paths.map do |path|
155
+ if path.end_with?('Public') || path.end_with?('Private')
156
+ path
157
+ else
158
+ path + '/**' # recursive
159
+ end
160
+ end
161
+ paths
162
+ end
163
+
164
+ end
165
+
166
+
167
+ # class Sandbox
168
+ # class HeadersStore
169
+ #
170
+ # def add_file(namespace, relative_header_path, mkdir: true)
171
+ # namespaced_path = root
172
+ # namespaced_path.mkpath if mkdir
173
+ #
174
+ # absolute_source = (sandbox.root + relative_header_path)
175
+ # namespaced_path += absolute_source.relative_path_from(sandbox.root).dirname
176
+ # namespaced_path.mkpath unless namespaced_path.exist?
177
+ #
178
+ # source = absolute_source.relative_path_from(namespaced_path)
179
+ # FileUtils.ln_sf(source, namespaced_path)
180
+ # namespaced_path + relative_header_path.basename
181
+ # end
182
+ #
183
+ # end
184
+ # end
185
+
186
+
187
+
188
+ end
189
+
190
+
@@ -0,0 +1,3 @@
1
+ module CocoapodsFastInstall
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,23 @@
1
+ module Pod
2
+ class Podfile
3
+ module DSL
4
+
5
+ def accelerate_xcproject_generating!(parameters={})
6
+
7
+ require 'cocoapods-fast-install/Patch'
8
+ require 'cocoapods-fast-install/validate_patch'
9
+
10
+ FastProjectGenerating.user_excluded_targets = []
11
+ skipped = parameters[:keeping_header_for]
12
+ if skipped.kind_of? String
13
+ FastProjectGenerating.user_excluded_targets << skipped
14
+ elsif skipped.kind_of? Array
15
+ FastProjectGenerating.user_excluded_targets += skipped
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+
23
+ require 'cocoapods-fast-install/print_duration'
@@ -0,0 +1,86 @@
1
+
2
+
3
+
4
+ # prints the durations
5
+
6
+ module Pod
7
+ class Installer
8
+
9
+ class << self
10
+
11
+ def count_seconds(method)
12
+ old_method = instance_method(method)
13
+ define_method(method) do |*args|
14
+ start = Time.new
15
+ result = old_method.bind(self).(*args)
16
+ ends = Time.new
17
+ puts "[Fast Install] #{method} spends #{ends - start} seconds"
18
+ next result
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ count_seconds :install!
25
+
26
+ count_seconds :prepare
27
+ count_seconds :resolve_dependencies
28
+ count_seconds :download_dependencies
29
+ count_seconds :validate_targets
30
+ count_seconds :generate_pods_project
31
+ count_seconds :integrate_user_project
32
+ count_seconds :perform_post_install_actions
33
+
34
+ end
35
+ end
36
+
37
+ # #print the separated step in generating
38
+ # module Pod
39
+ # class Installer
40
+ # class Xcode
41
+ # class PodsProjectGenerator
42
+ #
43
+ # class << self
44
+ #
45
+ # def count_seconds(method)
46
+ # old_method = instance_method(method)
47
+ # define_method(method) do |*args|
48
+ # start = Time.new
49
+ # result = old_method.bind(self).(*args)
50
+ # ends = Time.new
51
+ # puts "[Fast Install: PodsProjectGenerator] #{method} spends #{ends - start} seconds"
52
+ # next result
53
+ # end
54
+ # end
55
+ #
56
+ # end
57
+ #
58
+ # if Pod::VERSION.start_with? "1.5"
59
+ # count_seconds :prepare
60
+ # count_seconds :install_file_references
61
+ # count_seconds :install_libraries
62
+ # count_seconds :integrate_targets
63
+ # count_seconds :set_target_dependencies
64
+ # elsif Pod::VERSION.start_with? "1.6"
65
+ # count_seconds :generate!
66
+ #
67
+ # # count_seconds :prepare
68
+ # count_seconds :install_file_references
69
+ # count_seconds :install_targets
70
+ # # count_seconds :integrate_targets
71
+ # # count_seconds :wire_target_dependencies
72
+ # end
73
+ #
74
+ # end
75
+ # end
76
+ # end
77
+ # end
78
+
79
+ def print_duration(description, &block)
80
+ start = Time.new
81
+ result = block.call() if block_given?
82
+ stop = Time.new
83
+ puts "#{description} #{stop-start}"
84
+ return result
85
+ end
86
+
@@ -0,0 +1,18 @@
1
+
2
+ # Validate will trigger the cache of some methods. If we skip validate step, these
3
+ # methods will be used in generating step. So it have no significant effect.
4
+
5
+ unless Pod::VERSION.start_with? "1.5"
6
+
7
+ module Pod
8
+ class Installer
9
+
10
+ def validate_targets
11
+ # no need to validate
12
+ # depress the original function
13
+ end
14
+
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,3 @@
1
+
2
+
3
+ require 'cocoapods-fast-install/main'
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Generating do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ generating }).should.be.instance_of Command::Generating
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-fast-install
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Gao
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A short description of cocoapods-fast-install.
42
+ email:
43
+ - gaoji@bytedance.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - cocoapods-fast-install.gemspec
54
+ - lib/cocoapods-fast-install.rb
55
+ - lib/cocoapods-fast-install/Patch.rb
56
+ - lib/cocoapods-fast-install/gem_version.rb
57
+ - lib/cocoapods-fast-install/main.rb
58
+ - lib/cocoapods-fast-install/print_duration.rb
59
+ - lib/cocoapods-fast-install/validate_patch.rb
60
+ - lib/cocoapods_plugin.rb
61
+ - spec/command/generating_spec.rb
62
+ - spec/spec_helper.rb
63
+ homepage: https://github.com/EXAMPLE/cocoapods-fast-install
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.5.2.3
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: A longer description of cocoapods-fast-install.
87
+ test_files:
88
+ - spec/command/generating_spec.rb
89
+ - spec/spec_helper.rb