Commit 7c344bdd authored by Marius Rackwitz's avatar Marius Rackwitz

[Refactor] Extract #generate_target from Analyzer#generate_targets

parent ef070a7f
...@@ -180,52 +180,67 @@ module Pod ...@@ -180,52 +180,67 @@ module Pod
def generate_targets def generate_targets
targets = [] targets = []
result.specs_by_target.each do |target_definition, specs| result.specs_by_target.each do |target_definition, specs|
# Setup the aggregate target targets << generate_target(target_definition, specs)
target = AggregateTarget.new(target_definition, sandbox) end
targets << target targets
end
if config.integrate_targets? # Setup the aggregate target for a single user target
project_path = compute_user_project_path(target_definition) #
user_project = Xcodeproj::Project.open(project_path) # @param [TargetDefinition] target_definition
native_targets = compute_user_project_targets(target_definition, user_project) # the target definition for the user target.
#
target.host_requires_framework |= compute_user_project_targets_require_framework(native_targets) # @param [Array<Specification>] specs
target.user_project_path = project_path # the specifications that need to be installed grouped by the
target.client_root = project_path.dirname # given target definition.
target.user_target_uuids = native_targets.map(&:uuid) #
target.user_build_configurations = compute_user_build_configurations(target_definition, native_targets) # @return [AggregateTarget]
target.archs = @archs_by_target_def[target_definition] #
else def generate_target(target_definition, specs)
target.client_root = config.installation_root target = AggregateTarget.new(target_definition, sandbox)
target.user_target_uuids = []
target.user_build_configurations = target_definition.build_configurations || { 'Release' => :release, 'Debug' => :debug } if config.integrate_targets?
if target_definition.platform.name == :osx project_path = compute_user_project_path(target_definition)
target.archs = '$(ARCHS_STANDARD_64_BIT)' user_project = Xcodeproj::Project.open(project_path)
end native_targets = compute_user_project_targets(target_definition, user_project)
target.host_requires_framework |= compute_user_project_targets_require_framework(native_targets)
target.user_project_path = project_path
target.client_root = project_path.dirname
target.user_target_uuids = native_targets.map(&:uuid)
target.user_build_configurations = compute_user_build_configurations(target_definition, native_targets)
target.archs = @archs_by_target_def[target_definition]
else
target.client_root = config.installation_root
target.user_target_uuids = []
target.user_build_configurations = target_definition.build_configurations || { 'Release' => :release, 'Debug' => :debug }
if target_definition.platform.name == :osx
target.archs = '$(ARCHS_STANDARD_64_BIT)'
end end
end
# Group specs and subspecs by their root # Group specs and subspecs by their root
grouped_specs = specs.map do |spec| grouped_specs = specs.map do |spec|
specs.select { |s| s.root == spec.root } specs.select { |s| s.root == spec.root }
end.uniq end.uniq
# Create a target for each spec group and add it to the aggregate target # Create a target for each spec group and add it to the aggregate target
grouped_specs.each do |pod_specs| grouped_specs.each do |pod_specs|
pod_target = PodTarget.new(pod_specs, target_definition, sandbox) pod_target = PodTarget.new(pod_specs, target_definition, sandbox)
pod_target.host_requires_framework |= target.host_requires_framework pod_target.host_requires_framework |= target.host_requires_framework
if config.integrate_targets? if config.integrate_targets?
pod_target.user_build_configurations = target.user_build_configurations pod_target.user_build_configurations = target.user_build_configurations
pod_target.archs = @archs_by_target_def[target_definition] pod_target.archs = @archs_by_target_def[target_definition]
else else
pod_target.user_build_configurations = {} pod_target.user_build_configurations = {}
if target_definition.platform.name == :osx if target_definition.platform.name == :osx
pod_target.archs = '$(ARCHS_STANDARD_64_BIT)' pod_target.archs = '$(ARCHS_STANDARD_64_BIT)'
end
end end
target.pod_targets << pod_target
end end
target.pod_targets << pod_target
end end
targets
target
end end
# Generates dependencies that require the specific version of the Pods # Generates dependencies that require the specific version of the Pods
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment