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,12 +127,10 @@ 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
end
group.remove_from_project
end
......@@ -163,7 +165,6 @@ 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
......@@ -179,7 +180,6 @@ module Pod
remove_target(native_targets_by_name[target_name].first)
end
end
end
# @return [void]
#
......@@ -189,10 +189,12 @@ 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
# Adds and removes aggregate targets to the
#
......@@ -215,11 +217,13 @@ module Pod
aggregate_targets.each do |target|
unless target.target_definition.empty?
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,30 +49,24 @@ module Pod
# @return [void]
#
def add_source_files_references
UI.message "- Adding source files" do
add_paths_to_group(:source_files, :source_files)
end
end
# Adds the bundled frameworks to the Pods project
#
# @return [void]
#
def add_frameworks_bundles
UI.message "- Adding frameworks" do
add_paths_to_group(:vendored_frameworks, :frameworks_and_libraries)
end
end
# Adds the bundled libraries to the Pods project
#
# @return [void]
#
def add_vendored_libraries
UI.message "- Adding libraries" do
add_paths_to_group(:vendored_libraries, :frameworks_and_libraries)
end
end
# Adds the resources of the Pods to the Pods project.
#
......@@ -82,11 +76,9 @@ 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
end
private
......
......@@ -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,7 +53,6 @@ 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)
......@@ -66,7 +63,6 @@ module Pod
c.base_configuration_reference = xcconfig_file_ref
end
end
end
# Generates the contents of the xcconfig file and saves it to disk.
......@@ -75,13 +71,10 @@ 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
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)
......@@ -91,20 +84,17 @@ module Pod
c.base_configuration_reference = xcconfig_file_ref
end
end
end
# Generates a header which allows to inspect at compile time the installed
# 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
end
# Generates the bridge support metadata if requested by the {Podfile}.
#
......@@ -116,7 +106,6 @@ 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)
......@@ -125,7 +114,6 @@ module Pod
@bridge_support_file = path
end
end
end
# Generates the acknowledgement files (markdown and plist) for the target.
#
......@@ -133,7 +121,6 @@ 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
......@@ -142,7 +129,6 @@ module Pod
add_file_to_support_group(path)
end
end
end
# Creates a script that copies the resources to the bundle of the client
# target.
......@@ -153,7 +139,6 @@ 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
......@@ -166,7 +151,6 @@ module Pod
generator.save_as(path)
add_file_to_support_group(path)
end
end
# Creates a prefix header file which imports `UIKit` or `Cocoa` according
# to the platform of the target. This file also include any prefix header
......@@ -175,7 +159,6 @@ 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
......@@ -187,7 +170,6 @@ module Pod
c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
end
end
end
# Generates a dummy source file for each target so libraries that contain
......@@ -196,7 +178,6 @@ 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)
......@@ -206,7 +187,6 @@ module Pod
target.target.source_build_phase.add_file_reference(file_reference)
end
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,13 +12,11 @@ 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
end
private
......@@ -33,7 +31,6 @@ 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)
......@@ -42,7 +39,6 @@ module Pod
target.target.add_file_references(file_refs, flags)
end
end
end
# Adds the resources of the Pods to the Pods project.
#
......@@ -52,7 +48,6 @@ 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) }
......@@ -67,7 +62,6 @@ module Pod
end
end
end
end
# Add a file reference to the system frameworks if needed and links the
......@@ -79,14 +73,12 @@ 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
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