cint 0.1.8 → 0.2.0

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: 54ea5ee92cb9903a4f26197b00582d9ff6145b7a549efdd7e56041b3f1795d61
4
- data.tar.gz: ee696712694fa804445ba4b890dd67f4045c46390627526fc915a115c4fed6af
3
+ metadata.gz: 20a5e222485438a3ffb646bb8b4330e7cbb14001d41df6317d4a5cf8353cf437
4
+ data.tar.gz: 694344df09fbcdd6774feff23ce3ee9587aa813c0362228e2388b28a940e6253
5
5
  SHA512:
6
- metadata.gz: 2e588b623d4942b7edc74be77da755030370a460a9802832f024d0181eddaf1256b4cfcea359bab8edda4d3f2268863b09c0d11c51a56e879198bdf5a7f88e2a
7
- data.tar.gz: 35959160dac319b86203f95e60ee33d7f162459e49beddf0cd6b706d9cef682529a54dbed4fd671e7575aeab22963070d9af3b905347630b1d92951139269caf
6
+ metadata.gz: 12d6f169dd2e8f3914f5a4baa74345863fdc65f8bc9d494a7bda4852c7e6872390317b525866fff54786bddd38bd1035b3a422058c7e0a28110a0b4cb46c5b56
7
+ data.tar.gz: ea55553f8aa0300f081e1448f50ea8c57990de2bea1cf30e14dcf737545cbc18d28756b2ba648445c3994125da78082a4e30122157a210003e6b11a165b1b679
data/bin/cint CHANGED
@@ -15,6 +15,8 @@ program :version, Cint::VERSION
15
15
  program :description, 'Integrates Carthage Frameworks'
16
16
  program :help, 'Author', 'Alex Antonyuk <alex@antonyuk.me>'
17
17
 
18
+ default_command :install
19
+
18
20
  def error(message)
19
21
  puts "\nError: #{message}".red
20
22
  exit
@@ -40,19 +42,6 @@ SDK_TO_PLATFORM = {
40
42
 
41
43
  PLATFORMS = %w(iOS Mac watchOS tvOS).freeze
42
44
 
43
- # Carthage
44
- class CarthageFiles
45
- def self.exists
46
- Dir.exist? './Carthage/Build'
47
- end
48
-
49
- def self.frameworks(platform)
50
- return [] unless PLATFORMS.include?(platform)
51
- pattern = "./Carthage/Build/#{platform}/*.framework"
52
- Dir.glob(pattern)
53
- end
54
- end
55
-
56
45
  def prepare_inputs(frameworks)
57
46
  frameworks.map do |f|
58
47
  "$(SRCROOT)#{f[1..-1]}"
@@ -107,7 +96,7 @@ end
107
96
 
108
97
  def intergate_frameworks(target, project)
109
98
  platform = SDK_TO_PLATFORM[target.sdk]
110
- frameworks = CarthageFiles.frameworks(platform)
99
+ frameworks = Cint::CarthageFiles.frameworks(platform)
111
100
 
112
101
  if frameworks.empty?
113
102
  warning 'No frameworks found'
@@ -138,7 +127,7 @@ command :install do |c|
138
127
  c.syntax = 'cint install <project_name>'
139
128
  c.description = 'Adds frameworks built by Carthage into a project'
140
129
  c.action do |args, _|
141
- error 'Carthage build folder does not exists' unless CarthageFiles.exists
130
+ error 'Carthage build folder does not exists' unless Cint::CarthageFiles.exists
142
131
 
143
132
  # Choose Project
144
133
  project_name = get_project_name(args)
@@ -159,3 +148,56 @@ command :install do |c|
159
148
  info 'Done. Re-open Project'
160
149
  end
161
150
  end
151
+
152
+ def cleanup_orphaned_symbols(frameworks)
153
+ used_symbols = frameworks.flat_map do |framework|
154
+ Cint::Cleanup.bcsymbolmap(framework)
155
+ end
156
+ all = Cint::Cleanup.all_bcsymbolmap
157
+ orphans = all - used_symbols
158
+
159
+ warning "There are no orphan symbols" if orphans.empty?
160
+ orphans.each_with_index do |symb, index|
161
+ puts "(#{index + 1}/#{orphans.count}) Removing #{symb}...".red
162
+ File.delete(symb)
163
+ end
164
+ end
165
+
166
+ def cleanup_symbols(frameworks, args)
167
+ if args.empty?
168
+ filtered_frameworks = frameworks
169
+ else
170
+ filtered_frameworks = frameworks.select do |framework|
171
+ name = File.basename(framework)
172
+ args.include?(name)
173
+ end
174
+ end
175
+ warning "Nothing to precess" if filtered_frameworks.empty?
176
+
177
+ progress(filtered_frameworks) do |framework|
178
+ puts "Processing #{framework}...".green
179
+ Cint::Cleanup.bcsymbolmap(framework).each do |bcs|
180
+ if File.exists?(bcs)
181
+ print "\tRemoving #{bcs}".red
182
+ File.delete(bcs)
183
+ end
184
+ $stdout.flush
185
+ end
186
+ end
187
+ end
188
+
189
+ command :cleanup do |c|
190
+ c.syntax = 'cint cleanup [framework,...]'
191
+ c.description = 'Remove bcsymbolmap files for frameworks. If no parameters passed it will perform cleanup for every framework.'
192
+ c.option '--orphans'
193
+ c.action do |args, options|
194
+ frameworks = Cint::Cleanup.frameworks
195
+ error "There are not a single framework found. Check directory, it should be ran in Build/* directory." if frameworks.empty?
196
+
197
+ if options.orphans
198
+ cleanup_orphaned_symbols(frameworks)
199
+ else
200
+ cleanup_symbols(frameworks, args)
201
+ end
202
+ end
203
+ end
data/lib/cint.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require_relative "cint/version"
2
2
  require_relative "cint/project"
3
+ require_relative "cint/carthage_files"
4
+ require_relative "cint/cleanup"
3
5
 
4
6
  module Cint
5
7
  # Your code goes here...
@@ -0,0 +1,14 @@
1
+
2
+ module Cint
3
+ class CarthageFiles
4
+ def self.exists
5
+ Dir.exist? './Carthage/Build'
6
+ end
7
+
8
+ def self.frameworks(platform)
9
+ return [] unless PLATFORMS.include?(platform)
10
+ pattern = "./Carthage/Build/#{platform}/*.framework"
11
+ Dir.glob(pattern)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+
2
+ module Cint
3
+ class Cleanup
4
+ def self.frameworks
5
+ Dir.glob("*.framework")
6
+ end
7
+
8
+ def self.all_bcsymbolmap
9
+ Dir.glob("*.bcsymbolmap")
10
+ end
11
+
12
+ def self.bcsymbolmap(framework_path)
13
+ name = File.basename(framework_path, ".framework")
14
+ path = framework_path + "/#{name}"
15
+ uuids = `xcrun dwarfdump --uuid "#{path}" | awk '{print $2}'`.split("\n").map(&:chomp)
16
+ uuids.map { |uuid| "#{uuid}.bcsymbolmap" }
17
+ end
18
+ end
19
+ end
data/lib/cint/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cint
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Antonyuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-06 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -106,6 +106,8 @@ files:
106
106
  - README.md
107
107
  - bin/cint
108
108
  - lib/cint.rb
109
+ - lib/cint/carthage_files.rb
110
+ - lib/cint/cleanup.rb
109
111
  - lib/cint/project.rb
110
112
  - lib/cint/version.rb
111
113
  - lib/xcodeproj.rb