cocoapods-bindyf 0.1.29.3

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +13 -0
  4. data/Gemfile.lock +104 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +567 -0
  7. data/Rakefile +13 -0
  8. data/cocoapods-bin.gemspec +27 -0
  9. data/cocoapods-bindyf-0.1.29.2.gem +0 -0
  10. data/debug_install.sh +8 -0
  11. data/lib/cocoapods-bin.rb +4 -0
  12. data/lib/cocoapods-bin/command.rb +3 -0
  13. data/lib/cocoapods-bin/command/bin.rb +60 -0
  14. data/lib/cocoapods-bin/command/bin/archive.rb +130 -0
  15. data/lib/cocoapods-bin/command/bin/init.rb +71 -0
  16. data/lib/cocoapods-bin/command/bin/lib.rb +14 -0
  17. data/lib/cocoapods-bin/command/bin/lib/lint.rb +69 -0
  18. data/lib/cocoapods-bin/command/bin/list.rb +50 -0
  19. data/lib/cocoapods-bin/command/bin/open.rb +61 -0
  20. data/lib/cocoapods-bin/command/bin/repo.rb +15 -0
  21. data/lib/cocoapods-bin/command/bin/repo/push.rb +124 -0
  22. data/lib/cocoapods-bin/command/bin/repo/update.rb +42 -0
  23. data/lib/cocoapods-bin/command/bin/search.rb +69 -0
  24. data/lib/cocoapods-bin/command/bin/spec.rb +15 -0
  25. data/lib/cocoapods-bin/command/bin/spec/create.rb +75 -0
  26. data/lib/cocoapods-bin/command/bin/spec/lint.rb +119 -0
  27. data/lib/cocoapods-bin/command/bin/umbrella.rb +55 -0
  28. data/lib/cocoapods-bin/config/config.rb +80 -0
  29. data/lib/cocoapods-bin/config/config_asker.rb +58 -0
  30. data/lib/cocoapods-bin/gem_version.rb +11 -0
  31. data/lib/cocoapods-bin/helpers.rb +5 -0
  32. data/lib/cocoapods-bin/helpers/framework.rb +66 -0
  33. data/lib/cocoapods-bin/helpers/framework_builder.rb +190 -0
  34. data/lib/cocoapods-bin/helpers/sources_helper.rb +33 -0
  35. data/lib/cocoapods-bin/helpers/spec_creator.rb +147 -0
  36. data/lib/cocoapods-bin/helpers/spec_files_helper.rb +77 -0
  37. data/lib/cocoapods-bin/native.rb +20 -0
  38. data/lib/cocoapods-bin/native/acknowledgements.rb +27 -0
  39. data/lib/cocoapods-bin/native/analyzer.rb +53 -0
  40. data/lib/cocoapods-bin/native/installation_options.rb +26 -0
  41. data/lib/cocoapods-bin/native/installer.rb +115 -0
  42. data/lib/cocoapods-bin/native/linter.rb +26 -0
  43. data/lib/cocoapods-bin/native/path_source.rb +33 -0
  44. data/lib/cocoapods-bin/native/pod_source_installer.rb +19 -0
  45. data/lib/cocoapods-bin/native/podfile.rb +79 -0
  46. data/lib/cocoapods-bin/native/podfile_env.rb +36 -0
  47. data/lib/cocoapods-bin/native/podspec_finder.rb +25 -0
  48. data/lib/cocoapods-bin/native/resolver.rb +199 -0
  49. data/lib/cocoapods-bin/native/sandbox_analyzer.rb +34 -0
  50. data/lib/cocoapods-bin/native/source.rb +35 -0
  51. data/lib/cocoapods-bin/native/sources_manager.rb +20 -0
  52. data/lib/cocoapods-bin/native/specification.rb +31 -0
  53. data/lib/cocoapods-bin/native/validator.rb +16 -0
  54. data/lib/cocoapods-bin/source_provider_hook.rb +39 -0
  55. data/lib/cocoapods_plugin.rb +5 -0
  56. data/spec/command/bin_spec.rb +12 -0
  57. data/spec/spec_helper.rb +50 -0
  58. metadata +173 -0
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pod
4
+ class Command
5
+ class Bin < Command
6
+ class Umbrella < Bin
7
+ self.summary = '生成伞头文件 .'
8
+
9
+ self.arguments = [
10
+ CLAide::Argument.new('PATH', false)
11
+ ]
12
+
13
+ def initialize(argv)
14
+ @path = Pathname.new(argv.shift_argument || '.')
15
+ @spec_file = code_spec_files.first
16
+ super
17
+ end
18
+
19
+ def validate!
20
+ super
21
+ if @spec_file.nil?
22
+ help! '[!] No `Podspec` found in the project directory.'
23
+ end
24
+ end
25
+
26
+ def run
27
+ pod_name = @spec_file.to_s.split('.').first
28
+
29
+ @path += "#{pod_name}.h" if @path.directory?
30
+
31
+ UI.puts "Generateing umbrella file for #{pod_name}"
32
+
33
+ header_generator = Pod::Generator::Header.new(Platform.ios)
34
+ spec = Pod::Specification.from_file(Pathname.new(@spec_file))
35
+ public_header_files = spec.consumer(:ios).public_header_files
36
+ if public_header_files.empty?
37
+ public_header_files = spec.consumer(:ios).source_files
38
+ end
39
+ public_header_files = Pathname.glob(public_header_files).map(&:basename).select do |pathname|
40
+ pathname.extname.to_s == '.h' &&
41
+ pathname.basename('.h').to_s != pod_name
42
+ end
43
+
44
+ header_generator.imports = public_header_files
45
+
46
+ UI.puts "Save umbrella file to #{@path.expand_path}"
47
+
48
+ header_generator.save_as(@path)
49
+
50
+ UI.puts 'Done!'.green
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module CBin
6
+ class Config
7
+ def config_file
8
+ File.expand_path("#{Pod::Config.instance.home_dir}/bin.yml")
9
+ end
10
+
11
+ def template_hash
12
+ {
13
+ 'code_repo_url' => { description: '源码私有源 Git 地址', default: 'git@git.2dfire.net:ios/cocoapods-spec.git' },
14
+ 'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'git@git.2dfire.net:ios/cocoapods-spec-binary.git' },
15
+ 'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip' },
16
+ # 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
17
+ 'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] }
18
+ }
19
+ end
20
+
21
+ def sync_config(config)
22
+ File.open(config_file, 'w+') do |f|
23
+ f.write(config.to_yaml)
24
+ end
25
+ end
26
+
27
+ def default_config
28
+ @default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
29
+ end
30
+
31
+ private
32
+
33
+ def load_config
34
+ if File.exist?(config_file)
35
+ YAML.load_file(config_file)
36
+ else
37
+ default_config
38
+ end
39
+ end
40
+
41
+ def config
42
+ @config ||= begin
43
+ @config = OpenStruct.new load_config
44
+ validate!
45
+ @config
46
+ end
47
+ end
48
+
49
+ def validate!
50
+ template_hash.each do |k, v|
51
+ selection = v[:selection]
52
+ next if !selection || selection.empty?
53
+
54
+ config_value = @config.send(k)
55
+ next unless config_value
56
+ unless selection.include?(config_value)
57
+ raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
58
+ end
59
+ end
60
+ end
61
+
62
+ def respond_to_missing?(method, include_private = false)
63
+ config.respond_to?(method) || super
64
+ end
65
+
66
+ def method_missing(method, *args, &block)
67
+ if config.respond_to?(method)
68
+ config.send(method, *args)
69
+ elsif template_hash.keys.include?(method.to_s)
70
+ raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
71
+ else
72
+ super
73
+ end
74
+ end
75
+ end
76
+
77
+ def self.config
78
+ @config ||= Config.new
79
+ end
80
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'cocoapods-bin/config/config'
5
+
6
+ module CBin
7
+ class Config
8
+ class Asker
9
+ def show_prompt
10
+ print ' > '.green
11
+ end
12
+
13
+ def ask_with_answer(question, pre_answer, selection)
14
+ print "\n#{question}\n"
15
+
16
+ print_selection_info = lambda {
17
+ print "可选值:[ #{selection.join(' / ')} ]\n" if selection
18
+ }
19
+ print_selection_info.call
20
+ print "旧值:#{pre_answer}\n" unless pre_answer.nil?
21
+
22
+ answer = ''
23
+ loop do
24
+ show_prompt
25
+ answer = STDIN.gets.chomp.strip
26
+
27
+ if answer == '' && !pre_answer.nil?
28
+ answer = pre_answer
29
+ print answer.yellow
30
+ print "\n"
31
+ end
32
+
33
+ next if answer.empty?
34
+ break if !selection || selection.include?(answer)
35
+
36
+ print_selection_info.call
37
+ end
38
+
39
+ answer
40
+ end
41
+
42
+ def wellcome_message
43
+ print <<~EOF
44
+
45
+ 开始设置二进制化初始信息.
46
+ 所有的信息都会保存在 #{CBin.config.config_file} 文件中.
47
+ 你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
48
+
49
+ #{CBin.config.default_config.to_yaml}
50
+ EOF
51
+ end
52
+
53
+ def done_message
54
+ print "\n设置完成.\n".green
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CBin
4
+ VERSION = '0.1.29.3'
5
+ end
6
+
7
+ module Pod
8
+ def self.match_version?(*version)
9
+ Gem::Dependency.new('', *version).match?('', Pod::VERSION)
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cocoapods-bin/helpers/sources_helper'
4
+ require 'cocoapods-bin/helpers/spec_creator'
5
+ require 'cocoapods-bin/helpers/spec_files_helper'
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ module CBin
6
+ class Framework
7
+ attr_reader :headers_path
8
+ attr_reader :module_map_path
9
+ attr_reader :resources_path
10
+ attr_reader :root_path
11
+ attr_reader :fwk_path
12
+
13
+ def initialize(name, platform)
14
+ @name = name
15
+ @platform = platform
16
+ end
17
+
18
+ def make
19
+ make_root
20
+ make_framework
21
+ make_headers
22
+ make_resources
23
+ make_current_version
24
+ end
25
+
26
+ def delete_resources
27
+ if @resources_path.exist?
28
+ Pathname.new(@resources_path).rmtree
29
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def make_current_version
36
+ # current_version_path = @versions_path + Pathname.new('../Current')
37
+ # `ln -sf A #{current_version_path}`
38
+ # `ln -sf Versions/Current/Headers #{@fwk_path}/`
39
+ # `ln -sf Versions/Current/Resources #{@fwk_path}/`
40
+ # `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
41
+ end
42
+
43
+ def make_framework
44
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
45
+ @fwk_path.mkdir unless @fwk_path.exist?
46
+
47
+ @module_map_path = @fwk_path + Pathname.new('Modules')
48
+ # @versions_path = @fwk_path + Pathname.new('Versions/A')
49
+ end
50
+
51
+ def make_headers
52
+ @headers_path = @fwk_path + Pathname.new('Headers')
53
+ @headers_path.mkpath unless @headers_path.exist?
54
+ end
55
+
56
+ def make_resources
57
+ @resources_path = @fwk_path + Pathname.new('Resources')
58
+ @resources_path.mkpath unless @resources_path.exist?
59
+ end
60
+
61
+ def make_root
62
+ @root_path = Pathname.new(@platform)
63
+ @root_path.mkpath unless @root_path.exist?
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,190 @@
1
+ # frozen_string_literal: true
2
+
3
+ # copy from https://github.com/CocoaPods/cocoapods-packager
4
+
5
+ require 'cocoapods-bin/helpers/framework.rb'
6
+ require 'English'
7
+
8
+ module CBin
9
+ class Framework
10
+ class Builder
11
+ include Pod
12
+
13
+ def initialize(spec, file_accessor, platform, source_dir, use_framework=true)
14
+ @spec = spec
15
+ @source_dir = source_dir
16
+ @file_accessor = file_accessor
17
+ @platform = platform
18
+ @vendored_libraries = (file_accessor.vendored_static_frameworks + file_accessor.vendored_static_libraries).map(&:to_s)
19
+ @use_framework = use_framework
20
+ end
21
+
22
+ def build
23
+ UI.section("Building dynmic framework #{@spec}") do
24
+ defines = compile
25
+
26
+ build_sim_dynmic_framework(defines)
27
+
28
+ output = framework.fwk_path + Pathname.new(@spec.name)
29
+ build_dynmic_framework_for_ios(output)
30
+
31
+ merge_swift_header
32
+ copy_resources
33
+ copy_license
34
+ cp_to_source_dir
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def cp_to_source_dir
41
+ target_dir = "#{@source_dir}/#{framework_name}"
42
+ FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
43
+
44
+ `cp -fa #{@platform}/#{framework_name} #{@source_dir}`
45
+ end
46
+
47
+ def build_sim_dynmic_framework(defines)
48
+ UI.message 'Building simulator libraries'
49
+ xcodebuild(defines, '-sdk iphonesimulator', 'build-simulator')
50
+ end
51
+
52
+ def merge_swift_header
53
+ # <project>-Swift.h 需要区分模拟器和真机
54
+ sim_swift_header = Pathname.new("./build-simulator/#{framework_name}/Headers/#{target_name}-Swift.h")
55
+ iphone_swift_header = Pathname.new("./build/#{framework_name}/Headers/#{target_name}-Swift.h")
56
+ if sim_swift_header.exist? && iphone_swift_header.exist?
57
+
58
+ # 拼接文件
59
+ sim_readlines = File.readlines(sim_swift_header)
60
+ sim_readlines.insert(0, *["// 开始模拟器", "#if TARGET_IPHONE_SIMULATOR"])
61
+ sim_readlines << "// 结束模拟器"
62
+ sim_readlines << "#else"
63
+ sim_readlines << "// 开始真机"
64
+ sim_readlines << File.readlines(iphone_swift_header)
65
+ sim_readlines << "// 结束真机"
66
+ sim_readlines << "#endif"
67
+
68
+ # 清空源文件
69
+ File.open(iphone_swift_header, "w+") do |aFile|
70
+ # 写入
71
+ for line in sim_readlines do
72
+ aFile.puts line
73
+ end
74
+ end
75
+
76
+ `cp -fa #{iphone_swift_header} #{framework.headers_path}`
77
+ end
78
+ end
79
+
80
+ def copy_license
81
+ UI.message 'Copying license'
82
+ license_file = @spec.license[:file] || 'LICENSE'
83
+ `cp "#{license_file}" .` if Pathname(license_file).exist?
84
+ end
85
+
86
+ def copy_resources
87
+ bundles = Dir.glob('./build/*.bundle')
88
+ if bundles.count > 0
89
+ UI.message "Copying bundle files #{bundles}"
90
+ for bundle in bundles do
91
+ `cp -fa #{bundle} #{framework.fwk_path}`
92
+ end
93
+ end
94
+ end
95
+
96
+ def use_framework
97
+ return @use_framework
98
+ end
99
+
100
+ def framework_name
101
+ return "#{Pathname.new(@spec.name)}.framework"
102
+ end
103
+
104
+ def dynmic_libs_in_sandbox(build_dir = 'build')
105
+ Dir.glob("#{build_dir}/#{framework_name}/#{Pathname.new(@spec.name)}")
106
+ end
107
+
108
+ def build_dynmic_framework_for_ios(output)
109
+ UI.message "Building ios libraries with archs #{ios_architectures}"
110
+ static_libs = dynmic_libs_in_sandbox('build') + dynmic_libs_in_sandbox('build-simulator') + @vendored_libraries
111
+
112
+ # 暂时不过滤 arch, 操作的是framework里面的mach-o文件
113
+ libs = static_libs
114
+
115
+ `rm -rf #{framework.fwk_path}/*`
116
+ # 输出之前,先拷贝framework
117
+ # 模拟器 -> 新建framework
118
+ `cp -fRap build-simulator/#{framework_name}/* #{framework.fwk_path}/`
119
+ # 真机 -> 新建framework
120
+ `cp -fRap build/#{framework_name}/* #{framework.fwk_path}/`
121
+
122
+ # 多拷贝了资源和签名
123
+ `rm -rf #{framework.fwk_path}/_CodeSignature`
124
+
125
+ `lipo -create -output #{output} #{libs.join(' ')}`
126
+ end
127
+
128
+ def ios_build_options
129
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
130
+ end
131
+
132
+ def ios_architectures
133
+ archs = %w[x86_64 arm64 armv7 armv7s i386]
134
+ # 默认支持全平台
135
+ # @vendored_libraries.each do |library|
136
+ # archs = `lipo -info #{library}`.split & archs
137
+ # end
138
+ archs
139
+ end
140
+
141
+ def compile
142
+ defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited)'"
143
+ defines += ' '
144
+ defines += @spec.consumer(@platform).compiler_flags.join(' ')
145
+
146
+ options = ios_build_options
147
+ xcodebuild(defines, options)
148
+
149
+ defines
150
+ end
151
+
152
+ def target_name
153
+ if @spec.available_platforms.count > 1
154
+ "#{@spec.name}-#{Platform.string_name(@spec.consumer(@platform).platform_name)}"
155
+ else
156
+ @spec.name
157
+ end
158
+ end
159
+
160
+ def xcodebuild(defines = '', args = '', build_dir = 'build')
161
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration Release -target #{target_name} -project ./Pods.xcodeproj 2>&1"
162
+ output = `#{command}`.lines.to_a
163
+
164
+ if $CHILD_STATUS.exitstatus != 0
165
+ raise <<~EOF
166
+ Build command failed: #{command}
167
+ Output:
168
+ #{output.map { |line| " #{line}" }.join}
169
+ EOF
170
+
171
+ Process.exit
172
+ end
173
+ end
174
+
175
+ def expand_paths(path_specs)
176
+ path_specs.map do |path_spec|
177
+ Dir.glob(File.join(@source_dir, path_spec))
178
+ end
179
+ end
180
+
181
+ def framework
182
+ @framework ||= begin
183
+ framework = Framework.new(@spec.name, @platform.name.to_s)
184
+ framework.make
185
+ framework
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end