cocoapods-swordfish 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +35 -0
- data/lib/cocoapods_plugin.rb +86 -0
- data/lib/gem_version.rb +11 -0
- data/lib/swordfish/command/archive.rb +187 -0
- data/lib/swordfish/command/auto.rb +192 -0
- data/lib/swordfish/command/config.rb +70 -0
- data/lib/swordfish/command/repo/update.rb +42 -0
- data/lib/swordfish/command/spec/create.rb +78 -0
- data/lib/swordfish/command/spec/push.rb +114 -0
- data/lib/swordfish/command/swordfish.rb +41 -0
- data/lib/swordfish/command.rb +2 -0
- data/lib/swordfish/config/config.rb +137 -0
- data/lib/swordfish/config/config_asker.rb +57 -0
- data/lib/swordfish/config/config_builder.rb +216 -0
- data/lib/swordfish/helpers/build_helper.rb +160 -0
- data/lib/swordfish/helpers/build_utils.rb +94 -0
- data/lib/swordfish/helpers/framework.rb +85 -0
- data/lib/swordfish/helpers/framework_builder.rb +451 -0
- data/lib/swordfish/helpers/library.rb +54 -0
- data/lib/swordfish/helpers/library_builder.rb +90 -0
- data/lib/swordfish/helpers/sources_helper.rb +38 -0
- data/lib/swordfish/helpers/spec_creator.rb +167 -0
- data/lib/swordfish/helpers/spec_files_helper.rb +76 -0
- data/lib/swordfish/helpers/spec_source_creator.rb +266 -0
- data/lib/swordfish/helpers/upload_helper.rb +94 -0
- data/lib/swordfish/hmap/hmap_generator.rb +59 -0
- data/lib/swordfish/hmap/pod_target.rb +92 -0
- data/lib/swordfish/hmap/podfile_dsl.rb +36 -0
- data/lib/swordfish/hmap/post_install_hook_context.rb +41 -0
- data/lib/swordfish/hmap/xcconfig.rb +99 -0
- data/lib/swordfish/hmap.rb +4 -0
- data/lib/swordfish/native/acknowledgements.rb +27 -0
- data/lib/swordfish/native/analyzer.rb +55 -0
- data/lib/swordfish/native/file_accessor.rb +28 -0
- data/lib/swordfish/native/installation_options.rb +25 -0
- data/lib/swordfish/native/installer.rb +135 -0
- data/lib/swordfish/native/linter.rb +25 -0
- data/lib/swordfish/native/path_source.rb +33 -0
- data/lib/swordfish/native/pod_source_installer.rb +19 -0
- data/lib/swordfish/native/pod_target_installer.rb +94 -0
- data/lib/swordfish/native/podfile.rb +105 -0
- data/lib/swordfish/native/podfile_env.rb +36 -0
- data/lib/swordfish/native/podfile_generator.rb +195 -0
- data/lib/swordfish/native/podspec_finder.rb +24 -0
- data/lib/swordfish/native/resolver.rb +223 -0
- data/lib/swordfish/native/source.rb +35 -0
- data/lib/swordfish/native/sources_manager.rb +19 -0
- data/lib/swordfish/native/specification.rb +31 -0
- data/lib/swordfish/native/target_architectures.rb +79 -0
- data/lib/swordfish/native/target_validator.rb +41 -0
- data/lib/swordfish/native/validator.rb +39 -0
- data/lib/swordfish/native.rb +16 -0
- data/lib/swordfish.rb +2 -0
- metadata +167 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
|
2
|
+
require 'cocoapods'
|
3
|
+
require 'swordfish/config/config'
|
4
|
+
|
5
|
+
module Ocean
|
6
|
+
class Specification
|
7
|
+
class Creator
|
8
|
+
attr_reader :code_spec
|
9
|
+
attr_reader :template_spec
|
10
|
+
attr_reader :spec
|
11
|
+
|
12
|
+
def initialize(code_spec, template_spec, platforms = 'ios')
|
13
|
+
@code_spec = code_spec
|
14
|
+
@template_spec = template_spec
|
15
|
+
@platforms = Array(platforms)
|
16
|
+
validate!
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate!
|
20
|
+
raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
|
21
|
+
if code_spec.subspecs.any? && template_spec.nil?
|
22
|
+
raise Pod::Informative, "不支持自动生成存在 subspec 的二进制 podspec , 需要提供模版文件 #{code_spec.name}.binary.podspec.template ."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
spec = template_spec ? create_from_code_spec_and_template_spec : create_from_code_spec
|
28
|
+
|
29
|
+
Pod::UI.message '生成二进制 podspec 内容: '
|
30
|
+
spec.to_pretty_json.split("\n").each do |text|
|
31
|
+
Pod::UI.message text
|
32
|
+
end
|
33
|
+
|
34
|
+
spec
|
35
|
+
end
|
36
|
+
|
37
|
+
def write_spec_file(file = filename)
|
38
|
+
create unless spec
|
39
|
+
|
40
|
+
File.open(file, 'w+') do |f|
|
41
|
+
f.write(spec.to_pretty_json)
|
42
|
+
end
|
43
|
+
|
44
|
+
@filename = file
|
45
|
+
end
|
46
|
+
|
47
|
+
def clear_spec_file
|
48
|
+
File.delete(filename) if File.exist?(filename)
|
49
|
+
end
|
50
|
+
|
51
|
+
def filename
|
52
|
+
@filename ||= "#{spec.name}.binary.podspec.json"
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def create_from_code_spec
|
58
|
+
@spec = code_spec.dup
|
59
|
+
# vendored_frameworks | resources | source | source_files | public_header_files
|
60
|
+
# license | resource_bundles | vendored_libraries
|
61
|
+
|
62
|
+
# Project Linkin
|
63
|
+
@spec.vendored_frameworks = "#{code_spec.root.name}.framework"
|
64
|
+
|
65
|
+
# Resources
|
66
|
+
extnames = []
|
67
|
+
extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
|
68
|
+
if code_spec_consumer.resources.any?
|
69
|
+
extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
|
70
|
+
end
|
71
|
+
if extnames.any?
|
72
|
+
@spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
|
73
|
+
end
|
74
|
+
|
75
|
+
# Source Location
|
76
|
+
@spec.source = binary_source
|
77
|
+
|
78
|
+
# Source Code
|
79
|
+
@spec.source_files = framework_contents('Headers/*')
|
80
|
+
@spec.public_header_files = framework_contents('Headers/*')
|
81
|
+
|
82
|
+
# Unused for binary
|
83
|
+
spec_hash = @spec.to_hash
|
84
|
+
# spec_hash.delete('license')
|
85
|
+
spec_hash.delete('resource_bundles')
|
86
|
+
spec_hash.delete('exclude_files')
|
87
|
+
spec_hash.delete('preserve_paths')
|
88
|
+
# 这里不确定 vendored_libraries 指定的时动态/静态库
|
89
|
+
# 如果是静态库的话,需要移除,否则就不移除
|
90
|
+
# 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
|
91
|
+
# 这里统一只对命名后缀 .a 文件做处理
|
92
|
+
# spec_hash.delete('vendored_libraries')
|
93
|
+
# libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
|
94
|
+
spec_hash.delete('vendored_libraries')
|
95
|
+
spec_hash['vendored_libraries'] = binary_vendored_libraries
|
96
|
+
|
97
|
+
# vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
|
98
|
+
# if vendored_libraries.any?
|
99
|
+
# spec_hash['vendored_libraries'] = vendored_libraries
|
100
|
+
# end
|
101
|
+
|
102
|
+
# Filter platforms
|
103
|
+
platforms = spec_hash['platforms']
|
104
|
+
selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
|
105
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
106
|
+
|
107
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
108
|
+
@spec
|
109
|
+
end
|
110
|
+
|
111
|
+
def create_from_code_spec_and_template_spec
|
112
|
+
@spec = template_spec.dup
|
113
|
+
|
114
|
+
@spec.version = code_spec.version
|
115
|
+
@spec.source = binary_source
|
116
|
+
|
117
|
+
@spec.source_files = binary_source_files
|
118
|
+
@spec.public_header_files = binary_public_header_files
|
119
|
+
@spec.vendored_libraries = binary_vendored_libraries
|
120
|
+
|
121
|
+
@spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
|
122
|
+
|
123
|
+
@spec
|
124
|
+
end
|
125
|
+
|
126
|
+
def binary_source
|
127
|
+
{ http: format(Ocean.config.binary_download_url, code_spec.root.name, code_spec.version), type: Ocean.config.download_file_type }
|
128
|
+
end
|
129
|
+
|
130
|
+
def code_spec_consumer(_platform = :ios)
|
131
|
+
code_spec.consumer(:ios)
|
132
|
+
end
|
133
|
+
|
134
|
+
def framework_contents(name)
|
135
|
+
["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
136
|
+
end
|
137
|
+
|
138
|
+
def binary_source_files
|
139
|
+
{ http: format(Ocean.config.binary_download_url, code_spec.root.name, code_spec.version), type: Ocean.config.download_file_type }
|
140
|
+
end
|
141
|
+
|
142
|
+
def binary_source_files
|
143
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/Headers/*"
|
144
|
+
end
|
145
|
+
|
146
|
+
def binary_public_header_files
|
147
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
|
148
|
+
end
|
149
|
+
|
150
|
+
def binary_vendored_libraries
|
151
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/*.a"
|
152
|
+
end
|
153
|
+
|
154
|
+
def binary_resources
|
155
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/Resources/*"
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
#模板框架begin
|
162
|
+
# s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
|
163
|
+
# s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
|
164
|
+
# s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
|
165
|
+
#有图片资源的,要带上
|
166
|
+
#s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
|
167
|
+
#模板框架end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
require 'swordfish/native/sources_manager.rb'
|
3
|
+
require 'swordfish/helpers/spec_creator'
|
4
|
+
|
5
|
+
module Ocean
|
6
|
+
module SpecFilesHelper
|
7
|
+
def spec_files
|
8
|
+
@spec_files ||= Pathname.glob('*.podspec{,.json}')
|
9
|
+
end
|
10
|
+
|
11
|
+
def binary_spec_files
|
12
|
+
@binary_spec_files ||= Pathname.glob('*.binary.podspec{,.json}')
|
13
|
+
end
|
14
|
+
|
15
|
+
def binary_template_spec_files
|
16
|
+
@binary_spec_template_files ||= Pathname.glob('*.binary-template.podspec{,.json}')
|
17
|
+
end
|
18
|
+
|
19
|
+
def binary_template_spec_file
|
20
|
+
@binary_spec_template_file ||= binary_template_spec_files.first
|
21
|
+
end
|
22
|
+
|
23
|
+
def code_spec_files
|
24
|
+
@code_spec_files ||= spec_files - binary_spec_files - binary_template_spec_files
|
25
|
+
end
|
26
|
+
|
27
|
+
def code_spec
|
28
|
+
if code_spec_files.first
|
29
|
+
Pod::Specification.from_file(code_spec_files.first)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def binary_spec
|
34
|
+
if binary_spec_files.first
|
35
|
+
Pod::Specification.from_file(binary_spec_files.first)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def binary_template_spec
|
40
|
+
if binary_template_spec_file
|
41
|
+
Pod::Specification.from_file(binary_template_spec_file)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_spec_file(podspec)
|
46
|
+
path = Pathname(podspec)
|
47
|
+
raise Pod::Informative, "无法找到 #{podspec}" unless path.exist?
|
48
|
+
|
49
|
+
path
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_binary_spec_file(code_spec, template_spec)
|
53
|
+
# 1. code spec 是否有 subpsec
|
54
|
+
# 1.1 有,查找 template spec,并生成
|
55
|
+
# 1.2 没有,是否有 template spec
|
56
|
+
# 1.2.1 有,根据 template spec 生成
|
57
|
+
# 1.2.2 没有,根据 code spec 生成
|
58
|
+
|
59
|
+
unless code_spec
|
60
|
+
raise Pod::Informative, '没有二进制 podspec 的情况下,必须要提供源码 podspec.'
|
61
|
+
end
|
62
|
+
if code_spec.subspecs.any? && template_spec.nil?
|
63
|
+
raise Pod::Informative, '拥有 subspec 的组件,在生成二进制 podspec 时,必须要提供模版 podspec.'
|
64
|
+
end
|
65
|
+
|
66
|
+
@spec_creator = Ocean::Specification::Creator.new(code_spec, template_spec)
|
67
|
+
@spec_creator.create
|
68
|
+
@spec_creator.write_spec_file
|
69
|
+
@spec_creator.filename
|
70
|
+
end
|
71
|
+
|
72
|
+
def clear_binary_spec_file_if_needed
|
73
|
+
@spec_creator&.clear_spec_file
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,266 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'swordfish/config/config'
|
5
|
+
|
6
|
+
module Ocean
|
7
|
+
class SpecificationSource
|
8
|
+
class Creator
|
9
|
+
attr_reader :code_spec
|
10
|
+
attr_reader :spec
|
11
|
+
|
12
|
+
def initialize(code_spec, platforms = 'ios')
|
13
|
+
@code_spec = code_spec
|
14
|
+
@platforms = Array(platforms)
|
15
|
+
validate!
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate!
|
19
|
+
raise Pod::Informative, '源码 podspec 不能为空 .' unless code_spec
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(is_framework)
|
23
|
+
# spec = nil
|
24
|
+
if is_framework
|
25
|
+
spec = create_framework_from_code_spec
|
26
|
+
else
|
27
|
+
spec = create_from_code_spec
|
28
|
+
end
|
29
|
+
|
30
|
+
spec
|
31
|
+
end
|
32
|
+
|
33
|
+
def write_spec_file(file = filename)
|
34
|
+
|
35
|
+
FileUtils.mkdir_p(Ocean::Config::Builder.instance.binary_json_dir) unless File.exist?(Ocean::Config::Builder.instance.binary_json_dir)
|
36
|
+
FileUtils.rm_rf(file) if File.exist?(file)
|
37
|
+
|
38
|
+
File.open(file, 'w+') do |f|
|
39
|
+
# f.write("# MARK: converted automatically by plugin cocoapods-swordfish @slj \r\n")
|
40
|
+
f.write(spec.to_pretty_json)
|
41
|
+
end
|
42
|
+
|
43
|
+
@filename = file
|
44
|
+
end
|
45
|
+
|
46
|
+
def clear_spec_file
|
47
|
+
File.delete(filename) if File.exist?(filename)
|
48
|
+
end
|
49
|
+
|
50
|
+
def filename
|
51
|
+
@filename ||= "#{Ocean::Config::Builder.instance.binary_json_dir_name}/#{spec.name}.binary.podspec.json"
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def create_from_code_spec
|
57
|
+
@spec = code_spec.dup
|
58
|
+
# vendored_frameworks | resources | source | source_files | public_header_files
|
59
|
+
# license | resource_bundles | vendored_libraries
|
60
|
+
|
61
|
+
# Project Linkin
|
62
|
+
# @spec.vendored_frameworks = "#{code_spec.root.name}.framework"
|
63
|
+
|
64
|
+
# Resources
|
65
|
+
extnames = []
|
66
|
+
extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
|
67
|
+
if code_spec_consumer.resources.any?
|
68
|
+
extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
|
69
|
+
end
|
70
|
+
if extnames.any?
|
71
|
+
@spec.resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
|
72
|
+
end
|
73
|
+
|
74
|
+
# Source Location
|
75
|
+
@spec.source = binary_source
|
76
|
+
|
77
|
+
# Source Code
|
78
|
+
# @spec.source_files = framework_contents('Headers/*')
|
79
|
+
# @spec.public_header_files = framework_contents('Headers/*')
|
80
|
+
|
81
|
+
# Unused for binary
|
82
|
+
spec_hash = @spec.to_hash
|
83
|
+
# spec_hash.delete('license')
|
84
|
+
spec_hash.delete('resource_bundles')
|
85
|
+
spec_hash.delete('exclude_files')
|
86
|
+
spec_hash.delete('preserve_paths')
|
87
|
+
spec_hash.delete('vendored_frameworks')
|
88
|
+
spec_hash.delete('vendored_framework')
|
89
|
+
|
90
|
+
# 这里不确定 vendored_libraries 指定的时动态/静态库
|
91
|
+
# 如果是静态库的话,需要移除,否则就不移除
|
92
|
+
# 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
|
93
|
+
# 这里统一只对命名后缀 .a 文件做处理
|
94
|
+
# spec_hash.delete('vendored_libraries')
|
95
|
+
# libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
|
96
|
+
spec_hash.delete('vendored_libraries')
|
97
|
+
|
98
|
+
# vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
|
99
|
+
# if vendored_libraries.any?
|
100
|
+
# spec_hash['vendored_libraries'] = vendored_libraries
|
101
|
+
# end
|
102
|
+
|
103
|
+
# Filter platforms
|
104
|
+
platforms = spec_hash['platforms']
|
105
|
+
selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
|
106
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
107
|
+
|
108
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
109
|
+
|
110
|
+
#把命令 prepare_command 移除掉,如ReactiveCocoa会执行修改重命令的脚步
|
111
|
+
@spec.prepare_command = "" if @spec.prepare_command
|
112
|
+
@spec.version = code_spec.version
|
113
|
+
@spec.source = binary_source
|
114
|
+
@spec.source_files = binary_source_files
|
115
|
+
@spec.public_header_files = binary_public_header_files
|
116
|
+
@spec.vendored_libraries = binary_vendored_libraries
|
117
|
+
@spec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
|
118
|
+
@spec.description = <<-EOF
|
119
|
+
「 converted automatically by cocoapods-swordfish 」
|
120
|
+
#{@spec.description}
|
121
|
+
EOF
|
122
|
+
|
123
|
+
# 处理一下 subspecs ,使用相同的配置
|
124
|
+
if @spec.subspecs
|
125
|
+
@spec.subspecs.each do |subspec|
|
126
|
+
subspec.source_files = binary_source_files
|
127
|
+
subspec.public_header_files = binary_public_header_files
|
128
|
+
subspec.vendored_libraries = binary_vendored_libraries
|
129
|
+
subspec.resources = binary_resources if @spec.attributes_hash.keys.include?("resources")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
@spec
|
133
|
+
end
|
134
|
+
|
135
|
+
def create_framework_from_code_spec
|
136
|
+
@spec = code_spec.dup
|
137
|
+
# vendored_frameworks | resources | source | source_files | public_header_files
|
138
|
+
# license | resource_bundles | vendored_libraries
|
139
|
+
|
140
|
+
# Project Linkin
|
141
|
+
@spec.vendored_frameworks = "#{code_spec.root.name}.framework"
|
142
|
+
|
143
|
+
# Resources
|
144
|
+
resources = []
|
145
|
+
extnames = []
|
146
|
+
extnames << '*.bundle' if code_spec_consumer.resource_bundles.any?
|
147
|
+
if code_spec_consumer.resources.any?
|
148
|
+
extnames += code_spec_consumer.resources.map { |r| File.basename(r) }
|
149
|
+
end
|
150
|
+
if extnames.any?
|
151
|
+
resources = framework_contents('Resources').flat_map { |r| extnames.map { |e| "#{r}/#{e}" } }
|
152
|
+
end
|
153
|
+
@spec.resources = resources
|
154
|
+
|
155
|
+
# Source Location
|
156
|
+
@spec.source = binary_source
|
157
|
+
|
158
|
+
# Source Code
|
159
|
+
@spec.source_files = framework_contents('Headers/*')
|
160
|
+
@spec.public_header_files = framework_contents('Headers/*')
|
161
|
+
|
162
|
+
# 去除prepare_command
|
163
|
+
if @spec.prepare_command.nil? == false
|
164
|
+
@spec.prepare_command = ''
|
165
|
+
end
|
166
|
+
|
167
|
+
# Unused for binary
|
168
|
+
spec_hash = @spec.to_hash
|
169
|
+
# spec_hash.delete('license')
|
170
|
+
spec_hash.delete('resource_bundles')
|
171
|
+
spec_hash.delete('exclude_files')
|
172
|
+
spec_hash.delete('preserve_paths')
|
173
|
+
# 这里不确定 vendored_libraries 指定的时动态/静态库
|
174
|
+
# 如果是静态库的话,需要移除,否则就不移除
|
175
|
+
# 最好是静态库都独立成 Pod ,cocoapods-package 打静态库去 collect 目标文件时好做过滤
|
176
|
+
# 这里统一只对命名后缀 .a 文件做处理
|
177
|
+
# spec_hash.delete('vendored_libraries')
|
178
|
+
# libraries 只能假设为动态库不做处理了,如果有例外,需要开发者自行处理
|
179
|
+
vendored_libraries = spec_hash.delete('vendored_libraries')
|
180
|
+
vendored_libraries = Array(vendored_libraries).reject { |l| l.end_with?('.a') }
|
181
|
+
if vendored_libraries.any?
|
182
|
+
spec_hash['vendored_frameworks'] = vendored_libraries
|
183
|
+
end
|
184
|
+
|
185
|
+
# 解决不规范头文件引用问题
|
186
|
+
pod_target_xcconfig = spec_hash['pod_target_xcconfig'] || {}
|
187
|
+
pod_target_xcconfig['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
|
188
|
+
|
189
|
+
# Filter platforms
|
190
|
+
platforms = spec_hash['platforms']
|
191
|
+
selected_platforms = platforms.select { |k, _v| @platforms.include?(k) }
|
192
|
+
spec_hash['platforms'] = selected_platforms.empty? ? platforms : selected_platforms
|
193
|
+
|
194
|
+
@spec = Pod::Specification.from_hash(spec_hash)
|
195
|
+
@spec.description = <<-EOF
|
196
|
+
「 converted automatically by cocoapods-swordfish 」
|
197
|
+
#{@spec.description}
|
198
|
+
EOF
|
199
|
+
|
200
|
+
# 处理一下 subspecs ,使用相同的配置
|
201
|
+
if @spec.subspecs
|
202
|
+
@spec.subspecs.each do |subspec|
|
203
|
+
subspec.vendored_frameworks = "#{code_spec.root.name}.framework"
|
204
|
+
subspec.source_files = framework_contents('Headers/*')
|
205
|
+
subspec.public_header_files = framework_contents('Headers/*')
|
206
|
+
subspec.resources = resources
|
207
|
+
|
208
|
+
|
209
|
+
# if subspec.subspecs.empty? == false
|
210
|
+
# # 嵌套subspec
|
211
|
+
# subspec.subspecs.each do |subspec2|
|
212
|
+
# subspec2.vendored_frameworks = subspec.vendored_frameworks
|
213
|
+
# subspec2.source_files = subspec.source_files
|
214
|
+
# subspec2.public_header_files = subspec.public_header_files
|
215
|
+
# subspec2.resources = subspec.resources
|
216
|
+
# end
|
217
|
+
# end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
@spec
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
def binary_source
|
226
|
+
{ http: format(Ocean.config.binary_download_url, code_spec.root.name, code_spec.version), type: Ocean.config.download_file_type }
|
227
|
+
end
|
228
|
+
|
229
|
+
def code_spec_consumer(_platform = :ios)
|
230
|
+
code_spec.consumer(:ios)
|
231
|
+
end
|
232
|
+
|
233
|
+
def framework_contents(name)
|
234
|
+
["#{code_spec.root.name}.framework", "#{code_spec.root.name}.framework/Versions/A"].map { |path| "#{path}/#{name}" }
|
235
|
+
end
|
236
|
+
|
237
|
+
def binary_source_files
|
238
|
+
{ http: format(Ocean.config.binary_download_url, code_spec.root.name, code_spec.version), type: Ocean.config.download_file_type }
|
239
|
+
end
|
240
|
+
|
241
|
+
def binary_source_files
|
242
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/Headers/*"
|
243
|
+
end
|
244
|
+
|
245
|
+
def binary_public_header_files
|
246
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/Headers/*.h"
|
247
|
+
end
|
248
|
+
|
249
|
+
def binary_vendored_libraries
|
250
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/*.a"
|
251
|
+
end
|
252
|
+
|
253
|
+
def binary_resources
|
254
|
+
"swordfish_#{code_spec.name}_#{code_spec.version}/Resources/*"
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
#模板框架begin
|
261
|
+
# s.source_files = "bin_#{s.name}_#{s.version}/Headers/*"
|
262
|
+
# s.public_header_files = "bin_#{s.name}_#{s.version}/Headers/*.h"
|
263
|
+
# s.vendored_libraries = "bin_#{s.name}_#{s.version}/*.a"
|
264
|
+
#有图片资源的,要带上
|
265
|
+
#s.resources = 'bin_#{s.name}_#{s.version}/Resources/*.{json,png,jpg,gif,js,xib,eot,svg,ttf,woff,db,sqlite,mp3,bundle}'
|
266
|
+
#模板框架end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# copy from https://github.com/CocoaPods/cocoapods-packager
|
4
|
+
|
5
|
+
require 'cocoapods/command/gen'
|
6
|
+
require 'cocoapods/generate'
|
7
|
+
|
8
|
+
require 'swordfish/native/podfile'
|
9
|
+
require 'swordfish/helpers/framework_builder'
|
10
|
+
require 'swordfish/helpers/library_builder'
|
11
|
+
require 'swordfish/helpers/sources_helper'
|
12
|
+
require 'swordfish/command/spec/push'
|
13
|
+
require 'swordfish/helpers/spec_source_creator'
|
14
|
+
|
15
|
+
module Ocean
|
16
|
+
class Upload
|
17
|
+
class Helper
|
18
|
+
include Ocean::SourcesHelper
|
19
|
+
|
20
|
+
def initialize(spec,code_dependencies,sources)
|
21
|
+
@spec = spec
|
22
|
+
@code_dependencies = code_dependencies
|
23
|
+
@sources = sources
|
24
|
+
end
|
25
|
+
|
26
|
+
def upload(is_framework)
|
27
|
+
Dir.chdir(Ocean::Config::Builder.instance.root_dir) do
|
28
|
+
# 创建binary-template.podsepc
|
29
|
+
# 上传二进制文件
|
30
|
+
# 上传二进制 podspec
|
31
|
+
res_zip = curl_zip
|
32
|
+
if res_zip
|
33
|
+
filename = spec_creator(is_framework)
|
34
|
+
push_binary_repo(filename)
|
35
|
+
end
|
36
|
+
res_zip
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def spec_creator(is_framework)
|
41
|
+
spec_creator = Ocean::SpecificationSource::Creator.new(@spec)
|
42
|
+
spec_creator.create(is_framework)
|
43
|
+
spec_creator.write_spec_file
|
44
|
+
spec_creator.filename
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
#推送二进制
|
49
|
+
# curl http://ci.xxx:9192/frameworks -F "name=IMYFoundation" -F "version=7.7.4.2" -F "annotate=IMYFoundation_7.7.4.2_log" -F "file=@bin-zip/bin_IMYFoundation_7.7.4.2.zip"
|
50
|
+
def curl_zip
|
51
|
+
zip_file = "#{Ocean::Config::Builder.instance.library_file(@spec)}.zip"
|
52
|
+
res = File.exist?(zip_file)
|
53
|
+
unless res
|
54
|
+
zip_file = Ocean::Config::Builder.instance.framework_zip_file(@spec) + ".zip"
|
55
|
+
res = File.exist?(zip_file)
|
56
|
+
end
|
57
|
+
if res
|
58
|
+
command = "curl #{Ocean.config.binary_upload_url} -F \"name=#{@spec.name}\" -F \"version=#{@spec.version}\" -F \"annotate=#{@spec.name}_#{@spec.version}_log\" -F \"file=@#{zip_file}\""
|
59
|
+
print <<EOF
|
60
|
+
上传二进制文件
|
61
|
+
#{command}
|
62
|
+
EOF
|
63
|
+
upload_result = `#{command}`
|
64
|
+
puts "#{upload_result}"
|
65
|
+
end
|
66
|
+
|
67
|
+
res
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
# 上传二进制 podspec
|
72
|
+
def push_binary_repo(binary_podsepc_json)
|
73
|
+
argvs = [
|
74
|
+
"#{binary_podsepc_json}",
|
75
|
+
"--binary",
|
76
|
+
"--sources=#{sources_option(@code_dependencies, @sources)}",
|
77
|
+
"--skip-import-validation",
|
78
|
+
"--use-libraries",
|
79
|
+
"--allow-warnings",
|
80
|
+
"--verbose",
|
81
|
+
"--code-dependencies"
|
82
|
+
]
|
83
|
+
if @verbose
|
84
|
+
argvs += ['--verbose']
|
85
|
+
end
|
86
|
+
|
87
|
+
push = Pod::Command::Swordfish::Repo::Push.new(CLAide::ARGV.new(argvs))
|
88
|
+
push.validate!
|
89
|
+
push.run
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# !/usr/bin/env ruby
|
2
|
+
|
3
|
+
module Ocean
|
4
|
+
class HmapGenerator
|
5
|
+
QUOTE = 1 # 001
|
6
|
+
ANGLE_BRACKET = 2 # 010
|
7
|
+
BOTH = 3 # 011
|
8
|
+
def initialize
|
9
|
+
@hmap = Hash.new
|
10
|
+
end
|
11
|
+
# header_mapping : [Hash{FileAccessor => Hash}] Hash of file accessors by header mappings.
|
12
|
+
def add_hmap_with_header_mapping(header_mapping, type, target_name=nil, module_name=nil)
|
13
|
+
header_mapping.each do |facc, headers|
|
14
|
+
headers.each do |key, value|
|
15
|
+
value.each do |path|
|
16
|
+
pn = Pathname.new(path)
|
17
|
+
name = pn.basename.to_s
|
18
|
+
dirname = pn.dirname.to_s + '/'
|
19
|
+
# construct hmap hash info
|
20
|
+
path_info = Hash['suffix' => name, 'prefix' => dirname]
|
21
|
+
if type & QUOTE > 0
|
22
|
+
# import with quote
|
23
|
+
@hmap[name] = path_info
|
24
|
+
end
|
25
|
+
if type & ANGLE_BRACKET > 0
|
26
|
+
if target_name != nil
|
27
|
+
# import with angle bracket
|
28
|
+
@hmap["#{target_name}/#{name}"] = path_info
|
29
|
+
end
|
30
|
+
if module_name != nil && module_name != target_name
|
31
|
+
@hmap["#{module_name}/#{name}"] = path_info
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
# @path : path/to/xxx.hmap
|
39
|
+
# @return : succeed
|
40
|
+
def save_to(path)
|
41
|
+
if path != nil && @hmap.empty? == false
|
42
|
+
pn=Pathname(path)
|
43
|
+
json_path=pn.dirname.to_s + '/' + 'temp.json'
|
44
|
+
# write hmap json to file
|
45
|
+
File.open(json_path, 'w') { |file| file << @hmap.to_json }
|
46
|
+
# json to hmap
|
47
|
+
suc=system("hmap convert #{json_path} #{path}")
|
48
|
+
# delete json file
|
49
|
+
File.delete(json_path)
|
50
|
+
suc
|
51
|
+
else
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
def empty?
|
56
|
+
@hmap.empty?
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|