cocoapods-packager-ext 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fe4f327fcf1e83c2c98b3e7536e32d0a7a282d35d2a01785e976ec5d42ea490
4
- data.tar.gz: 8e511d747b8cd997dad144f8bdbc07fb291798524022db110c63a23eb0a0d2d2
3
+ metadata.gz: 9d1533e3a81379cabda6ffb6cf8a0ec7ac1e044d42af7f41e94344cd480bd38f
4
+ data.tar.gz: 53da1e28b909db61fa9cdabf3cb242307d2eea126da42dd0381ce481c2e07bea
5
5
  SHA512:
6
- metadata.gz: f3d309b76e55409eb00290a3a8417f748f78ebc381d3ad4276d262d602b87391381765e60e469caf0f4922de3846f0de8181f3d130cde37fa2da899f72024ffd
7
- data.tar.gz: '05863f3099b61ba477b227eca7734f52fcb2deac2cd549f55042cdcd6b51ec9d9712df4acee2d572981ef768b3b0bbc06959f0ae2185d8596931b8ff7f73ed37'
6
+ metadata.gz: 4ba30867ac2e65c3e0540e9897cbcf06306493786233333b8a90c5ca593c277f7bec718b054c47bd68f79417da06a600a15e46a880280d4905885b5516c74093
7
+ data.tar.gz: 247481474b4035c2c7bbe819edf2080e05f9af133a0c4fea4800b880eb34b44031582290ef0d22e018487e0a37d3ce2f87eca052f891ae42ae856ce9a7880f4e
@@ -1,5 +1,7 @@
1
1
  require 'cocoapods-packager-ext/ext/downloader/lnpath'
2
2
  require 'cocoapods-packager-ext/ext/downloader_ext'
3
+ require 'cocoapods-packager-ext/ext/pod_utils'
4
+
3
5
  module Pod
4
6
  class Command
5
7
  # This is an example of a cocoapods plugin adding a top-level subcommand
@@ -26,9 +28,7 @@ module Pod
26
28
  alias options_t options
27
29
  def options
28
30
  o = options_t
29
- o.push(['--all-deps','embedded all-depends'])
30
31
  o.push(['--archs','select archs'])
31
- o.push(['--black-deps','select exclude deps'])
32
32
  o.push(['--podfile','select deps version from podfile'])
33
33
  o.push(['--platform','select platform'])
34
34
  o.concat(super)
@@ -42,14 +42,39 @@ module Pod
42
42
 
43
43
  alias initialize_t initialize
44
44
  def initialize(argv)
45
- @all_deps = argv.flag?('all-deps',false)
45
+ @exclude_dep_items = argv.option('exclude-deps','').split(',')
46
46
  @select_archs = argv.option('archs','').split(',')
47
- @black_deps = argv.option('black-deps','').split(',')
48
47
  @podfile = argv.option('podfile','')
49
48
  @platform = argv.option('platform','')
50
49
  initialize_t argv
51
50
  end
52
51
 
52
+ alias build_in_sandbox_t build_in_sandbox
53
+ def build_in_sandbox(platform)
54
+ config.installation_root = Pathname.new(Dir.pwd)
55
+ config.sandbox_root = 'Pods'
56
+
57
+ static_sandbox = build_static_sandbox(@dynamic)
58
+ static_installer = install_pod(platform.name, static_sandbox)
59
+
60
+ if @dynamic
61
+ dynamic_sandbox = build_dynamic_sandbox(static_sandbox, static_installer)
62
+ install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
63
+ end
64
+
65
+ begin
66
+ perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
67
+ ensure # in case the build fails; see Builder#xcodebuild.
68
+ if ENV['ENABLE_BACKUP_WORKSPACE']
69
+ target_dir = "#{@source_dir}/#{@spec.name}-#{@spec.version}/workspace_#{platform}"
70
+ Dir.mkdir target_dir
71
+ `mv "#{Dir.pwd}" "#{target_dir}"`
72
+ end
73
+ Pathname.new(config.sandbox_root).rmtree
74
+ FileUtils.rm_f('Podfile.lock')
75
+ end
76
+ end
77
+
53
78
  alias build_package_t build_package
54
79
  def build_package
55
80
  if @platform == ''
@@ -72,13 +97,11 @@ module Pod
72
97
  File.open(@spec.name + '.podspec', 'w') { |file| file.write(newspec) }
73
98
  end
74
99
 
75
-
76
-
77
100
  end
78
101
 
79
102
  alias perform_build_t perform_build
80
103
  def perform_build(platform, static_sandbox, dynamic_sandbox,static_installer)
