cocoapods-mapfile 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +65 -64
- data/lib/cocoapods_plugin.rb +16 -16
- data/lib/hmap/command/hmap_gen.rb +19 -27
- data/lib/hmap/command/hmap_reader.rb +5 -5
- data/lib/hmap/command/hmap_writer.rb +5 -3
- data/lib/hmap/command.rb +3 -1
- data/lib/hmap/constants.rb +198 -0
- data/lib/hmap/{executable.rb → helper/executable.rb} +5 -6
- data/lib/hmap/hmap/hmap_bucketstr.rb +20 -0
- data/lib/hmap/{hmap_reader.rb → hmap/hmap_reader.rb} +4 -20
- data/lib/hmap/{hmap_saver.rb → hmap/hmap_saver.rb} +11 -6
- data/lib/hmap/{hmap_struct.rb → hmap/hmap_struct.rb} +0 -0
- data/lib/hmap/hmap/hmap_writer.rb +52 -0
- data/lib/hmap/{mapfile.rb → hmap/mapfile.rb} +1 -1
- data/lib/hmap/user_interface.rb +22 -0
- data/lib/hmap/version.rb +1 -1
- data/lib/hmap/xc/context.rb +23 -0
- data/lib/hmap/xc/header_entry.rb +55 -0
- data/lib/hmap/xc/header_type.rb +32 -0
- data/lib/hmap/xc/pbx_helper.rb +68 -0
- data/lib/hmap/xc/product_helper.rb +36 -0
- data/lib/hmap/xc/resolver.rb +129 -0
- data/lib/hmap/xc/target/build_setting.rb +126 -0
- data/lib/hmap/xc/target/target.rb +76 -0
- data/lib/hmap/xc/target/target_context.rb +29 -0
- data/lib/hmap/xc/target/target_helper.rb +114 -0
- data/lib/hmap/xc/target/target_vfs.rb +122 -0
- data/lib/hmap/xc/target/xcconfig_helper.rb +109 -0
- data/lib/hmap/xc/workspace/project.rb +120 -0
- data/lib/hmap/xc/workspace/project_helper.rb +92 -0
- data/lib/hmap/xc/workspace/workspace.rb +83 -0
- data/lib/hmap.rb +16 -14
- metadata +58 -20
- data/lib/hmap/framework/framework_vfs.rb +0 -94
- data/lib/hmap/helper/build_setting_constants.rb +0 -13
- data/lib/hmap/helper/hmap_helper.rb +0 -212
- data/lib/hmap/helper/pods_helper.rb +0 -98
- data/lib/hmap/helper/xcconfig_helper.rb +0 -105
- data/lib/hmap/hmap_writer.rb +0 -99
- data/lib/hmap/pods_specification.rb +0 -65
| @@ -1,105 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module HMap
         | 
| 4 | 
            -
              # A collection of xcodeproj Helper functions used throughout hmap.
         | 
| 5 | 
            -
              class XcodeprojHelper
         | 
| 6 | 
            -
                require 'xcodeproj'
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                attr_reader :xcconfig_path, :build_setting_key
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                def initialize(xcconfig)
         | 
| 11 | 
            -
                  @xcconfig_path = xcconfig
         | 
| 12 | 
            -
                  @xcconfig = Xcodeproj::Config.new(xcconfig_path)
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                def change_hmap_build_setting_and_save(values, use_headermap: false, save_origin: false)
         | 
| 16 | 
            -
                  ocf = values[BuildSettingConstants::OTHER_CFLAGS]
         | 
| 17 | 
            -
                  ocppf = values[BuildSettingConstants::OTHER_CPLUSPLUSFLAGS]
         | 
| 18 | 
            -
                  change_xcconfig_build_setting(BuildSettingConstants::OTHER_CFLAGS, ocf, true)
         | 
| 19 | 
            -
                  change_xcconfig_build_setting(BuildSettingConstants::OTHER_CPLUSPLUSFLAGS, ocppf, true) if  build_setting?(BuildSettingConstants::OTHER_CPLUSPLUSFLAGS)
         | 
