cocoapods-imy-bin 0.3.0.11 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 053c2971deff73611963c8a4382c4bd1291ddc13
4
- data.tar.gz: 4026e712a30ad0a92cc5f2b77638362cf183c688
2
+ SHA256:
3
+ metadata.gz: 9615d9bdb0593016773bd1eef955f538a514f95df8e3448857e56b6a08c9a9e7
4
+ data.tar.gz: 3e17dae46e3bd0342915a98867ec14f4e1884810bb6e650d4cefa6d96038ad39
5
5
  SHA512:
6
- metadata.gz: 1aa193c1293ffceaa47ef0a926db26749e182771a86bad1bcd1be7a9227d7e7b601ea0efce9cfd71454c1796c2ec1ffb4fae8ab8c475b11b7269f67fe1644ca6
7
- data.tar.gz: e5cff6c4998c8ca5bf56bd1c4b85802af2a465fb5f28e9cad9968998f9588948559332401da006724db91524abdae7dfce767837f43742ad2af5b8a374669181
6
+ metadata.gz: 44987c514c588474b9b6ef7fe1559eaf0aee3a0c60c5423f247d889342cdba4880f3fa02e488aa50f68acf3dbf697f4631bae9f83f9cf0431caf22da25134e33
7
+ data.tar.gz: ca023cae9c83faa5ae8a6d8e811e55cffa39483204ebb4fc12c62a475fe01c50caf7a99269e366aea4bf0bad2ca568fd77065c61576163227db0f2557b34afcc
@@ -46,11 +46,14 @@ module Pod
46
46
  super
47
47
  end
48
48
 
49
+ def validate!
50
+ help! "未找到 podspec文件" unless @podspec
51
+ super
52
+ end
53
+
49
54
  def run
55
+ @specification = Specification.from_file(@podspec)
50
56
 
51
- unless @podspec
52
- raise Informative, "未找到 podspec文件"
53
- end
54
57
  sources_sepc = run_archive
55
58
 
56
59
  fail_push_specs = []
@@ -120,7 +123,7 @@ module Pod
120
123
  argvs += ["--env=#{@env}"]
121
124
  end
122
125
  argvs += ["--configuration=#{@config}"]
123
-
126
+
124
127
  archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
125
128
  archive.validate!
126
129
  sources_sepc = archive.run
@@ -175,17 +178,19 @@ module Pod
175
178
 
176
179
  #Dir.glob 可替代
177
180
  def find_podspec
181
+ name = nil
178
182
  Pathname.pwd.children.each do |child|
179
183
  puts child
180
184
  if File.file?(child)
181
185
  if child.extname == '.podspec'
182
- name = File.basename(child)
183
- unless name.include?("binary-template")
184
- return name
185
- end
186
+ name = File.basename(child)
187
+ unless name.include?("binary-template")
188
+ return name
189
+ end
186
190
  end
187
191
  end
188
192
  end
193
+ return name
189
194
  end
190
195
 
191
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
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.3.0.11'
3
+ VERSION = '0.3.1.2'
4
4
  end
5
5
 
6
6
  module Pod
@@ -1,7 +1,7 @@
1
-
2
-
1
+ require 'cocoapods/installer/project_cache/target_metadata.rb'
3
2
  require 'parallel'
4
3
  require 'cocoapods'
4
+ require 'xcodeproj'
5
5
  require 'cocoapods-imy-bin/native/pod_source_installer'
6
6
 
7
7
  module Pod
@@ -93,6 +93,26 @@ module Pod
93
93
  end
94
94
  end
95
95
  end
96
+
97
+ alias old_write_lockfiles write_lockfiles
98
+ def write_lockfiles
99
+ old_write_lockfiles
100
+ if File.exist?('Podfile_local')
101
+
102
+ project = Xcodeproj::Project.open(config.sandbox.project_path)
103
+ #获取主group
104
+ group = project.main_group
105
+ group.set_source_tree('SOURCE_ROOT')
106
+ #向group中添加 文件引用
107
+ file_ref = group.new_reference(config.sandbox.root + '../Podfile_local')
108
+ #podfile_local排序
109
+ podfile_local_group = group.children.last
110
+ group.children.pop
111
+ group.children.unshift(podfile_local_group)
112
+ #保存
113
+ project.save
114
+ end
115
+ end
96
116
  end
97
117
 
98
118
  module Downloader
@@ -5,19 +5,25 @@ require 'cocoapods/user_interface'
5
5
  Pod::HooksManager.register('cocoapods-imy-bin', :pre_install) do |_context, _|
6
6
  require 'cocoapods-imy-bin/native'
7
7
 
