cocoapods-tdf-bin 0.0.1.1
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 +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +103 -0
- data/lib/cocoapods-tdf-bin.rb +2 -0
- data/lib/cocoapods-tdf-bin/command.rb +2 -0
- data/lib/cocoapods-tdf-bin/command/bin.rb +57 -0
- data/lib/cocoapods-tdf-bin/command/bin/archive.rb +222 -0
- data/lib/cocoapods-tdf-bin/command/bin/auto.rb +216 -0
- data/lib/cocoapods-tdf-bin/command/bin/code.rb +232 -0
- data/lib/cocoapods-tdf-bin/command/bin/imy.rb +46 -0
- data/lib/cocoapods-tdf-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-tdf-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-tdf-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-tdf-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-tdf-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-tdf-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-tdf-bin/command/bin/spec/push.rb +114 -0
- data/lib/cocoapods-tdf-bin/command/bin/update.rb +157 -0
- data/lib/cocoapods-tdf-bin/config/config.rb +138 -0
- data/lib/cocoapods-tdf-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-tdf-bin/config/config_builder.rb +238 -0
- data/lib/cocoapods-tdf-bin/config/config_hot_key.rb +103 -0
- data/lib/cocoapods-tdf-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-tdf-bin/gem_version.rb +10 -0
- data/lib/cocoapods-tdf-bin/helpers.rb +5 -0
- data/lib/cocoapods-tdf-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-tdf-bin/helpers/build_helper.rb +162 -0
- data/lib/cocoapods-tdf-bin/helpers/build_utils.rb +101 -0
- data/lib/cocoapods-tdf-bin/helpers/framework.rb +85 -0
- data/lib/cocoapods-tdf-bin/helpers/framework_builder.rb +283 -0
- data/lib/cocoapods-tdf-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-tdf-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-tdf-bin/helpers/sources_helper.rb +36 -0
- data/lib/cocoapods-tdf-bin/helpers/spec_creator.rb +168 -0
- data/lib/cocoapods-tdf-bin/helpers/spec_files_helper.rb +77 -0
- data/lib/cocoapods-tdf-bin/helpers/spec_source_creator.rb +228 -0
- data/lib/cocoapods-tdf-bin/helpers/upload_helper.rb +89 -0
- data/lib/cocoapods-tdf-bin/native.rb +23 -0
- data/lib/cocoapods-tdf-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-tdf-bin/native/analyzer.rb +55 -0
- data/lib/cocoapods-tdf-bin/native/configuration.rb +26 -0
- data/lib/cocoapods-tdf-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-tdf-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-tdf-bin/native/installer.rb +135 -0
- data/lib/cocoapods-tdf-bin/native/linter.rb +26 -0
- data/lib/cocoapods-tdf-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-tdf-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-tdf-bin/native/pod_target_installer.rb +94 -0
- data/lib/cocoapods-tdf-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-tdf-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-tdf-bin/native/podfile_generator.rb +199 -0
- data/lib/cocoapods-tdf-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-tdf-bin/native/resolver.rb +243 -0
- data/lib/cocoapods-tdf-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-tdf-bin/native/source.rb +35 -0
- data/lib/cocoapods-tdf-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-tdf-bin/native/specification.rb +31 -0
- data/lib/cocoapods-tdf-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-tdf-bin/native/validator.rb +40 -0
- data/lib/cocoapods-tdf-bin/source_provider_hook.rb +54 -0
- data/lib/cocoapods_plugin.rb +3 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7850a7e2d211d7344509a463662379d0acac9264c8440ea731748e8d20d2f299
|
4
|
+
data.tar.gz: f7e4d843eeded01faaf453bf7eb35f508b1276a8cc6f6bfb781e69f91fd1caf5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c995c6ab6503da88f17112b348b12c8192f0eefcc550cbca09f105fcdd54ddff9460a17e92342663a30a4198db858eae4501a613e6d0e8ca6c8ba02b78e6f5e
|
7
|
+
data.tar.gz: 5337c1c8554e26487807d1bbfa2a1abc2d29e8ec4dae195aedc9d208c702a4693b0404b09243cf16c4aef8f63abd85fb66f18b61c354257a1723b2448a0ce380
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 tripleCC <triplec.linux@gmail.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.
|
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
### 一、概要
|
2
|
+
|
3
|
+
cocoapods-tdf-bin功能点:
|
4
|
+
|
5
|
+
- 组件二进制化,`无入侵式`支持组件二进制化,完全自动化,无需手动操作。致力于解决Ci打包速度慢、研发编译慢等编译问题。
|
6
|
+
|
7
|
+
cocoapods-imy-bin插件所关联的组件二进制化策略:
|
8
|
+
|
9
|
+
- 预先将打包成 `.framework` 的组件保存到静态服务器上,并在 `install` 时,去下载组件对应的二进制版本,以减少组件编译时间,达到加快 App 打包、组件发布等操作的目的。
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
### 二、准备工作
|
14
|
+
|
15
|
+
#### 1. 安装插件
|
16
|
+
|
17
|
+
```shell
|
18
|
+
gem install cocoapods-tdf-bin # 没有权限用 sudo gem install cocoapods-tdf-bin
|
19
|
+
```
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
### 三、使用二进制插件
|
24
|
+
|
25
|
+
#### 1. 环境搭建
|
26
|
+
|
27
|
+
使用二进制时,本插件需要提供以下资源:
|
28
|
+
|
29
|
+
- [二进制私有源仓库(保存组件二进制版本 podspec)](https://git.2dfire.net/ios/cocoapods-spec-binary);
|
30
|
+
- 静态资源服务器( [FrameworkServer](https://git.2dfire.net/ios/FrameworkServer),附详细使用教程);
|
31
|
+
|
32
|
+
#### 2. 初始化插件
|
33
|
+
|
34
|
+
```shell
|
35
|
+
pod bin init
|
36
|
+
|
37
|
+
====== dev 环境 ========
|
38
|
+
|
39
|
+
开始设置二进制化初始信息.
|
40
|
+
所有的信息都会保存在 /Users/imwcl/.cocoapods/bin_dev.yml 文件中.
|
41
|
+
%w[bin_dev.yml bin_debug_iphoneos.yml bin_release_iphoneos.yml]
|
42
|
+
你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
|
43
|
+
|
44
|
+
---
|
45
|
+
configuration_env: dev
|
46
|
+
code_repo_url: git@git.2dfire.net:ios/cocoapods-spec.git
|
47
|
+
binary_repo_url: git@git.2dfire.net:ios/cocoapods-spec-binary.git
|
48
|
+
binary_download_url: http://iosframeworkserver-shopkeeperclient.app.2dfire.com/download/%s/%s.zip
|
49
|
+
binary_upload_url: http://iosframeworkserver-shopkeeperclient.app.2dfire.com/upload/%s/%s.zip
|
50
|
+
download_file_type: zip
|
51
|
+
```
|
52
|
+
|
53
|
+
按提示输入`所属环境`、源码私有源、二进制私有源、二进制下载地址、下载文件类型后,插件就配置完成了。其中 `binary_download_url` 需要预留组件名称与组件版本占位符,插件内部会依次替换 `%s` 为相应组件的值。
|
54
|
+
|
55
|
+
`cococapods-tdf-bin` 也支持从 url 下载配置文件,方便对多台机器进行配置:
|
56
|
+
|
57
|
+
```shell
|
58
|
+
pod bin init --bin-url=https://github.com/su350380433/cocoapods-imy-bin-configs/raw/master/bin_dev.yml
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
### 四、制作二进制组件
|
64
|
+
|
65
|
+
#### 1. 制作命令
|
66
|
+
|
67
|
+
可以直接使用插件的 `pod bin auto`命令,在插件初始化配置完成后,目录下只要有包含podspec文件,根据podspec文件的version版本号会自动化执行build、组装二进制组件、制作二进制podspec、上传二进制文件、上传二进制podspec到私有源仓库。
|
68
|
+
|
69
|
+
```shell
|
70
|
+
pod bin auto
|
71
|
+
# --code-dependencies 为源码依赖
|
72
|
+
# --only-build 为只生成产物,不上传代码
|
73
|
+
# --all-make 为将所有依赖库都打包
|
74
|
+
# --use-modular-headers 为输出 framework 为modular-headers
|
75
|
+
# pod bin auto --code-dependencies --only-build --all-make --use-modular-headers
|
76
|
+
```
|
77
|
+
|
78
|
+
#### 2. 二进制Podspec
|
79
|
+
|
80
|
+
会自动生成、上传,无需关心。
|
81
|
+
|
82
|
+
#### 3. 查看结果
|
83
|
+
|
84
|
+
- 二进制存储服务:http://iosframeworkserver-shopkeeperclient.app.2dfire.com/frameworks?allinfo=true;
|
85
|
+
- 二进制私有源:https://git.2dfire.net/ios/cocoapods-spec-binary;
|
86
|
+
|
87
|
+
#### 4. 使用二进制
|
88
|
+
|
89
|
+
在Podfile文件中,加入这两行代码,对已经制作二进制的就会生效,自动转换二进制组件依赖:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
plugin 'cocoapods-tdf-bin'
|
93
|
+
|
94
|
+
# 全部开启二进制
|
95
|
+
use_binaries!
|
96
|
+
|
97
|
+
set_use_source_pods [
|
98
|
+
# 需要源码调试的业务库
|
99
|
+
]
|
100
|
+
```
|
101
|
+
|
102
|
+
|
103
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-tdf-bin/command/bin/initHotKey'
|
3
|
+
require 'cocoapods-tdf-bin/command/bin/init'
|
4
|
+
require 'cocoapods-tdf-bin/command/bin/archive'
|
5
|
+
require 'cocoapods-tdf-bin/command/bin/auto'
|
6
|
+
require 'cocoapods-tdf-bin/command/bin/code'
|
7
|
+
require 'cocoapods-tdf-bin/command/bin/update'
|
8
|
+
require 'cocoapods-tdf-bin/command/bin/install'
|
9
|
+
require 'cocoapods-tdf-bin/command/bin/imy'
|
10
|
+
|
11
|
+
require 'cocoapods-tdf-bin/helpers'
|
12
|
+
|
13
|
+
module Pod
|
14
|
+
class Command
|
15
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
16
|
+
# to the 'pod' command.
|
17
|
+
#
|
18
|
+
# You can also create subcommands of existing or new commands. Say you
|
19
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
20
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
21
|
+
# to change.
|
22
|
+
#
|
23
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
24
|
+
# the class to exist in the the Pod::Command::List namespace
|
25
|
+
# - change this class to extend from `List` instead of `Command`. This
|
26
|
+
# tells the plugin system that it is a subcommand of `list`.
|
27
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
28
|
+
#
|
29
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
30
|
+
# in the `plugins.json` file, once your plugin is released.
|
31
|
+
#
|
32
|
+
class Bin < Command
|
33
|
+
include CBin::SourcesHelper
|
34
|
+
include CBin::SpecFilesHelper
|
35
|
+
|
36
|
+
self.abstract_command = true
|
37
|
+
self.summary = '组件二进制化插件.'
|
38
|
+
self.description = <<-DESC
|
39
|
+
组件二进制化插件。利用源码私有源与二进制私有源实现对组件依赖类型的切换。
|
40
|
+
DESC
|
41
|
+
|
42
|
+
def initialize(argv)
|
43
|
+
require 'cocoapods-tdf-bin/native'
|
44
|
+
|
45
|
+
@help = argv.flag?('help')
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate!
|
50
|
+
super
|
51
|
+
# 这里由于 --help 是在 validate! 方法中提取的,会导致 --help 失效
|
52
|
+
# pod lib create 也有这个问题
|
53
|
+
banner! if @help
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'cocoapods-tdf-bin/native/podfile'
|
2
|
+
require 'cocoapods-tdf-bin/native/configuration'
|
3
|
+
require 'cocoapods/command/gen'
|
4
|
+
require 'cocoapods/generate'
|
5
|
+
require 'cocoapods-tdf-bin/helpers/framework_builder'
|
6
|
+
require 'cocoapods-tdf-bin/helpers/library_builder'
|
7
|
+
require 'cocoapods-tdf-bin/helpers/build_helper'
|
8
|
+
require 'cocoapods-tdf-bin/helpers/spec_source_creator'
|
9
|
+
require 'cocoapods-tdf-bin/config/config_builder'
|
10
|
+
require 'cocoapods-tdf-bin/command/bin/lib/lint'
|
11
|
+
|
12
|
+
module Pod
|
13
|
+
class Command
|
14
|
+
class Bin < Command
|
15
|
+
class Archive < Bin
|
16
|
+
|
17
|
+
@@missing_binary_specs = []
|
18
|
+
|
19
|
+
self.summary = '将组件归档为静态库 .a.'
|
20
|
+
self.description = <<-DESC
|
21
|
+
将组件归档为静态库 framework,仅支持 iOS 平台
|
22
|
+
此静态 framework 不包含依赖组件的 symbol
|
23
|
+
DESC
|
24
|
+
|
25
|
+
def self.options
|
26
|
+
[
|
27
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
28
|
+
['--code-dependencies', '使用源码依赖'],
|
29
|
+
['--no-clean', '保留构建中间产物'],
|
30
|
+
['--sources', '私有源地址,多个用分号区分'],
|
31
|
+
['--framework-output', '输出framework文件'],
|
32
|
+
['--no-zip', '不压缩静态库 为 zip'],
|
33
|
+
['--use-modular-headers', '使用modular-headers打包'],
|
34
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
35
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
|
36
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
37
|
+
end
|
38
|
+
|
39
|
+
self.arguments = [
|
40
|
+
CLAide::Argument.new('NAME.podspec', false)
|
41
|
+
]
|
42
|
+
|
43
|
+
def initialize(argv)
|
44
|
+
@env = argv.option('env') || 'dev'
|
45
|
+
CBin.config.set_configuration_env(@env)
|
46
|
+
UI.warn "====== cocoapods-tdf-bin #{CBin::VERSION} 版本 ======== \n "
|
47
|
+
UI.warn "====== #{@env} 环境 ======== \n "
|
48
|
+
|
49
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
50
|
+
@framework_output = argv.flag?('framework-output', false )
|
51
|
+
@clean = argv.flag?('no-clean', false)
|
52
|
+
@zip = argv.flag?('zip', true)
|
53
|
+
@all_make = argv.flag?('all-make', false )
|
54
|
+
@use_modular_headers = argv.flag?('use-modular-headers', false )
|
55
|
+
@sources = argv.option('sources') || []
|
56
|
+
@platform = Platform.new(:ios)
|
57
|
+
|
58
|
+
@config = argv.option('configuration', 'Release')
|
59
|
+
|
60
|
+
@framework_path
|
61
|
+
super
|
62
|
+
|
63
|
+
@additional_args = argv.remainder!
|
64
|
+
@build_finshed = false
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def run
|
69
|
+
#清除之前的缓存
|
70
|
+
zip_dir = CBin::Config::Builder.instance.zip_dir
|
71
|
+
FileUtils.rm_rf(zip_dir) if File.exist?(zip_dir)
|
72
|
+
|
73
|
+
@spec = Specification.from_file(spec_file)
|
74
|
+
|
75
|
+
generate_project
|
76
|
+
|
77
|
+
source_specs = Array.new
|
78
|
+
source_specs.concat(build_root_spec)
|
79
|
+
source_specs.concat(build_dependencies) if @all_make
|
80
|
+
|
81
|
+
source_specs
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_root_spec
|
85
|
+
source_specs = []
|
86
|
+
builder = CBin::Build::Helper.new(@spec,
|
87
|
+
@platform,
|
88
|
+
@framework_output,
|
89
|
+
@zip,
|
90
|
+
@spec,
|
91
|
+
CBin::Config::Builder.instance.white_pod_list.include?(@spec.name),
|
92
|
+
@config)
|
93
|
+
|
94
|
+
builder.build
|
95
|
+
builder.clean_workspace if @clean && !@all_make
|
96
|
+
source_specs << @spec unless CBin::Config::Builder.instance.white_pod_list.include?(@spec.name)
|
97
|
+
|
98
|
+
source_specs
|
99
|
+
end
|
100
|
+
|
101
|
+
def build_dependencies
|
102
|
+
@build_finshed = true
|
103
|
+
#如果没要求,就清空依赖库数据
|
104
|
+
source_specs = []
|
105
|
+
@@missing_binary_specs.uniq.each do |spec|
|
106
|
+
next if spec.name.include?('/')
|
107
|
+
next if spec.name == @spec.name
|
108
|
+
# 过滤白名单
|
109
|
+
next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name)
|
110
|
+
# 在编译名单里面才编译
|
111
|
+
if CBin::Config::Builder.instance.build_pod_list.length != 0
|
112
|
+
next unless CBin::Config::Builder.instance.build_pod_list.include?(spec.name)
|
113
|
+
end
|
114
|
+
|
115
|
+
#过滤 git
|
116
|
+
if spec.source[:git] && spec.source[:git]
|
117
|
+
spec_git = spec.source[:git]
|
118
|
+
spec_git_res = false
|
119
|
+
CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
|
120
|
+
spec_git_res = spec_git.include?(ignore_git)
|
121
|
+
break if spec_git_res
|
122
|
+
end
|
123
|
+
next if spec_git_res
|
124
|
+
end
|
125
|
+
UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks']
|
126
|
+
next if spec.attributes_hash['vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
127
|
+
next if spec.attributes_hash['ios.vendored_frameworks'] && @spec.name != spec.name #过滤带有vendored_frameworks的
|
128
|
+
#获取没有制作二进制版本的spec集合
|
129
|
+
source_specs << spec
|
130
|
+
end
|
131
|
+
|
132
|
+
fail_build_specs = []
|
133
|
+
source_specs.uniq.each do |spec|
|
134
|
+
begin
|
135
|
+
builder = CBin::Build::Helper.new(spec,
|
136
|
+
@platform,
|
137
|
+
@framework_output,
|
138
|
+
@zip,
|
139
|
+
@spec,
|
140
|
+
false ,
|
141
|
+
@config)
|
142
|
+
builder.build
|
143
|
+
rescue Object => exception
|
144
|
+
UI.puts exception
|
145
|
+
fail_build_specs << spec
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
if fail_build_specs.any?
|
150
|
+
fail_build_specs.uniq.each do |spec|
|
151
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ."
|
152
|
+
end
|
153
|
+
end
|
154
|
+
source_specs - fail_build_specs
|
155
|
+
end
|
156
|
+
|
157
|
+
# 解析器传过来的
|
158
|
+
def Archive.missing_binary_specs(missing_binary_specs)
|
159
|
+
@@missing_binary_specs = missing_binary_specs unless @build_finshed
|
160
|
+
end
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
def generate_project
|
165
|
+
Podfile.execute_with_bin_plugin do
|
166
|
+
Podfile.execute_with_use_binaries(!@code_dependencies) do
|
167
|
+
argvs = [
|
168
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
169
|
+
"--gen-directory=#{CBin::Config::Builder.instance.gen_dir}",
|
170
|
+
'--clean',
|
171
|
+
*@additional_args
|
172
|
+
]
|
173
|
+
|
174
|
+
if @use_modular_headers
|
175
|
+
argvs += ['--use-modular-headers']
|
176
|
+
end
|
177
|
+
|
178
|
+
# podfile = File.join(Pathname.pwd, "Podfile")
|
179
|
+
|
180
|
+
# unless File.exist?(podfile)
|
181
|
+
# podfile = File.join(Pathname.pwd, "Example/Podfile")
|
182
|
+
# end
|
183
|
+
|
184
|
+
# podfile_instance = Pod::Podfile.from_file(podfile)
|
185
|
+
# podfile_instance.use_frameworks!(:linkage => :static)
|
186
|
+
# podfile_instance.to_yaml
|
187
|
+
|
188
|
+
# if File.exist?(podfile)
|
189
|
+
# argvs += ['--use-podfile', "--podfile-path=#{podfile}"]
|
190
|
+
# end
|
191
|
+
|
192
|
+
argvs << spec_file if spec_file
|
193
|
+
|
194
|
+
gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs))
|
195
|
+
gen.validate!
|
196
|
+
gen.run
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
def spec_file
|
203
|
+
@spec_file ||= begin
|
204
|
+
if @podspec
|
205
|
+
find_spec_file(@podspec)
|
206
|
+
else
|
207
|
+
if code_spec_files.empty?
|
208
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
209
|
+
end
|
210
|
+
|
211
|
+
spec_file = code_spec_files.first
|
212
|
+
spec_file
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods-tdf-bin/command/bin/auto'
|
3
|
+
require 'cocoapods-tdf-bin/helpers/upload_helper'
|
4
|
+
require 'cocoapods-tdf-bin/native/resolver'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Command
|
8
|
+
class Bin < Command
|
9
|
+
class Auto < Bin
|
10
|
+
self.summary = '打开 workspace 工程.'
|
11
|
+
|
12
|
+
self.arguments = [
|
13
|
+
CLAide::Argument.new('NAME.podspec', false)
|
14
|
+
]
|
15
|
+
def self.options
|
16
|
+
[
|
17
|
+
['--code-dependencies', '使用源码依赖'],
|
18
|
+
['--allow-prerelease', '允许使用 prerelease 的版本'],
|
19
|
+
['--no-clean', '保留构建中间产物'],
|
20
|
+
['--framework-output', '输出framework文件'],
|
21
|
+
['--no-zip', '不压缩静态 framework 为 zip'],
|
22
|
+
['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
|
23
|
+
['--configuration', 'Build the specified configuration (e.g. Release ). Defaults to Debug'],
|
24
|
+
['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"],
|
25
|
+
['--only-build', "该组件只编译生成产物,不上传"],
|
26
|
+
['--use-modular-headers', '使用modular-headers打包']
|
27
|
+
].concat(Pod::Command::Gen.options).concat(super).uniq
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(argv)
|
31
|
+
|
32
|
+
@env = argv.option('env') || 'dev'
|
33
|
+
CBin.config.set_configuration_env(@env)
|
34
|
+
|
35
|
+
@podspec = argv.shift_argument || find_podspec
|
36
|
+
@specification = Specification.from_file(@podspec)
|
37
|
+
|
38
|
+
@code_dependencies = argv.flag?('code-dependencies')
|
39
|
+
@only_build = argv.flag?('only-build', false )
|
40
|
+
@use_modular_headers = argv.flag?('use-modular-headers', false )
|
41
|
+
|
42
|
+
@allow_prerelease = argv.flag?('allow-prerelease')
|
43
|
+
@framework_output = argv.flag?('framework-output', false )
|
44
|
+
@clean = argv.flag?('clean', true)
|
45
|
+
@zip = argv.flag?('zip', true)
|
46
|
+
@all_make = argv.flag?('all-make', false )
|
47
|
+
@verbose = argv.flag?('verbose',true)
|
48
|
+
|
49
|
+
@config = argv.option('configuration', 'Debug')
|
50
|
+
@additional_args = argv.remainder!
|
51
|
+
|
52
|
+
Pod::Resolver.build_dependencies_only_build(@only_build)
|
53
|
+
|
54
|
+
super
|
55
|
+
end
|
56
|
+
|
57
|
+
def validate!
|
58
|
+
help! "未找到 podspec文件" unless @podspec
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
62
|
+
def run
|
63
|
+
@specification = Specification.from_file(@podspec)
|
64
|
+
|
65
|
+
source_specs = run_archive
|
66
|
+
|
67
|
+
fail_push_specs = []
|
68
|
+
|
69
|
+
|
70
|
+
if !@only_build
|
71
|
+
source_specs.uniq.each do |spec|
|
72
|
+
begin
|
73
|
+
fail_push_specs << spec unless CBin::Upload::Helper.new(spec,@code_dependencies,@sources).upload
|
74
|
+
rescue Object => exception
|
75
|
+
UI.puts exception
|
76
|
+
fail_push_specs << spec
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
if fail_push_specs.any?
|
81
|
+
fail_push_specs.uniq.each do |spec|
|
82
|
+
UI.warn "【#{spec.name} | #{spec.version}】组件spec push失败 ."
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
success_specs = source_specs - fail_push_specs
|
88
|
+
if success_specs.any?
|
89
|
+
auto_success = ""
|
90
|
+
success_specs.uniq.each do |spec|
|
91
|
+
auto_success += "#{spec.name} | #{spec.version}\n"
|
92
|
+
UI.warn "===【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!! "
|
93
|
+
end
|
94
|
+
puts "============== auto_success"
|
95
|
+
puts auto_success
|
96
|
+
ENV['auto_success'] = auto_success
|
97
|
+
end
|
98
|
+
#pod repo update
|
99
|
+
UI.section("\nUpdating Spec Repositories\n".yellow) do
|
100
|
+
Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
#制作二进制包
|
106
|
+
|
107
|
+
def run_archive
|
108
|
+
argvs = [
|
109
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
110
|
+
@additional_args
|
111
|
+
]
|
112
|
+
|
113
|
+
argvs << spec_file if spec_file
|
114
|
+
argvs.delete(Array.new)
|
115
|
+
|
116
|
+
unless @clean
|
117
|
+
argvs += ['--no-clean']
|
118
|
+
end
|
119
|
+
if @code_dependencies
|
120
|
+
argvs += ['--code-dependencies']
|
121
|
+
end
|
122
|
+
if @verbose
|
123
|
+
argvs += ['--verbose']
|
124
|
+
end
|
125
|
+
if @allow_prerelease
|
126
|
+
argvs += ['--allow-prerelease']
|
127
|
+
end
|
128
|
+
if @framework_output
|
129
|
+
argvs += ['--framework-output']
|
130
|
+
end
|
131
|
+
if @all_make
|
132
|
+
argvs += ['--all-make']
|
133
|
+
end
|
134
|
+
if @env
|
135
|
+
argvs += ["--env=#{@env}"]
|
136
|
+
end
|
137
|
+
|
138
|
+
if @use_modular_headers
|
139
|
+
argvs += ['--use-modular-headers']
|
140
|
+
end
|
141
|
+
|
142
|
+
argvs += ["--configuration=#{@config}"]
|
143
|
+
|
144
|
+
archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
|
145
|
+
archive.validate!
|
146
|
+
source_specs = archive.run
|
147
|
+
source_specs
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
def code_podsepc_extname
|
152
|
+
'.podsepc'
|
153
|
+
end
|
154
|
+
|
155
|
+
def binary_podsepc_json
|
156
|
+
"#{@specification.name}.binary.podspec.json"
|
157
|
+
end
|
158
|
+
|
159
|
+
def binary_template_podsepc
|
160
|
+
"#{@specification.name}.binary-template.podspec"
|
161
|
+
end
|
162
|
+
|
163
|
+
def template_spec_file
|
164
|
+
@template_spec_file ||= begin
|
165
|
+
if @template_podspec
|
166
|
+
find_spec_file(@template_podspec)
|
167
|
+
else
|
168
|
+
binary_template_spec_file
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def spec_file
|
174
|
+
@spec_file ||= begin
|
175
|
+
if @podspec
|
176
|
+
find_spec_file(@podspec) || @podspec
|
177
|
+
else
|
178
|
+
if code_spec_files.empty?
|
179
|
+
raise Informative, '当前目录下没有找到可用源码 podspec.'
|
180
|
+
end
|
181
|
+
|
182
|
+
spec_file = if @binary
|
183
|
+
code_spec = Pod::Specification.from_file(code_spec_files.first)
|
184
|
+
if template_spec_file
|
185
|
+
template_spec = Pod::Specification.from_file(template_spec_file)
|
186
|
+
end
|
187
|
+
create_binary_spec_file(code_spec, template_spec)
|
188
|
+
else
|
189
|
+
code_spec_files.first
|
190
|
+
end
|
191
|
+
spec_file
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
#Dir.glob 可替代
|
197
|
+
def find_podspec
|
198
|
+
name = nil
|
199
|
+
Pathname.pwd.children.each do |child|
|
200
|
+
puts child
|
201
|
+
if File.file?(child)
|
202
|
+
if child.extname == '.podspec'
|
203
|
+
name = File.basename(child)
|
204
|
+
unless name.include?("binary-template")
|
205
|
+
return name
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
return name
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|