Module: Ninja

Defined in:
lib/ninja.rb

Defined Under Namespace

Classes: Build, Explicitly, Implicitly, Rule, Target

Constant Summary collapse

DEFAULT_NINJA_FILENAME =
"build.ninja"

Class Method Summary collapse

Class Method Details

.__to_ninja_format(xs) ⇒ Object



109
110
111
# File 'lib/ninja.rb', line 109

def self.__to_ninja_format(xs)
  xs.map{ |x| x.to_ninja_format }.join "\n\n"
end

.Build(rule, target, explicit, implicit = nil) ⇒ Object



169
170
171
# File 'lib/ninja.rb', line 169

def self.Build(rule, target, explicit, implicit=nil)
  Ninja::Build.new(rule, target, explicit, implicit)
end

.create_ninja_file(ninjas) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/ninja.rb', line 123

def self.create_ninja_file(ninjas)
  namespace :ninja do
    desc("generate ninja file if ninja.rake is changed")
    file DEFAULT_NINJA_FILENAME => "ninja.rake" do 
      puts "--- REGENERATING THE NINJA FILE NOW ---"
      f = File.new(DEFAULT_NINJA_FILENAME, "w")
	txt = to_ninja_format(ninjas)
      f.write(txt)
      f.close
    end
  end
end

.create_UUIDObject



8
9
10
# File 'lib/ninja.rb', line 8

def self.create_UUID
  UUIDTools::UUID.random_create
end

.end_of_ninja(*ninjas) ⇒ Object



153
154
155
156
157
158
159
160
161
# File 'lib/ninja.rb', line 153

def self.end_of_ninja(*ninjas)
  create_ninja_file(ninjas.flatten)

  ninjas.each do |ninja|
    ninja.get_target_object.to_a.each do |target|
      make_ninja_task(target)
    end
  end
end

.Explicitly(*xs) ⇒ Object



177
178
179
# File 'lib/ninja.rb', line 177

def self.Explicitly(*xs)
  Ninja::Explicitly.new(xs)
end

.Implicitly(*xs) ⇒ Object



181
182
183
# File 'lib/ninja.rb', line 181

def self.Implicitly(*xs)
  Ninja::Implicitly.new(xs)
end

.make_ninja_task(target) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/ninja.rb', line 136

def self.make_ninja_task(target) 
  namespace :ninja do
    namespace :build do
      task target =>  DEFAULT_NINJA_FILENAME do 
        sh "ninja #{target}"
      end
      task :all => target
    end
    namespace :clean do
      task target => DEFAULT_NINJA_FILENAME do
        sh "ninja -t clean #{target}"
      end
      task :all => target
    end 
  end
end

.Rule(rule, depfile = "") ⇒ Object

Facade To Hide the implementation



165
166
167
# File 'lib/ninja.rb', line 165

def self.Rule(rule, depfile="") 
  Ninja::Rule.new(rule, depfile)
end

.rules(ninjas) ⇒ Object



113
114
115
116
# File 'lib/ninja.rb', line 113

def self.rules(ninjas)
  __rules = ninjas.map{ |x| x.get_rule_object } 
  Set.new(__rules).to_a
end

.Target(*xs) ⇒ Object



173
174
175
# File 'lib/ninja.rb', line 173

def self.Target(*xs)
  Ninja::Target.new(xs)
end

.to_ninja_format(ninjas) ⇒ Object



118
119
120
121
# File 'lib/ninja.rb', line 118

def self.to_ninja_format(ninjas)
  xs = (rules(ninjas) + ninjas).flatten
  __to_ninja_format(xs)
end