8
- # pod bin repo update 更新二进制私有源
9
- Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
10
-
11
- # 有插件/本地库 且是dev环境下,默认进入源码白名单 过滤 archive命令
12
- if _context.podfile.plugins.keys.include?('cocoapods-imy-bin') && _context.podfile.configuration_env == 'dev'
13
- dependencies = _context.podfile.dependencies
14
- dependencies.each do |d|
15
- next unless d.respond_to?(:external_source) &&
16
- d.external_source.is_a?(Hash) &&
17
- !d.external_source[:path].nil? &&
18
- $ARGV[1] != 'archive'
19
- _context.podfile.set_use_source_pods d.name
20
- end
8
+ #pod bin update || install 不走这里
9
+ if $ARGV[1] = 'update' || $ARGV[1] != 'install'
10
+
11
+ else
12
+ # pod bin repo update 更新二进制私有源
13
+ Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
14
+
15
+ # 有插件/本地库 且是dev环境下,默认进入源码白名单 过滤 archive命令
16
+ if _context.podfile.plugins.keys.include?('cocoapods-imy-bin') && _context.podfile.configuration_env == 'dev'
17
+ dependencies = _context.podfile.dependencies
18
+ dependencies.each do |d|
19
+ next unless d.respond_to?(:external_source) &&
20
+ d.external_source.is_a?(Hash) &&
21
+ !d.external_source[:path].nil? &&
22
+ $ARGV[1] != 'archive'
23
+ _context.podfile.set_use_source_pods d.name
24
+ end
25
+ end
26
+
21
27
  end
22
28
 
23
29
  # 同步 BinPodfile 文件
@@ -39,16 +45,22 @@ Pod::HooksManager.register('cocoapods-imy-bin', :pre_install) do |_context, _|
39
45
  end
40
46
 
41
47
  Pod::HooksManager.register('cocoapods-imy-bin', :source_provider) do |context, _|
42
- sources_manager = Pod::Config.instance.sources_manager
43
- podfile = Pod::Config.instance.podfile
48
+ #pod bin update || install 不走这里
49
+ if $ARGV[1] == 'update' || $ARGV[1] != 'install'
50
+
51
+ else
52
+ sources_manager = Pod::Config.instance.sources_manager
53
+ podfile = Pod::Config.instance.podfile
44
54
 
45
- if podfile
46
- # 添加源码私有源 && 二进制私有源
47
- added_sources = [sources_manager.code_source]
48
- if podfile.use_binaries? || podfile.use_binaries_selector
49
- added_sources << sources_manager.binary_source
50
- added_sources.reverse!
51
- end
52
- added_sources.each { |source| context.add_source(source) }
55
+ if podfile
56
+ # 添加源码私有源 && 二进制私有源
57
+ added_sources = [sources_manager.code_source]
58
+ if podfile.use_binaries? || podfile.use_binaries_selector
59
+ added_sources << sources_manager.binary_source
60
+ added_sources.reverse!
61
+ end
62
+ added_sources.each { |source| context.add_source(source) }
63
+ end
53
64
  end
65
+
54
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-imy-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.11
4
+ version: 0.3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 苏良锦
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
11
+ date: 2021-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: cocoapods-generate
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.0.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -96,12 +96,12 @@ files:
96
96
  - lib/cocoapods-imy-bin/command/bin/archive.rb
97
97
  - lib/cocoapods-imy-bin/command/bin/auto.rb
98
98
  - lib/cocoapods-imy-bin/command/bin/code.rb
99
+ - lib/cocoapods-imy-bin/command/bin/dup.rb
99
100
  - lib/cocoapods-imy-bin/command/bin/imy.rb
100
101
  - lib/cocoapods-imy-bin/command/bin/init.rb
101
102
  - lib/cocoapods-imy-bin/command/bin/initHotKey.rb
102
103
  - lib/cocoapods-imy-bin/command/bin/install.rb
103
104
  - lib/cocoapods-imy-bin/command/bin/lib/lint.rb
104
- - lib/cocoapods-imy-bin/command/bin/local.rb
105
105
  - lib/cocoapods-imy-bin/command/bin/repo/update.rb
106
106
  - lib/cocoapods-imy-bin/command/bin/spec/create.rb
107
107
  - lib/cocoapods-imy-bin/command/bin/spec/push.rb
@@ -120,11 +120,6 @@ files:
120
120
  - lib/cocoapods-imy-bin/helpers/framework_builder.rb
121
121
  - lib/cocoapods-imy-bin/helpers/library.rb
122
122
  - lib/cocoapods-imy-bin/helpers/library_builder.rb
