Commit da121866 authored by Fabio Pelosin's avatar Fabio Pelosin

[Config] #project_root -> #installation_root & project_pods_root -> sandbox_root

parent c8060b62
...@@ -121,24 +121,26 @@ module Pod ...@@ -121,24 +121,26 @@ module Pod
# @return [Pathname] the root of the CocoaPods installation where the # @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located. # Podfile is located.
# #
def project_root def installation_root
@project_root ||= Pathname.pwd @installation_root ||= Pathname.pwd
end end
attr_writer :project_root attr_writer :installation_root
alias :project_root :installation_root
# @return [Pathname] The root of the sandbox. # @return [Pathname] The root of the sandbox.
# #
def project_pods_root def sandbox_root
@project_pods_root ||= @project_root + 'Pods' @sandbox_root ||= installation_root + 'Pods'
end end
attr_writer :project_pods_root attr_writer :sandbox_root
alias :project_pods_root :sandbox_root
# @return [Sandbox] The sandbox of the current project. # @return [Sandbox] The sandbox of the current project.
# #
def sandbox def sandbox
@sandbox ||= Sandbox.new(project_pods_root) @sandbox ||= Sandbox.new(sandbox_root)
end end
# @return [Podfile] The Podfile to use for the current execution. # @return [Podfile] The Podfile to use for the current execution.
...@@ -190,9 +192,9 @@ module Pod ...@@ -190,9 +192,9 @@ module Pod
# #
def podfile_path def podfile_path
unless @podfile_path unless @podfile_path
@podfile_path = project_root + 'CocoaPods.podfile' @podfile_path = installation_root + 'CocoaPods.podfile'
unless @podfile_path.exist? unless @podfile_path.exist?
@podfile_path = project_root + 'Podfile' @podfile_path = installation_root + 'Podfile'
end end
end end
@podfile_path @podfile_path
...@@ -203,7 +205,7 @@ module Pod ...@@ -203,7 +205,7 @@ module Pod
# @note The Lockfile is named `Podfile.lock`. # @note The Lockfile is named `Podfile.lock`.
# #
def lockfile_path def lockfile_path
@lockfile_path ||= project_root + 'Podfile.lock' @lockfile_path ||= installation_root + 'Podfile.lock'
end end
#--------------------------------------# #--------------------------------------#
......
...@@ -198,7 +198,7 @@ module Pod ...@@ -198,7 +198,7 @@ module Pod
lib.user_build_configurations = compute_user_build_configurations(target_definition, lib.user_targets) lib.user_build_configurations = compute_user_build_configurations(target_definition, lib.user_targets)
lib.platform = compute_platform_for_target_definition(target_definition, lib.user_targets) lib.platform = compute_platform_for_target_definition(target_definition, lib.user_targets)
else else
lib.user_project_path = config.project_root lib.user_project_path = config.installation_root
lib.user_project = nil lib.user_project = nil
lib.user_targets = [] lib.user_targets = []
lib.user_build_configurations = {} lib.user_build_configurations = {}
...@@ -374,7 +374,7 @@ module Pod ...@@ -374,7 +374,7 @@ module Pod
# #
def compute_user_project_path(target_definition) def compute_user_project_path(target_definition)
if target_definition.user_project_path if target_definition.user_project_path
path = config.project_root + target_definition.user_project_path path = config.installation_root + target_definition.user_project_path
path = "#{path}.xcodeproj" unless File.extname(path) == '.xcodeproj' path = "#{path}.xcodeproj" unless File.extname(path) == '.xcodeproj'
path = Pathname.new(path) path = Pathname.new(path)
unless path.exist? unless path.exist?
...@@ -383,7 +383,7 @@ module Pod ...@@ -383,7 +383,7 @@ module Pod
end end
else else
xcodeprojs = Pathname.glob(config.project_root + '*.xcodeproj') xcodeprojs = Pathname.glob(config.installation_root + '*.xcodeproj')
if xcodeprojs.size == 1 if xcodeprojs.size == 1
path = xcodeprojs.first path = xcodeprojs.first
else else
......
...@@ -31,7 +31,7 @@ module Pod ...@@ -31,7 +31,7 @@ module Pod
# should be inferred by the project. If the workspace should be in # should be inferred by the project. If the workspace should be in
# the same dir of the project, this could be removed. # the same dir of the project, this could be removed.
# #
attr_reader :project_root attr_reader :installation_root
# @return [Library] the libraries generated by the installer. # @return [Library] the libraries generated by the installer.
# #
...@@ -39,15 +39,15 @@ module Pod ...@@ -39,15 +39,15 @@ module Pod
# @param [Podfile] podfile @see #podfile # @param [Podfile] podfile @see #podfile
# @param [Sandbox] sandbox @see #sandbox # @param [Sandbox] sandbox @see #sandbox
# @param [Pathname] project_root @see #project_root # @param [Pathname] installation_root @see #installation_root
# @param [Library] libraries @see #libraries # @param [Library] libraries @see #libraries
# #
# @todo Too many initialization arguments # @todo Too many initialization arguments
# #
def initialize(podfile, sandbox, project_root, libraries) def initialize(podfile, sandbox, installation_root, libraries)
@podfile = podfile @podfile = podfile
@sandbox = sandbox @sandbox = sandbox
@project_root = project_root @installation_root = installation_root
@libraries = libraries @libraries = libraries
end end
...@@ -143,7 +143,7 @@ module Pod ...@@ -143,7 +143,7 @@ module Pod
podfile.workspace_path podfile.workspace_path
elsif user_project_paths.count == 1 elsif user_project_paths.count == 1
project = user_project_paths.first.basename('.xcodeproj') project = user_project_paths.first.basename('.xcodeproj')
project_root + "#{project}.xcworkspace" installation_root + "#{project}.xcworkspace"
else else
raise Informative, "Could not automatically select an Xcode " \ raise Informative, "Could not automatically select an Xcode " \
"workspace. Specify one in your Podfile like so:\n\n" \ "workspace. Specify one in your Podfile like so:\n\n" \
......
...@@ -212,8 +212,8 @@ module Pod ...@@ -212,8 +212,8 @@ module Pod
validation_dir.rmtree if validation_dir.exist? validation_dir.rmtree if validation_dir.exist?
validation_dir.mkpath validation_dir.mkpath
@original_config = Config.instance.clone @original_config = Config.instance.clone
config.project_root = validation_dir config.installation_root = validation_dir
config.project_pods_root = validation_dir + 'Pods' config.sandbox_root = validation_dir + 'Pods'
config.silent = !config.verbose config.silent = !config.verbose
config.integrate_targets = false config.integrate_targets = false
config.generate_docs = false config.generate_docs = false
...@@ -231,7 +231,7 @@ module Pod ...@@ -231,7 +231,7 @@ module Pod
# #
def install_pod def install_pod
podfile = podfile_from_spec(consumer.platform, spec.deployment_target(consumer.platform)) podfile = podfile_from_spec(consumer.platform, spec.deployment_target(consumer.platform))
sandbox = Sandbox.new(config.project_pods_root) sandbox = Sandbox.new(config.sandbox_root)
installer = Installer.new(sandbox, podfile) installer = Installer.new(sandbox, podfile)
installer.install! installer.install!
...@@ -254,7 +254,7 @@ module Pod ...@@ -254,7 +254,7 @@ module Pod
else else
UI.message "\nBuilding with xcodebuild.\n".yellow do UI.message "\nBuilding with xcodebuild.\n".yellow do
messages = [] messages = []
output = Dir.chdir(config.project_pods_root) { `xcodebuild clean build 2>&1` } output = Dir.chdir(config.sandbox_root) { `xcodebuild clean build 2>&1` }
UI.puts output UI.puts output
parsed_output = parse_xcodebuild_output(output) parsed_output = parse_xcodebuild_output(output)
parsed_output.each do |message| parsed_output.each do |message|
......
...@@ -14,11 +14,11 @@ puts " [!] ".red << "Skipping xcodebuild based checks, because it can't be found ...@@ -14,11 +14,11 @@ puts " [!] ".red << "Skipping xcodebuild based checks, because it can't be found
def should_xcodebuild(target_definition) def should_xcodebuild(target_definition)
return if skip_xcodebuild? return if skip_xcodebuild?
target = target_definition target = target_definition
Dir.chdir(config.project_pods_root) do Dir.chdir(config.sandbox_root) do
print "[!] Compiling #{target.label}...\r" print "[!] Compiling #{target.label}...\r"
should_successfully_perform "xcodebuild -target '#{target.label}'" should_successfully_perform "xcodebuild -target '#{target.label}'"
product_name = "lib#{target_definition.label}.a" product_name = "lib#{target_definition.label}.a"
lib_path = config.project_pods_root + "build/Release#{'-iphoneos' if target.platform == :ios}" + product_name lib_path = config.sandbox_root + "build/Release#{'-iphoneos' if target.platform == :ios}" + product_name
`lipo -info '#{lib_path}'`.should.include "#{target.platform == :ios ? 'armv7' : 'x86_64'}" `lipo -info '#{lib_path}'`.should.include "#{target.platform == :ios ? 'armv7' : 'x86_64'}"
end end
end end
...@@ -94,7 +94,7 @@ module Pod ...@@ -94,7 +94,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile) installer = Installer.new(config.sandbox, podfile)
installer.install! installer.install!
dummy = (config.project_pods_root + 'Pods-dummy.m').read dummy = (config.sandbox_root + 'Pods-dummy.m').read
dummy.should.include?('@implementation PodsDummy_Pods') dummy.should.include?('@implementation PodsDummy_Pods')
end end
...@@ -113,7 +113,7 @@ module Pod ...@@ -113,7 +113,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile) installer = Installer.new(config.sandbox, podfile)
installer.install! installer.install!
dummy = (config.project_pods_root + 'Pods-AnotherTarget-dummy.m').read dummy = (config.sandbox_root + 'Pods-AnotherTarget-dummy.m').read
dummy.should.include?('@implementation PodsDummy_Pods_AnotherTarget') dummy.should.include?('@implementation PodsDummy_Pods_AnotherTarget')
end end
...@@ -180,9 +180,9 @@ module Pod ...@@ -180,9 +180,9 @@ module Pod
installer = Installer.new(config.sandbox, podfile) installer = Installer.new(config.sandbox, podfile)
installer.install! installer.install!
doc = (config.project_pods_root + 'Documentation/JSONKit/html/index.html').read doc = (config.sandbox_root + 'Documentation/JSONKit/html/index.html').read
doc.should.include?('<title>JSONKit 1.4 Reference</title>') doc.should.include?('<title>JSONKit 1.4 Reference</title>')
doc = (config.project_pods_root + 'Documentation/SSToolkit/html/index.html').read doc = (config.sandbox_root + 'Documentation/SSToolkit/html/index.html').read
doc.should.include?('<title>SSToolkit 1.0.0 Reference</title>') doc.should.include?('<title>SSToolkit 1.0.0 Reference</title>')
end end
end end
...@@ -195,7 +195,7 @@ module Pod ...@@ -195,7 +195,7 @@ module Pod
describe "Multi-platform (#{test_platform})" do describe "Multi-platform (#{test_platform})" do
before do before do
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root) FileUtils.cp_r(fixture('integration/.'), config.sandbox_root)
end end
#--------------------------------------# #--------------------------------------#
...@@ -208,12 +208,12 @@ module Pod ...@@ -208,12 +208,12 @@ module Pod
pre_install do |installer| pre_install do |installer|
memo = "PODS:#{installer.pods * ', '} TARGETS:#{installer.project.targets.to_a * ', '}" memo = "PODS:#{installer.pods * ', '} TARGETS:#{installer.project.targets.to_a * ', '}"
File.open(installer.config.project_pods_root + 'memo.txt', 'w') {|f| f.puts memo} File.open(installer.config.sandbox_root + 'memo.txt', 'w') {|f| f.puts memo}
end end
end end
Installer.new(config.sandbox, podfile).install! Installer.new(config.sandbox, podfile).install!
File.open(config.project_pods_root + 'memo.txt','rb').read.should == "PODS:SSZipArchive (0.1.0) TARGETS:\n" File.open(config.sandbox_root + 'memo.txt','rb').read.should == "PODS:SSZipArchive (0.1.0) TARGETS:\n"
end end
#--------------------------------------# #--------------------------------------#
...@@ -280,7 +280,7 @@ module Pod ...@@ -280,7 +280,7 @@ module Pod
lockfile.delete("SPEC CHECKSUMS") lockfile.delete("SPEC CHECKSUMS")
lockfile.should == lockfile_contents lockfile.should == lockfile_contents
root = config.project_pods_root root = config.sandbox_root
(root + 'Pods.xcconfig').read.should == installer.libraries.first.xcconfig.to_s (root + 'Pods.xcconfig').read.should == installer.libraries.first.xcconfig.to_s
project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s
saved_project = Xcodeproj.read_plist(project_file) saved_project = Xcodeproj.read_plist(project_file)
...@@ -303,7 +303,7 @@ module Pod ...@@ -303,7 +303,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile) installer = Installer.new(config.sandbox, podfile)
installer.install! installer.install!
contents = (config.project_pods_root + 'Pods-resources.sh').read contents = (config.sandbox_root + 'Pods-resources.sh').read
contents.should.include "install_resource 'SSZipArchive/LICENSE'\n" \ contents.should.include "install_resource 'SSZipArchive/LICENSE'\n" \
"install_resource 'SSZipArchive/Readme.markdown'" "install_resource 'SSZipArchive/Readme.markdown'"
end end
...@@ -327,7 +327,7 @@ module Pod ...@@ -327,7 +327,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile) installer = Installer.new(config.sandbox, podfile)
installer.install! installer.install!
project = Xcodeproj::Project.new(config.project_pods_root + 'Pods.xcodeproj') project = Xcodeproj::Project.new(config.sandbox_root + 'Pods.xcodeproj')
disk_source_files = project.files.sort.reject { |f| f.build_files.empty? } disk_source_files = project.files.sort.reject { |f| f.build_files.empty? }
installer_source_files = installer.pods_project.files.sort.reject { |f| f.build_files.empty? } installer_source_files = installer.pods_project.files.sort.reject { |f| f.build_files.empty? }
disk_source_files.should == installer_source_files disk_source_files.should == installer_source_files
...@@ -352,7 +352,7 @@ module Pod ...@@ -352,7 +352,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile) installer = Installer.new(config.sandbox, podfile)
installer.install! installer.install!
project = Xcodeproj::Project.new(config.project_pods_root + 'Pods.xcodeproj') project = Xcodeproj::Project.new(config.sandbox_root + 'Pods.xcodeproj')
project.targets.count.should == 3 project.targets.count.should == 3
project.targets.each do |target| project.targets.each do |target|
phase = target.build_phases.find { |phase| phase.isa == 'PBXSourcesBuildPhase' } phase = target.build_phases.find { |phase| phase.isa == 'PBXSourcesBuildPhase' }
...@@ -383,7 +383,7 @@ module Pod ...@@ -383,7 +383,7 @@ module Pod
] ]
expected_files.each do |file| expected_files.each do |file|
(config.project_pods_root + file).should.exist (config.sandbox_root + file).should.exist
end end
should_xcodebuild(podfile.target_definitions[:default]) should_xcodebuild(podfile.target_definitions[:default])
...@@ -439,7 +439,7 @@ module Pod ...@@ -439,7 +439,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile) installer = Installer.new(config.sandbox, podfile)
installer.install! installer.install!
root = config.project_pods_root root = config.sandbox_root
(root + 'Pods.xcconfig').should.exist (root + 'Pods.xcconfig').should.exist
(root + 'Headers').should.exist (root + 'Headers').should.exist
(root + 'Headers/SSZipArchive').should.exist (root + 'Headers/SSZipArchive').should.exist
......
...@@ -7,12 +7,10 @@ module Bacon ...@@ -7,12 +7,10 @@ module Bacon
define_method(:run_requirement) do |description, spec| define_method(:run_requirement) do |description, spec|
::Pod::Config.instance = nil ::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c| ::Pod::Config.instance.tap do |c|
# c.verbose = ENV['VERBOSE_SPECS']
# c.silent = !ENV['VERBOSE_SPECS']
c.verbose = false c.verbose = false
c.silent = true c.silent = true
c.repos_dir = fixture('spec-repos') c.repos_dir = fixture('spec-repos')
c.project_root = SpecHelper.temporary_directory c.installation_root = SpecHelper.temporary_directory
c.install_docs = false c.install_docs = false
c.generate_docs = false c.generate_docs = false
c.skip_repo_update = true c.skip_repo_update = true
......
...@@ -20,11 +20,11 @@ module Pod ...@@ -20,11 +20,11 @@ module Pod
describe "Concerning a user's project, which is expected in the current working directory" do describe "Concerning a user's project, which is expected in the current working directory" do
before do before do
config.project_root = temporary_directory config.installation_root = temporary_directory
end end
it "returns the path to the project root" do it "returns the path to the project root" do
config.project_root.should == temporary_directory config.installation_root.should == temporary_directory
end end
it "returns the path to the project Podfile if it exists" do it "returns the path to the project Podfile if it exists" do
...@@ -38,7 +38,7 @@ module Pod ...@@ -38,7 +38,7 @@ module Pod
end end
it "returns the path to the Pods directory that holds the dependencies" do it "returns the path to the Pods directory that holds the dependencies" do
config.project_pods_root.should == temporary_directory + 'Pods' config.sandbox_root.should == temporary_directory + 'Pods'
end end
end end
......
...@@ -92,7 +92,7 @@ module Pod ...@@ -92,7 +92,7 @@ module Pod
@analyzer.analyze @analyzer.analyze
lib = @analyzer.libraries.first lib = @analyzer.libraries.first
lib.user_project_path.should == config.project_root lib.user_project_path.should == config.installation_root
lib.user_project.should.be.nil lib.user_project.should.be.nil
lib.user_targets.map(&:name).should == [] lib.user_targets.map(&:name).should == []
lib.user_build_configurations.should == {} lib.user_build_configurations.should == {}
...@@ -199,7 +199,7 @@ module Pod ...@@ -199,7 +199,7 @@ module Pod
it "if not specified in the target definition if looks if there is only one project" do it "if not specified in the target definition if looks if there is only one project" do
target_definition = Podfile::TargetDefinition.new(:default, nil, nil) target_definition = Podfile::TargetDefinition.new(:default, nil, nil)
config.project_root = config.project_root + 'SampleProject' config.installation_root = config.installation_root + 'SampleProject'
path = @analyzer.send(:compute_user_project_path, target_definition) path = @analyzer.send(:compute_user_project_path, target_definition)
path.to_s.should.include 'SampleProject/SampleProject.xcodeproj' path.to_s.should.include 'SampleProject/SampleProject.xcodeproj'
......
...@@ -20,7 +20,7 @@ module Pod ...@@ -20,7 +20,7 @@ module Pod
end end
end end
@project_root = @sample_project_path.dirname @installation_root = @sample_project_path.dirname
@pods_project = Project.new() @pods_project = Project.new()
config.sandbox.project = @pods_project config.sandbox.project = @pods_project
@libraries = @podfile.target_definitions.values.map do |target_definition| @libraries = @podfile.target_definitions.values.map do |target_definition|
...@@ -32,7 +32,7 @@ module Pod ...@@ -32,7 +32,7 @@ module Pod
lib.user_project = sample_project lib.user_project = sample_project
lib lib
end end
@integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, @project_root, @libraries) @integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, @installation_root, @libraries)
end end
it "uses the path of the workspace defined in the podfile" do it "uses the path of the workspace defined in the podfile" do
......
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