Sha256: 8812a4eb5966677872bff380ca43222d84a18e7b5458c0fc5d6bbae160b5a7b9

Contents?: true

Size: 1.14 KB

Versions: 24

Compression:

Stored size: 1.14 KB

Contents

module Symbols
  def symbols_from_library(library)
    syms = `nm -defined-only -extern-only #{library}`.split("\n")
    result = classes_from_symbols(syms)
    result += constants_from_symbols(syms)

    result.select do |e|
      case e
      when 'llvm.cmdline', 'llvm.embedded.module', '__clang_at_available_requires_core_foundation_framework'
        false
      else
        true
      end
    end
  end

  module_function :symbols_from_library

  private

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

  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

  module_function :classes_from_symbols
  module_function :constants_from_symbols
end

Version data entries

24 entries across 24 versions & 10 rubygems

Version Path
cocoapods-packager-next-2.0.1 lib/cocoapods-packager/symbols.rb
cocoapods-packager-next-2.0.0 lib/cocoapods-packager/symbols.rb
cocoapods-packagerthk-1.0.4 lib/cocoapods-packagerthk/symbols.rb
cocoapods-packagerthk-1.0.3 lib/cocoapods-packagerthk/symbols.rb
cocoapods-packagerthk-1.0.2 lib/cocoapods-packagerthk/symbols.rb
cocoapods-packagerthk-1.0.1 lib/cocoapods-packagerthk/symbols.rb
cocoapods-packagerthk-1.0.0 lib/cocoapods-packagerthk/symbols.rb
cocoapods-packagerthk-0.0.1 lib/cocoapods-packagerthk/symbols.rb
cocoapods-packager-test-scl-1.6.2 lib/cocoapods-packager/symbols.rb
cocoapods-packager-test-scl-1.6.1 lib/cocoapods-packager/symbols.rb
cocoapods-packager-test-scl-1.6.0 lib/cocoapods-packager/symbols.rb
cocoapods-packager-test-scl-1.5.0 lib/cocoapods-packager/symbols.rb
cocoapods-packager-clone-master-1.5.2 lib/cocoapods-packager/symbols.rb
cocoapods-nepackage-0.0.2 lib/cocoapods-nepackager/symbols.rb
cocoapods-gd-0.0.3 lib/cocoapods-gd/symbols.rb
cocoapods-gd-0.0.2 lib/cocoapods-gd/symbols.rb
cocoapods-gd-0.0.1 lib/cocoapods-gd/symbols.rb
cocoapods-nepackage-0.0.1 lib/cocoapods-nepackager/symbols.rb
cocoapods-xzpackager-1.0.2 lib/cocoapods-packager/symbols.rb
cocoapods-xzpackager-1.0.1 lib/cocoapods-packager/symbols.rb