Module: ZergXcode::Builder::Runner

Defined in:
lib/zerg_xcode/builder/runner.rb

Overview

Runs the Xcode build process.

Class Method Summary collapse

Class Method Details

.action(project, sdk, configuration, options, verb) ⇒ Object

Executes an action using the Xcode builder.

Returns true if the action suceeded, and false otherwise.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/zerg_xcode/builder/runner.rb', line 36

def self.action(project, sdk, configuration, options, verb)
  # NOTE: not using -parallelizeTargets so the command line is less brittle,
  #       and to accomodate projects with bad dependencies
  command = 'xcodebuild -project ' +
      File.dirname(project.source_filename).inspect +
      %Q| -sdk #{sdk[:arg]} -configuration #{configuration.inspect} | +
      '-alltargets ' + options.map { "#{k}=#{v}".inspect }.join(' ') + ' ' +
      verb.inspect + ' 2>&1'
  begin
    output = Kernel.`(command)
    return (/\*\* .* SUCCEEDED \*\*/ =~ output) ? true : false
  end
end

.build(project, sdk, configuration, options = {}) ⇒ Object

Builds an Xcode project.

Returns the directory containing the build products, or nil if the build failed.



19
20
21
22
# File 'lib/zerg_xcode/builder/runner.rb', line 19

def self.build(project, sdk, configuration, options = {})
  return nil unless action(project, sdk, configuration, options, 'build')
  Dir.glob(File.join(project.root_path, 'build', configuration + '-*')).first
end

.clean(project, sdk, configuration, options = {}) ⇒ Object

Removes the build products for an Xcode project.

Returns true for success, or false if the removal failed.



27
28
29
30
31
# File 'lib/zerg_xcode/builder/runner.rb', line 27

def self.clean(project, sdk, configuration, options = {})
  return_value = action(project, sdk, configuration, options, 'clean')
  FileUtils.rm_rf File.join(project.root_path, 'build')
  return_value
end