81
- if @all_deps || @select_archs.length > 0
104
+ if @select_archs.length > 0 || @exclude_dep_items.length > 0
82
105
  static_sandbox_root = config.sandbox_root.to_s
83
106
 
84
107
  if @dynamic
@@ -100,8 +123,7 @@ module Pod
100
123
  @config,
101
124
  @bundle_identifier,
102
125
  @exclude_deps,
103
- @all_deps,
104
- @black_deps,
126
+ @exclude_dep_items,
105
127
  @select_archs
106
128
  )
107
129
 
@@ -2,81 +2,88 @@ require "fileutils"
2
2
 
3
3
  module Pod
4
4
  class Builder
5
- #移动资源文件和静态库文件到build目录
6
- def deal_target(path)
7
- for item in @target_type_ext
8
- if File.extname(path) == item
9
- isBlack = false
10
- for black in @black_deps
11
- if File.basename(path).include? black
12
- isBlack = true
13
- end
14
- end
15
- if isBlack
16
- return
17
- end
18
- begin
19
- if File.directory? path
20
- FileUtils.copy_entry(path,"#{@target_dir_ext_ext}/#{File.basename(path)}", false,false, true)
21
- else
22
- FileUtils.cp(path,"#{@target_dir_ext_ext}/#{File.basename(path)}")
23
- end
24
- rescue Exception => e
25
- puts e
26
- end
27
- return
28
- end
29
- end
30
- if File.directory? path
31
- is_black = false
32
- for black in @black_list_ext
33
- if black == path
34
- is_black = true
35
- break
36
- end
37
- end
38
- if is_black
39
- return
40
- end
41
- Dir.foreach(path) do |file|
42
- if file != '.' && file != '..'
43
- deal_target(path+'/'+file)
44
- end
5
+
6
+ alias build_static_library_for_ios_t build_static_library_for_ios
7
+ def build_static_library_for_ios(output)
8
+ if @exclude_dep_items.length > 0
9
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim') + vendored_libraries
10
+ static_libs.reject! {|lib| @exclude_dep_items.any? {|item| lib.to_s.include? item}}
11
+ libs = ios_architectures.map do |arch|
12
+ library = "#{@static_sandbox_root}/build/package-#{arch}.a"
13
+ `libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
14
+ library
45
15
  end
16
+
17
+ `lipo -create -output #{output} #{libs.join(' ')}`
46
18
 
19
+ # static_libs = static_libs_in_sandbox('build')
20
+ # sim_libs = static_libs_in_sandbox('build-sim')
21
+ # for item in @black_deps
22
+ # static_libs.delete_if do |obj|
23
+ # obj.include? item
24
+ # end
25
+ # sim_libs.delete_if do |obj|
26
+ # obj.include? item
27
+ # end
28
+ # end
29
+ # UI.puts "links statics:#{static_libs.join(' ')}, sim_libs:#{sim_libs.join(' ')}"
30
+ # `xcrun -r libtool -no_warning_for_no_symbols -static -o #{output} #{static_libs.join(' ')} #{sim_libs.join(' ')}`
31
+ else
32
+ build_static_library_for_ios_t output
47
33
  end
48
34
  end
49
35
 
50
36
 
51
- alias build_static_library_for_ios_t build_static_library_for_ios
52
- def build_library(output)
53
- deal_target(@static_sandbox_root)
54
- if @all_deps
55
- static_libs = static_libs_in_sandbox('build')
56
- sim_libs = static_libs_in_sandbox('build-sim')
57
- for item in @black_deps
58
- static_libs.delete_if do |obj|
59
- obj.include? item
60
- end
61
- sim_libs.delete_if do |obj|
62
- obj.include? item
63
- end
64
- end
65
- UI.puts "links statics:#{static_libs.join(' ')}, sim_libs:#{sim_libs.join(' ')}"
66
- `xcrun -r libtool -no_warning_for_no_symbols -static -o #{output} #{static_libs.join(' ')} #{sim_libs.join(' ')}`
37
+ alias static_linker_flags_in_sandbox_t ios_architectures
38
+ def static_linker_flags_in_sandbox
39
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim') + vendored_libraries
40
+ linker_flags = static_libs.map do |lib|
41
+ lib = lib.chomp('.a').split('/').last
42
+ lib.slice!('lib')
43
+ "-l#{lib}"
44
+ end
45
+ linker_flags.reject { |e| e == "-l#{@spec.name}" || e == '-lPods-packager' }
46
+ end
47
+
48
+ def ios_build_options
49
+ if ENV['DISABLE_BITCODE']
50
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-Qunused-arguments\'"
51
+ else
52
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
53
+ end
54
+ end
55
+
56
+ def static_linker_defines
57
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim')
58
+ static_libs = static_libs.map { |path| Pathname("#{Dir.pwd}/#{path}").parent.to_s }
59
+ vendored_libs = vendored_libraries.map { |path| Pathname(path).parent.to_s }
60
+ link_paths = static_libs + vendored_libs
61
+ link_paths.uniq.join(" ")
62
+ end
63
+ alias build_dynamic_framework_for_ios_t build_dynamic_framework_for_ios
64
+ def build_dynamic_framework_for_ios(defines, output)
65
+ # Specify frameworks to link and search paths
66
+ linker_flags = static_linker_flags_in_sandbox
67
+ defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"
68
+
69
+ # Build Target Dynamic Framework for both device and Simulator
70
+ device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{static_linker_defines}\""
71
+ device_options = ios_build_options << ' -sdk iphoneos'
72
+ xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
73
+ if @select_archs.size == 0 || @select_archs.include?('i386') || @select_archs.include?('x86_64')
74
+ sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
75
+ xcodebuild(sim_defines, '-sdk iphonesimulator', 'build-sim', @spec.name.to_s, @dynamic_sandbox_root.to_s)
76
+ # Combine architectures
77
+ `lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
67
78
  else
68
- build_static_library_for_ios output
79
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{output}`
69
80
  end
