cocoapods-imy-bin 0.2.7 → 0.3.1.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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -453
  3. data/lib/cocoapods-imy-bin/command/bin/archive.rb +43 -5
  4. data/lib/cocoapods-imy-bin/command/bin/auto.rb +22 -15
  5. data/lib/cocoapods-imy-bin/command/bin/dup.rb +78 -0
  6. data/lib/cocoapods-imy-bin/config/config.rb +1 -1
  7. data/lib/cocoapods-imy-bin/config/config_builder.rb +39 -2
  8. data/lib/cocoapods-imy-bin/gem_version.rb +1 -1
  9. data/lib/cocoapods-imy-bin/helpers.rb +1 -0
  10. data/lib/cocoapods-imy-bin/helpers/Info.plist +0 -0
  11. data/lib/cocoapods-imy-bin/helpers/build_helper.rb +15 -7
  12. data/lib/cocoapods-imy-bin/helpers/build_utils.rb +63 -0
  13. data/lib/cocoapods-imy-bin/helpers/framework.rb +25 -2
  14. data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +165 -54
  15. data/lib/cocoapods-imy-bin/helpers/library.rb +2 -2
  16. data/lib/cocoapods-imy-bin/helpers/sources_helper.rb +5 -2
  17. data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +65 -8
  18. data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +8 -3
  19. data/lib/cocoapods-imy-bin/native.rb +4 -0
  20. data/lib/cocoapods-imy-bin/native/analyzer.rb +2 -0
  21. data/lib/cocoapods-imy-bin/native/file_accessor.rb +28 -0
  22. data/lib/cocoapods-imy-bin/native/installer.rb +22 -2
  23. data/lib/cocoapods-imy-bin/native/pod_target_installer.rb +94 -0
  24. data/lib/cocoapods-imy-bin/native/podfile_generator.rb +11 -2
  25. data/lib/cocoapods-imy-bin/native/target_validator.rb +41 -0
  26. data/lib/cocoapods-imy-bin/native/validator.rb +1 -38
  27. data/lib/cocoapods-imy-bin/source_provider_hook.rb +35 -23
  28. metadata +12 -12
  29. data/lib/cocoapods-imy-bin/command/bin/local.rb +0 -156
  30. data/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb +0 -57
  31. data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +0 -146
  32. data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +0 -65
  33. data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +0 -174
  34. data/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb +0 -92
@@ -7,6 +7,7 @@ require 'cocoapods-imy-bin/helpers/build_helper'
7
7
  require 'cocoapods-imy-bin/helpers/spec_source_creator'
8
8
  require 'cocoapods-imy-bin/config/config_builder'
9
9
  require 'cocoapods-imy-bin/command/bin/lib/lint'
10
+ require 'xcodeproj'
10
11
 
11
12
  module Pod
12
13
  class Command
@@ -62,13 +63,14 @@ module Pod
62
63
  end
63
64
 
64
65
  def run
65
- #清除之前的缓存
66
- zip_dir = CBin::Config::Builder.instance.zip_dir
67
- FileUtils.rm_rf(zip_dir) if File.exist?(zip_dir)
66
+ # 清除之前的缓存
67
+ CBin::Config::Builder.instance.clean
68
68
 
69
69
  @spec = Specification.from_file(spec_file)
70
70
  generate_project
71
71
 
72
+ swift_pods_buildsetting
73
+
72
74
  build_root_spec
73
75
 
74
76
  sources_sepc = Array.new
@@ -127,7 +129,8 @@ module Pod
127
129
  false ,
128
130
  @config)
129
131
  builder.build
130
- rescue
132
+ rescue Object => exception
133
+ UI.puts exception
131
134
  fail_build_specs << spec
132
135
  end
133
136
  end
@@ -154,10 +157,18 @@ module Pod
154
157
  "--sources=#{sources_option(@code_dependencies, @sources)}",
155
158
  "--gen-directory=#{CBin::Config::Builder.instance.gen_dir}",
156
159
  '--clean',
157
- '--use-podfile',
160
+ "--verbose",
158
161
  *@additional_args
159
162
  ]
160
163
 
