lib/xcjobs/xcodebuild.rb in xcjobs-0.2.5 vs lib/xcjobs/xcodebuild.rb in xcjobs-0.3.0

- old
+ new

@@ -24,16 +24,19 @@ attr_reader :destinations attr_reader :provisioning_profile_name attr_reader :provisioning_profile_uuid + attr_accessor :unsetenv_others + def initialize(name) $stdout.sync = $stderr.sync = true @name = name @destinations = [] @build_settings = {} + @unsetenv_others = false end def project if @project File.extname(@project).empty? ? "#{@project}.xcodeproj" : @project @@ -80,12 +83,15 @@ puts (cmd + ['|', @formatter]).join(" ") else puts cmd.join(" ") end + env = {} + options = { unsetenv_others: unsetenv_others } + if @formatter - Open3.pipeline_r(cmd, [@formatter]) do |stdout, wait_thrs| + Open3.pipeline_r([env] + cmd + [options], [@formatter]) do |stdout, wait_thrs| output = [] while line = stdout.gets puts line output << line end @@ -96,11 +102,11 @@ else fail "xcodebuild failed (exited with status: #{status.exitstatus})" end end else - Open3.popen2e(*cmd) do |stdin, stdout_err, wait_thr| + Open3.popen2e(env, *cmd, options) do |stdin, stdout_err, wait_thr| output = [] while line = stdout_err.gets puts line output << line end @@ -205,11 +211,11 @@ targetSettings = settings.select { |key, _| settings[key]['PRODUCT_TYPE'] != 'com.apple.product-type.bundle.unit-test' } targetSettings.each do |target, settings| if settings['PRODUCT_TYPE'] == 'com.apple.product-type.framework' if sdk.start_with?('iphone') && settings['ONLY_ACTIVE_ARCH'] == 'NO' - target_dir = settings['OBJECT_FILE_DIR_normal'].gsub('Build/Intermediates', "Build/Intermediates/CodeCoverage/#{target}/Intermediates") + target_dir = settings['OBJECT_FILE_DIR_normal'].gsub('Build/Intermediates', "Build/Intermediates/CodeCoverage/Intermediates") executable_name = settings['EXECUTABLE_NAME'] target_path = File.join(File.join(target_dir, settings['CURRENT_ARCH']), executable_name) else target_dir = settings['CODESIGNING_FOLDER_PATH'].gsub('Build/Products', "Build/Intermediates/CodeCoverage/#{target}/Products") executable_name = settings['EXECUTABLE_NAME'] @@ -217,11 +223,11 @@ end else end - code_coverage_dir = settings['BUILD_DIR'].gsub('Build/Products', "Build/Intermediates/CodeCoverage/#{target}/") + code_coverage_dir = settings['BUILD_DIR'].gsub('Build/Products', "/Build/Intermediates/CodeCoverage/") profdata_path = File.join(code_coverage_dir, 'Coverage.profdata') show_coverage(profdata_path, target_path) generate_gcov_file(profdata_path, target_path) end @@ -349,23 +355,26 @@ attr_accessor :export_path attr_accessor :export_provisioning_profile attr_accessor :export_signing_identity attr_accessor :export_installer_identity attr_accessor :export_with_original_signing_identity + attr_accessor :options_plist def initialize(name = :export) super + self.unsetenv_others = true + @export_format = 'IPA' yield self if block_given? define end def archive_path @archive_path || (build_dir && scheme ? File.join(build_dir, scheme) : nil) end def export_format - @export_format || 'IPA' + @export_format end def export_provisioning_profile=(provisioning_profile) provisioning_profile_path, provisioning_profile_uuid, provisioning_profile_name = XCJobs::Helper.extract_provisioning_profile(provisioning_profile) if provisioning_profile_name @@ -386,9 +395,10 @@ end end def options [].tap do |opts| + opts.concat(['-exportOptionsPlist', options_plist]) if options_plist opts.concat(['-archivePath', archive_path]) if archive_path opts.concat(['-exportFormat', export_format]) if export_format opts.concat(['-exportPath', export_path]) if export_path opts.concat(['-exportProvisioningProfile', export_provisioning_profile]) if export_provisioning_profile opts.concat(['-exportSigningIdentity', export_signing_identity]) if export_signing_identity