| 20 | 
            -
                  change_xcconfig_build_setting(BuildSettingConstants::USE_HEADERMAP, 'NO', false) unless use_headermap
         | 
| 21 | 
            -
                  build_settings = [BuildSettingConstants::HEAD_SEARCH_PATHS, BuildSettingConstants::USER_HEADER_SEARCH_PATHS]
         | 
| 22 | 
            -
                  if save_origin
         | 
| 23 | 
            -
                    clean_hmap_build_settings_to_xcconfig(build_settings)
         | 
| 24 | 
            -
                  else
         | 
| 25 | 
            -
                    save_build_settings_to_xcconfig(build_settings)
         | 
| 26 | 
            -
                  end
         | 
| 27 | 
            -
                  save_to_path
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                def change_xcconfig_build_settings(settings, save_origin)
         | 
| 31 | 
            -
                  settings.each do |key, value|
         | 
| 32 | 
            -
                    change_xcconfig_build_setting(key.to_s, value, save_origin)
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                def change_xcconfig_build_setting(build_setting_key, setting, save_origin)
         | 
| 37 | 
            -
                  return if setting.nil?
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                  save_origin_build_setting = save_build_setting_to_xcconfig(build_setting_key)
         | 
| 40 | 
            -
                  value = setting
         | 
| 41 | 
            -
                  value = "#{value} ${#{save_key(build_setting_key)}}" if save_origin && !save_origin_build_setting.nil?
         | 
| 42 | 
            -
                  @xcconfig.attributes[hmap_key(build_setting_key)] = value
         | 
| 43 | 
            -
                  @xcconfig.attributes[build_setting_key] = "${#{hmap_key(build_setting_key)}}"
         | 
| 44 | 
            -
                  yield(@xcconfig) if block_given?
         | 
| 45 | 
            -
                end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                def save_build_settings_to_xcconfig(build_settings)
         | 
| 48 | 
            -
                  build_settings ||= []
         | 
| 49 | 
            -
                  build_settings.each { |key| save_build_setting_to_xcconfig(key) }
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                def save_build_setting_to_xcconfig(key)
         | 
| 53 | 
            -
                  origin_build_setting = @xcconfig.attributes[key]
         | 
| 54 | 
            -
                  if origin_build_setting.nil? || !origin_build_setting.include?(hmap_key(key))
         | 
| 55 | 
            -
                    @xcconfig.attributes[save_key(key)] = origin_build_setting unless origin_build_setting.nil?
         | 
| 56 | 
            -
                    @xcconfig.attributes.delete(key)
         | 
| 57 | 
            -
                  end
         | 
| 58 | 
            -
                  @xcconfig.attributes[save_key(key)]
         | 
| 59 | 
            -
                end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                def clean_hmap_build_setting_and_save
         | 
| 62 | 
            -
                  clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::OTHER_CFLAGS)
         | 
| 63 | 
            -
                  clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::OTHER_CPLUSPLUSFLAGS)
         | 
| 64 | 
            -
                  clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::HEAD_SEARCH_PATHS)
         | 
| 65 | 
            -
                  clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::USER_HEADER_SEARCH_PATHS)
         | 
| 66 | 
            -
                  clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::USE_HEADERMAP)
         | 
| 67 | 
            -
                  save_to_path
         | 
| 68 | 
            -
                end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                def clean_hmap_build_settings_to_xcconfig(build_settings)
         | 
| 71 | 
            -
                  build_settings ||= []
         | 
| 72 | 
            -
                  build_settings.each { |build_setting| clean_hmap_build_setting_to_xcconfig(build_setting) }
         | 
| 73 | 
            -
                end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                def clean_hmap_build_setting_to_xcconfig(build_setting)
         | 
| 76 | 
            -
                  save_origin_build_setting = @xcconfig.attributes[save_key(build_setting)]
         | 
| 77 | 
            -
                  origin_build_setting = @xcconfig.attributes[build_setting]
         | 
| 78 | 
            -
                  if save_origin_build_setting.nil? && !origin_build_setting.nil? && origin_build_setting.include?(hmap_key(build_setting))
         | 
| 79 | 
            -
                    @xcconfig.attributes.delete(build_setting)
         | 
