Sha256: 78d707c8aed0a4e95368e5891e5d50121996f6bcc980e94defdabb97f226e014

Contents?: true

Size: 1021 Bytes

Versions: 1

Compression:

Stored size: 1021 Bytes

Contents

# frozen_string_literal: true

require 'xcodeproj'

module Pandan
  class Parser
    attr_reader :workspace, :workspace_dir, :regex

    def initialize(workspace_path, filter)
      @workspace_dir = File.dirname(workspace_path)
      @workspace = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
      @regex = filter
      @regex ||= '.*' # Match everything
    end

    def all_targets
      @projects ||= projects
      projects.flat_map(&:targets).select { |target| target.name =~ /#{regex}/ }
    end

    def other_linker_flags
      @projects ||= projects
      ld_flags_info = {}
      projects.flat_map(&:targets).each do |target|
        ld_flags_info[target] = target.resolved_build_setting('OTHER_LDFLAGS', true)
      end
      ld_flags_info
    end

    private

    def projects
      all_project_paths = workspace.file_references.map(&:path)
      all_project_paths.map do |project_path|
        Xcodeproj::Project.open(File.expand_path(project_path, @workspace_dir))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pandan-0.0.3 lib/pandan/parser.rb