Commit a6564cd0 authored by Marius Rackwitz's avatar Marius Rackwitz

[Linter] Add new option `--use-frameworks`

This let lint use frameworks to install the given spec.
parent 8e697ee2
...@@ -113,6 +113,7 @@ module Pod ...@@ -113,6 +113,7 @@ module Pod
['--subspec=NAME', 'Lint validates only the given subspec'], ['--subspec=NAME', 'Lint validates only the given subspec'],
['--no-subspecs', 'Lint skips validation of subspecs'], ['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection'], ['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--use-frameworks', 'Lint uses frameworks to install the spec'],
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \ ['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\ '(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super) 'Multiple sources must be comma-delimited.']].concat(super)
...@@ -124,6 +125,7 @@ module Pod ...@@ -124,6 +125,7 @@ module Pod
@clean = argv.flag?('clean', true) @clean = argv.flag?('clean', true)
@subspecs = argv.flag?('subspecs', true) @subspecs = argv.flag?('subspecs', true)
@only_subspec = argv.option('subspec') @only_subspec = argv.option('subspec')
@use_frameworks = argv.flag?('use-frameworks')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',') @source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments! @podspecs_paths = argv.arguments!
super super
...@@ -144,6 +146,7 @@ module Pod ...@@ -144,6 +146,7 @@ module Pod
validator.allow_warnings = @allow_warnings validator.allow_warnings = @allow_warnings
validator.no_subspecs = !@subspecs || @only_subspec validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec validator.only_subspec = @only_subspec
validator.use_frameworks = @use_frameworks
validator.validate validator.validate
unless @clean unless @clean
......
...@@ -68,6 +68,7 @@ module Pod ...@@ -68,6 +68,7 @@ module Pod
['--subspec=NAME', 'Lint validates only the given subspec'], ['--subspec=NAME', 'Lint validates only the given subspec'],
['--no-subspecs', 'Lint skips validation of subspecs'], ['--no-subspecs', 'Lint skips validation of subspecs'],
['--no-clean', 'Lint leaves the build directory intact for inspection'], ['--no-clean', 'Lint leaves the build directory intact for inspection'],
['--use-frameworks', 'Lint uses frameworks to install the spec'],
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \ ['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
'(defaults to https://github.com/CocoaPods/Specs.git). '\ '(defaults to https://github.com/CocoaPods/Specs.git). '\
'Multiple sources must be comma-delimited.']].concat(super) 'Multiple sources must be comma-delimited.']].concat(super)
...@@ -79,6 +80,7 @@ module Pod ...@@ -79,6 +80,7 @@ module Pod
@clean = argv.flag?('clean', true) @clean = argv.flag?('clean', true)
@subspecs = argv.flag?('subspecs', true) @subspecs = argv.flag?('subspecs', true)
@only_subspec = argv.option('subspec') @only_subspec = argv.option('subspec')
@use_frameworks = argv.flag?('use-frameworks')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',') @source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@podspecs_paths = argv.arguments! @podspecs_paths = argv.arguments!
super super
...@@ -94,6 +96,7 @@ module Pod ...@@ -94,6 +96,7 @@ module Pod
validator.allow_warnings = @allow_warnings validator.allow_warnings = @allow_warnings
validator.no_subspecs = !@subspecs || @only_subspec validator.no_subspecs = !@subspecs || @only_subspec
validator.only_subspec = @only_subspec validator.only_subspec = @only_subspec
validator.use_frameworks = @use_frameworks
validator.validate validator.validate
invalid_count += 1 unless validator.validated? invalid_count += 1 unless validator.validated?
......
...@@ -143,6 +143,10 @@ module Pod ...@@ -143,6 +143,10 @@ module Pod
# #
attr_accessor :no_subspecs attr_accessor :no_subspecs
# @return [Bool] Whether frameworks should be used for the installation.
#
attr_accessor :use_frameworks
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# !@group Lint results # !@group Lint results
...@@ -299,7 +303,7 @@ module Pod ...@@ -299,7 +303,7 @@ module Pod
# #
def install_pod def install_pod
deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name) deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name)
podfile = podfile_from_spec(consumer.platform_name, deployment_target) podfile = podfile_from_spec(consumer.platform_name, deployment_target, use_frameworks)
sandbox = Sandbox.new(config.sandbox_root) sandbox = Sandbox.new(config.sandbox_root)
installer = Installer.new(sandbox, podfile) installer = Installer.new(sandbox, podfile)
installer.install! installer.install!
...@@ -457,19 +461,23 @@ module Pod ...@@ -457,19 +461,23 @@ module Pod
# the deployment target, which should be declared in # the deployment target, which should be declared in
# the Podfile. # the Podfile.
# #
# @param [Bool] use_frameworks
# whether frameworks should be used for the installation
#
# @return [Podfile] a podfile that requires the specification on the # @return [Podfile] a podfile that requires the specification on the
# current platform. # current platform.
# #
# @note The generated podfile takes into account whether the linter is # @note The generated podfile takes into account whether the linter is
# in local mode. # in local mode.
# #
def podfile_from_spec(platform_name, deployment_target) def podfile_from_spec(platform_name, deployment_target, use_frameworks = nil)
name = subspec_name ? subspec_name : spec.name name = subspec_name ? subspec_name : spec.name
podspec = file.realpath podspec = file.realpath
local = local? local = local?
urls = source_urls urls = source_urls
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
urls.each { |u| source(u) } urls.each { |u| source(u) }
use_frameworks!(use_frameworks) unless use_frameworks.nil?
platform(platform_name, deployment_target) platform(platform_name, deployment_target)
if local if local
pod name, :path => podspec.dirname.to_s pod name, :path => podspec.dirname.to_s
......
...@@ -295,9 +295,9 @@ module Pod ...@@ -295,9 +295,9 @@ module Pod
s.ios.deployment_target = '7.0' s.ios.deployment_target = '7.0'
end end
validator.spec.stubs(:subspecs).returns([subspec]) validator.spec.stubs(:subspecs).returns([subspec])
validator.expects(:podfile_from_spec).with(:osx, nil).once validator.expects(:podfile_from_spec).with(:osx, nil, nil).once
validator.expects(:podfile_from_spec).with(:ios, nil).once validator.expects(:podfile_from_spec).with(:ios, nil, nil).once
validator.expects(:podfile_from_spec).with(:ios, '7.0').once validator.expects(:podfile_from_spec).with(:ios, '7.0', nil).once
podfile = validator.send(:perform_extensive_analysis, validator.spec) podfile = validator.send(:perform_extensive_analysis, validator.spec)
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