| 80 | 
            -
                  end
         | 
| 81 | 
            -
                  @xcconfig.attributes[build_setting] = save_origin_build_setting unless save_origin_build_setting.nil?
         | 
| 82 | 
            -
                  @xcconfig.attributes.delete(hmap_key(build_setting))
         | 
| 83 | 
            -
                  @xcconfig.attributes.delete(save_key(build_setting))
         | 
| 84 | 
            -
                end
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                def save_to_path(path = nil)
         | 
| 87 | 
            -
                  path = xcconfig_path if path.nil?
         | 
| 88 | 
            -
                  @xcconfig.save_as(path)
         | 
| 89 | 
            -
                end
         | 
| 90 | 
            -
             | 
| 91 | 
            -
                private
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                def build_setting?(key)
         | 
| 94 | 
            -
                  !@xcconfig.attributes[key].nil?
         | 
| 95 | 
            -
                end
         | 
| 96 | 
            -
             | 
| 97 | 
            -
                def hmap_key(key)
         | 
| 98 | 
            -
                  "HMAP_PODS_#{key}"
         | 
| 99 | 
            -
                end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                def save_key(key)
         | 
| 102 | 
            -
                  "SAVE_#{key}"
         | 
| 103 | 
            -
                end
         | 
| 104 | 
            -
              end
         | 
| 105 | 
            -
            end
         | 
    
        data/lib/hmap/hmap_writer.rb
    DELETED
    
    | @@ -1,99 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            # require 'cocoapods'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            module HMap
         | 
| 6 | 
            -
              # Helper module which returns handle method from MapFileWriter.
         | 
| 7 | 
            -
              class MapFileWriter
         | 
| 8 | 
            -
                # @param save_origin_header_search_paths save_origin_header_search_paths
         | 
| 9 | 
            -
                # @param clean_hmap clean up all hmap setup
         | 
| 10 | 
            -
                # @param allow_targets this targets will save origin build setting
         | 
| 11 | 
            -
                # @param use_build_in_headermap option use Xcode header map
         | 
| 12 | 
            -
                def initialize(save_origin_build_setting, clean_hmap, allow_targets, use_build_in_headermap: true)
         | 
| 13 | 
            -
                  @allow_targets = allow_targets
         | 
| 14 | 
            -
                  puts "hmap allow targets: #{allow_targets}" unless allow_targets.empty?
         | 
| 15 | 
            -
                  @save_origin_build_setting = save_origin_build_setting
         | 
| 16 | 
            -
                  @use_build_in_headermap = use_build_in_headermap
         | 
| 17 | 
            -
                  create_mapfile(clean_hmap)
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                private
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                # Integrates the projects mapfile associated
         | 
| 23 | 
            -
                # with the App project and Pods project.
         | 
| 24 | 
            -
                #
         | 
| 25 | 
            -
                # @param  [clean] clean hmap dir @see #podfile
         | 
| 26 | 
            -
                # @return [void]
         | 
| 27 | 
            -
                #
         | 
| 28 | 
            -
                def create_mapfile(clean)
         | 
| 29 | 
            -
                  analyze = PodsSpecification.instance.analyze
         | 
| 30 | 
            -
                  targets = analyze.targets
         | 
| 31 | 
            -
                  pod_targets = analyze.pod_targets
         | 
| 32 | 
            -
                  return if Pods.clean_hmap_setting(clean, targets, pod_targets)
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                  merge_all_pods_target_headers_mapfile(pod_targets)
         | 
| 35 | 
            -
                  merge_all_target_public_headers_mapfile(targets)
         | 
| 36 | 
            -
                end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                def vfs_from_target(target, helper)
         | 
| 39 | 
            -
                  return unless target.build_as_framework?
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                  spec_path = target.specs.map(&:defined_in_file).uniq.first
         | 
| 42 | 
            -
                  platforms = Pods.target_support_platforms(spec_path)
         | 
| 43 | 
            -
                  headers = Pods.headers_mappings_by_file(target).flat_map { |h| h }
         | 
| 44 | 
            -
                  helper.add_framework_entry(target.user_build_configurations.keys,
         | 
| 45 | 
            -
                                             platforms, target.name, target.product_basename, target.support_files_dir, headers)
         | 
