cocoapods-imy-bin 0.2.6 → 0.3.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -540
  3. data/lib/cocoapods-imy-bin/command/bin/archive.rb +43 -4
  4. data/lib/cocoapods-imy-bin/command/bin/auto.rb +9 -7
  5. data/lib/cocoapods-imy-bin/command/bin/code.rb +1 -6
  6. data/lib/cocoapods-imy-bin/command/bin/local.rb +16 -7
  7. data/lib/cocoapods-imy-bin/config/config.rb +1 -1
  8. data/lib/cocoapods-imy-bin/config/config_builder.rb +39 -2
  9. data/lib/cocoapods-imy-bin/gem_version.rb +1 -1
  10. data/lib/cocoapods-imy-bin/helpers.rb +1 -0
  11. data/lib/cocoapods-imy-bin/helpers/Info.plist +0 -0
  12. data/lib/cocoapods-imy-bin/helpers/build_helper.rb +15 -7
  13. data/lib/cocoapods-imy-bin/helpers/build_utils.rb +63 -0
  14. data/lib/cocoapods-imy-bin/helpers/framework.rb +25 -2
  15. data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +172 -57
  16. data/lib/cocoapods-imy-bin/helpers/library.rb +2 -2
  17. data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +38 -6
  18. data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +20 -0
  19. data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +91 -38
  20. data/lib/cocoapods-imy-bin/helpers/sources_helper.rb +5 -2
  21. data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +65 -8
  22. data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +8 -3
  23. data/lib/cocoapods-imy-bin/native.rb +4 -0
  24. data/lib/cocoapods-imy-bin/native/analyzer.rb +2 -0
  25. data/lib/cocoapods-imy-bin/native/file_accessor.rb +28 -0
  26. data/lib/cocoapods-imy-bin/native/pod_target_installer.rb +94 -0
  27. data/lib/cocoapods-imy-bin/native/podfile_generator.rb +11 -2
  28. data/lib/cocoapods-imy-bin/native/target_validator.rb +41 -0
  29. data/lib/cocoapods-imy-bin/native/validator.rb +1 -38
  30. metadata +7 -2
@@ -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,9 +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',
160
+ "--verbose",
157
161
  *@additional_args
158
162
  ]
159
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
+
160
172
  argvs << spec_file if spec_file
161
173
 
162
174
  gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
@@ -166,6 +178,33 @@ module Pod
166
178
  end
167
179
  end
168
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
169
208
 
170
209
  def spec_file
171
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,7 +40,8 @@ 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!
44
45
 
45
46
  super
46
47
  end
@@ -56,7 +57,8 @@ module Pod
56
57
  sources_sepc.uniq.each do |spec|
57
58
  begin
58
59
  fail_push_specs << spec unless CBin::Upload::Helper.new(spec,@code_dependencies,@sources).upload
59
- rescue
60
+ rescue Object => exception
61
+ UI.puts exception
60
62
  fail_push_specs << spec
61
63
  end
62
64
  end
@@ -86,15 +88,15 @@ module Pod
86
88
  end
87
89
 
88
90
  #制作二进制包
89
- # `pod bin archive --verbose --code-dependencies --no-clean --sources=https://gitlab.xxx.com/iOS/imyspecs.git,https://cdn.cocoapods.org/ --use-libraries`
91
+
90
92
  def run_archive
91
93
  argvs = [
92
94
  "--sources=#{sources_option(@code_dependencies, @sources)},https:\/\/cdn.cocoapods.org",
93
- "--use-libraries",
94
- "--verbose"
95
+ @additional_args
95
96
  ]
96
97
 
97
98
  argvs << spec_file if spec_file
99
+ argvs.delete(Array.new)
98
100
 
99
101
  unless @clean
100
102
  argvs += ['--no-clean']
@@ -83,11 +83,6 @@ module Pod
83
83
  FileUtils.rm_rf(target_path)
84
84
 
85
85
  find_dependency = find_dependency(name)
86
- # 意义不大,需要可以使用--source参数 对 github-ios 仓库对做特殊处理
87
- # if find_dependency && find_dependency.external_source[:podspec].include?(http_gitlib_GitHub_iOS_path)
88
- # github_ios = find_dependency.external_source[:podspec]
89
- # find_dependency.external_source[:podspec] = github_ios.gsub(http_gitlib_GitHub_iOS_path,http_gitlib_iOS_path)
90
- # end
91
86
 
92
87
  spec = fetch_external_source(find_dependency, @config.podfile,@config.lockfile, @config.sandbox,true )
93
88
 
@@ -106,7 +101,6 @@ module Pod
106
101
  break
107
102
  end
108
103
  end
109
-
110
104
  find_dependency