81
+
82
+ FileUtils.mkdir(@platform.name.to_s)
83
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
84
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
70
85
  end
71
86
 
72
- # alias ios_build_options_t ios_build_options
73
- # def ios_build_options
74
- # if @select_archs.size != 0
75
- # return "ARCHS=\'#{@select_archs.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
76
- # else
77
- # return ios_build_options_t
78
- # end
79
- # end
80
87
  alias ios_architectures_t ios_architectures
81
88
  def ios_architectures
82
89
  if @select_archs.size != 0
@@ -85,6 +92,79 @@ module Pod
85
92
  return ios_architectures_t
86
93
  end
87
94
  end
95
+ alias copy_headers_t copy_headers
96
+ def copy_headers
97
+ headers_source_root = "#{@public_headers_root}/#{@spec.name}"
98
+
99
+ Dir.glob("#{headers_source_root}/**/*.h").
100
+ each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
101
+
102
+ # If custom 'module_map' is specified add it to the framework distribution
103
+ # otherwise check if a header exists that is equal to 'spec.name', if so
104
+ # create a default 'module_map' one using it.
105
+ if !@spec.module_map.nil?
106
+ module_map_file = @file_accessors.flat_map(&:module_map).first
107
+ module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
108
+ elsif File.exist?("#{@public_headers_root}/#{@spec.name}/#{@spec.name}.h")
109
+ module_map = <<MAP
110
+ framework module #{@spec.name} {
111
+ umbrella header "#{@spec.name}.h"
112
+
113
+ export *
114
+ module * { export * }
115
+ }
116
+ MAP
117
+ else
118
+
119
+ f = File.new(File.join("#{@fwk.headers_path}","#{@spec.name}.h"), "w+")
120
+ f.puts("#import <UIKit/UIKit.h>")
121
+ f.puts("#import <Foundation/Foundation.h>")
122
+ Dir.foreach(@fwk.headers_path) do |filename|
123
+ if filename != "." and filename != ".."
124
+ f.puts("#import \"#{filename}\"")
125
+ end
126
+ end
127
+ f.close
128
+
129
+ module_map = <<MAP
130
+ framework module #{@spec.name} {
131
+ umbrella header "#{@spec.name}.h"
132
+
133
+ export *
134
+ module * { export * }
135
+ }
136
+ MAP
137
+ end
138
+
139
+ unless module_map.nil?
140
+ @fwk.module_map_path.mkpath unless @fwk.module_map_path.exist?
141
+ File.write("#{@fwk.module_map_path}/module.modulemap", module_map)
142
+ end
143
+ end
144
+
145
+ alias copy_resources_t copy_resources
146
+ def copy_resources
147
+ if @exclude_deps
148
+ bundles = @static_installer.pod_targets.flat_map(&:file_accessors).flat_map{|item|item.resources}
149
+ else
150
+ bundles = @static_installer.pod_targets.reject { |t| @exclude_dep_items.any?{|item|t.pod_name == item}}.flat_map(&:file_accessors).flat_map{|item|item.resources}
151
+ end
152
+ if @dynamic
153
+ resources_path = "ios/#{@spec.name}.framework"
154
+ bundles.tap{|path| FileUtils.cp_r path,resources_path}
155
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{resources_path} 2>&1`
156
+ else
157
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{@fwk.resources_path} 2>&1`
158
+ resources = expand_paths(@spec.consumer(@platform).resources)
159
+ if resources.count == 0 && bundles.count == 0
160
+ @fwk.delete_resources
161
+ return
162
+ end
163
+ if resources.count > 0
164
+ `cp -rp #{resources.join(' ')} #{@fwk.resources_path}`
165
+ end
166
+ end
167
+ end
88
168
 
