Skip to content
This repository has been archived by the owner on Oct 2, 2018. It is now read-only.

Added support for -derivedDataPath and -resultBundlePath options. #172

Merged
merged 1 commit into from
Jan 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/gym/generators/build_command_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def options
options << "-destination '#{config[:destination]}'" if config[:destination]
options << "-xcconfig '#{config[:xcconfig]}'" if config[:xcconfig]
options << "-archivePath '#{archive_path}'"
options << "-derivedDataPath '#{config[:derived_data_path]}'" if config[:derived_data_path]
options << "-resultBundlePath '#{result_bundle_path}'" if config[:result_bundle]
options << config[:xcargs] if config[:xcargs]

options
Expand Down Expand Up @@ -99,6 +101,13 @@ def archive_path
end
return Gym.cache[:archive_path]
end

def result_bundle_path
unless Gym.cache[:result_bundle_path]
Gym.cache[:result_bundle_path] = File.join(Gym.config[:output_directory], Gym.config[:output_name]) + ".result"
end
return Gym.cache[:result_bundle_path]
end
end
end
end
11 changes: 11 additions & 0 deletions lib/gym/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ def self.plain_options
env_name: "GYM_ARCHIVE_PATH",
description: "The directory in which the archive file should be stored in",
optional: true),
FastlaneCore::ConfigItem.new(key: :derived_data_path,
short_option: "-f",
env_name: "GYM_DERIVED_DATA_PATH",
description: "The directory where build products and other derived data will go",
optional: true),
FastlaneCore::ConfigItem.new(key: :result_bundle,
short_option: "-u",
env_name: "GYM_RESULT_BUNDLE",
is_string: false,
description: "Produce the result bundle describing what occurred will be placed",
optional: true),
FastlaneCore::ConfigItem.new(key: :buildlog_path,
short_option: "-l",
env_name: "GYM_BUILDLOG_PATH",
Expand Down
50 changes: 48 additions & 2 deletions spec/build_command_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"-archivePath '#{Gym::BuildCommandGenerator.archive_path}'",
"DEBUG=1 BUNDLE_NAME=Example\\ App",
:archive,
"| tee '#{log_path}' | xcpretty"
"| tee #{log_path.shellescape} | xcpretty"
])
end

Expand All @@ -49,7 +49,7 @@
"-destination 'generic/platform=iOS'",
"-archivePath '#{Gym::BuildCommandGenerator.archive_path}'",
:archive,
"| tee '#{log_path}' | xcpretty"
"| tee #{log_path.shellescape} | xcpretty"
])
end

Expand Down Expand Up @@ -82,5 +82,51 @@
expect(result.to_s).to include("Library/Logs/gym")
end
end

describe "Derived Data Example" do
before do
options = { project: "./examples/standard/Example.xcodeproj", derived_data_path: "/tmp/my/derived_data" }
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)
end

it "uses the correct build command with the example project" do
log_path = File.expand_path("~/Library/Logs/gym/ExampleProductName-Example.log")

result = Gym::BuildCommandGenerator.generate
expect(result).to eq([
"set -o pipefail &&",
"xcodebuild",
"-scheme 'Example'",
"-project './examples/standard/Example.xcodeproj'",
"-destination 'generic/platform=iOS'",
"-archivePath '#{Gym::BuildCommandGenerator.archive_path}'",
"-derivedDataPath '/tmp/my/derived_data'",
:archive,
"| tee #{log_path.shellescape} | xcpretty"
])
end
end

describe "Result Bundle Example" do
it "uses the correct build command with the example project" do
log_path = File.expand_path("~/Library/Logs/gym/ExampleProductName-Example.log")

options = { project: "./examples/standard/Example.xcodeproj", result_bundle: true }
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)

result = Gym::BuildCommandGenerator.generate
expect(result).to eq([
"set -o pipefail &&",
"xcodebuild",
"-scheme 'Example'",
"-project './examples/standard/Example.xcodeproj'",
"-destination 'generic/platform=iOS'",
"-archivePath '#{Gym::BuildCommandGenerator.archive_path}'",
"-resultBundlePath './ExampleProductName.result'",
:archive,
"| tee #{log_path.shellescape} | xcpretty"
])
end
end
end
end