Class: Rake::Leaves::XcodeTask

Inherits:
TaskLib
  • Object
show all
Defined in:
lib/leaves/xcode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TaskLib

#upaste

Constructor Details

#initialize(name = '') {|_self| ... } ⇒ XcodeTask

Returns a new instance of XcodeTask.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/leaves/xcode.rb', line 17

def initialize(name = '')
  @name = (name.to_s.empty? ? nil : name)
  
  project = nil
  if RUBY_PLATFORM.match(/darwin7/)
    project = FileList.new('*.xcode').to_a.first
  else
    project = FileList.new('*.xcodeproj').to_a.first
  end
  
  @project = project if project
  @config = name.to_s.camelize
  
  yield self if block_given?
  define
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



15
16
17
# File 'lib/leaves/xcode.rb', line 15

def config
  @config
end

#projectObject

Returns the value of attribute project.



14
15
16
# File 'lib/leaves/xcode.rb', line 14

def project
  @project
end

Instance Method Details

#defineObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/leaves/xcode.rb', line 34

def define
  if @name
    
    desc "Build using Xcode."
    task paste("build_", @name) => [paste("compile_", @name)]
    
    task paste("compile_", @name) do
      cmd = "xcodebuild"
      cmd << " -project \"#{@project}\"" if @project
      if RUBY_PLATFORM.match(/darwin7/)
        cmd << " -buildstyle \"#{@config}\"" if @config
      else
        cmd << " -configuration \"#{@config}\"" if @config
      end
      sh cmd
    end
    
    task paste("clean_", @name) do
      cmd = "xcodebuild"
      cmd << " -project \"#{@project}\"" if @project
      if RUBY_PLATFORM.match(/darwin7/)
        cmd << " -buildstyle \"#{@config}\"" if @config
      else
        cmd << " -configuration \"#{@config}\"" if @config
      end
      cmd << " clean"
      sh cmd
    end
  
  else
  
    proj = XcodeIDE::Project.new(@project)
    proj.configurations.each do |cfg|
      name = cfg.underscore
      config = cfg.dup
      
      desc "Build using Xcode."
      task paste("build_", name) => [paste("compile_", name)]
      
      task paste("compile_", name) do
        cmd = "xcodebuild"
        cmd << " -project \"#{@project}\""
        if RUBY_PLATFORM.match(/darwin7/)
          cmd << " -buildstyle \"#{config}\""
        else
          cmd << " -configuration \"#{config}\""
        end
        sh cmd
      end
      
      task paste("clean_", name) do
        cmd = "xcodebuild"
        cmd << " -project \"#{@project}\""
        if RUBY_PLATFORM.match(/darwin7/)
          cmd << " -buildstyle \"#{config}\""
        else
          cmd << " -configuration \"#{config}\""
        end
        cmd << " clean"
        sh cmd
      end
    end
  
  end
  
  self
end