111
105
  end
112
106
 
@@ -150,6 +144,7 @@ module Pod
150
144
  FileUtils.rm_rf(File.join(dir,basename))
151
145
  `ln -s #{target_path} #{dir}/#{basename}`
152
146
  end
147
+
153
148
  check(lib_file,dir,basename)
154
149
  end
155
150
 
@@ -61,11 +61,11 @@ module Pod
61
61
 
62
62
  def run
63
63
  # 清除之前的缓存
64
- temp = File.join(@local_build_dir, @platform.to_s)
65
- FileUtils.rm_r(temp) if File.exist? temp
66
- if File.exist?(CBin::Config::Builder.instance.zip_dir)
67
- FileUtils.rm_r(CBin::Config::Builder.instance.zip_dir)
68
- end
64
+ # temp = File.join(@local_build_dir, @platform.to_s)
65
+ # FileUtils.rm_r(temp) if File.exist? temp
66
+ # if File.exist?(CBin::Config::Builder.instance.zip_dir)
67
+ # FileUtils.rm_rf(Dir.glob("#{CBin::Config::Builder.instance.zip_dir}/*"))
68
+ # end
69
69
 
70
70
  sources_spec = []
71
71
  Dir.chdir(CBin::Config::Builder.instance.local_psec_dir) do
@@ -107,6 +107,7 @@ module Pod
107
107
  # 获取没有制作二进制版本的spec集合
108
108
  sources_sepc << spec
109
109
  end
110
+
110
111
  fail_build_specs = []
111
112
  sources_sepc.uniq.each do |spec|
112
113
  begin
@@ -146,9 +147,17 @@ module Pod
146
147
  private
147
148
 
148
149
  def library_exist(spec)
149
- File.exist?(File.join(@local_build_dir, "lib#{spec.name}.a"))
150
+ File.exist?(File.join(@local_build_dir, "lib#{spec.name}.a")) || is_framework(spec)
151
+ end
152
+ # 使用了user_framework 会有#{@spec.name}.framework
153
+ # 未使用的 需要判断文件
154
+ def is_framework(spec)
155
+ res = File.exist?(File.join(@local_build_dir, "#{spec.name}.framework"))
156
+ unless res
157
+ res = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{spec.name}","Swift Compatibility Header"))
158
+ end
159
+ res
150
160
  end
151
-
152
161
 
153
162
  end
154
163
  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.6'
3
+ VERSION = '0.3.0.11'
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
@@ -7,6 +7,8 @@ module CBin
7
7
  attr_reader :resources_path
8
8
  attr_reader :root_path
9
9
  attr_reader :versions_path
10
+ attr_reader :swift_module_path
11
+ attr_reader :fwk_path
10
12
 
11
13
  def initialize(name, platform)
12
14
  @name = name
@@ -22,8 +24,24 @@ module CBin
22
24
  end
23
25
 
24
26
  def delete_resources
25
- Pathname.new(@resources_path).rmtree
26
- (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
27
+ Pathname.new(@resources_path).rmtree if File.exist? (@resources_path)
28
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete if File.exist?(Pathname.new(@fwk_path) + Pathname.new('Resources'))
29
+ end
30
+
31
+ def remove_current_version
32
+ FileUtils.rm_f(File.join(@fwk_path,@name))
33
+ FileUtils.rm_f(File.join(@fwk_path,"Headers"))
34
+ FileUtils.rm_f(File.join(@fwk_path,"Resources"))
35
+
36
+ FileUtils.cp_r("#{@versions_path}/.", @fwk_path)
37
+ # FileUtils.remove_dir(@versions_path)
38
+ FileUtils.remove_dir("#{@fwk_path}/Versions")
39
+
40
+ # current_version_path = @versions_path + Pathname.new('../Current')
41
+ # `ln -sf A #{current_version_path}`
42
+ # `ln -sf Versions/Current/Headers #{@fwk_path}/`
43
+ # `ln -sf Versions/Current/Resources #{@fwk_path}/`
44
+ # `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
27
45
  end
28
46
 
29
47
  private
@@ -36,11 +54,16 @@ module CBin
36
54
  `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
37
55
  end
38
56
 
57
+
58
+
39
59
  def make_framework
40
60
  @fwk_path = @root_path + Pathname.new(@name + '.framework')
41
61
  @fwk_path.mkdir unless @fwk_path.exist?
42
62
 
43
63
  @module_map_path = @fwk_path + Pathname.new('Modules')
64
+ @swift_module_path = @module_map_path + Pathname.new(@name + '.swiftmodule')
65
+
66
+
44
67
  @versions_path = @fwk_path + Pathname.new('Versions/A')
45
68
  end
46
69