Commit 0aea0bef authored by Gwendal Roué's avatar Gwendal Roué

[#221] code cleanup

parent 5a2c29c0
...@@ -73,7 +73,7 @@ module Pod ...@@ -73,7 +73,7 @@ module Pod
# Indirect HEADER_SEARCH_PATHS, so that configure_build_configurations can override it # Indirect HEADER_SEARCH_PATHS, so that configure_build_configurations can override it
xcconfig.merge!('HEADER_SEARCH_PATHS' => '${PODS_HEADER_SEARCH_PATHS}') xcconfig.merge!('HEADER_SEARCH_PATHS' => '${PODS_HEADER_SEARCH_PATHS}')
xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_header_storage.search_paths).join(" ")) xcconfig.merge!('PODS_HEADER_SEARCH_PATHS' => quoted(sandbox.public_headers.search_paths).join(" "))
support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label) support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label)
support_files_group.create_files(target_support_files) support_files_group.create_files(target_support_files)
...@@ -89,7 +89,7 @@ module Pod ...@@ -89,7 +89,7 @@ module Pod
config.build_settings['OTHER_LDFLAGS'] = '' config.build_settings['OTHER_LDFLAGS'] = ''
config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name
config.build_settings['PODS_ROOT'] = '${SRCROOT}' config.build_settings['PODS_ROOT'] = '${SRCROOT}'
config.build_settings['PODS_HEADER_SEARCH_PATHS'] = quoted(sandbox.build_header_storage.search_paths).join(" ") config.build_settings['PODS_HEADER_SEARCH_PATHS'] = quoted(sandbox.build_headers.search_paths).join(" ")
end end
end end
......
...@@ -85,10 +85,10 @@ module Pod ...@@ -85,10 +85,10 @@ module Pod
def link_headers def link_headers
copy_header_mappings.each do |namespaced_path, files| copy_header_mappings.each do |namespaced_path, files|
@sandbox.build_header_storage.add_files(namespaced_path, files) @sandbox.build_headers.add_files(namespaced_path, files)
end end
copy_public_header_mappings.each do |namespaced_path, files| copy_public_header_mappings.each do |namespaced_path, files|
@sandbox.public_header_storage.add_files(namespaced_path, files) @sandbox.public_headers.add_files(namespaced_path, files)
end end
end end
......
...@@ -3,17 +3,16 @@ require 'fileutils' ...@@ -3,17 +3,16 @@ require 'fileutils'
module Pod module Pod
class Sandbox class Sandbox
attr_reader :root attr_reader :root
attr_reader :build_header_storage attr_reader :build_headers
attr_reader :public_header_storage attr_reader :public_headers
PUBLIC_HEADERS_DIR = "Headers"
BUILD_HEADERS_DIR = "BuildHeaders" BUILD_HEADERS_DIR = "BuildHeaders"
PUBLIC_HEADERS_DIR = "Headers"
def initialize(path) def initialize(path)
@root = Pathname.new(path) @root = Pathname.new(path)
@build_header_storage = HeaderStorage.new(self, BUILD_HEADERS_DIR) @build_headers = HeadersDirectory.new(self, BUILD_HEADERS_DIR)
@public_header_storage = HeaderStorage.new(self, PUBLIC_HEADERS_DIR) @public_headers = HeadersDirectory.new(self, PUBLIC_HEADERS_DIR)
FileUtils.mkdir_p(@root) FileUtils.mkdir_p(@root)
end end
...@@ -26,8 +25,8 @@ module Pod ...@@ -26,8 +25,8 @@ module Pod
end end
def prepare_for_install def prepare_for_install
build_header_storage.prepare_for_install build_headers.prepare_for_install
public_header_storage.prepare_for_install public_headers.prepare_for_install
end end
def podspec_for_name(name) def podspec_for_name(name)
...@@ -45,7 +44,7 @@ module Pod ...@@ -45,7 +44,7 @@ module Pod
end end
end end
class HeaderStorage class HeadersDirectory
def initialize(sandbox, base_dir) def initialize(sandbox, base_dir)
@sandbox = sandbox @sandbox = sandbox
@base_dir = base_dir @base_dir = base_dir
...@@ -57,7 +56,7 @@ module Pod ...@@ -57,7 +56,7 @@ module Pod
end end
def add_file(namespace_path, relative_header_path) def add_file(namespace_path, relative_header_path)
namespaced_header_path = @sandbox.root + @base_dir + namespace_path namespaced_header_path = root + namespace_path
namespaced_header_path.mkpath unless File.exist?(namespaced_header_path) namespaced_header_path.mkpath unless File.exist?(namespaced_header_path)
source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_header_path) source = (@sandbox.root + relative_header_path).relative_path_from(namespaced_header_path)
Dir.chdir(namespaced_header_path) { FileUtils.ln_sf(source, relative_header_path.basename)} Dir.chdir(namespaced_header_path) { FileUtils.ln_sf(source, relative_header_path.basename)}
......
...@@ -51,7 +51,7 @@ describe Pod::Installer::TargetInstaller do ...@@ -51,7 +51,7 @@ describe Pod::Installer::TargetInstaller do
it 'adds the sandbox header search paths to the xcconfig, with quotes' do it 'adds the sandbox header search paths to the xcconfig, with quotes' do
do_install! do_install!
@installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.build_header_storage.search_paths.join('" "')}\"") @installer.xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include("\"#{@sandbox.build_headers.search_paths.join('" "')}\"")
end end
it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do it 'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it' do
......
...@@ -61,7 +61,7 @@ describe Pod::LocalPod do ...@@ -61,7 +61,7 @@ describe Pod::LocalPod do
it "can link it's headers into the sandbox" do it "can link it's headers into the sandbox" do
@pod.link_headers @pod.link_headers
expected_header_path = @sandbox.build_header_storage.root + "BananaLib/Banana.h" expected_header_path = @sandbox.build_headers.root + "BananaLib/Banana.h"
expected_header_path.should.be.symlink expected_header_path.should.be.symlink
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end end
...@@ -147,7 +147,7 @@ describe "A Pod::LocalPod, with installed source," do ...@@ -147,7 +147,7 @@ describe "A Pod::LocalPod, with installed source," do
def @spec.copy_header_mapping(from) def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename Pathname.new('ns') + from.basename
end end
@spec.build_header_storage.search_paths.should == %w{ @spec.build_headers.search_paths.should == %w{
"$(PODS_ROOT)/Headers/SSZipArchive" "$(PODS_ROOT)/Headers/SSZipArchive"
"$(PODS_ROOT)/Headers/SSZipArchive/ns" "$(PODS_ROOT)/Headers/SSZipArchive/ns"
} }
...@@ -158,7 +158,7 @@ describe "A Pod::LocalPod, with installed source," do ...@@ -158,7 +158,7 @@ describe "A Pod::LocalPod, with installed source," do
def @spec.copy_header_mapping(from) def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename Pathname.new('ns') + from.basename
end end
@spec.build_header_storage.search_paths.should == %w{ @spec.build_headers.search_paths.should == %w{
"$(PODS_ROOT)/Headers/AnotherRoot" "$(PODS_ROOT)/Headers/AnotherRoot"
"$(PODS_ROOT)/Headers/AnotherRoot/ns" "$(PODS_ROOT)/Headers/AnotherRoot/ns"
} }
......
...@@ -24,7 +24,7 @@ describe Pod::Sandbox do ...@@ -24,7 +24,7 @@ describe Pod::Sandbox do
end end
it "returns it's headers root" do it "returns it's headers root" do
@sandbox.build_header_storage.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers")) @sandbox.build_headers.root.should == Pathname.new(File.join(TMP_POD_ROOT, "Headers"))
end end
it "can add namespaced headers to it's header path using symlinks and return the relative path" do it "can add namespaced headers to it's header path using symlinks and return the relative path" do
...@@ -32,7 +32,7 @@ describe Pod::Sandbox do ...@@ -32,7 +32,7 @@ describe Pod::Sandbox do
namespace_path = Pathname.new("ExampleLib") namespace_path = Pathname.new("ExampleLib")
relative_header_path = Pathname.new("ExampleLib/Headers/MyHeader.h") relative_header_path = Pathname.new("ExampleLib/Headers/MyHeader.h")
File.open(@sandbox.root + relative_header_path, "w") { |file| file.write('hello') } File.open(@sandbox.root + relative_header_path, "w") { |file| file.write('hello') }
symlink_path = @sandbox.build_header_storage.add_file(namespace_path, relative_header_path) symlink_path = @sandbox.build_headers.add_file(namespace_path, relative_header_path)
symlink_path.should.be.symlink symlink_path.should.be.symlink
File.read(symlink_path).should == 'hello' File.read(symlink_path).should == 'hello'
end end
...@@ -47,7 +47,7 @@ describe Pod::Sandbox do ...@@ -47,7 +47,7 @@ describe Pod::Sandbox do
relative_header_paths.each do |path| relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') } File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end end
symlink_paths = @sandbox.build_header_storage.add_files(namespace_path, relative_header_paths) symlink_paths = @sandbox.build_headers.add_files(namespace_path, relative_header_paths)
symlink_paths.each do |path| symlink_paths.each do |path|
path.should.be.symlink path.should.be.symlink
File.read(path).should == "hello" File.read(path).should == "hello"
...@@ -64,7 +64,7 @@ describe Pod::Sandbox do ...@@ -64,7 +64,7 @@ describe Pod::Sandbox do
relative_header_paths.each do |path| relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') } File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end end
@sandbox.build_header_storage.add_files(namespace_path, relative_header_paths) @sandbox.build_headers.add_files(namespace_path, relative_header_paths)
@sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib") @sandbox.header_search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib")
end end
...@@ -74,6 +74,6 @@ describe Pod::Sandbox do ...@@ -74,6 +74,6 @@ describe Pod::Sandbox do
it 'clears out its headers root when preparing for install' do it 'clears out its headers root when preparing for install' do
@sandbox.prepare_for_install @sandbox.prepare_for_install
@sandbox.build_header_storage.root.should.not.exist @sandbox.build_headers.root.should.not.exist
end end
end end
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