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

[PodProjectGenerator] Significant progress

parent d1b84cb9
...@@ -17,7 +17,7 @@ GIT ...@@ -17,7 +17,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 23d64ce79dd23e928dadac986a858a13c07ac988 revision: 41644f62741f5fb71d776b08bfb1e55c017f75e7
branch: master branch: master
specs: specs:
xcodeproj (0.10.1) xcodeproj (0.10.1)
...@@ -41,7 +41,7 @@ GIT ...@@ -41,7 +41,7 @@ GIT
GIT GIT
remote: https://github.com/irrationalfab/PrettyBacon.git remote: https://github.com/irrationalfab/PrettyBacon.git
revision: 59cde2c52a3211c06f894e7324e5e4fac9d8476a revision: 926c214ade1ec1cbc9544d603e36f15a780f7e68
branch: master branch: master
specs: specs:
prettybacon (0.0.1) prettybacon (0.0.1)
......
...@@ -87,7 +87,6 @@ module Pod ...@@ -87,7 +87,6 @@ module Pod
@project = Pod::Project.open(sandbox.project_path) @project = Pod::Project.open(sandbox.project_path)
remove_groups remove_groups
detect_native_targets detect_native_targets
# remove_unrecognized_targets
end end
end end
...@@ -103,12 +102,17 @@ module Pod ...@@ -103,12 +102,17 @@ module Pod
pod_names.include?(group.display_name) pod_names.include?(group.display_name)
end 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 aggregate_names = aggregate_targets.map(&:label).uniq.sort
groups_to_remove << project.support_files_group.children.reject do |group| groups_to_remove << project.support_files_group.children.reject do |group|
aggregate_names.include?(group.display_name) aggregate_names.include?(group.display_name)
end end
groups_to_remove.flatten.each do |group| groups_to_remove.flatten.each do |group|
p group
remove_group(group) remove_group(group)
end end
end end
...@@ -123,12 +127,10 @@ module Pod ...@@ -123,12 +127,10 @@ module Pod
remove_group(child) remove_group(child)
end end
UI.message"- Removing targets" do
targets = project.targets.select { |target| group.children.include?(target.product_reference) } targets = project.targets.select { |target| group.children.include?(target.product_reference) }
targets.each do |target| targets.each do |target|
remove_target(target) remove_target(target)
end end
end
group.remove_from_project group.remove_from_project
end end
...@@ -163,7 +165,6 @@ module Pod ...@@ -163,7 +165,6 @@ module Pod
# @return [void] # @return [void]
# #
def detect_native_targets def detect_native_targets
UI.message"- Matching targets" do
native_targets_by_name = project.targets.group_by(&:name) native_targets_by_name = project.targets.group_by(&:name)
native_targets_to_remove = native_targets_by_name.keys.dup native_targets_to_remove = native_targets_by_name.keys.dup
cp_targets = aggregate_targets + all_pod_targets cp_targets = aggregate_targets + all_pod_targets
...@@ -179,7 +180,6 @@ module Pod ...@@ -179,7 +180,6 @@ module Pod
remove_target(native_targets_by_name[target_name].first) remove_target(native_targets_by_name[target_name].first)
end end
end end
end
# @return [void] # @return [void]
# #
...@@ -189,10 +189,12 @@ module Pod ...@@ -189,10 +189,12 @@ module Pod
end end
all_pod_targets.each do |target| all_pod_targets.each do |target|
UI.message"- Generating support files for target `#{target.label}`" do
gen = SupportFilesGenerator.new(target, sandbox.project) gen = SupportFilesGenerator.new(target, sandbox.project)
gen.generate! gen.generate!
end end
end end
end
# Adds and removes aggregate targets to the # Adds and removes aggregate targets to the
# #
...@@ -215,11 +217,13 @@ module Pod ...@@ -215,11 +217,13 @@ module Pod
aggregate_targets.each do |target| aggregate_targets.each do |target|
unless target.target_definition.empty? unless target.target_definition.empty?
UI.message"- Generating support files for target `#{target.label}`" do
gen = SupportFilesGenerator.new(target, sandbox.project) gen = SupportFilesGenerator.new(target, sandbox.project)
gen.generate! gen.generate!
end end
end end
end end
end
# #
# #
...@@ -232,10 +236,10 @@ module Pod ...@@ -232,10 +236,10 @@ module Pod
# #
# #
def add_pod(name) def add_pod(name)
remove_group(project.pod_group(name)) if project.pod_group(name)
UI.message"- Installing `#{name}`" do UI.message"- Installing `#{name}`" do
pod_targets = all_pod_targets.select { |target| target.pod_name == name } 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 UI.message"- Installing file references" do
path = sandbox.pod_dir(name) path = sandbox.pod_dir(name)
local = sandbox.local?(name) local = sandbox.local?(name)
...@@ -245,7 +249,8 @@ module Pod ...@@ -245,7 +249,8 @@ module Pod
end end
pod_targets.each do |pod_target| 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! PodTargetInstaller.new(sandbox, pod_target).install!
end end
end end
......
...@@ -49,30 +49,24 @@ module Pod ...@@ -49,30 +49,24 @@ module Pod
# @return [void] # @return [void]
# #
def add_source_files_references def add_source_files_references
UI.message "- Adding source files" do
add_paths_to_group(:source_files, :source_files) add_paths_to_group(:source_files, :source_files)
end end
end
# Adds the bundled frameworks to the Pods project # Adds the bundled frameworks to the Pods project
# #
# @return [void] # @return [void]
# #
def add_frameworks_bundles def add_frameworks_bundles
UI.message "- Adding frameworks" do
add_paths_to_group(:vendored_frameworks, :frameworks_and_libraries) add_paths_to_group(:vendored_frameworks, :frameworks_and_libraries)
end end
end
# Adds the bundled libraries to the Pods project # Adds the bundled libraries to the Pods project
# #
# @return [void] # @return [void]
# #
def add_vendored_libraries def add_vendored_libraries
UI.message "- Adding libraries" do
add_paths_to_group(:vendored_libraries, :frameworks_and_libraries) add_paths_to_group(:vendored_libraries, :frameworks_and_libraries)
end end
end
# Adds the resources of the Pods to the Pods project. # Adds the resources of the Pods to the Pods project.
# #
...@@ -82,11 +76,9 @@ module Pod ...@@ -82,11 +76,9 @@ module Pod
# @return [void] # @return [void]
# #
def add_resources def add_resources
UI.message "- Adding resources" do
add_paths_to_group(:resources, :resources) add_paths_to_group(:resources, :resources)
add_paths_to_group(:resource_bundle_files, :resources) add_paths_to_group(:resource_bundle_files, :resources)
end end
end
private private
......
...@@ -22,7 +22,6 @@ module Pod ...@@ -22,7 +22,6 @@ module Pod
def generate! def generate!
validate validate
# TODO clean up # TODO clean up
if target.is_a?(AggregateTarget) if target.is_a?(AggregateTarget)
create_xcconfig_file_aggregate create_xcconfig_file_aggregate
...@@ -34,7 +33,6 @@ module Pod ...@@ -34,7 +33,6 @@ module Pod
create_xcconfig_file_pods create_xcconfig_file_pods
create_prefix_header create_prefix_header
end end
create_dummy_source create_dummy_source
end end
...@@ -55,7 +53,6 @@ module Pod ...@@ -55,7 +53,6 @@ module Pod
# @return [void] # @return [void]
# #
def create_xcconfig_file_aggregate def create_xcconfig_file_aggregate
UI.message "- Generating xcconfig file" do
path = target.xcconfig_path path = target.xcconfig_path
gen = Generator::XCConfig::AggregateXCConfig.new(target) gen = Generator::XCConfig::AggregateXCConfig.new(target)
gen.save_as(path) gen.save_as(path)
...@@ -66,7 +63,6 @@ module Pod ...@@ -66,7 +63,6 @@ module Pod
c.base_configuration_reference = xcconfig_file_ref c.base_configuration_reference = xcconfig_file_ref
end end
end end
end
# Generates the contents of the xcconfig file and saves it to disk. # Generates the contents of the xcconfig file and saves it to disk.
...@@ -75,13 +71,10 @@ module Pod ...@@ -75,13 +71,10 @@ module Pod
# #
def create_xcconfig_file_pods def create_xcconfig_file_pods
public_gen = Generator::XCConfig::PublicPodXCConfig.new(target) public_gen = Generator::XCConfig::PublicPodXCConfig.new(target)
UI.message "- Generating public xcconfig file" do
path = target.xcconfig_path path = target.xcconfig_path
public_gen.save_as(path) public_gen.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end
UI.message "- Generating private xcconfig file" do
path = target.xcconfig_private_path path = target.xcconfig_private_path
private_gen = Generator::XCConfig::PrivatePodXCConfig.new(target, public_gen.xcconfig) private_gen = Generator::XCConfig::PrivatePodXCConfig.new(target, public_gen.xcconfig)
private_gen.save_as(path) private_gen.save_as(path)
...@@ -91,20 +84,17 @@ module Pod ...@@ -91,20 +84,17 @@ module Pod
c.base_configuration_reference = xcconfig_file_ref c.base_configuration_reference = xcconfig_file_ref
end end
end end
end
# Generates a header which allows to inspect at compile time the installed # Generates a header which allows to inspect at compile time the installed
# pods and the installed specifications of a pod. # pods and the installed specifications of a pod.
# #
def create_target_environment_header def create_target_environment_header
UI.message "- Generating target environment header" do
path = target.target_environment_header_path path = target.target_environment_header_path
generator = Generator::TargetEnvironmentHeader.new(target.pod_targets.map { |l| l.specs }.flatten) generator = Generator::TargetEnvironmentHeader.new(target.pod_targets.map { |l| l.specs }.flatten)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
end
# Generates the bridge support metadata if requested by the {Podfile}. # Generates the bridge support metadata if requested by the {Podfile}.
# #
...@@ -116,7 +106,6 @@ module Pod ...@@ -116,7 +106,6 @@ module Pod
# #
def create_bridge_support_file def create_bridge_support_file
if target.target_definition.podfile.generate_bridge_support? if target.target_definition.podfile.generate_bridge_support?
UI.message "- Generating BridgeSupport metadata" do
path = target.bridge_support_path path = target.bridge_support_path
headers = target.target.headers_build_phase.files.map { |bf| bf.file_ref.real_path } headers = target.target.headers_build_phase.files.map { |bf| bf.file_ref.real_path }
generator = Generator::BridgeSupport.new(headers) generator = Generator::BridgeSupport.new(headers)
...@@ -125,7 +114,6 @@ module Pod ...@@ -125,7 +114,6 @@ module Pod
@bridge_support_file = path @bridge_support_file = path
end end
end end
end
# Generates the acknowledgement files (markdown and plist) for the target. # Generates the acknowledgement files (markdown and plist) for the target.
# #
...@@ -133,7 +121,6 @@ module Pod ...@@ -133,7 +121,6 @@ module Pod
# #
def create_acknowledgements def create_acknowledgements
Generator::Acknowledgements.generators.each do |generator_class| Generator::Acknowledgements.generators.each do |generator_class|
UI.message "- Generating acknowledgements" do
basepath = target.acknowledgements_basepath basepath = target.acknowledgements_basepath
path = generator_class.path_from_basepath(basepath) path = generator_class.path_from_basepath(basepath)
file_accessors = target.pod_targets.map(&:file_accessors).flatten file_accessors = target.pod_targets.map(&:file_accessors).flatten
...@@ -142,7 +129,6 @@ module Pod ...@@ -142,7 +129,6 @@ module Pod
add_file_to_support_group(path) add_file_to_support_group(path)
end end
end end
end
# Creates a script that copies the resources to the bundle of the client # Creates a script that copies the resources to the bundle of the client
# target. # target.
...@@ -153,7 +139,6 @@ module Pod ...@@ -153,7 +139,6 @@ module Pod
# @return [void] # @return [void]
# #
def create_copy_resources_script def create_copy_resources_script
UI.message "- Generating copy resources script" do
path = target.copy_resources_script_path path = target.copy_resources_script_path
file_accessors = target.pod_targets.map(&:file_accessors).flatten 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_paths = file_accessors.map { |accessor| accessor.resources.flatten.map { |res| res.relative_path_from(path.dirname) }}.flatten
...@@ -166,7 +151,6 @@ module Pod ...@@ -166,7 +151,6 @@ module Pod
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
end
# Creates a prefix header file which imports `UIKit` or `Cocoa` according # Creates a prefix header file which imports `UIKit` or `Cocoa` according
# to the platform of the target. This file also include any prefix header # to the platform of the target. This file also include any prefix header
...@@ -175,7 +159,6 @@ module Pod ...@@ -175,7 +159,6 @@ module Pod
# @return [void] # @return [void]
# #
def create_prefix_header def create_prefix_header
UI.message "- Generating prefix header" do
path = target.prefix_header_path path = target.prefix_header_path
generator = Generator::PrefixHeader.new(target.file_accessors, target.platform) generator = Generator::PrefixHeader.new(target.file_accessors, target.platform)
generator.imports << target.target_environment_header_path.basename generator.imports << target.target_environment_header_path.basename
...@@ -187,7 +170,6 @@ module Pod ...@@ -187,7 +170,6 @@ module Pod
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end end
end end
end
# Generates a dummy source file for each target so libraries that contain # Generates a dummy source file for each target so libraries that contain
...@@ -196,7 +178,6 @@ module Pod ...@@ -196,7 +178,6 @@ module Pod
# @return [void] # @return [void]
# #
def create_dummy_source def create_dummy_source
UI.message "- Generating dummy source file" do
path = target.dummy_source_path path = target.dummy_source_path
generator = Generator::DummySource.new(target.label) generator = Generator::DummySource.new(target.label)
generator.save_as(path) generator.save_as(path)
...@@ -206,7 +187,6 @@ module Pod ...@@ -206,7 +187,6 @@ module Pod
target.target.source_build_phase.add_file_reference(file_reference) target.target.source_build_phase.add_file_reference(file_reference)
end end
end end
end
......
...@@ -42,7 +42,7 @@ module Pod ...@@ -42,7 +42,7 @@ module Pod
name = target.label name = target.label
platform = target.platform.name platform = target.platform.name
deployment_target = target.platform.deployment_target.to_s 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 = {} settings = {}
if target.platform.requires_legacy_ios_archs? if target.platform.requires_legacy_ios_archs?
...@@ -56,6 +56,7 @@ module Pod ...@@ -56,6 +56,7 @@ module Pod
@native_target.add_build_configuration(bc_name, type) @native_target.add_build_configuration(bc_name, type)
end end
target.target = @native_target target.target = @native_target
end end
......
...@@ -12,13 +12,11 @@ module Pod ...@@ -12,13 +12,11 @@ module Pod
# @return [void] # @return [void]
# #
def install! def install!
UI.message "- Installing target `#{target.name}` #{target.platform}" do
add_target add_target
add_files_to_build_phases add_files_to_build_phases
add_resources_bundle_targets add_resources_bundle_targets
link_to_system_frameworks link_to_system_frameworks
end end
end
private private
...@@ -33,7 +31,6 @@ module Pod ...@@ -33,7 +31,6 @@ module Pod
# @return [void] # @return [void]
# #
def add_files_to_build_phases def add_files_to_build_phases
UI.message "- Adding build files" do
target.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
consumer = file_accessor.spec_consumer consumer = file_accessor.spec_consumer
flags = compiler_flags_for_consumer(consumer) flags = compiler_flags_for_consumer(consumer)
...@@ -42,7 +39,6 @@ module Pod ...@@ -42,7 +39,6 @@ module Pod
target.target.add_file_references(file_refs, flags) target.target.add_file_references(file_refs, flags)
end end
end end
end
# Adds the resources of the Pods to the Pods project. # Adds the resources of the Pods to the Pods project.
# #
...@@ -52,7 +48,6 @@ module Pod ...@@ -52,7 +48,6 @@ module Pod
# @return [void] # @return [void]
# #
def add_resources_bundle_targets def add_resources_bundle_targets
UI.message "- Adding resource bundles" do
target.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
file_accessor.resource_bundles.each do |bundle_name, paths| file_accessor.resource_bundles.each do |bundle_name, paths|
file_references = paths.map { |sf| project.reference_for_path(sf) } file_references = paths.map { |sf| project.reference_for_path(sf) }
...@@ -67,7 +62,6 @@ module Pod ...@@ -67,7 +62,6 @@ module Pod
end end
end end
end end
end
# Add a file reference to the system frameworks if needed and links the # Add a file reference to the system frameworks if needed and links the
...@@ -79,14 +73,12 @@ module Pod ...@@ -79,14 +73,12 @@ module Pod
# @return [void] # @return [void]
# #
def link_to_system_frameworks def link_to_system_frameworks
UI.message "- Linking to system frameworks" do
target.specs.each do |spec| target.specs.each do |spec|
spec.consumer(target.platform).frameworks.each do |framework| spec.consumer(target.platform).frameworks.each do |framework|
project.add_system_framework(framework, target.target) project.add_system_framework(framework, target.target)
end end
end end
end end
end
......
...@@ -189,7 +189,12 @@ module Pod ...@@ -189,7 +189,12 @@ module Pod
# @return [PBXGroup] The new group. # @return [PBXGroup] The new group.
# #
def add_aggregate_pod_group(aggregate_name, pod_name, path) 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 end
# Returns the group for the pod target with the given name and aggregate. # 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