Commit 3b752904 authored by Fabio Pelosin's avatar Fabio Pelosin

[Specification] add support for library_files

parent 05d0f7de
...@@ -57,6 +57,9 @@ module Pod ...@@ -57,6 +57,9 @@ module Pod
file_accessor.framework_bundles.each do |framework_bundle| file_accessor.framework_bundles.each do |framework_bundle|
XCConfigHelper.add_framework_build_settings(framework_bundle, @xcconfig, target.sandbox.root) XCConfigHelper.add_framework_build_settings(framework_bundle, @xcconfig, target.sandbox.root)
end end
file_accessor.library_files.each do |library_file|
XCConfigHelper.add_library_build_settings(library_file, @xcconfig, target.sandbox.root)
end
end end
end end
......
...@@ -47,6 +47,9 @@ module Pod ...@@ -47,6 +47,9 @@ module Pod
file_accessor.framework_bundles.each do |framework_bundle| file_accessor.framework_bundles.each do |framework_bundle|
XCConfigHelper.add_framework_build_settings(framework_bundle, @xcconfig, target.sandbox.root) XCConfigHelper.add_framework_build_settings(framework_bundle, @xcconfig, target.sandbox.root)
end end
file_accessor.library_files.each do |library_file|
XCConfigHelper.add_library_build_settings(library_file, @xcconfig, target.sandbox.root)
end
end end
@xcconfig @xcconfig
end end
......
...@@ -68,6 +68,25 @@ module Pod ...@@ -68,6 +68,25 @@ module Pod
xcconfig.merge!(build_settings) xcconfig.merge!(build_settings)
end end
# Configures the given Xcconfig with the the build settings for the given
# framework path.
#
# @param [Pathanme] framework_path
# The path of the framework.
#
# @param [Xcodeproj::Config] xcconfig
# The xcconfig to edit.
#
def self.add_library_build_settings(library_path, xcconfig, sandbox_root)
name = File.basename(library_path, ".a").sub(/\Alib/, '')
dirname = File.dirname(library_path).sub(sandbox_root.to_s, '$(PODS_ROOT)')
build_settings = {
'OTHER_LDFLAGS' => "-l#{name}",
'LIBRARY_SEARCH_PATHS' => quote([dirname])
}
xcconfig.merge!(build_settings)
end
# @return [Array<String>] The search paths for the developer frameworks. # @return [Array<String>] The search paths for the developer frameworks.
# #
DEVELOPER_FRAMEWORKS_SEARCH_PATHS = [ DEVELOPER_FRAMEWORKS_SEARCH_PATHS = [
......
...@@ -83,14 +83,16 @@ module Pod ...@@ -83,14 +83,16 @@ module Pod
# #
def add_frameworks_bundles def add_frameworks_bundles
UI.message "- Adding frameworks to Pods project" do UI.message "- Adding frameworks to Pods project" do
add_file_acessors_paths_to_pods_group(:framework_bundles, :frameworks) add_file_acessors_paths_to_pods_group(:framework_bundles, :frameworks_and_libraries)
end end
end end
# TODO # TODO
# #
def add_library_files def add_library_files
UI.message "- Adding frameworks to Pods project" do
add_file_acessors_paths_to_pods_group(:library_files, :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.
......
...@@ -230,6 +230,7 @@ module Pod ...@@ -230,6 +230,7 @@ module Pod
def used_files def used_files
files = [ files = [
file_accessors.map(&:framework_bundles), file_accessors.map(&:framework_bundles),
file_accessors.map(&:library_files),
file_accessors.map(&:license), file_accessors.map(&:license),
file_accessors.map(&:prefix_header), file_accessors.map(&:prefix_header),
file_accessors.map(&:preserve_paths), file_accessors.map(&:preserve_paths),
......
...@@ -122,7 +122,7 @@ module Pod ...@@ -122,7 +122,7 @@ module Pod
case type case type
when :source_files then sub_group = 'Source Files' when :source_files then sub_group = 'Source Files'
when :resources then sub_group = 'Resources' when :resources then sub_group = 'Resources'
when :frameworks then sub_group = 'Frameworks' when :frameworks_and_libraries then sub_group = 'Frameworks & Libraries'
when :support_files then sub_group = 'Support Files' when :support_files then sub_group = 'Support Files'
else raise "[BUG]" else raise "[BUG]"
end end
......
...@@ -21,11 +21,15 @@ module Pod ...@@ -21,11 +21,15 @@ module Pod
# #
attr_reader :spec_consumer attr_reader :spec_consumer
# @param [Sandbox::PathList] path_list @see path_list # @param [Sandbox::PathList, Pathname] path_list @see path_list
# @param [Specification::Consumer] spec_consumer @see spec_consumer # @param [Specification::Consumer] spec_consumer @see spec_consumer
# #
def initialize(path_list, spec_consumer) def initialize(path_list, spec_consumer)
if path_list.is_a?(PathList)
@path_list = path_list @path_list = path_list
else
@path_list = PathList.new(path_list)
end
@spec_consumer = spec_consumer @spec_consumer = spec_consumer
unless @spec_consumer unless @spec_consumer
...@@ -106,7 +110,14 @@ module Pod ...@@ -106,7 +110,14 @@ module Pod
# shipped with the Pod. # shipped with the Pod.
# #
def framework_bundles def framework_bundles
expanded_paths(spec_consumer.framework_bundles, :include_dirs => true) paths_for_attribute(:framework_bundles, true)
end
# @return [Array<Pathname>] The paths of the framework bundles that come
# shipped with the Pod.
#
def library_files
paths_for_attribute(:library_files)
end end
# @return [Pathname] The of the prefix header file of the specification. # @return [Pathname] The of the prefix header file of the specification.
......
...@@ -17,9 +17,9 @@ module Pod ...@@ -17,9 +17,9 @@ module Pod
@spec.frameworks = ['QuartzCore'] @spec.frameworks = ['QuartzCore']
@spec.weak_frameworks = ['iAd'] @spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2'] @spec.libraries = ['xml2']
file_accessors = [Sandbox::FileAccessor.new(nil, @spec.consumer(:ios))] file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @spec.consumer(:ios))]
framework_bundle_paths = [config.sandbox.root + 'BananaLib/BananaLib.framework'] # framework_bundle_paths = [config.sandbox.root + 'BananaLib/BananaLib.framework']
Sandbox::FileAccessor.any_instance.stubs(:framework_bundles).returns(framework_bundle_paths) # Sandbox::FileAccessor.any_instance.stubs(:framework_bundles).returns(framework_bundle_paths)
@pod_target.target_definition.stubs(:podfile).returns(@podfile) @pod_target.target_definition.stubs(:podfile).returns(@podfile)
@pod_target.stubs(:file_accessors).returns(file_accessors) @pod_target.stubs(:file_accessors).returns(file_accessors)
...@@ -51,26 +51,29 @@ module Pod ...@@ -51,26 +51,29 @@ module Pod
@spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' } @spec.xcconfig = { 'OTHER_LDFLAGS' => '-no_compact_unwind' }
@spec.frameworks = ['SenTestingKit'] @spec.frameworks = ['SenTestingKit']
xcconfig = @generator.generate xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks" "$(PODS_ROOT)/BananaLib"' framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS']
framework_search_paths.should.include('$(SDKROOT)/Developer')
end end
it "doesn't include the developer frameworks if already present" do it "doesn't include the developer frameworks if already present" do
spec = fixture_spec('banana-lib/BananaLib.podspec') @spec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"' }
pod_target = PodTarget.new([@spec, spec], @target_definition, config.sandbox) @spec.frameworks = ['SenTestingKit']
pod_target.stubs(:platform).returns(:ios) xcconfig = @generator.generate
generator = PublicPodXCConfig.new(pod_target) framework_search_paths = xcconfig.to_hash['FRAMEWORK_SEARCH_PATHS'].split(' ')
spec.frameworks = ['SenTestingKit'] framework_search_paths.select { |path| path == '"$(SDKROOT)/Developer/Library/Frameworks"'}.count.should == 1
file_accessors = [Sandbox::FileAccessor.new(nil, spec.consumer(:ios))] framework_search_paths.select { |path| path == '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"'}.count.should == 1
pod_target.stubs(:file_accessors).returns(file_accessors)
xcconfig = generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should == '$(inherited) "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks" "$(PODS_ROOT)/BananaLib"'
end end
it "includes the build settings of the frameworks bundles of the spec" do it "includes the build settings of the frameworks bundles of the spec" do
@spec.framework_bundles = ['BananaLib.framework'] config.sandbox.stubs(:root).returns(fixture(''))
xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"')
end
it "includes the build settings of the libraries shipped with the spec" do
config.sandbox.stubs(:root).returns(fixture(''))
xcconfig = @generator.generate xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/BananaLib"') xcconfig.to_hash["LIBRARY_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"')
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -134,6 +134,19 @@ module Pod ...@@ -134,6 +134,19 @@ module Pod
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
describe "::add_library_build_settings" do
it "adds the build settings of a framework to the given xcconfig" do
path = config.sandbox.root + 'MapBox/Proj4/libProj4.a'
xcconfig = Xcodeproj::Config.new
@sut.add_library_build_settings(path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == "-lProj4"
hash_config['LIBRARY_SEARCH_PATHS'].should == '"$(PODS_ROOT)/MapBox/Proj4"'
end
end
#---------------------------------------------------------------------#
describe "::add_framework_build_settings" do describe "::add_framework_build_settings" do
it "adds the developer frameworks search paths to the xcconfig if SenTestingKit has been detected" do it "adds the developer frameworks search paths to the xcconfig if SenTestingKit has been detected" do
xcconfig = Xcodeproj::Config.new({'OTHER_LDFLAGS' => '-framework SenTestingKit'}) xcconfig = Xcodeproj::Config.new({'OTHER_LDFLAGS' => '-framework SenTestingKit'})
......
...@@ -35,6 +35,12 @@ module Pod ...@@ -35,6 +35,12 @@ module Pod
file_ref.should.be.not.nil file_ref.should.be.not.nil
end end
xit "adds the file references of the frameworks of the projet" do
end
xit "adds the file references of the libraries of the project"
it "adds the files references of the resources the Pods project" do it "adds the files references of the resources the Pods project" do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Resources/logo-sidebar.png'] file_ref = @installer.pods_project['Pods/BananaLib/Resources/logo-sidebar.png']
......
...@@ -171,6 +171,7 @@ module Pod ...@@ -171,6 +171,7 @@ module Pod
it "compacts the used files as nil would be converted to the empty string" do it "compacts the used files as nil would be converted to the empty string" do
Sandbox::FileAccessor.any_instance.stubs(:source_files) Sandbox::FileAccessor.any_instance.stubs(:source_files)
Sandbox::FileAccessor.any_instance.stubs(:library_files)
Sandbox::FileAccessor.any_instance.stubs(:resources).returns(nil) Sandbox::FileAccessor.any_instance.stubs(:resources).returns(nil)
Sandbox::FileAccessor.any_instance.stubs(:preserve_paths) Sandbox::FileAccessor.any_instance.stubs(:preserve_paths)
Sandbox::FileAccessor.any_instance.stubs(:prefix_header) Sandbox::FileAccessor.any_instance.stubs(:prefix_header)
......
...@@ -107,6 +107,10 @@ module Pod ...@@ -107,6 +107,10 @@ module Pod
@accessor.framework_bundles.should.include?(@root + "Bananalib.framework") @accessor.framework_bundles.should.include?(@root + "Bananalib.framework")
end end
it "returns the paths of the library files" do
@accessor.library_files.should.include?(@root + "libBananalib.a")
end
it "returns the prefix header of the specification" do it "returns the prefix header of the specification" do
@accessor.prefix_header.should == @root + 'Classes/BananaLib.pch' @accessor.prefix_header.should == @root + 'Classes/BananaLib.pch'
end end
......
...@@ -23,6 +23,7 @@ module Pod ...@@ -23,6 +23,7 @@ module Pod
README README
Resources/logo-sidebar.png Resources/logo-sidebar.png
Resources/sub_dir/logo-sidebar.png Resources/sub_dir/logo-sidebar.png
libBananalib.a
preserve_me.txt preserve_me.txt
sub-dir/sub-dir-2/somefile.txt sub-dir/sub-dir-2/somefile.txt
] ]
......
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