164
+ if File.exist?(Pod::Config.instance.podfile_path)
165
+ argvs += ['--use-podfile']
166
+ end
167
+
168
+ unless CBin::Build::Utils.uses_frameworks?
169
+ argvs += ['--use-libraries']
170
+ end
171
+
161
172
  argvs << spec_file if spec_file
162
173
 
163
174
  gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
@@ -167,6 +178,33 @@ module Pod
167
178
  end
168
179
  end
169
180
 
181
+ def swift_pods_buildsetting
182
+ # swift_project_link_header
183
+ worksppace_path = File.expand_path("#{CBin::Config::Builder.instance.gen_dir}/#{@spec.name}")
184
+ path = File.join(worksppace_path, "Pods.xcodeproj")
185
+ path = File.join(worksppace_path, "Pods/Pods.xcodeproj") unless File.exist?(path)
186
+ raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
187
+ project = Xcodeproj::Project.open(path)
188
+ project.build_configurations.each do |x|
189
+ x.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = true #设置生成swift inter
190
+ end
191
+ project.save
192
+ end
193
+
194
+ # def swift_project_link_header
195
+ # worksppace_path = Pod::Config.instance.installation_root
196
+ # Dir.chdir(worksppace_path) do
197
+ # shell_script = <<-'SH'.strip_heredoc
198
+ # ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${CBin::Config::Builder.instance.gen_dir}"
199
+ # SH
200
+ # shell_script
201
+ #
202
+ # # project = Xcodeproj::Project.open(Dir.glob('*.xcodeproj').first)
203
+ # # project.build_configurations.each do |x|
204
+ # # x.build_settings['DERIVED_SOURCES_DIR']
205
+ # # end
206
+ # end
207
+ # end
170
208
 
171
209
  def spec_file
172
210
  @spec_file ||= begin
@@ -19,9 +19,9 @@ module Pod
19
19
  ['--framework-output', '输出framework文件'],
20
20
  ['--no-zip', '不压缩静态 framework 为 zip'],
21
21
  ['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
22
- ['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
22
+ ['--configuration', 'Build the specified configuration (e.g. Release ). Defaults to Debug'],
23
23
  ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
24
- ]
24
+ ].concat(Pod::Command::Gen.options).concat(super).uniq
25
25
  end
26
26
 
27
27
  def initialize(argv)
@@ -40,23 +40,28 @@ module Pod
40
40
  @all_make = argv.flag?('all-make', false )
41
41
  @verbose = argv.flag?('verbose',true)
42
42
 
43
- @config = argv.option('configuration', 'Release')
43
+ @config = argv.option('configuration', 'Debug')
44
+ @additional_args = argv.remainder!
45
+
46
+ super
47
+ end
44
48
 
49
+ def validate!
50
+ help! "未找到 podspec文件" unless @podspec
45
51
  super
46
52
  end
47
53
 
48
54
  def run
55
+ @specification = Specification.from_file(@podspec)
49
56
 
50
- unless @podspec
51
- raise Informative, "未找到 podspec文件"
52
- end
53
57
  sources_sepc = run_archive
54
58
 
55
59
  fail_push_specs = []
56
60
  sources_sepc.uniq.each do |spec|
57
61
  begin
58
62
  fail_push_specs << spec unless CBin::Upload::Helper.new(spec,@code_dependencies,@sources).upload
59
- rescue
63
+ rescue Object => exception
64
+ UI.puts exception
60
65
  fail_push_specs << spec
61
66
  end
62
67
  end
@@ -86,15 +91,15 @@ module Pod
86
91
  end
87
92
 
88
93
  #制作二进制包
89
- # `pod bin archive --verbose --code-dependencies --no-clean --sources=https://gitlab.xxx.com/iOS/imyspecs.git,https://cdn.cocoapods.org/ --use-libraries`
94
+
90
95
  def run_archive
91
96
  argvs = [
92
97
  "--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
93
- "--use-libraries",
94
- "--verbose"
98
+ @additional_args
95
99
  ]
96
100
 
97
101
  argvs << spec_file if spec_file
102
+ argvs.delete(Array.new)
98
103
 
99
104
  unless @clean
100
105
  argvs += ['--no-clean']
@@ -118,7 +123,7 @@ module Pod
118
123
  argvs += ["--env=#{@env}"]
