lib/xcjobs/xcodebuild.rb in xcjobs-0.4.3 vs lib/xcjobs/xcodebuild.rb in xcjobs-0.5.0

- old
+ new

@@ -8,10 +8,11 @@ module XCJobs class Xcodebuild < Rake::TaskLib include Rake::DSL if defined?(Rake::DSL) attr_accessor :name + attr_accessor :description attr_accessor :project attr_accessor :target attr_accessor :workspace attr_accessor :scheme attr_accessor :sdk @@ -144,10 +145,11 @@ end class Test < Xcodebuild def initialize(name = :test) super + @description = 'test application' yield self if block_given? define end def sdk @@ -207,29 +209,31 @@ end def coverage_report(options) settings = build_settings(options) + xcode_version = `xcodebuild -version`.split("\n").first.scan(/\d+/).join('.') + targetSettings = settings.select { |key, _| settings[key]['PRODUCT_TYPE'] != 'com.apple.product-type.bundle.unit-test' } targetSettings.each do |target, settings| + objroot = settings['OBJROOT'] + product_type = settings['PRODUCT_TYPE'] if product_type == 'com.apple.product-type.framework' || product_type == 'com.apple.product-type.application' if sdk.start_with?('iphone') && settings['ONLY_ACTIVE_ARCH'] == 'NO' - 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) + target_path = Dir.glob(File.join(objroot, '/**/' +executable_name)).first else - target_dir = (product_type == 'com.apple.product-type.application' ? settings['CONFIGURATION_BUILD_DIR'] : settings['CODESIGNING_FOLDER_PATH']).gsub('Build/Products', "Build/Intermediates/CodeCoverage/Products") executable_name = product_type == 'com.apple.product-type.application' ? settings['EXECUTABLE_PATH'] : settings['EXECUTABLE_NAME'] - target_path = File.join(target_dir, executable_name) + target_path = Dir.glob(File.join(objroot, '/**/' +executable_name)).select { |f| File.stat(f).file? }.first end elsif raise %[Product type (PRODUCT_TYPE) '#{product_type}' is unsupported.] end - code_coverage_dir = settings['BUILD_DIR'].gsub('Build/Products', "Build/Intermediates/CodeCoverage") - profdata_path = File.join(code_coverage_dir, 'Coverage.profdata') + puts target_path + profdata_path = Dir.glob(File.join(objroot, '/**/Coverage.profdata')).first show_coverage(profdata_path, target_path) generate_gcov_file(profdata_path, target_path) end end @@ -253,11 +257,11 @@ def define raise 'test action requires specifying a scheme' unless scheme raise 'cannot specify both a scheme and targets' if scheme && target - desc 'test application' + desc @description task @name do if sdk == 'iphonesimulator' add_build_setting('CODE_SIGN_IDENTITY', '""') add_build_setting('CODE_SIGNING_REQUIRED', 'NO') end @@ -274,10 +278,11 @@ end class Build < Xcodebuild def initialize(name = :build) super + @description = 'build application' yield self if block_given? define end private @@ -287,11 +292,11 @@ raise 'cannot specify both a scheme and targets' if scheme && target CLEAN.include(build_dir) if build_dir CLOBBER.include(build_dir) if build_dir - desc 'build application' + desc @description task @name do add_build_setting('CONFIGURATION_TEMP_DIR', File.join(build_dir, 'temp')) if build_dir add_build_setting('CODE_SIGN_IDENTITY', signing_identity) if signing_identity add_build_setting('PROVISIONING_PROFILE', provisioning_profile_uuid) if provisioning_profile_uuid @@ -303,10 +308,11 @@ class Archive < Xcodebuild attr_accessor :archive_path def initialize(name = :archive) super + @description = 'make xcarchive' yield self if block_given? define end private @@ -318,11 +324,11 @@ if build_dir CLEAN.include(build_dir) CLOBBER.include(build_dir) end - desc 'make xcarchive' + desc @description namespace :build do task @name do add_build_setting('CONFIGURATION_TEMP_DIR', File.join(build_dir, 'temp')) if build_dir add_build_setting('CODE_SIGN_IDENTITY', signing_identity) if signing_identity add_build_setting('PROVISIONING_PROFILE', provisioning_profile_uuid) if provisioning_profile_uuid @@ -361,10 +367,11 @@ attr_accessor :options_plist def initialize(name = :export) super self.unsetenv_others = true + @description = 'export from an archive' @export_format = 'IPA' yield self if block_given? define end @@ -386,10 +393,10 @@ end private def define - desc 'export from an archive' + desc @description namespace :build do task name do run(['xcodebuild', '-exportArchive'] + options) end end