cocoapods-meitu-bin 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +56 -0
  4. data/lib/cocoapods-meitu-bin/command/bin/archive.rb +206 -0
  5. data/lib/cocoapods-meitu-bin/command/bin/auto.rb +212 -0
  6. data/lib/cocoapods-meitu-bin/command/bin/build_all.rb +345 -0
  7. data/lib/cocoapods-meitu-bin/command/bin/header_files_specifications.rb +262 -0
  8. data/lib/cocoapods-meitu-bin/command/bin/init.rb +72 -0
  9. data/lib/cocoapods-meitu-bin/command/bin/install.rb +44 -0
  10. data/lib/cocoapods-meitu-bin/command/bin/lib/lint.rb +67 -0
  11. data/lib/cocoapods-meitu-bin/command/bin/lock/dependency.rb +89 -0
  12. data/lib/cocoapods-meitu-bin/command/bin/lock/spec_repo.rb +105 -0
  13. data/lib/cocoapods-meitu-bin/command/bin/lock/version.rb +68 -0
  14. data/lib/cocoapods-meitu-bin/command/bin/lock.rb +36 -0
  15. data/lib/cocoapods-meitu-bin/command/bin/output_source.rb +146 -0
  16. data/lib/cocoapods-meitu-bin/command/bin/repo/push.rb +88 -0
  17. data/lib/cocoapods-meitu-bin/command/bin/repo/update.rb +42 -0
  18. data/lib/cocoapods-meitu-bin/command/bin/repo.rb +14 -0
  19. data/lib/cocoapods-meitu-bin/command/bin/source/add.rb +148 -0
  20. data/lib/cocoapods-meitu-bin/command/bin/source/delete.rb +59 -0
  21. data/lib/cocoapods-meitu-bin/command/bin/source/list.rb +46 -0
  22. data/lib/cocoapods-meitu-bin/command/bin/source.rb +30 -0
  23. data/lib/cocoapods-meitu-bin/command/bin/spec/create.rb +73 -0
  24. data/lib/cocoapods-meitu-bin/command/bin/spec/lint.rb +109 -0
  25. data/lib/cocoapods-meitu-bin/command/bin/spec.rb +13 -0
  26. data/lib/cocoapods-meitu-bin/command/bin/update.rb +154 -0
  27. data/lib/cocoapods-meitu-bin/command/bin/upload.rb +175 -0
  28. data/lib/cocoapods-meitu-bin/command/bin.rb +69 -0
  29. data/lib/cocoapods-meitu-bin/command.rb +1 -0
  30. data/lib/cocoapods-meitu-bin/config/config.rb +149 -0
  31. data/lib/cocoapods-meitu-bin/config/config_asker.rb +57 -0
  32. data/lib/cocoapods-meitu-bin/config/config_builder.rb +216 -0
  33. data/lib/cocoapods-meitu-bin/gem_version.rb +9 -0
  34. data/lib/cocoapods-meitu-bin/helpers/Info.plist +0 -0
  35. data/lib/cocoapods-meitu-bin/helpers/buildAll/bin_helper.rb +97 -0
  36. data/lib/cocoapods-meitu-bin/helpers/buildAll/builder.rb +434 -0
  37. data/lib/cocoapods-meitu-bin/helpers/buildAll/podspec_util.rb +140 -0
  38. data/lib/cocoapods-meitu-bin/helpers/buildAll/zip_file_helper.rb +87 -0
  39. data/lib/cocoapods-meitu-bin/helpers/build_helper.rb +167 -0
  40. data/lib/cocoapods-meitu-bin/helpers/build_utils.rb +64 -0
  41. data/lib/cocoapods-meitu-bin/helpers/framework.rb +86 -0
  42. data/lib/cocoapods-meitu-bin/helpers/framework_builder.rb +551 -0
  43. data/lib/cocoapods-meitu-bin/helpers/library.rb +54 -0
  44. data/lib/cocoapods-meitu-bin/helpers/library_builder.rb +90 -0
  45. data/lib/cocoapods-meitu-bin/helpers/pod_size_helper.rb +54 -0
  46. data/lib/cocoapods-meitu-bin/helpers/sources_helper.rb +35 -0
  47. data/lib/cocoapods-meitu-bin/helpers/spec_creator.rb +170 -0
  48. data/lib/cocoapods-meitu-bin/helpers/spec_files_helper.rb +80 -0
  49. data/lib/cocoapods-meitu-bin/helpers/spec_source_creator.rb +304 -0
  50. data/lib/cocoapods-meitu-bin/helpers/upload_helper.rb +104 -0
  51. data/lib/cocoapods-meitu-bin/helpers.rb +5 -0
  52. data/lib/cocoapods-meitu-bin/native/acknowledgements.rb +27 -0
  53. data/lib/cocoapods-meitu-bin/native/analyzer.rb +109 -0
  54. data/lib/cocoapods-meitu-bin/native/file_accessor.rb +28 -0
  55. data/lib/cocoapods-meitu-bin/native/gen.rb +79 -0
  56. data/lib/cocoapods-meitu-bin/native/installation_options.rb +28 -0
  57. data/lib/cocoapods-meitu-bin/native/installer.rb +259 -0
  58. data/lib/cocoapods-meitu-bin/native/linter.rb +26 -0
  59. data/lib/cocoapods-meitu-bin/native/lockfile.rb +85 -0
  60. data/lib/cocoapods-meitu-bin/native/path_source.rb +33 -0
  61. data/lib/cocoapods-meitu-bin/native/pod_source_installer.rb +19 -0
  62. data/lib/cocoapods-meitu-bin/native/pod_target_installer.rb +87 -0
  63. data/lib/cocoapods-meitu-bin/native/podfile.rb +99 -0
  64. data/lib/cocoapods-meitu-bin/native/podfile_env.rb +38 -0
  65. data/lib/cocoapods-meitu-bin/native/podfile_generator.rb +201 -0
  66. data/lib/cocoapods-meitu-bin/native/podspec_finder.rb +25 -0
  67. data/lib/cocoapods-meitu-bin/native/resolver.rb +299 -0
  68. data/lib/cocoapods-meitu-bin/native/sandbox_analyzer.rb +34 -0
  69. data/lib/cocoapods-meitu-bin/native/source.rb +35 -0
  70. data/lib/cocoapods-meitu-bin/native/sources_manager.rb +21 -0
  71. data/lib/cocoapods-meitu-bin/native/specification.rb +31 -0
  72. data/lib/cocoapods-meitu-bin/native/target_validator.rb +41 -0
  73. data/lib/cocoapods-meitu-bin/native/validator.rb +40 -0
  74. data/lib/cocoapods-meitu-bin/native.rb +26 -0
  75. data/lib/cocoapods-meitu-bin/source_provider_hook.rb +68 -0
  76. data/lib/cocoapods-meitu-bin.rb +2 -0
  77. data/lib/cocoapods_plugin.rb +11 -0
  78. data/spec/command/bin_spec.rb +12 -0
  79. data/spec/spec_helper.rb +50 -0
  80. metadata +201 -0
