diff --git a/lib/gym/generators/build_command_generator.rb b/lib/gym/generators/build_command_generator.rb index 94a8e77..c140555 100644 --- a/lib/gym/generators/build_command_generator.rb +++ b/lib/gym/generators/build_command_generator.rb @@ -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 @@ -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 diff --git a/lib/gym/options.rb b/lib/gym/options.rb index 32c8c31..1c6537a 100644 --- a/lib/gym/options.rb +++ b/lib/gym/options.rb @@ -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", diff --git a/spec/build_command_generator_spec.rb b/spec/build_command_generator_spec.rb index a10fff5..0012091 100644 --- a/spec/build_command_generator_spec.rb +++ b/spec/build_command_generator_spec.rb @@ -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 @@ -49,7 +49,7 @@ "-destination 'generic/platform=iOS'", "-archivePath '#{Gym::BuildCommandGenerator.archive_path}'", :archive, - "| tee '#{log_path}' | xcpretty" + "| tee #{log_path.shellescape} | xcpretty" ]) end @@ -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