| 46 | 
            -
                end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                def hmap_from_header_mappings(target, helper, type = :source_files)
         | 
| 49 | 
            -
                  Pods.headers_mappings_by_file_accessor(target, type).each do |key, headers|
         | 
| 50 | 
            -
                    helper.header_mappings(headers, Pod::Config.instance.sandbox.root.join(target.headers_sandbox),
         | 
| 51 | 
            -
                                           target.product_basename, key)
         | 
| 52 | 
            -
                  end
         | 
| 53 | 
            -
                end
         | 
| 54 | 
            -
             | 
| 55 | 
            -
                def hmap_vfs_from_target(target, helper, type = :source_files)
         | 
| 56 | 
            -
                  vfs_from_target(target, helper)
         | 
| 57 | 
            -
                  hmap_from_header_mappings(target, helper, type)
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                def merge_all_target_public_headers_mapfile(targets)
         | 
| 61 | 
            -
                  helper = HMapHelper.new(Pods.hmap_files_dir)
         | 
| 62 | 
            -
                  targets.each do |target|
         | 
| 63 | 
            -
                    hmap_name = target.name.to_s
         | 
| 64 | 
            -
                    target.pod_targets.each do |p_target|
         | 
| 65 | 
            -
                      hmap_from_header_mappings(p_target, helper, :public_header_files)
         | 
| 66 | 
            -
                    end
         | 
| 67 | 
            -
                    change_hmap_build_setting_and_save(target, false, helper, hmap_name, save_origin: @save_origin_build_setting)
         | 
| 68 | 
            -
                    helper.write_hmap_vfs_to_paths(hmap_name)
         | 
| 69 | 
            -
                  end
         | 
| 70 | 
            -
                end
         | 
| 71 | 
            -
             | 
| 72 | 
            -
                def merge_all_pods_target_headers_mapfile(pod_targets)
         | 
| 73 | 
            -
                  return Pods.clean_hmap_build_setting(pod_targets) if @use_build_in_headermap
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                  helper = HMapHelper.new(Pods.hmap_files_dir)
         | 
| 76 | 
            -
                  hmap_name = 'all-pods'
         | 
| 77 | 
            -
                  pod_targets.each do |target|
         | 
| 78 | 
            -
                    hmap_vfs_from_target(target, helper)
         | 
| 79 | 
            -
                    change_hmap_build_setting_and_save(target, target.build_as_framework?, helper, hmap_name,
         | 
| 80 | 
            -
                                                       save_origin: @save_origin_build_setting)
         | 
| 81 | 
            -
                  end
         | 
| 82 | 
            -
                  helper.write_hmap_vfs_to_paths(hmap_name)
         | 
| 83 | 
            -
                end
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                # Cteate hmap files and vfs files
         | 
| 86 | 
            -
                #
         | 
| 87 | 
            -
                # @param [target] Pods project target @see Pod#PodTarget
         | 
| 88 | 
            -
                # @param [hmap_helper] @see HMap#HMapHelper
         | 
| 89 | 
            -
                # @param [hmap_name] hmap file contains pod targets header type
         | 
| 90 | 
            -
                # @param [save_origin] save or not save origin build setting
         | 
| 91 | 
            -
                def change_hmap_build_setting_and_save(target, build_as_framework, hmap_helper, hmap_name, save_origin: false)
         | 
| 92 | 
            -
                  save_origin = true if @allow_targets.include?(target.name)
         | 
| 93 | 
            -
                  setting = hmap_helper.xcconfig_header_setting(build_as_framework, Pods.pods_hmap_files_dir, hmap_name)
         | 
| 94 | 
            -
                  Pods.xcconfig_path_from(target) do |xcconfig|
         | 
| 95 | 
            -
                    XcodeprojHelper.new(xcconfig).change_hmap_build_setting_and_save(setting, save_origin: save_origin)
         | 
| 96 | 
            -
                  end
         | 
| 97 | 
            -
                end
         | 
| 98 | 
            -
              end
         | 
| 99 | 
            -
            end
         | 
