Class: HMap::Project

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/hmap/xc/workspace/project.rb,
lib/hmap/xc/workspace/project_helper.rb

Defined Under Namespace

Modules: Helper

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#build_data_dir, #build_dir, #build_root, #context, #hmap_root, #project_dir, #project_name, #project_references, #temp_dir, #temp_name

Methods included from HeaderType

#headers_hash, #private_entrys, #project_entrys, #public_entrys, #use_vfs?

Constructor Details

#initialize(project, workspace) ⇒ Project

Returns a new instance of Project.



14
15
16
17
# File 'lib/hmap/xc/workspace/project.rb', line 14

def initialize(project, workspace)
  @project = project
  @workspace = workspace
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



12
13
14
# File 'lib/hmap/xc/workspace/project.rb', line 12

def project
  @project
end

#workspaceObject (readonly)

Returns the value of attribute workspace.



12
13
14
# File 'lib/hmap/xc/workspace/project.rb', line 12

def workspace
  @workspace
end

Instance Method Details

#platformsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hmap/xc/workspace/project.rb', line 19

def platforms
  return @platforms if defined? @platforms

  build_configurations = project.build_configuration_list.build_configurations
  build_configurations += project.targets.flat_map do |target|
    target.build_configuration_list.build_configurations
  end

  ps = build_configurations.flatten.each_with_object({}) do |configuration, sum|
    bs = configuration.build_settings
    d_t = []
    d_t << :osx unless bs['MACOSX_DEPLOYMENT_TARGET'].nil?
    d_t << :ios unless bs['IPHONEOS_DEPLOYMENT_TARGET'].nil?
    d_t << :watchos unless bs['WATCHOS_DEPLOYMENT_TARGET'].nil?
    d_t << :tvos unless bs['TVOS_DEPLOYMENT_TARGET'].nil?
    sum[configuration.name] ||= []
    sum[configuration.name] += d_t unless d_t.empty?
  end

  @platforms = ps.flat_map do |key, value|
    Platform.new_from_platforms(key, value.uniq)
  end
end

#remove_hmap_settings!Object



82
83
84
# File 'lib/hmap/xc/workspace/project.rb', line 82

def remove_hmap_settings!
  targets.each(&:remove_hmap_settings!)
end

#save_hmap_settings!Object



78
79
80
# File 'lib/hmap/xc/workspace/project.rb', line 78

def save_hmap_settings!
  targets.each(&:save_hmap_settings!)
end

#targetsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/hmap/xc/workspace/project.rb', line 43

def targets
  return @targets if defined?(@targets)

  project_dir = project.project_dir

  h_ts = project.targets.map do |target|
    next if target.is_a?(Constants::PBXAggregateTarget)

    headers = target.build_phases.flat_map do |phase|
      next unless phase.is_a?(Constants::PBXHeadersBuildPhase)

      phase.files.flat_map do |file|
        ff = file.file_ref
        f_path = ff.instance_variable_get('@simple_attributes_hash')['path'] || ''
        g_path = PBXHelper.group_paths(ff)
        header_entry(project_dir, g_path, f_path, file)
      end
    end.compact
    Target.new(headers, target, self)
  end.compact
  @targets = h_ts || []
end

#write_hmapfile!Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/hmap/xc/workspace/project.rb', line 66

def write_hmapfile!
  hmap_writer = BuildSettingsWriter.new(platforms, context)
  types = %i[all_non_framework_target_headers project_headers all_target_headers all_product_headers]
  datas = headers_hash(*types)
  hmap_writer.write_or_symlink(nil, datas, %i[all_product_headers])
  targets.each do |target|
    target.write_hmapfile!
    UserInterface.puts("[hmapfile] #{target.target_name} hmap files generated".green)
  end
  UserInterface.puts("[hmapfile] There are #{targets.length} targets hmap files generated")
end