Commit 0444422d authored by Fabio Pelosin's avatar Fabio Pelosin

[PodProjectGenerator] Significant progress

parent d1b84cb9
......@@ -17,7 +17,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 23d64ce79dd23e928dadac986a858a13c07ac988
revision: 41644f62741f5fb71d776b08bfb1e55c017f75e7
branch: master
specs:
xcodeproj (0.10.1)
......@@ -41,7 +41,7 @@ GIT
GIT
remote: https://github.com/irrationalfab/PrettyBacon.git
revision: 59cde2c52a3211c06f894e7324e5e4fac9d8476a
revision: 926c214ade1ec1cbc9544d603e36f15a780f7e68
branch: master
specs:
prettybacon (0.0.1)
......
......@@ -87,7 +87,6 @@ module Pod
@project = Pod::Project.open(sandbox.project_path)
remove_groups
detect_native_targets
# remove_unrecognized_targets
end
end
......@@ -103,12 +102,17 @@ module Pod
pod_names.include?(group.display_name)
end
groups_to_remove << project.aggregate_groups.map(&:groups).flatten.reject do |group|
pod_names.include?(group.display_name)
end
aggregate_names = aggregate_targets.map(&:label).uniq.sort
groups_to_remove << project.support_files_group.children.reject do |group|
aggregate_names.include?(group.display_name)
end
groups_to_remove.flatten.each do |group|
p group
remove_group(group)
end
end
......@@ -123,11 +127,9 @@ module Pod
remove_group(child)
end
UI.message"- Removing targets" do
targets = project.targets.select { |target| group.children.include?(target.product_reference) }
targets.each do |target|
remove_target(target)
end
targets = project.targets.select { |target| group.children.include?(target.product_reference) }
targets.each do |target|
remove_target(target)
end
group.remove_from_project
......@@ -146,7 +148,7 @@ module Pod
ref.remove_from_project
end
end
target.remove_from_project
target.remove_from_project
target.product_reference.referrers.each do |ref|
if ref.isa == 'PBXBuildFile'
......@@ -163,21 +165,19 @@ module Pod
# @return [void]
#
def detect_native_targets
UI.message"- Matching targets" do
native_targets_by_name = project.targets.group_by(&:name)
native_targets_to_remove = native_targets_by_name.keys.dup
cp_targets = aggregate_targets + all_pod_targets
cp_targets.each do |pod_target|
native_targets = native_targets_by_name[pod_target.label]
if native_targets
pod_target.target = native_targets.first
native_targets_to_remove.delete(pod_target.label)
end
native_targets_by_name = project.targets.group_by(&:name)
native_targets_to_remove = native_targets_by_name.keys.dup
cp_targets = aggregate_targets + all_pod_targets
cp_targets.each do |pod_target|
native_targets = native_targets_by_name[pod_target.label]
if native_targets
pod_target.target = native_targets.first
native_targets_to_remove.delete(pod_target.label)
end
end
native_targets_to_remove.each do |target_name|
remove_target(native_targets_by_name[target_name].first)
end
native_targets_to_remove.each do |target_name|
remove_target(native_targets_by_name[target_name].first)
end
end
......@@ -189,8 +189,10 @@ module Pod
end
all_pod_targets.each do |target|
UI.message"- Generating support files for target `#{target.label}`" do
gen = SupportFilesGenerator.new(target, sandbox.project)
gen.generate!
end
end
end
......@@ -215,8 +217,10 @@ module Pod
aggregate_targets.each do |target|
unless target.target_definition.empty?
gen = SupportFilesGenerator.new(target, sandbox.project)
gen.generate!
UI.message"- Generating support files for target `#{target.label}`" do
gen = SupportFilesGenerator.new(target, sandbox.project)
gen.generate!
end
end
end
end
......@@ -232,10 +236,10 @@ module Pod
#
#
def add_pod(name)
remove_group(project.pod_group(name)) if project.pod_group(name)
UI.message"- Installing `#{name}`" do
pod_targets = all_pod_targets.select { |target| target.pod_name == name }
remove_group(project.pod_group(name)) if project.pod_group(name)
UI.message"- Installing file references" do
path = sandbox.pod_dir(name)
local = sandbox.local?(name)
......@@ -245,7 +249,8 @@ module Pod
end
pod_targets.each do |pod_target|
UI.message"- Installing targets" do
remove_target(pod_target.target) if pod_target.target
UI.message "- Installing target `#{pod_target.name}` #{pod_target.platform}" do
PodTargetInstaller.new(sandbox, pod_target).install!
end
end
......
......@@ -49,9 +49,7 @@ module Pod
# @return [void]
#
def add_source_files_references
UI.message "- Adding source files" do
add_paths_to_group(:source_files, :source_files)
end
add_paths_to_group(:source_files, :source_files)
end
# Adds the bundled frameworks to the Pods project
......@@ -59,9 +57,7 @@ module Pod
# @return [void]
#
def add_frameworks_bundles
UI.message "- Adding frameworks" do
add_paths_to_group(:vendored_frameworks, :frameworks_and_libraries)
end
add_paths_to_group(:vendored_frameworks, :frameworks_and_libraries)
end
# Adds the bundled libraries to the Pods project
......@@ -69,9 +65,7 @@ module Pod
# @return [void]
#
def add_vendored_libraries
UI.message "- Adding libraries" do
add_paths_to_group(:vendored_libraries, :frameworks_and_libraries)
end
add_paths_to_group(:vendored_libraries, :frameworks_and_libraries)
end
# Adds the resources of the Pods to the Pods project.
......@@ -82,10 +76,8 @@ module Pod
# @return [void]
#
def add_resources
UI.message "- Adding resources" do
add_paths_to_group(:resources, :resources)
add_paths_to_group(:resource_bundle_files, :resources)
end
add_paths_to_group(:resources, :resources)
add_paths_to_group(:resource_bundle_files, :resources)
end
......
......@@ -22,7 +22,6 @@ module Pod
def generate!
validate
# TODO clean up
if target.is_a?(AggregateTarget)
create_xcconfig_file_aggregate
......@@ -34,7 +33,6 @@ module Pod
create_xcconfig_file_pods
create_prefix_header
end
create_dummy_source
end
......@@ -55,16 +53,14 @@ module Pod
# @return [void]
#
def create_xcconfig_file_aggregate
UI.message "- Generating xcconfig file" do
path = target.xcconfig_path
gen = Generator::XCConfig::AggregateXCConfig.new(target)
gen.save_as(path)
target.xcconfig = gen.xcconfig
xcconfig_file_ref = add_file_to_support_group(path)
target.target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref
end
path = target.xcconfig_path
gen = Generator::XCConfig::AggregateXCConfig.new(target)
gen.save_as(path)
target.xcconfig = gen.xcconfig
xcconfig_file_ref = add_file_to_support_group(path)
target.target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref
end
end
......@@ -75,21 +71,17 @@ module Pod
#
def create_xcconfig_file_pods
public_gen = Generator::XCConfig::PublicPodXCConfig.new(target)
UI.message "- Generating public xcconfig file" do
path = target.xcconfig_path
public_gen.save_as(path)
add_file_to_support_group(path)
end
path = target.xcconfig_path
public_gen.save_as(path)
add_file_to_support_group(path)
UI.message "- Generating private xcconfig file" do
path = target.xcconfig_private_path
private_gen = Generator::XCConfig::PrivatePodXCConfig.new(target, public_gen.xcconfig)
private_gen.save_as(path)
xcconfig_file_ref = add_file_to_support_group(path)
path = target.xcconfig_private_path
private_gen = Generator::XCConfig::PrivatePodXCConfig.new(target, public_gen.xcconfig)
private_gen.save_as(path)
xcconfig_file_ref = add_file_to_support_group(path)
target.target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref
end
target.target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref
end
end
......@@ -98,12 +90,10 @@ module Pod
# pods and the installed specifications of a pod.
#
def create_target_environment_header
UI.message "- Generating target environment header" do
path = target.target_environment_header_path
generator = Generator::TargetEnvironmentHeader.new(target.pod_targets.map { |l| l.specs }.flatten)
generator.save_as(path)
add_file_to_support_group(path)
end
path = target.target_environment_header_path
generator = Generator::TargetEnvironmentHeader.new(target.pod_targets.map { |l| l.specs }.flatten)
generator.save_as(path)
add_file_to_support_group(path)
end
# Generates the bridge support metadata if requested by the {Podfile}.
......@@ -116,14 +106,12 @@ module Pod
#
def create_bridge_support_file
if target.target_definition.podfile.generate_bridge_support?
UI.message "- Generating BridgeSupport metadata" do
path = target.bridge_support_path
headers = target.target.headers_build_phase.files.map { |bf| bf.file_ref.real_path }
generator = Generator::BridgeSupport.new(headers)
generator.save_as(path)
add_file_to_support_group(path)
@bridge_support_file = path
end
path = target.bridge_support_path
headers = target.target.headers_build_phase.files.map { |bf| bf.file_ref.real_path }
generator = Generator::BridgeSupport.new(headers)
generator.save_as(path)
add_file_to_support_group(path)
@bridge_support_file = path
end
end
......@@ -133,14 +121,12 @@ module Pod
#
def create_acknowledgements
Generator::Acknowledgements.generators.each do |generator_class|
UI.message "- Generating acknowledgements" do
basepath = target.acknowledgements_basepath
path = generator_class.path_from_basepath(basepath)
file_accessors = target.pod_targets.map(&:file_accessors).flatten
generator = generator_class.new(file_accessors)
generator.save_as(path)
add_file_to_support_group(path)
end
basepath = target.acknowledgements_basepath
path = generator_class.path_from_basepath(basepath)
file_accessors = target.pod_targets.map(&:file_accessors).flatten
generator = generator_class.new(file_accessors)
generator.save_as(path)
add_file_to_support_group(path)
end
end
......@@ -153,19 +139,17 @@ module Pod
# @return [void]
#
def create_copy_resources_script
UI.message "- Generating copy resources script" do
path = target.copy_resources_script_path
file_accessors = target.pod_targets.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(path.dirname) }}.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
resources = []
resources.concat(resource_paths)
resources.concat(resource_bundles)
resources << bridge_support_file.relative_path_from(project.path.dirname) if bridge_support_file
generator = Generator::CopyResourcesScript.new(resources, target.platform)
generator.save_as(path)
add_file_to_support_group(path)
end
path = target.copy_resources_script_path
file_accessors = target.pod_targets.map(&:file_accessors).flatten
resource_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(path.dirname) }}.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
resources = []
resources.concat(resource_paths)
resources.concat(resource_bundles)
resources << bridge_support_file.relative_path_from(project.path.dirname) if bridge_support_file
generator = Generator::CopyResourcesScript.new(resources, target.platform)
generator.save_as(path)
add_file_to_support_group(path)
end
# Creates a prefix header file which imports `UIKit` or `Cocoa` according
......@@ -175,17 +159,15 @@ module Pod
# @return [void]
#
def create_prefix_header
UI.message "- Generating prefix header" do
path = target.prefix_header_path
generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
generator.imports << target.target_environment_header_path.basename
generator.save_as(path)
add_file_to_support_group(path)
target.target.build_configurations.each do |c|
relative_path = path.relative_path_from(project.path.dirname)
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end
path = target.prefix_header_path
generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
generator.imports << target.target_environment_header_path.basename
generator.save_as(path)
add_file_to_support_group(path)
target.target.build_configurations.each do |c|
relative_path = path.relative_path_from(project.path.dirname)
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end
end
......@@ -196,15 +178,13 @@ module Pod
# @return [void]
#
def create_dummy_source
UI.message "- Generating dummy source file" do
path = target.dummy_source_path
generator = Generator::DummySource.new(target.label)
generator.save_as(path)
file_reference = add_file_to_support_group(path)
existing = target.target.source_build_phase.files_references.include?(file_reference)
unless existing
target.target.source_build_phase.add_file_reference(file_reference)
end
path = target.dummy_source_path
generator = Generator::DummySource.new(target.label)
generator.save_as(path)
file_reference = add_file_to_support_group(path)
existing = target.target.source_build_phase.files_references.include?(file_reference)
unless existing
target.target.source_build_phase.add_file_reference(file_reference)
end
end
......
......@@ -42,7 +42,7 @@ module Pod
name = target.label
platform = target.platform.name
deployment_target = target.platform.deployment_target.to_s
@native_target = project.new_target(:static_target, name, platform, deployment_target)
@native_target = project.new_target(:static_library, name, platform, deployment_target)
settings = {}
if target.platform.requires_legacy_ios_archs?
......@@ -56,6 +56,7 @@ module Pod
@native_target.add_build_configuration(bc_name, type)
end
target.target = @native_target
end
......
......@@ -12,12 +12,10 @@ module Pod
# @return [void]
#
def install!
UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target
add_files_to_build_phases
add_resources_bundle_targets
link_to_system_frameworks
end
add_target
add_files_to_build_phases
add_resources_bundle_targets
link_to_system_frameworks
end
private
......@@ -33,14 +31,12 @@ module Pod
# @return [void]
#
def add_files_to_build_phases
UI.message "- Adding build files" do
target.file_accessors.each do |file_accessor|
consumer = file_accessor.spec_consumer
flags = compiler_flags_for_consumer(consumer)
source_files = file_accessor.source_files
file_refs = source_files.map { |sf| project.reference_for_path(sf) }
target.target.add_file_references(file_refs, flags)
end
target.file_accessors.each do |file_accessor|
consumer = file_accessor.spec_consumer
flags = compiler_flags_for_consumer(consumer)
source_files = file_accessor.source_files
file_refs = source_files.map { |sf| project.reference_for_path(sf) }
target.target.add_file_references(file_refs, flags)
end
end
......@@ -52,19 +48,17 @@ module Pod
# @return [void]
#
def add_resources_bundle_targets
UI.message "- Adding resource bundles" do
target.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths|
file_references = paths.map { |sf| project.reference_for_path(sf) }
bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
bundle_target.add_resources(file_references)
target.user_build_configurations.each do |bc_name, type|
bundle_target.add_build_configuration(bc_name, type)
end
target.add_dependency(bundle_target)
target.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths|
file_references = paths.map { |sf| project.reference_for_path(sf) }
bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
bundle_target.add_resources(file_references)
target.user_build_configurations.each do |bc_name, type|
bundle_target.add_build_configuration(bc_name, type)
end
target.add_dependency(bundle_target)
end
end
end
......@@ -79,11 +73,9 @@ module Pod
# @return [void]
#
def link_to_system_frameworks
UI.message "- Linking to system frameworks" do
target.specs.each do |spec|
spec.consumer(target.platform).frameworks.each do |framework|
project.add_system_framework(framework, target.target)
end
target.specs.each do |spec|
spec.consumer(target.platform).frameworks.each do |framework|
project.add_system_framework(framework, target.target)
end
end
end
......
......@@ -189,7 +189,12 @@ module Pod
# @return [PBXGroup] The new group.
#
def add_aggregate_pod_group(aggregate_name, pod_name, path)
group = aggregate_group(aggregate_name).new_group(pod_name, path)
if existing = aggregate_pod_group(aggregate_name, pod_name)
existing
else
aggregate_group = aggregate_group(aggregate_name)
aggregate_group.new_group(pod_name, path)
end
end
# Returns the group for the pod target with the given name and aggregate.
......
Subproject commit 7d8fe481f635c00369636acd831ee466557055da
Subproject commit 684084445b742eb4c9e080d1b2a6a8ea66d23375
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