Skip to content

Commit

Permalink
Add support for xcfilelist in script_phase DSL.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkoutso committed Mar 6, 2019
1 parent c68211e commit ea0932a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

##### Enhancements

* None.
* Add support for `xcfilelist` in `script_phase` DSL.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#517](https://github.com/CocoaPods/Core/pull/517)

##### Bug Fixes

Expand Down
20 changes: 14 additions & 6 deletions lib/cocoapods-core/podfile/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,21 @@ def target(name, options = nil)
# @option options [String] :shell_path
# the shell path to use for this script phase, for example `/usr/bin/ruby` to use Ruby for this phase.
#
# @option options [Array<String>] :input_paths
# the input paths to use for script. This is used by Xcode to determine whether to re-execute this
# script phase if the input paths have changed or not.
# @option options [Array<String>] :input_files
# the input paths to use for this script phase. This is used by Xcode to determine whether to re-execute
# this script phase if the input paths have changed or not.
#
# @option options [Array<String>] :output_paths
# the output paths to use for script. This is used by Xcode to avoid re-executing this script phase if
# none of the output paths have changed.
# @option options [Array<String>] :output_files
# the output paths to use for this script phase. This is used by Xcode to avoid re-executing this script
# phase if none of the output paths have changed.
#
# @option options [Array<String>] :input_file_lists
# the input file lists to use for this script phase. This is used by Xcode to determine whether to
# re-execute this script phase if the input paths have changed or not.
#
# @option options [Array<String>] :output_file_lists
# the output file lists to use for this script phase. This is used by Xcode to avoid re-executing this
# script phase if none of the output paths have changed.
#
# @option options [Boolean] :show_env_vars_in_log
# whether this script phase should output the environment variables during execution.
Expand Down
15 changes: 14 additions & 1 deletion lib/cocoapods-core/specification/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,8 @@ def dependency=(args)

SCRIPT_PHASE_REQUIRED_KEYS = [:name, :script].freeze

SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :show_env_vars_in_log, :execution_position].freeze
SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :input_file_lists, :output_file_lists,
:show_env_vars_in_log, :execution_position].freeze

EXECUTION_POSITION_KEYS = [:before_compile, :after_compile, :any].freeze

Expand Down Expand Up @@ -1022,6 +1023,18 @@ def dependency=(args)
#
# @example
#
# spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"',
# :input_files => ['/path/to/input_file.txt'], :output_files => ['/path/to/output_file.txt']
# }
#
# @example
#
# spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"',
# :input_file_lists => ['/path/to/input_files.xcfilelist'], :output_files => ['/path/to/output_files.xcfilelist']
# }
#
# @example
#
# spec.script_phases = [
# { :name => 'Hello World', :script => 'echo "Hello World"' },
# { :name => 'Hello Ruby World', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby' },
Expand Down
3 changes: 2 additions & 1 deletion spec/podfile/target_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ module Pod
it 'raises if script phase includes an unrecognized key' do
e = lambda { @parent.store_script_phase(:name => 'PhaseName', :unknown => 'Unknown') }.should.raise Podfile::StandardError
e.message.should == 'Unrecognized options `[:unknown]` in shell script `PhaseName` within `MyApp` target. ' \
'Available options are `[:name, :script, :shell_path, :input_files, :output_files, :show_env_vars_in_log, :execution_position]`.'
'Available options are `[:name, :script, :shell_path, :input_files, :output_files, :input_file_lists, ' \
':output_file_lists, :show_env_vars_in_log, :execution_position]`.'
end

it 'raises if script phase includes an invalid execution position key' do
Expand Down
5 changes: 3 additions & 2 deletions spec/specification/linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,11 @@ def result_should_include(*values)
result_should_include('script_phases', 'Missing required shell script phase options `script` in script phase `Hello World`.')
end

it 'checks script phases include the required keys' do
it 'checks script phases that include unknown keys' do
@spec.script_phases = { :name => 'Hello World', :script => 'echo "Hello World"', :unknown => 'unknown' }
result_should_include('script_phases', 'Unrecognized option(s) `unknown` in script phase `Hello World`. ' \
'Available options are `name, script, shell_path, input_files, output_files, show_env_vars_in_log, execution_position`.')
'Available options are `name, script, shell_path, input_files, output_files, input_file_lists, ' \
'output_file_lists, show_env_vars_in_log, execution_position`.')
end

it 'checks script phases include a valid execution position value' do
Expand Down

0 comments on commit ea0932a

Please sign in to comment.