@@ -0,0 +1,87 @@
1
+ require 'json'
2
+ require 'cocoapods-meitu-bin/helpers/buildAll/bin_helper'
3
+
4
+ module CBin
5
+ module BuildAll
6
+ class ZipFileHelper
7
+ include Pod
8
+
9
+ def initialize(pod_target, version, product_dir, build_as_framework = false, configuration = 'Debug')
10
+ @pod_target = pod_target
11
+ @version = version
12
+ @product_dir = product_dir
13
+ @build_as_framework = build_as_framework
14
+ @configuration = configuration
15
+ end
16
+
17
+ # 上传静态库
18
+ def upload_zip_lib
19
+ Dir.chdir(@product_dir) do
20
+ zip_file = File.join(Dir.pwd, "#{zip_file_name}")
21
+ unless File.exist?(zip_file)
22
+ UI.info "`#{Dir.pwd}`目录下无`#{zip_file_name}`文件".red
23
+ return false
24
+ end
25
+ UI.info "Uploading binary zip file `#{@pod_target.root_spec.name} (#{version})`".yellow do
26
+ upload_url = CBin.config.binary_upload_url_str
27
+ xcode_version = BinHelper.xcode_version
28
+ command = "curl -F \"name=#{@pod_target.product_module_name}\" -F \"version=#{version}\" -F \"xcode_version=#{xcode_version}\" -F \"configuration=#{@configuration}\" -F \"file=@#{zip_file}\" #{upload_url}"
29
+ UI.info "#{command}"
30
+ json = `#{command}`
31
+ UI.info json
32
+ begin
33
+ success = JSON.parse(json)["success"]
34
+ if success
35
+ Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传成功".green
36
+ return true
37
+ else
38
+ Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传失败".red
39
+ return false
40
+ end
41
+ rescue JSON::ParserError => e
42
+ Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传失败".red
43
+ Pod::UI.info "#{e.to_s}".red
44
+ return false
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ # 压缩静态库
51
+ def zip_lib
52
+ Dir.chdir(@product_dir) do
53
+ input_library = "#{@pod_target.framework_name}"
54
+ output_library = File.join(Dir.pwd, zip_file_name)
55
+ FileUtils.rm_f(output_library) if File.exist?(output_library)
56
+ unless File.exist?(input_library)
57
+ UI.info "没有需要压缩的二进制文件:`#{input_library}`".red
58
+ return false
59
+ end
60
+
61
+ UI.info "Compressing `#{input_library}` into `#{zip_file_name}`".yellow do
62
+ command = "zip --symlinks -r #{output_library} #{input_library}"
63
+ UI.info "#{command}"
64
+ `#{command}`
65
+ unless File.exist?(output_library)
66
+ UI.info "压缩`#{output_library}`失败".red
67
+ return false
68
+ end
69
+ return true
70
+ end
71
+ end
72
+ end
73
+
74
+ # zip文件名字
75
+ def zip_file_name
76
+ @zip_file_name ||= begin
77
+ "#{@pod_target.framework_name}_#{@version || @pod_target.root_spec.version}.zip"
78
+ end
79
+ end
80
+
81
+ def version
82
+ @version || @pod_target.root_spec.version
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,167 @@
1
+ # copy from https://github.com/CocoaPods/cocoapods-packager
2
+
3
+ require 'cocoapods-meitu-bin/native/podfile'
4
+ require 'cocoapods/command/gen'
5
+ require 'cocoapods/generate'
6
+ require 'cocoapods-meitu-bin/helpers/framework_builder'
7
+ require 'cocoapods-meitu-bin/helpers/library_builder'
8
+ require 'cocoapods-meitu-bin/config/config_builder'
9
+
10
+ module CBin
11
+ class Build
12
+ class Helper
13
+ include Pod
14
+ #class var
15
+ @@build_defines = ""
16
+ #Debug下还待完成
17
+ def initialize(spec,
18
+ platform,
19
+ framework_output,
20
+ zip,
21
+ rootSpec,
22
+ skip_archive = false,
23
+ build_model="Release",
24
+ installer = nil)
25
+ @spec = spec
26
+ @platform = platform
27
+ @build_model = build_model
28
+ @rootSpec = rootSpec
29
+ @isRootSpec = rootSpec.name == spec.name
30
+ @skip_archive = skip_archive
31
+ @framework_output = framework_output
32
+ @zip = zip
33
+ @installer = installer
34
+
35
+ @framework_path
36
+ end
37
+
38
+ # 构建.a或.framework
39
+ def build
40
+ unless @skip_archive
41
+ unless CBin::Build::Utils.is_framework(@spec)
42
+ build_static_library
43
+ zip_static_library
44
+ else
45
+ build_static_framework
46
+ zip_static_framework
47
+ end
48
+ end
49
+ end
50
+
51
+ # 构建静态framework
52
+ def build_static_framework
53
+ UI.title("Building static framework #{@spec}") do
54
+ source_dir = Dir.pwd
55
+ # file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
56
+ Dir.chdir(workspace_directory) do
57
+ builder = CBin::Framework::Builder.new(@spec, @installer, @platform, source_dir, @isRootSpec, @build_model )
58
+ # 编译当前库
59
+ @@build_defines = builder.build if @isRootSpec
60
+ begin
61
+ @framework_path = builder.lipo_create(@@build_defines) unless @skip_archive
62
+ rescue
63
+ @skip_archive = true
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ # 构建library
70
+ def build_static_library
71
+ source_dir = zip_dir
72
+ file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
73
+ Dir.chdir(workspace_directory) do
74
+ builder = CBin::Library::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path)
75
+ builder.build
76
+ end
77
+ end
78
+
79
+ # 压缩静态framework
80
+ def zip_static_framework
81
+ Dir.chdir(File.join(workspace_directory,@framework_path.root_path)) do
82
+ output_name = File.join(zip_dir, framework_name_zip)
83
+ unless File.exist?(framework_name)
84
+ UI.info "没有需要压缩的 framework 文件:#{framework_name}"
85
+ return
86
+ end
87
+
88
+ UI.title "Compressing #{framework_name} into #{output_name}" do
89
+ Dir.mkdir(zip_dir) unless File.exist?(zip_dir)
90
+ command = "zip --symlinks -r #{output_name} #{framework_name}"
91
+ UI.info "#{command}"
92
+ `#{command}`
93
+ end
94
+ end
95
+ end
96
+
97
+ # 压缩library
98
+ def zip_static_library
99
+ Dir.chdir(zip_dir) do
100
+ output_library = "#{library_name}.zip"
101
+ unless File.exist?(library_name)
102
+ raise Informative, "没有需要压缩的 library 文件:#{library_name}"
103
+ end
104
+
105
+ UI.puts "Compressing #{library_name} into #{output_library}"
106
+ `zip --symlinks -r #{output_library} #{library_name}`
107
+ end
108
+
109
+ end
110
+
111
+ # 清理缓存
112
+ def clean_workspace
113
+ UI.puts 'Cleaning workspace'
114
+
115
+ FileUtils.rm_rf(gen_name)
116
+ Dir.chdir(zip_dir) do
117
+ FileUtils.rm_rf(framework_name) if @zip
118
+ FileUtils.rm_rf(library_name)
119
+ FileUtils.rm_rf(framework_name) unless @framework_output
120
+ FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output
121
+ end
122
+ end
123
+
124
+ def framework_name
125
+ CBin::Config::Builder.instance.framework_name(@spec)
126
+ end
127
+
128
+ def framework_name_zip
129
+ CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip"
130
+ end
131
+
132
+ def library_name
133
+ CBin::Config::Builder.instance.library_name(@spec)
134
+ end
135
+
136
+ # "PodA-build-temp/bin-archive/PodA"
137
+ def workspace_directory
138
+ File.expand_path("#{gen_name}/#{@rootSpec.name}")
139
+ end
140
+
141
+ def zip_dir
142
+ CBin::Config::Builder.instance.zip_dir
143
+ end
144
+
145
+ def gen_name
146
+ CBin::Config::Builder.instance.gen_dir
147
+ end
148
+
149
+
150
+ def spec_file
151
+ @spec_file ||= begin
152
+ if @podspec
153
+ find_spec_file(@podspec)
154
+ else
155
+ if code_spec_files.empty?
156
+ raise Informative, '当前目录下没有找到可用源码 podspec.'
157
+ end
158
+
159
+ spec_file = code_spec_files.first
160
+ spec_file
161
+ end
162
+ end
163
+ end
164
+
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,64 @@
1
+ require 'yaml'
2
+ require 'cocoapods-meitu-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
+ return true
48
+ uses_frameworks = false
49
+ Pod::Config.instance.podfile.target_definitions.each do |key,value|
50
+ if key != "Pods"
51
+ uses_frameworks = value.uses_frameworks?
52
+ if uses_frameworks
53
+ break ;
54
+ end
55
+ end
56
+ end
57
+
58
+ return uses_frameworks
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,86 @@
1
+ # copy from https://github.com/CocoaPods/cocoapods-packager
2
+
3
+ module CBin
4
+ class Framework
5
+ attr_reader :headers_path
6
+ attr_reader :module_map_path
7
+ attr_reader :resources_path
8
+ attr_reader :root_path
9
+ attr_reader :versions_path
10
+ attr_reader :swift_module_path
11
+ attr_reader :fwk_path
12
+
13
+ def initialize(name, platform)
14
+ @name = name
15
+ @platform = platform
16
+ end
17
+
18
+ def make
19
+ make_root
20
+ make_framework
21
+ # make_headers
22
+ # make_resources
23
+ # make_current_version
24
+ end
25
+
26
+ def delete_resources
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}/`
45
+ end
46
+
47
+ private
48
+
49
+ def make_current_version
50
+ current_version_path = @versions_path + Pathname.new('../Current')
51
+ `ln -sf A #{current_version_path}`
52
+ `ln -sf Versions/Current/Headers #{@fwk_path}/`
53
+ `ln -sf Versions/Current/Resources #{@fwk_path}/`
54
+ `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
55
+ end
56
+
57
+
58
+
59
+ def make_framework
60
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
61
+ @fwk_path.mkdir unless @fwk_path.exist?
62
+
63
+ @module_map_path = @fwk_path + Pathname.new('Modules')
64
+ @swift_module_path = @module_map_path + Pathname.new(@name + '.swiftmodule')
65
+
66
+
67
+ # @versions_path = @fwk_path + Pathname.new('Versions/A')
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
+ # bin-archive/PodA/ios
81
+ def make_root
82
+ @root_path = Pathname.new(@platform)
83
+ @root_path.mkpath unless @root_path.exist?
84
+ end
85
+ end
86
+ end