123
- - lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb
124
- - lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb
125
- - lib/cocoapods-imy-bin/helpers/local/local_framework.rb
126
- - lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb
127
- - lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb
128
123
  - lib/cocoapods-imy-bin/helpers/sources_helper.rb
129
124
  - lib/cocoapods-imy-bin/helpers/spec_creator.rb
130
125
  - lib/cocoapods-imy-bin/helpers/spec_files_helper.rb
@@ -174,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
169
  - !ruby/object:Gem::Version
175
170
  version: '0'
176
171
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.5.2.3
172
+ rubygems_version: 3.0.1
179
173
  signing_key:
180
174
  specification_version: 4
181
175
  summary: cocoapods-imy-bin is a plugin which helps develpers switching pods between
@@ -1,165 +0,0 @@
1
-
2
- require 'cocoapods-imy-bin/native/podfile'
3
- require 'cocoapods/command/gen'
4
- require 'cocoapods/generate'
5
- require 'cocoapods-imy-bin/helpers/local/local_framework_builder'
6
- require 'cocoapods-imy-bin/helpers/local/local_library_builder'
7
- require 'cocoapods-imy-bin/helpers/local/local_build_helper'
8
- require 'cocoapods-imy-bin/helpers/spec_source_creator'
9
- require 'cocoapods-imy-bin/config/config_builder'
10
-
11
- module Pod
12
- class Command
13
- class Bin < Command
14
- class Local < Bin
15
- self.summary = '根据podfile中信息 将本地已存在的组件静态包 归档,需要归档的组件由外部传入'
16
- self.description = <<-DESC
17
- 根据podfile中信息 将本地已存在的组件静态包 归档,需要归档的组件由外部传入
18
- 仅支持 iOS 平台
19
- 此静态 framework/.a 不包含依赖组件的 symbol
20
-
21
- 一个用ccache,一个是cocoapods-imy-bin插件支持下的,
22
- 拿xcodebuild生成的中间构建产物,如生成的 libIMYYQHome.a,利用cocoapods-imy-bin 制作成二进制静态库,保存起来。
23
- 下次pod update 工程时,在pod update时去捞已经生成的二进制组件打包。这样可以大大减少编译时间
24
-
25
- 制作流程:
26
- 每次pod update 时记录无二进制组件的库,build完后,自动制作缺失二进制组件库。
27
- 如果pod update 时无二进制组件的库,采用源码编译,源码编译同时有ccache缓存支持,也能加快速度
28
- DESC
29
-
30
- def self.options
31
- [
32
- ['--no-clean', '保留构建中间产物'],
33
- ['--framework-output', '输出framework文件'],
34
- ['--no-zip', '不压缩静态 framework 为 zip'],
35
- ['--make-binary-specs', '需要制作spec集合'],
36
- ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
37
- ].concat(Pod::Command::Gen.options).concat(super).uniq
38
- end
39
-
40
- def initialize(argv)
41
- @env = argv.option('env') || 'dev'
42
- CBin.config.set_configuration_env(@env)
43
- UI.warn "====== cocoapods-imy-bin #{CBin::VERSION} 版本 ======== \n "
44
- UI.warn "====== #{@env} 环境 ======== "
45
-
46
-
47
- @make_binary_specs = argv.option('make-binary-specs') || []
48
- @framework_output = argv.flag?('framework-output', false)
49
- @clean = argv.flag?('no-clean', true)
50
- @zip = argv.flag?('zip', true)
51
- @sources = argv.option('sources') || []
52
- @platform = Platform.new(:ios)
53
-
54
- @target_name = CBin::Config::Builder.instance.target_name
55
- @local_build_dir_name = CBin::Config::Builder.instance.xcode_build_name
56
- @local_build_dir = CBin::Config::Builder.instance.xcode_build_dir
57
-
58
- @framework_path
59
- super
60
- end
61
-
62
- def run
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_rf(Dir.glob("#{CBin::Config::Builder.instance.zip_dir}/*"))
68
- # end
69
-
70
- sources_spec = []
71
- Dir.chdir(CBin::Config::Builder.instance.local_psec_dir) do
72
- spec_files = Dir.glob(%w[*.json *.podspec])
73
- spec_files.each do |file|
74
- spec = Pod::Specification.from_file(file)
75
- sources_spec << spec
76
- end
77
- end
78
-
79
- build(sources_spec)
80
- end
81
-
82
- def build(make_binary_specs)
83
- # 如果没要求,就清空依赖库数据
84
- sources_sepc = []
85
- make_binary_specs.uniq.each do |spec|
86
- next if spec.name.include?('/')
87
- next if spec.name == @target_name
88
- #过滤白名单
89
- next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name)
90
- #过滤 git
91
- if spec.source[:git] && spec.source[:git]
92
- spec_git = spec.source[:git]
93
- spec_git_res = false
94
- CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
95
- spec_git_res = spec_git.include?(ignore_git)
96
- break if spec_git_res
97
- end
98
- next if spec_git_res
99
- end
100
- UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks']
101
- next if spec.attributes_hash['vendored_frameworks'] && @target_name != spec.name #过滤带有vendored_frameworks的
102
- next if (spec.attributes_hash['ios'] && spec.attributes_hash['ios']['vendored_frameworks']) #过滤带有vendored_frameworks的
103
- #获取没有制作二进制版本的spec集合
104
-
105
- next unless library_exist(spec)
106
-
107
- # 获取没有制作二进制版本的spec集合
108
- sources_sepc << spec
109
- end
110
-
111
- fail_build_specs = []
112
- sources_sepc.uniq.each do |spec|
113
- begin
114
- builder = CBin::LocalBuild::Helper.new(spec,
115
- @platform,
116
- @framework_output,
117
- @zip,
118
- @clean,
119
- @target_name,
120
- @local_build_dir_name,
121
- @local_build_dir)
122
- builder.build
123
- CBin::Upload::Helper.new(spec, @code_dependencies, @sources).upload
124
- rescue StandardError
125
- fail_build_specs << spec
126
- end
127
- end
128
-
129
- if fail_build_specs.any?
130
- fail_build_specs.uniq.each do |spec|
131
- UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
132
- end
133
- end
134
-
135
- success_specs = sources_sepc - fail_build_specs
136
- if success_specs.any?
137
- success_specs.uniq.each do |spec|
138
- UI.warn " =======【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!!"
139
- end
140
- end
141
- # pod repo update
142
- UI.section("\nUpdating Spec Repositories\n".yellow) do
143
- Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
144
- end
145
- end
146
-
147
- private
148
-
149
- def library_exist(spec)
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
160
- end
161
-
162
- end
163
- end
164
- end
165
- end
@@ -1,57 +0,0 @@
1
-
2
-
3
- # copy from https://github.com/CocoaPods/cocoapods-packager
4
- require 'cocoapods-imy-bin/config/config_builder'
5
-
6
- module CBin
7
- class LocalLibrary
8
- attr_reader :headers_path
9
- attr_reader :resources_path
10
- attr_reader :root_path
11
- attr_reader :versions_path
12
- attr_reader :name_path
13
-
14
- def initialize(name, platform, version)
15
- @name = name
16
- @platform = platform
17
- @version = version
18
- end
19
-
20
- def make
21
- make_root
22
- make_library
23
- make_headers
24
- make_resources
25
- end
26
-
27
- def delete_resources
28
- Pathname.new(@resources_path).rmtree
29
- (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
30
- end
31
-
32
- private
33
-
34
- def make_library
35
- @name_path = CBin::Config::Builder.instance.library_name_version(@name, @version)
36
- @fwk_path = @root_path + Pathname.new(@name_path)
37
- @fwk_path.mkdir unless @fwk_path.exist?
38
-
39
- @versions_path = @fwk_path
40
- end
41
-
42
- def make_headers
43
- @headers_path = @versions_path + Pathname.new('Headers')
44
- # @headers_path.mkpath unless @headers_path.exist?
45
- end
46
-
47
- def make_resources
48
- @resources_path = @versions_path + Pathname.new('Resources')
49
- # @resources_path.mkpath unless @resources_path.exist?
50
- end
51
-
52
- def make_root
53
- @root_path = Pathname.new(@platform)
54
- @root_path.mkpath unless @root_path.exist?
55
- end
56
- end
57
- end
@@ -1,178 +0,0 @@
1
-
2
-
3
- # copy from https://github.com/CocoaPods/cocoapods-packager
4
-
5
- require 'cocoapods-imy-bin/native/podfile'
6
- require 'cocoapods/command/gen'
7
- require 'cocoapods/generate'
8
- require 'cocoapods-imy-bin/helpers/framework_builder'
9
- require 'cocoapods-imy-bin/helpers/library_builder'
10
- require 'cocoapods-imy-bin/config/config_builder'
11
-
12
- module CBin
13
- class LocalBuild
14
- class Helper
15
- include Pod
16
- #class var
17
- @@build_defines = ""
18
- #Debug下还待完成
19
- def initialize(spec,
20
- platform,
21
- framework_output,
22
- zip,
23
- clean,
24
- target_name,
25
- local_build_dir_name,
26
- local_build_dir)
27
- @spec = spec
28
- @target_name = target_name
29
- @platform = platform
30
-
31
- @framework_output = framework_output
32
- @zip = zip
33
- @local_build_dir_name = local_build_dir_name
34
- @local_build_dir = local_build_dir
35
- @clean = clean
36
- @framework_path
37
- @is_library = !is_framework
38
- end
39
-
40
- def build
41
- UI.section("Building static framework #{@spec}") do
42
-
43
- build_static_framework
44
- if @is_library
45
- build_static_library
46
- zip_static_framework if @zip &&= @framework_output
47
- zip_static_library
48
- else
49
- zip_static_framework
50
- end
51
-
52
- clean_workspace if @clean
53
- end
54
-
55
- end
56
-
57
- def build_static_framework
58
- file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
59
- Dir.chdir(workspace_directory) do
60
- builder = CBin::LocalFramework::Builder.new(@spec, file_accessor, @platform, @local_build_dir_name,@local_build_dir, @is_library, frameWork_dir)
61
- @framework_path = builder.create
62
- end
63
- end
64
-
65
- def build_static_library
66
- source_dir = zip_dir
67
- file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
68
- Dir.chdir(workspace_directory) do
69
- builder = CBin::LocalLibrary::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path)
70
- builder.build
71
- end
72
- end
73
-
74
- def zip_static_framework
75
- Dir.chdir(zip_dir) do
76
- # output_name = "#{framework_name}.zip"
77
- output_name = File.join(zip_dir, framework_name_zip)
78
- unless File.exist?(framework_name)
79
- UI.warn "没有需要压缩的 framework 文件:#{framework_name}"
80
- end
81
-
82
- UI.puts "Compressing #{framework_name} into #{output_name}"
83
- `zip --symlinks -r #{output_name} #{framework_name}`
84
-
85
- end
86
- end
87
-
88
- def zip_static_library
89
- Dir.chdir(zip_dir) do
90
- output_library = "#{library_name}.zip"
91
- unless File.exist?(library_name)
92
- raise Informative, "没有需要压缩的 library 文件:#{library_name}"
93
- end
94
-
95
- UI.puts "Compressing #{library_name} into #{output_library}"
96
-
97
- `zip --symlinks -r #{output_library} #{library_name}`
98
- end
99
-
100
- end
101
-
102
-
103
- def clean_workspace
104
- UI.puts 'Cleaning workspace'
105
-
106
- FileUtils.rm_rf(gen_name)
107
- Dir.chdir(zip_dir) do
108
- FileUtils.rm_rf(framework_name) if @zip
109
- FileUtils.rm_rf(library_name)
110
- FileUtils.rm_rf(framework_name) unless @framework_output
111
- FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output
112
- end
113
- end
114
-
115
- def framework_name
116
- CBin::Config::Builder.instance.framework_name(@spec)
117
- end
118
-
119
- def framework_name_zip
120
- CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip"
121
- end
122
-
123
- def library_name
124
- CBin::Config::Builder.instance.library_name(@spec)
125
- end
126
-
127
- def workspace_directory
128
- @local_build_dir
129
- end
130
-
131
- def zip_dir
132
- CBin::Config::Builder.instance.zip_dir
133
- end
134
-
135
- def gen_name
136
- CBin::Config::Builder.instance.gen_name
137
- end
138
-
139
- def is_library
140
- File.exist?(File.join(@local_build_dir, "lib#{@spec.name}.a"))
141
- end
142
-
143
- # 使用了user_framework 会有#{@spec.name}.framework
144
- # 未使用的 需要判断文件
145
- def is_framework
146
- res = File.exist?(File.join(@local_build_dir, "#{@spec.name}.framework"))
147
- unless res
148
- res = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}","Swift Compatibility Header"))
149
- end
150
- res
151
- end
152
-
153
- def frameWork_dir
154
- dir = File.join(@local_build_dir, "#{@spec.name}.framework")
155
- unless File.exist?(dir)
156
- dir = File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}")
157
- end
158
- dir
159
- end
160
-
161
- def spec_file
162
- @spec_file ||= begin
163
- if @podspec
164
- find_spec_file(@podspec)
165
- else
166
- if code_spec_files.empty?
167
- raise Informative, '当前目录下没有找到可用源码 podspec.'
168
- end
169
-
170
- spec_file = code_spec_files.first
171
- spec_file
172
- end
173
- end
174
- end
175
-
176
- end
177
- end
178
- end
@@ -1,85 +0,0 @@
1
-
2
-
3
- # copy from https://github.com/CocoaPods/cocoapods-packager
4
-
5
- module CBin
6
- class LocalFramework
7
- attr_reader :headers_path
8
- attr_reader :module_map_path
9
- attr_reader :resources_path
10
- attr_reader :root_path
11
- attr_reader :versions_path
12
- attr_reader :swift_module_path
13
- attr_reader :fwk_path
14
-
15
- def initialize(name, platform, local_build_dir)
16
- @name = name
17
- @platform = platform
18
- @local_build_dir = local_build_dir
19
- end
20
-
21
- def make
22
- make_root
23
- make_framework
24
- make_headers
25
- make_resources
26
- make_current_version
27
- end
28
-
29
- def delete_resources
30
- Pathname.new(@resources_path).rmtree
31
- (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
32
- end
33
-
34
- def remove_current_version
35
- FileUtils.rm_f(File.join(@fwk_path,@name))
36
- FileUtils.rm_f(File.join(@fwk_path,"Headers"))
37
- FileUtils.rm_f(File.join(@fwk_path,"Resources"))
38
-
39
- FileUtils.cp_r("#{@versions_path}/.", @fwk_path)
40
- # FileUtils.remove_dir(@versions_path)
41
- FileUtils.remove_dir("#{@fwk_path}/Versions")
42
-
43
- # current_version_path = @versions_path + Pathname.new('../Current')
44
- # `ln -sf A #{current_version_path}`
45
- # `ln -sf Versions/Current/Headers #{@fwk_path}/`
46
- # `ln -sf Versions/Current/Resources #{@fwk_path}/`
47
- # `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
48
- end
49
- private
50
-
51
- def make_current_version
52
- current_version_path = @versions_path + Pathname.new('../Current')
53
- `ln -sf A #{current_version_path}`
54
- `ln -sf Versions/Current/Headers #{@fwk_path}/`
55
- `ln -sf Versions/Current/Resources #{@fwk_path}/`
56
- `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
57
- end
58
-
59
- def make_framework
60
- @fwk_path = @root_path + Pathname.new(@name + '.framework')
61
- FileUtils.remove_dir(@fwk_path) if @fwk_path.exist?
62
- @fwk_path.mkdir unless @fwk_path.exist?
63
-
64
- @module_map_path = @fwk_path + Pathname.new('Modules')
65
- @versions_path = @fwk_path + Pathname.new('Versions/A')
66
- @fwk_path.exist?
67
- @swift_module_path = @module_map_path + Pathname.new(@name + '.swiftmodule')
68
- end
69
-
70
- def make_headers
71
- @headers_path = @versions_path + Pathname.new('Headers')
72
- @headers_path.mkpath unless @headers_path.exist?
73
- end
74
-
75
- def make_resources
76
- @resources_path = @versions_path + Pathname.new('Resources')
77
- @resources_path.mkpath unless @resources_path.exist?
78
- end
79
-
80
- def make_root
81
- @root_path = Pathname.new(File.join(@local_build_dir, @platform))
82
- @root_path.mkpath unless @root_path.exist?
83
- end
84
- end
85
- end
@@ -1,227 +0,0 @@
1
-
2
-
3
- # copy from https://github.com/CocoaPods/cocoapods-packager
4
-
5
- require 'cocoapods-imy-bin/helpers/local/local_framework'
6
- require 'English'
7
- require 'cocoapods-imy-bin/config/config_builder'
8
- require 'shellwords'
9
-
10
- module CBin
11
- class LocalFramework
12
- class Builder
13
- include Pod
14
- #Debug下还待完成
15
- def initialize(spec, file_accessor, platform, local_build_dir_name, local_build_dir, is_library = true, framework_BuildProductsPath = "")
16
- @spec = spec
17
- @file_accessor = file_accessor
18
- @platform = platform
19
- @local_build_dir_name = local_build_dir_name
20
- @local_build_dir = local_build_dir
21
- @is_library = is_library
22
- @framework_BuildProductsPath = framework_BuildProductsPath
23
- end
24
-
25
- def create
26
- begin
27
- #如果是.a 文件, 或者 swift下,是.a文件的
28
- if @is_library || (!@is_library && @framework_BuildProductsPath != framework_name)
29
-
30
- UI.section("Building static library #{@spec}") do
31
- output = framework.versions_path + Pathname.new(@spec.name)
32
- build_static_library_for_ios(output)
33
- res = copy_headers
34
- # maybe fails for copy_headers
35
- if res
36
- copy_resources
37
- cp_to_source_dir
38
- else
39
- FileUtils.remove_dir(framework.fwk_path) if File.exist?(framework.fwk_path)
40
- return nil
41
- end
42
- end
43
-
44
- else
45
- UI.section("Building static framework #{@spec}") do
46
- output = File.join(CBin::Config::Builder.instance.zip_dir,"#{@spec.name}.framework")
47
- build_static_framework_for_ios(output)
48
- end
49
- end
50
-
51
- rescue StandardError
52
- UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本组装失败 ."
53
- end
54
-
55
- framework
56
- end
57
-
58
- private
59
-
60
- def cp_to_source_dir
61
- # 删除Versions 软链接
62
- framework.remove_current_version if CBin::Build::Utils.is_swift_module(@spec)
63
-
64
- target_dir = File.join(CBin::Config::Builder.instance.root_dir,CBin::Config::Builder.instance.framework_file(@spec))
65
- FileUtils.rm_rf(target_dir) if File.exist?(target_dir)
66
-
67
- zip_dir = CBin::Config::Builder.instance.zip_dir
68
- FileUtils.mkdir_p(zip_dir) unless File.exist?(zip_dir)
69
-
70
- `cp -fa #{@platform}/#{CBin::Config::Builder.instance.framework_name(@spec)} #{target_dir}`
71
- end
72
-
73
-
74
- def copy_headers
75
- #by slj 如果没有头文件,去 "Headers/Public"拿
76
- # if public_headers.empty?
77
- Dir.chdir(File.join(Pod::Config.instance.installation_root,'Pods')) do
78
-
79
- if File.exist?("./Headers/Public/#{@spec.name}")
80
- #走 podsepc中的public_headers
81
- public_headers = Array.new
82
-
83
- Dir.chdir("./Headers/Public/#{@spec.name}") do
84
- headers = Dir.glob('*.h')
85
- headers.each do |h|
86
- public_headers << Pathname.new(File.join(Dir.pwd,h))
87
- end
88
- end
89
-
90
- UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
91
-
92
- public_headers.each do |h|
93
- `ditto #{h} #{framework.headers_path}/#{h.basename}`
94
- end
95
-
96
- # If custom 'module_map' is specified add it to the framework distribution
97
- # otherwise check if a header exists that is equal to 'spec.name', if so
98
- # create a default 'module_map' one using it.
99
- if !@spec.module_map.nil?
100
- module_map_file = @file_accessor.module_map
101
- if Pathname(module_map_file).exist?
102
- module_map = File.read(module_map_file)
103
- end
104
- elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}-umbrella.h")
105
- module_map = <<-MAP
106
- framework module #{@spec.name} {
107
- umbrella header "#{@spec.name}-umbrella.h"
108
-
109
- export *
110
- module * { export * }
111
- }
112
- MAP
113
- end
114
-
115
- unless module_map.nil?
116
- UI.message "Writing module map #{module_map}"
117
- unless framework.module_map_path.exist?
118
- framework.module_map_path.mkpath
119
- end
120
- File.write("#{framework.module_map_path}/module.modulemap", module_map)
121
-
122
- # unless framework.swift_module_path.exist?
123
- # framework.swift_module_path.mkpath
124
- # end
125
- # DO BuildProductsPath swiftModule拷贝到 framework.swift_module_path
126
- swiftmodule_path = File.join(@framework_BuildProductsPath, "#{@spec.name}.swiftmodule")
127
- if File.directory?(swiftmodule_path)
128
- FileUtils.cp_r("#{swiftmodule_path}/.", framework.swift_module_path)
129
- end
130
- swift_Compatibility_Header = "#{@framework_BuildProductsPath}/Swift\ Compatibility\ Header/#{@spec.name}-Swift.h"
131
- FileUtils.cp(swift_Compatibility_Header,framework.headers_path) if File.exist?(swift_Compatibility_Header)
132
- info_plist_file = File.join(File.dirname(File.dirname(__FILE__)),"info.plist")
133
- FileUtils.cp(info_plist_file,framework.fwk_path)
134
- end
135
- else
136
- UI.warn "== Headers/Public/#{@spec.name} no exist"
137
- return false
138
- end
139
-
140
- end
141
- return true
142
- end
143
-
144
- def copy_resources
145
-
146
-
147
- Dir.chdir(Pod::Config.instance.sandbox_root) do
148
-
149
- bundles = Dir.glob('./build/*.bundle')
150
-
151
- bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
152
- consumer = spec.consumer(@platform)
153
- consumer.resource_bundles.keys +
154
- consumer.resources.map do |r|
155
- File.basename(r, '.bundle') if File.extname(r) == 'bundle'
156
- end
157
- end.compact.uniq
158
-
159
- bundles.select! do |bundle|
160
- bundle_name = File.basename(bundle, '.bundle')
161
- bundle_names.include?(bundle_name)
162
- end
163
-
164
- if bundles.count > 0
165
- UI.message "Copying bundle files #{bundles}"
166
- bundle_files = bundles.join(' ')
167
- `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
168
- end
169
-
170
- real_source_dir = @spec.name
171
- resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
172
- expand_paths(real_source_dir, spec.consumer(@platform).resources)
173
- end.compact.uniq
174
-
175
- if (resources.count == 0 || (resources.count == 1 && resources[0].count == 0)) && bundles.count == 0
176
- framework.delete_resources
177
- return
178
- end
179
-
180
- if resources.count > 0
181
- #把 路径转义。 避免空格情况下拷贝失败
182
- escape_resource = []
183
- resources.each do |source|
184
- escape_resource << Shellwords.join(source)
185
- end
186
- UI.message "Copying resources #{escape_resource}"
187
- `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
188
- end
189
-
190
- end
191
-
192
- end
193
-
194
-
195
- def build_static_library_for_ios(output)
196
- `cp -rp #{library_name} #{output}`
197
- end
198
-
199
- def build_static_framework_for_ios(output)
200
- FileUtils.cp_r(framework_name, output)
201
- end
202
-
203
- def library_name
204
- File.join(@local_build_dir, "lib#{@spec.name}.a")
205
- end
206
-
207
- def framework_name
208
- File.join(@local_build_dir, "#{@spec.name}.framework")
209
- end
210
-
211
- def expand_paths(source_dir, path_specs)
212
- path_specs.map do |path_spec|
213
- Dir.glob(File.join(source_dir, path_spec))
214
- end
215
- end
216
-
217
- def framework
218
- @framework ||= begin
219
- framework = CBin::LocalFramework.new(@spec.name, @platform.name.to_s,@local_build_dir)
220
- framework.make
221
- framework
222
- end
223
- end
224
-
225
- end
226
- end
227
- end
@@ -1,92 +0,0 @@
1
-
2
-
3
-
4
- # copy from https://github.com/CocoaPods/cocoapods-packager
5
-
6
- require 'cocoapods-imy-bin/helpers/framework.rb'
7
- require 'cocoapods-imy-bin/helpers/library.rb'
8
-
9
- require 'English'
10
-
11
- module CBin
12
- class LocalLibrary
13
- class Builder
14
- include Pod
15
-
16
- def initialize(spec, file_accessor, platform, source_dir,framework_path)
17
- @spec = spec
18
- @source_dir = source_dir
19
- @file_accessor = file_accessor
20
- @platform = platform
21
- @framework = framework_path
22
- @source_files = "#{@source_dir}/#{library.name_path}"
23
- @source_zip_file = "#{@source_files}.zip"
24
- end
25
-
26
- def build
27
- UI.section("Building static library #{@spec}") do
28
-
29
- clean_source_dir
30
-
31
- copy_headers
32
- copy_library
33
- copy_resources
34
-
35
- cp_to_source_dir
36
- end
37
- end
38
-
39
- private
40
-
41
- def clean_source_dir
42
- FileUtils.rm_rf(@source_files) if File.exist?(@source_files)
43
- FileUtils.rm_rf(@source_zip_file) if File.exist?(@source_zip_file)
44
- end
45
-
46
- def cp_to_source_dir
47
- target_dir = library.versions_path
48
- dest_file = "#{@source_dir}/#{library.name_path}"
49
- FileUtils.rm_rf(dest_file) if File.exist?(dest_file)
50
-
51
- `cp -fa #{target_dir} #{dest_file}/`
52
- end
53
-
54
- def copy_headers
55
- FileUtils.cp_r(framework.headers_path,library.versions_path) if File.exist?(framework.headers_path)
56
- end
57
-
58
- def copy_library
59
- src_file = "#{framework.versions_path}/#{@spec.name}"
60
- unless File.exist?(src_file)
61
- raise Informative, "framework没有文件:#{src_file}"
62
- end
63
-
64
- dest_file = "#{library.versions_path}/#{@spec.name}"
65
- rename_dest_file = "#{library.versions_path}/lib#{@spec.name}.a"
66
- FileUtils.cp_r(src_file,dest_file)
67
- File.rename(dest_file, rename_dest_file ) if File.exist?(dest_file)
68
- end
69
-
70
- def copy_resources
71
- FileUtils.cp_r(framework.resources_path,library.versions_path) if File.exist?(framework.resources_path)
72
- end
73
-
74
-
75
- def framework
76
- @framework ||= begin
77
- framework = Framework.new(@spec.name, @platform.name.to_s)
78
- framework.make
79
- framework
80
- end
81
- end
82
-
83
- def library
84
- @library ||= begin
85
- library = Library.new(@spec.name, @platform.name.to_s,@spec.version)
86
- library.make
87
- library
88
- end
89
- end
90
- end
91
- end
92
- end