119
124
  end
120
125
  argvs += ["--configuration=#{@config}"]
121
-
126
+
122
127
  archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
123
128
  archive.validate!
124
129
  sources_sepc = archive.run
@@ -173,17 +178,19 @@ module Pod
173
178
 
174
179
  #Dir.glob 可替代
175
180
  def find_podspec
181
+ name = nil
176
182
  Pathname.pwd.children.each do |child|
177
183
  puts child
178
184
  if File.file?(child)
179
185
  if child.extname == '.podspec'
180
- name = File.basename(child)
181
- unless name.include?("binary-template")
182
- return name
183
- end
186
+ name = File.basename(child)
187
+ unless name.include?("binary-template")
188
+ return name
189
+ end
184
190
  end
185
191
  end
186
192
  end
193
+ return name
187
194
  end
188
195
 
189
196
  end
@@ -0,0 +1,78 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods/target/pod_target'
3
+
4
+ module Pod
5
+ class Command
6
+ class Bin < Command
7
+ class Dup < Bin
8
+ self.summary = '在Podfile目录下,查找Pods下同名资源名'
9
+
10
+ self.description = <<-DESC
11
+ 在Podfile目录下,查找Pods下同名资源名
12
+ DESC
13
+
14
+ self.arguments = [
15
+ CLAide::Argument.new('NAME', false)
16
+ ]
17
+ def self.options
18
+ [
19
+ ['--all-clean', '删除所有已经下载的源码'],
20
+ ['--clean', '删除所有指定下载的源码'],
21
+ ['--list', '展示所有一级下载的源码以及其大小'],
22
+ ['--source', '源码路径,本地路径,会去自动链接本地源码']
23
+ ]
24
+ end
25
+
26
+ def initialize(argv)
27
+ @codeSource = argv.option('source') || nil
28
+
29
+ @config = Pod::Config.instance
30
+
31
+ super
32
+ end
33
+
34
+
35
+ def run
36
+ target_definition = Pod::Config.instance.podfile.target_definition_list[1]
37
+
38
+ user_build_configurations = target_definition.build_configurations || Target::DEFAULT_BUILD_CONFIGURATIONS
39
+ aggregateTarget = AggregateTarget.new(Pod::Config.instance.sandbox,
40
+ target_definition.uses_frameworks?,
41
+ user_build_configurations ,
42
+ nil,
43
+ target_definition.platform,
44
+ target_definition,
45
+ Pod::Config.instance.installation_root,
46
+ nil,
47
+ nil ,
48
+ user_build_configurations)
49
+ input_file = aggregateTarget.copy_resources_script_path
50
+ output_pods_suffix_txt = File.join(Pod::Config.instance.project_root,"output_pods_suffix.txt")
51
+ output_pods_uniq_txt = File.join(Pod::Config.instance.project_root,"output_pods_uniq.txt")
52
+ ignore_array = ["bundle","mp3"]
53
+ resources_path = File.join(File.dirname(File.dirname(File.dirname(__FILE__))),"resources")
54
+ shell_file = File.join(resources_path,"Pods-check-deduplication-resources.sh")
55
+ #ruby 调用shell 文件、命令传入
56
+ # stdout shell 脚本输出的文本
57
+ # status 退出的状态
58
+ stdout, status = Open3.capture2('/bin/sh',
59
+ "#{shell_file}",
60
+ "#{input_file}",
61
+ "#{output_pods_suffix_txt}",
62
+ "#{output_pods_uniq_txt}",
63
+ "#{ignore_array}")
64
+
65
+ #重复资源 抛出异常
66
+ if status.to_i != 0
67
+ raise "由于权限不足,请手动创建 后重试"
68
+ else #重复资源,警告
69
+ raise "由于权限不足,请手动创建 后重试"
70
+
71
+ end
72
+ end
73
+
74
+
75
+ end
76
+ end
77
+ end
78
+ end
@@ -14,7 +14,7 @@ module CBin
14
14
  'configuration_env' => { description: '编译环境', default: 'dev', selection: %w[dev debug_iphoneos release_iphoneos] },
15
15
  'code_repo_url' => { description: '源码私有源 Git 地址', default: 'git@github.com:su350380433/example_spec_source.git' },