| @@ -1,65 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module HMap
         | 
| 4 | 
            -
              class PodsSpecification
         | 
| 5 | 
            -
                attr_reader :workspace_path, :analyze, :app_build_dir, :project_temp_dir
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                BUILD_DIR = 'BUILD_DIR'
         | 
| 8 | 
            -
                PROJECT_TEMP_DIR = 'PROJECT_TEMP_DIR'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                private_constant :BUILD_DIR
         | 
| 11 | 
            -
                private_constant :PROJECT_TEMP_DIR
         | 
| 12 | 
            -
                
         | 
| 13 | 
            -
                def self.instance
         | 
| 14 | 
            -
                  @instance ||= new
         | 
| 15 | 
            -
                end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                def initialize
         | 
| 18 | 
            -
                  @workspace_path = workspace
         | 
| 19 | 
            -
                  @analyze = pod_analyze
         | 
| 20 | 
            -
                  workspace_build_dir
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                private
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                def workspace_build_dir
         | 
| 26 | 
            -
                  workspace_dic = xcodebuild('-list', workspace_path)['workspace']
         | 
| 27 | 
            -
                  scheme = workspace_dic['schemes'].first
         | 
| 28 | 
            -
                  build_settings = xcodebuild('analyze', workspace_path, scheme).first['buildSettings']
         | 
| 29 | 
            -
                  @app_build_dir = build_settings[BUILD_DIR]
         | 
| 30 | 
            -
                  @project_temp_dir = build_settings[PROJECT_TEMP_DIR]
         | 
| 31 | 
            -
                end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                def xcodebuild(action, workspace, scheme = nil)
         | 
| 34 | 
            -
                  command = %W[#{action} -workspace #{workspace} -json]
         | 
| 35 | 
            -
                  command += %W[-scheme #{scheme} -showBuildSettings] unless scheme.nil?
         | 
| 36 | 
            -
                  results = Executable.execute_command('xcodebuild', command, false)
         | 
| 37 | 
            -
                  JSON.parse(results) unless results.nil?
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                def pod_analyze
         | 
| 41 | 
            -
                  podfile = Pod::Podfile.from_file(Pod::Config.instance.podfile_path)
         | 
| 42 | 
            -
                  lockfile = Pod::Lockfile.from_file(Pod::Config.instance.lockfile_path)
         | 
| 43 | 
            -
                  Pod::Installer::Analyzer.new(Pod::Config.instance.sandbox, podfile, lockfile).analyze
         | 
| 44 | 
            -
                end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                def workspace
         | 
| 47 | 
            -
                  podfile = Pod::Podfile.from_file(Pod::Config.instance.podfile_path)
         | 
| 48 | 
            -
                  user_project_paths = pod_analyze.targets.map(&:user_project_path).compact.uniq
         | 
| 49 | 
            -
                  if podfile.workspace_path
         | 
| 50 | 
            -
                    declared_path = podfile.workspace_path
         | 
| 51 | 
            -
                    path_with_ext = File.extname(declared_path) == '.xcworkspace' ? declared_path : "#{declared_path}.xcworkspace"
         | 
| 52 | 
            -
                    podfile_dir   = File.dirname(podfile.defined_in_file || '')
         | 
| 53 | 
            -
                    absolute_path = File.expand_path(path_with_ext, podfile_dir)
         | 
| 54 | 
            -
                    Pathname.new(absolute_path)
         | 
| 55 | 
            -
                  elsif user_project_paths.count == 1
         | 
| 56 | 
            -
                    project = user_project_paths.first.basename('.xcodeproj')
         | 
| 57 | 
            -
                    Pod::Config.instance.installation_root + "#{project}.xcworkspace"
         | 
| 58 | 
            -
                  else
         | 
| 59 | 
            -
                    raise Informative, 'Could not automatically select an Xcode ' \
         | 
| 60 | 
            -
                      "workspace. Specify one in your Podfile like so:\n\n"       \
         | 
| 61 | 
            -
                      "    workspace 'path/to/Workspace.xcworkspace'\n"
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
                end
         | 
| 64 | 
            -
              end
         | 
| 65 | 
            -
            end
         |