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
# @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located.
#
def project_root
@project_root ||= Pathname.pwd
def installation_root
@installation_root ||= Pathname.pwd
end
attr_writer :project_root
attr_writer :installation_root
alias :project_root :installation_root
# @return [Pathname] The root of the sandbox.
#
def project_pods_root
@project_pods_root ||= @project_root + 'Pods'
def sandbox_root
@sandbox_root ||= installation_root + 'Pods'
end
attr_writer :project_pods_root
attr_writer :sandbox_root
alias :project_pods_root :sandbox_root
# @return [Sandbox] The sandbox of the current project.
#
def sandbox
@sandbox ||= Sandbox.new(project_pods_root)
@sandbox ||= Sandbox.new(sandbox_root)
end
# @return [Podfile] The Podfile to use for the current execution.
......@@ -190,9 +192,9 @@ module Pod
#
def podfile_path
unless @podfile_path
@podfile_path = project_root + 'CocoaPods.podfile'
@podfile_path = installation_root + 'CocoaPods.podfile'
unless @podfile_path.exist?
@podfile_path = project_root + 'Podfile'
@podfile_path = installation_root + 'Podfile'
end
end
@podfile_path
......@@ -203,7 +205,7 @@ module Pod
# @note The Lockfile is named `Podfile.lock`.
#
def lockfile_path
@lockfile_path ||= project_root + 'Podfile.lock'
@lockfile_path ||= installation_root + 'Podfile.lock'
end
#--------------------------------------#
......
......@@ -198,7 +198,7 @@ module Pod
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)
else
lib.user_project_path = config.project_root
lib.user_project_path = config.installation_root
lib.user_project = nil
lib.user_targets = []
lib.user_build_configurations = {}
......@@ -374,7 +374,7 @@ module Pod
#
def compute_user_project_path(target_definition)
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 = Pathname.new(path)
unless path.exist?
......@@ -383,7 +383,7 @@ module Pod
end
else
xcodeprojs = Pathname.glob(config.project_root + '*.xcodeproj')
xcodeprojs = Pathname.glob(config.installation_root + '*.xcodeproj')
if xcodeprojs.size == 1
path = xcodeprojs.first
else
......
......@@ -31,7 +31,7 @@ module Pod
# should be inferred by the project. If the workspace should be in
# 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.
#
......@@ -39,16 +39,16 @@ module Pod
# @param [Podfile] podfile @see #podfile
# @param [Sandbox] sandbox @see #sandbox
# @param [Pathname] project_root @see #project_root
# @param [Pathname] installation_root @see #installation_root
# @param [Library] libraries @see #libraries
#
# @todo Too many initialization arguments
#
def initialize(podfile, sandbox, project_root, libraries)
@podfile = podfile
def initialize(podfile, sandbox, installation_root, libraries)
@podfile = podfile
@sandbox = sandbox
@project_root = project_root
@libraries = libraries
@installation_root = installation_root
@libraries = libraries
end
# Integrates the user projects associated with the {TargetDefinitions}
......@@ -143,7 +143,7 @@ module Pod
podfile.workspace_path
elsif user_project_paths.count == 1
project = user_project_paths.first.basename('.xcodeproj')
project_root + "#{project}.xcworkspace"
installation_root + "#{project}.xcworkspace"
else
raise Informative, "Could not automatically select an Xcode " \
"workspace. Specify one in your Podfile like so:\n\n" \
......
......@@ -212,8 +212,8 @@ module Pod
validation_dir.rmtree if validation_dir.exist?
validation_dir.mkpath
@original_config = Config.instance.clone
config.project_root = validation_dir
config.project_pods_root = validation_dir + 'Pods'
config.installation_root = validation_dir
config.sandbox_root = validation_dir + 'Pods'
config.silent = !config.verbose
config.integrate_targets = false
config.generate_docs = false
......@@ -231,7 +231,7 @@ module Pod
#
def install_pod
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.install!
......@@ -254,7 +254,7 @@ module Pod
else
UI.message "\nBuilding with xcodebuild.\n".yellow do
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
parsed_output = parse_xcodebuild_output(output)
parsed_output.each do |message|
......
......@@ -14,11 +14,11 @@ puts " [!] ".red << "Skipping xcodebuild based checks, because it can't be found
def should_xcodebuild(target_definition)
return if skip_xcodebuild?
target = target_definition
Dir.chdir(config.project_pods_root) do
Dir.chdir(config.sandbox_root) do
print "[!] Compiling #{target.label}...\r"
should_successfully_perform "xcodebuild -target '#{target.label}'"
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'}"
end
end
......@@ -94,7 +94,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile)
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')
end
......@@ -113,7 +113,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile)
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')
end
......@@ -180,9 +180,9 @@ module Pod
installer = Installer.new(config.sandbox, podfile)
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 = (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>')
end
end
......@@ -195,7 +195,7 @@ module Pod
describe "Multi-platform (#{test_platform})" do
before do
FileUtils.cp_r(fixture('integration/.'), config.project_pods_root)
FileUtils.cp_r(fixture('integration/.'), config.sandbox_root)
end
#--------------------------------------#
......@@ -208,12 +208,12 @@ module Pod
pre_install do |installer|
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
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
#--------------------------------------#
......@@ -280,7 +280,7 @@ module Pod
lockfile.delete("SPEC CHECKSUMS")
lockfile.should == lockfile_contents
root = config.project_pods_root
root = config.sandbox_root
(root + 'Pods.xcconfig').read.should == installer.libraries.first.xcconfig.to_s
project_file = (root + 'Pods.xcodeproj/project.pbxproj').to_s
saved_project = Xcodeproj.read_plist(project_file)
......@@ -303,7 +303,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile)
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" \
"install_resource 'SSZipArchive/Readme.markdown'"
end
......@@ -327,7 +327,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile)
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? }
installer_source_files = installer.pods_project.files.sort.reject { |f| f.build_files.empty? }
disk_source_files.should == installer_source_files
......@@ -352,7 +352,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile)
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.each do |target|
phase = target.build_phases.find { |phase| phase.isa == 'PBXSourcesBuildPhase' }
......@@ -383,7 +383,7 @@ module Pod
]
expected_files.each do |file|
(config.project_pods_root + file).should.exist
(config.sandbox_root + file).should.exist
end
should_xcodebuild(podfile.target_definitions[:default])
......@@ -439,7 +439,7 @@ module Pod
installer = Installer.new(config.sandbox, podfile)
installer.install!
root = config.project_pods_root
root = config.sandbox_root
(root + 'Pods.xcconfig').should.exist
(root + 'Headers').should.exist
(root + 'Headers/SSZipArchive').should.exist
......
......@@ -7,15 +7,13 @@ module Bacon
define_method(:run_requirement) do |description, spec|
::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
# c.verbose = ENV['VERBOSE_SPECS']
# c.silent = !ENV['VERBOSE_SPECS']
c.verbose = false
c.silent = true
c.repos_dir = fixture('spec-repos')
c.project_root = SpecHelper.temporary_directory
c.install_docs = false
c.generate_docs = false
c.skip_repo_update = true
c.verbose = false
c.silent = true
c.repos_dir = fixture('spec-repos')
c.installation_root = SpecHelper.temporary_directory
c.install_docs = false
c.generate_docs = false
c.skip_repo_update = true
end
::Pod::UI.output = ''
......
......@@ -20,11 +20,11 @@ module Pod
describe "Concerning a user's project, which is expected in the current working directory" do
before do
config.project_root = temporary_directory
config.installation_root = temporary_directory
end
it "returns the path to the project root" do
config.project_root.should == temporary_directory
config.installation_root.should == temporary_directory
end
it "returns the path to the project Podfile if it exists" do
......@@ -38,7 +38,7 @@ module Pod
end
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
......
......@@ -92,7 +92,7 @@ module Pod
@analyzer.analyze
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_targets.map(&:name).should == []
lib.user_build_configurations.should == {}
......@@ -199,7 +199,7 @@ module Pod
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)
config.project_root = config.project_root + 'SampleProject'
config.installation_root = config.installation_root + 'SampleProject'
path = @analyzer.send(:compute_user_project_path, target_definition)
path.to_s.should.include 'SampleProject/SampleProject.xcodeproj'
......
......@@ -20,7 +20,7 @@ module Pod
end
end
@project_root = @sample_project_path.dirname
@installation_root = @sample_project_path.dirname
@pods_project = Project.new()
config.sandbox.project = @pods_project
@libraries = @podfile.target_definitions.values.map do |target_definition|
......@@ -32,7 +32,7 @@ module Pod
lib.user_project = sample_project
lib
end
@integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, @project_root, @libraries)
@integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, @installation_root, @libraries)
end
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