Module: Symbols

Defined in:
lib/mangle.rb,
lib/symbols.rb

Class Method Summary collapse

Class Method Details

.classes_from_symbols(syms) ⇒ Object



13
14
15
16
17
18
# File 'lib/symbols.rb', line 13

def classes_from_symbols(syms)
  classes = syms.select { |klass| klass[/OBJC_CLASS_\$_/] }
  classes = classes.select { |klass| klass !~ /_NS|_UI/ }
  classes = classes.uniq
  classes.map! { |klass| klass.gsub(/^.*\$_/, '') }
end

.constants_from_symbols(syms) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/symbols.rb', line 20

def constants_from_symbols(syms)
  consts = syms.select { |const| const[/ S /] }
  consts = consts.select { |const| const !~ /OBJC|\.eh/ }
  consts = consts.uniq
  consts = consts.map! { |const| const.gsub(/^.* _/, '') }

  other_consts = syms.select { |const| const[/ T /] }
  other_consts = other_consts.uniq
  other_consts = other_consts.map! { |const| const.gsub(/^.* _/, '') }

  consts + other_consts
end

.mangle_for_pod_dependencies(pod_name, sandbox_root) ⇒ Object

performs symbol aliasing

for each dependency: - determine symbols for classes and global constants - alias each symbol to Pod#pod_name_#symbol - put defines into ‘GCC_PREPROCESSOR_DEFINITIONS` for passing to Xcode



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mangle.rb', line 10

def mangle_for_pod_dependencies(pod_name, sandbox_root)
  pod_libs = Dir.glob("#{sandbox_root}/build/libPods-*.a").select do
    |file| file !~ /#{pod_name}/
  end

  all_syms = []

  pod_libs.each do |pod_lib|
    syms = Symbols.symbols_from_library(pod_lib)
    all_syms += syms.map! { |sym| sym + "=Pod#{pod_name}_" + sym }
  end

  "GCC_PREPROCESSOR_DEFINITIONS='${inherited} #{all_syms.uniq.join(' ')}'"
end

.symbols_from_library(library) ⇒ Object



2
3
4
5
6
7
# File 'lib/symbols.rb', line 2

def symbols_from_library(library)
  syms = `nm -g #{library}`.split("\n")

  result = classes_from_symbols(syms)
  result + constants_from_symbols(syms)
end