Skip to content

Commit

Permalink
add shell script input/output paths (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-makarov authored Jan 13, 2019
1 parent 00660cc commit e5af9b6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/xcake/dsl/build_phase/shell_script_build_phase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ class ShellScriptBuildPhase < BuildPhase
# String coataining the contents of the script to run
attr_accessor :script

# input/output paths
attr_accessor :input_paths
attr_accessor :output_paths
attr_accessor :input_file_list_paths
attr_accessor :output_file_list_paths

def build_phase_type
Xcodeproj::Project::Object::PBXShellScriptBuildPhase
end

def configure_native_build_phase(native_build_phase, _context)
native_build_phase.name = name
native_build_phase.shell_script = script.strip_heredoc
native_build_phase.input_paths = input_paths || []
native_build_phase.output_paths = output_paths || []
native_build_phase.input_file_list_paths = input_file_list_paths || []
native_build_phase.output_file_list_paths = output_file_list_paths || []
end

def to_s
Expand Down
33 changes: 33 additions & 0 deletions spec/dsl/build_phase/shell_script_build_phase_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ module Xcake

allow(@native_build_phase).to receive(:name=)
allow(@native_build_phase).to receive(:shell_script=)

@paths = %w(path1 path2 path3 path4 path5).shuffle

allow(@native_build_phase).to receive(:input_paths=)
allow(@native_build_phase).to receive(:output_paths=)
allow(@native_build_phase).to receive(:input_file_list_paths=)
allow(@native_build_phase).to receive(:output_file_list_paths=)
end

it 'should use correct build phase type' do
Expand All @@ -30,5 +37,31 @@ module Xcake
expect(@native_build_phase).to receive(:shell_script=).with(@script.strip_heredoc)
@phase.configure_native_build_phase(@native_build_phase, nil)
end

context 'Input/Ouput paths' do
it 'should set input paths' do
@phase.input_paths = @paths
expect(@native_build_phase).to receive(:input_paths=).with(@paths)
@phase.configure_native_build_phase(@native_build_phase, nil)
end

it 'should set output paths' do
@phase.output_paths = @paths
expect(@native_build_phase).to receive(:output_paths=).with(@paths)
@phase.configure_native_build_phase(@native_build_phase, nil)
end

it 'should set input file list paths' do
@phase.input_file_list_paths = @paths
expect(@native_build_phase).to receive(:input_file_list_paths=).with(@paths)
@phase.configure_native_build_phase(@native_build_phase, nil)
end

it 'should set output file list paths' do
@phase.output_file_list_paths = @paths
expect(@native_build_phase).to receive(:output_file_list_paths=).with(@paths)
@phase.configure_native_build_phase(@native_build_phase, nil)
end
end
end
end

0 comments on commit e5af9b6

Please sign in to comment.