16
16
  'binary_repo_url' => { description: '二进制私有源 Git 地址', default: 'git@github.com:su350380433/example_spec_bin_dev.git' },
17
- 'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://localhost:8080/frameworks/%s/%s.zip' },
17
+ 'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ', default: 'http://localhost:8080/frameworks/%s/%s/zip' },
18
18
  # 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
19
19
  'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] }
20
20
  }
@@ -12,6 +12,7 @@ module CBin
12
12
 
13
13
  def initialize
14
14
  load_build_config
15
+ # clean
15
16
  end
16
17
 
17
18
  # 加载配置项
@@ -35,6 +36,13 @@ module CBin
35
36
 
36
37
  end
37
38
 
39
+ def clean
40
+ #清除之前的缓存
41
+ FileUtils.rm_rf(Dir.glob("#{zip_dir}/*")) if File.exist?(zip_dir)
42
+ FileUtils.rm_rf(Dir.glob("#{binary_json_dir}/*")) if File.exist?(binary_json_dir)
43
+ FileUtils.rm_rf(Dir.glob("#{local_psec_dir}/*")) if File.exist?(local_psec_dir)
44
+ end
45
+
38
46
  # 制作二进制打包 工程目录
39
47
  def gen_name
40
48
  'bin-archive'
@@ -49,10 +57,19 @@ module CBin
49
57
  end
50
58
  end
51
59
 
60
+
52
61
  def framework_name(spec)
53
62
  "#{spec.name}.framework"
54
63
  end
55
64
 
65
+ def framework_name_version(spec)
66
+ "#{spec.name}.framework_#{spec.version}"
67
+ end
68
+
69
+ def framework_zip_file(spec)
70
+ File.join(zip_dir_name, framework_name_version(spec))
71
+ end
72
+
56
73
  def framework_file(spec)
57
74
  File.join(zip_dir_name, framework_name(spec))
58
75
  end
@@ -110,7 +127,8 @@ module CBin
110
127
  #编译target名,如 seeyou
111
128
  def target_name
112
129
  @target_name ||= begin
113
- Pod::Config.instance.podfile.root_target_definitions.first.children.first.to_s.split('-').last
130
+ target_name_str = Pod::Config.instance.podfile.root_target_definitions.first.children.first.to_s
131
+ target_name_str[5,target_name_str.length]
114
132
  end
115
133
  end
116
134
 
@@ -129,6 +147,7 @@ module CBin
129
147
  if @xcode_build_name.nil? || Dir.exist?(@xcode_build_name)
130
148
  @xcode_build_name = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/"
131
149
  end
150
+ puts @xcode_build_name
132
151
  @xcode_build_name
133
152
  end
134
153
  end
@@ -146,7 +165,25 @@ module CBin
146
165
  end
147
166
  end
148
167
  end
149
-
168
+ #完整的xcodebuild BuildProductsPath输出路径,
169
+ def xcode_BuildProductsPath_dir
170
+ @xcode_BuildProductsPath_dir ||= begin
171
+ temp_xcode_BuildProductsPath_dir = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/BuildProductsPath/"
172
+ full_path = File.join(root_dir, temp_xcode_BuildProductsPath_dir)
173
+
174
+ if (File.exist?(full_path))
175
+ Dir.chdir(full_path) do
176
+ iphoneos = Dir.glob('*-iphoneos')
177
+ if iphoneos.length > 0
178
+ full_path = File.join(full_path,iphoneos.first)
179
+ else
180
+ UI.warn "====== 找不到 *-iphoneos @xcode_BuildProductsPath_dir = #{@xcode_BuildProductsPath_dir}"
181
+ end
182
+ end
183
+ end
184
+ Pathname.new(full_path)
185
+ end
186
+ end
150
187
 
151
188
 
152
189
  #处理编译产物后存储根目录,会存放spec、 json、zip的父目录,默认是工程的同级目录下,"#{basename}-build-temp"
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.2.7'
3
+ VERSION = '0.3.1.2'
4
4
  end
5
5
 
6
6
  module Pod
@@ -2,3 +2,4 @@ require 'cocoapods-imy-bin/helpers/sources_helper'
2
2
  require 'cocoapods-imy-bin/helpers/spec_creator'
