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,11 +127,9 @@ module Pod ...@@ -123,11 +127,9 @@ 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
...@@ -146,7 +148,7 @@ module Pod ...@@ -146,7 +148,7 @@ module Pod
ref.remove_from_project ref.remove_from_project
end end
end end
target.remove_from_project target.remove_from_project
target.product_reference.referrers.each do |ref| target.product_reference.referrers.each do |ref|
if ref.isa == 'PBXBuildFile' if ref.isa == 'PBXBuildFile'
...@@ -163,21 +165,19 @@ module Pod ...@@ -163,21 +165,19 @@ 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 cp_targets.each do |pod_target|
cp_targets.each do |pod_target| native_targets = native_targets_by_name[pod_target.label]
native_targets = native_targets_by_name[pod_target.label] if native_targets
if native_targets pod_target.target = native_targets.first
pod_target.target = native_targets.first native_targets_to_remove.delete(pod_target.label)
native_targets_to_remove.delete(pod_target.label)
end
end end
end
native_targets_to_remove.each do |target_name| native_targets_to_remove.each do |target_name|
remove_target(native_targets_by_name[target_name].first) remove_target(native_targets_by_name[target_name].first)
end
end end
end end
...@@ -189,8 +189,10 @@ module Pod ...@@ -189,8 +189,10 @@ 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
...@@ -215,8 +217,10 @@ module Pod ...@@ -215,8 +217,10 @@ module Pod
aggregate_targets.each do |target| aggregate_targets.each do |target|
unless target.target_definition.empty? unless target.target_definition.empty?
gen = SupportFilesGenerator.new(target, sandbox.project) UI.message"- Generating support files for target `#{target.label}`" do
gen.generate! gen = SupportFilesGenerator.new(target, sandbox.project)
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,9 +49,7 @@ module Pod ...@@ -49,9 +49,7 @@ 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
...@@ -59,9 +57,7 @@ module Pod ...@@ -59,9 +57,7 @@ module Pod
# @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
...@@ -69,9 +65,7 @@ module Pod ...@@ -69,9 +65,7 @@ module Pod
# @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,10 +76,8 @@ module Pod ...@@ -82,10 +76,8 @@ 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
......
...@@ -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,16 +53,14 @@ module Pod ...@@ -55,16 +53,14 @@ 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) target.xcconfig = gen.xcconfig
target.xcconfig = gen.xcconfig xcconfig_file_ref = add_file_to_support_group(path)
xcconfig_file_ref = add_file_to_support_group(path)
target.target.build_configurations.each do |c|
target.target.build_configurations.each do |c| c.base_configuration_reference = xcconfig_file_ref
c.base_configuration_reference = xcconfig_file_ref
end
end end
end end
...@@ -75,21 +71,17 @@ module Pod ...@@ -75,21 +71,17 @@ 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) xcconfig_file_ref = add_file_to_support_group(path)
xcconfig_file_ref = add_file_to_support_group(path)
target.target.build_configurations.each do |c| target.target.build_configurations.each do |c|
c.base_configuration_reference = xcconfig_file_ref c.base_configuration_reference = xcconfig_file_ref
end
end end
end end
...@@ -98,12 +90,10 @@ module Pod ...@@ -98,12 +90,10 @@ module Pod
# 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,14 +106,12 @@ module Pod ...@@ -116,14 +106,12 @@ 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) generator.save_as(path)
generator.save_as(path) add_file_to_support_group(path)
add_file_to_support_group(path) @bridge_support_file = path
@bridge_support_file = path
end
end end
end end
...@@ -133,14 +121,12 @@ module Pod ...@@ -133,14 +121,12 @@ 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 generator = generator_class.new(file_accessors)
generator = generator_class.new(file_accessors) generator.save_as(path)
generator.save_as(path) add_file_to_support_group(path)
add_file_to_support_group(path)
end
end end
end end
...@@ -153,19 +139,17 @@ module Pod ...@@ -153,19 +139,17 @@ 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 resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten
resource_bundles = file_accessors.map { |accessor| accessor.resource_bundles.keys.map {|name| "${BUILT_PRODUCTS_DIR}/#{name}.bundle" } }.flatten resources = []
resources = [] resources.concat(resource_paths)
resources.concat(resource_paths) resources.concat(resource_bundles)
resources.concat(resource_bundles) resources << bridge_support_file.relative_path_from(project.path.dirname) if bridge_support_file
resources << bridge_support_file.relative_path_from(project.path.dirname) if bridge_support_file generator = Generator::CopyResourcesScript.new(resources, target.platform)
generator = Generator::CopyResourcesScript.new(resources, target.platform) 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
...@@ -175,17 +159,15 @@ module Pod ...@@ -175,17 +159,15 @@ 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 generator.save_as(path)
generator.save_as(path) add_file_to_support_group(path)
add_file_to_support_group(path)
target.target.build_configurations.each do |c|
target.target.build_configurations.each do |c| relative_path = path.relative_path_from(project.path.dirname)
relative_path = path.relative_path_from(project.path.dirname) 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
...@@ -196,15 +178,13 @@ module Pod ...@@ -196,15 +178,13 @@ 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) file_reference = add_file_to_support_group(path)
file_reference = add_file_to_support_group(path) existing = target.target.source_build_phase.files_references.include?(file_reference)
existing = target.target.source_build_phase.files_references.include?(file_reference) unless existing
unless existing 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,12 +12,10 @@ module Pod ...@@ -12,12 +12,10 @@ 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,14 +31,12 @@ module Pod ...@@ -33,14 +31,12 @@ 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) source_files = file_accessor.source_files
source_files = file_accessor.source_files file_refs = source_files.map { |sf| project.reference_for_path(sf) }
file_refs = source_files.map { |sf| project.reference_for_path(sf) } target.target.add_file_references(file_refs, flags)
target.target.add_file_references(file_refs, flags)
end
end end
end end
...@@ -52,19 +48,17 @@ module Pod ...@@ -52,19 +48,17 @@ 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) } bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name)
bundle_target = project.new_resources_bundle(bundle_name, file_accessor.spec_consumer.platform_name) bundle_target.add_resources(file_references)
bundle_target.add_resources(file_references)
target.user_build_configurations.each do |bc_name, type|
target.user_build_configurations.each do |bc_name, type| bundle_target.add_build_configuration(bc_name, type)
bundle_target.add_build_configuration(bc_name, type)
end
target.add_dependency(bundle_target)
end end
target.add_dependency(bundle_target)
end end
end end
end end
...@@ -79,11 +73,9 @@ module Pod ...@@ -79,11 +73,9 @@ 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