89
169
  alias build_sim_libraries_t build_sim_libraries
90
170
  def build_sim_libraries(defines)
@@ -97,13 +177,9 @@ module Pod
97
177
  end
98
178
 
99
179
  alias initialize_t initialize
100
- def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps,all_deps= false ,black_deps=[],select_archs=[])
101
- @all_deps = all_deps
102
- @black_deps = black_deps
180
+ def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps,exclude_dep_items=[],select_archs=[])
181
+ @exclude_dep_items = exclude_dep_items
103
182
  @select_archs = select_archs
104
- @target_type_ext = ['.a','.bundle']
105
- @target_dir_ext_ext = "#{static_sandbox_root}/build"
106
- @black_list_ext = ["#{static_sandbox_root}/build","#{static_sandbox_root}/build-sim"]
107
183
  initialize_t(platform, static_installer,source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps)
108
184
  end
109
185
  end
@@ -0,0 +1,57 @@
1
+ module Pod
2
+ class Command
3
+ class Package
4
+
5
+ # @param [Pod::Installer] static_installer
6
+ #
7
+ # @return [Pod::PodTarget]
8
+ #
9
+ alias build_dynamic_target_t build_dynamic_target
10
+
11
+ def build_dynamic_target(dynamic_sandbox, static_installer, platform)
12
+ spec_targets = static_installer.pod_targets.select do |target|
13
+ target.name == @spec.name
14
+ end
15
+ static_target = spec_targets[0]
16
+
17
+ file_accessors = create_file_accessors(static_target, dynamic_sandbox)
18
+
19
+ archs = []
20
+ dynamic_target = Pod::PodTarget.new(dynamic_sandbox, BuildType.dynamic_framework, static_target.user_build_configurations, archs, platform, static_target.specs, static_target.target_definitions, file_accessors)
21
+ dynamic_target
22
+ end
23
+ alias copy_dynamic_target_t copy_dynamic_target
24
+ def copy_dynamic_target(static_sandbox, _dynamic_target, dynamic_sandbox)
25
+ command = "ln -sf #{static_sandbox.root}/#{@spec.name} #{dynamic_sandbox.root}"
26
+ `#{command}`
27
+ end
28
+
29
+ alias write_pod_project_t write_pod_project
30
+ def write_pod_project(dynamic_project, dynamic_sandbox)
31
+ UI.message "- Writing Xcode project file to #{UI.path dynamic_sandbox.project_path}" do
32
+ dynamic_project.pods.remove_from_project if dynamic_project.pods.empty?
33
+ dynamic_project.development_pods.remove_from_project if dynamic_project.development_pods.empty?
34
+ dynamic_project.sort(:groups_position => :below)
35
+ dynamic_project.recreate_user_schemes(false)
36
+
37
+ # Edit search paths so that we can find our dependency headers
38
+ dynamic_project.targets.first.build_configuration_list.build_configurations.each do |config|
39
+ header_path = Dir.glob("#{Dir.pwd}/Pods/Static/Headers/*/*")
40
+ header_path.push "#{Dir.pwd}/Pods/Static/Headers/Public"
41
+ header_path.push "#{Dir.pwd}/Pods/Static/Headers/Private"
42
+ header_path.reject! {|item|item.split('/').last == dynamic_project.targets.first.name}
43
+ header_path = header_path.join " "
44
+ config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) #{header_path}"
45
+ config.build_settings['USER_HEADER_SEARCH_PATHS'] = "$(inherited) #{header_path}"
46
+ config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
47
+
48
+ if ENV['DISABLE_BITCODE']
49
+ config.build_settings['ENABLE_BITCODE'] = 'NO'
50
+ end
51
+ end
52
+ dynamic_project.save
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPackagerExt
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.22"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-packager-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyle.zhou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,7 @@ files:
72
72
  - lib/cocoapods-packager-ext/ext/builder.rb
73
73
  - lib/cocoapods-packager-ext/ext/downloader/lnpath.rb
74
74
  - lib/cocoapods-packager-ext/ext/downloader_ext.rb
75
+ - lib/cocoapods-packager-ext/ext/pod_utils.rb
75
76
  - lib/cocoapods-packager-ext/gem_version.rb
76
77
  - lib/cocoapods_plugin.rb
77
78
  - spec/command/ext_spec.rb