3
3
  require 'cocoapods-imy-bin/helpers/spec_files_helper'
4
4
  require 'cocoapods-imy-bin/helpers/spec_source_creator'
5
+ require 'cocoapods-imy-bin/helpers/build_utils'
@@ -38,9 +38,12 @@ module CBin
38
38
 
39
39
  build_static_framework
40
40
  unless @skip_archive
41
- build_static_library
42
- zip_static_framework if @zip &&= @framework_output
43
- zip_static_library
41
+ unless CBin::Build::Utils.is_framework(@spec)
42
+ build_static_library
43
+ zip_static_library
44
+ else
45
+ zip_static_framework
46
+ end
44
47
  end
45
48
 
46
49
  end
@@ -71,15 +74,15 @@ module CBin
71
74
  end
72
75
 
73
76
  def zip_static_framework
74
- Dir.chdir(zip_dir) do
75
- output_name = "#{framework_name}.zip"
77
+ Dir.chdir(File.join(workspace_directory,@framework_path.root_path)) do
78
+ output_name = File.join(zip_dir, framework_name_zip)
76
79
  unless File.exist?(framework_name)
77
- raise Informative, "没有需要压缩的 framework 文件:#{framework_name}"
80
+ UI.puts "没有需要压缩的 framework 文件:#{framework_name}"
81
+ return
78
82
  end
79
83
 
80
84
  UI.puts "Compressing #{framework_name} into #{output_name}"
81
85
  `zip --symlinks -r #{output_name} #{framework_name}`
82
-
83
86
  end
84
87
  end
85
88
 
@@ -114,6 +117,10 @@ module CBin
114
117
  CBin::Config::Builder.instance.framework_name(@spec)
115
118
  end
116
119
 
120
+ def framework_name_zip
121
+ CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip"
122
+ end
123
+
117
124
  def library_name
118
125
  CBin::Config::Builder.instance.library_name(@spec)
119
126
  end
@@ -130,6 +137,7 @@ module CBin
130
137
  CBin::Config::Builder.instance.gen_dir
131
138
  end
132
139
 
140
+
133
141
  def spec_file
134
142
  @spec_file ||= begin
135
143
  if @podspec
@@ -0,0 +1,63 @@
1
+ require 'yaml'
2
+ require 'cocoapods-imy-bin/config/config'
3
+
4
+ module CBin
5
+ class Build
6
+
7
+ class Utils
8
+
9
+ def Utils.is_framework(spec)
10
+ if Utils.uses_frameworks?
11
+ return true
12
+ end
13
+
14
+ return Utils.is_swift_module(spec)
15
+ end
16
+
17
+ def Utils.is_swift_module(spec)
18
+
19
+ is_framework = false
20
+ dir = File.join(CBin::Config::Builder.instance.gen_dir, CBin::Config::Builder.instance.target_name)
21
+ #auto 走这里
22
+ if File.exist?(dir)
23
+ Dir.chdir(dir) do
24
+ public_headers = Array.new
25
+ spec_header_dir = "./Headers/Public/#{spec.name}"
26
+
27
+ unless File.exist?(spec_header_dir)
28
+ spec_header_dir = "./Pods/Headers/Public/#{spec.name}"
29
+ end
30
+ return false unless File.exist?(spec_header_dir)
31
+
32
+ is_framework = File.exist?(File.join(spec_header_dir, "#{spec.name}-umbrella.h"))
33
+ end
34
+ end
35
+
36
+ if $ARGV[1] == "local"
37
+ is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_build_dir, "#{spec.name}.framework"))
38
+ unless is_framework
39
+ is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{spec.name}","Swift Compatibility Header"))
40
+ end
41
+ end
42
+
43
+ is_framework
44
+ end
45
+
46
+ def Utils.uses_frameworks?
47
+ uses_frameworks = false
48
+ Pod::Config.instance.podfile.target_definitions.each do |key,value|
49
+ if key != "Pods"
50
+ uses_frameworks = value.uses_frameworks?
51
+ if uses_frameworks
52
+ break ;
53
+ end
54
+ end
55
+ end
56
+
57
+ return uses_frameworks
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+ end