class Rmk::CompDB

Invoke ninja compdb to generate JSON compile database.

Constants

FILENAME
RULES

Attributes

filename[RW]

output file in build directory (default: +“compile_commands.json”+)

rules[R]

Public Class Methods

new() click to toggle source
Calls superclass method Rmk::NinjaGenerator.new
# File tools/compdb.rb, line 18
def initialize
  super
  data = tool_params(:CompDB, generator.configuration)
  @filename = data[:filename] || FILENAME
  @rules = data[:rules] || RULES
  @enabled = data[:enabled] || false
  @slot = SLOTS[:begin]
end

Public Instance Methods

command_generate_compdb() click to toggle source
# File tools/compdb.rb, line 32
def command_generate_compdb
  "#{$PROGRAM_NAME} --compdb #{@rules.join(',')} -n > $builddir/#{@filename}"
end
ninja_build(writer = generator.ninja) click to toggle source
# File tools/compdb.rb, line 42
def ninja_build(writer = generator.ninja)
  return unless @enabled
  writer.build("$builddir/#{@filename}", 'compdb',
               ["$builddir/#{generator.ninja_file_name}"])
  # Note: name target "cmpdb" to avoid clash with ninja command "compdb".
  generator.add_to_intermediate_target(:cmpdb, "$builddir/#{@filename}")
  generator.add_to_toplevel_target(%i[default all], :cmpdb)
end
ninja_rules(writer = generator.ninja) click to toggle source
# File tools/compdb.rb, line 36
def ninja_rules(writer = generator.ninja)
  return unless @enabled
  writer.rule('compdb', command_generate_compdb,
              description: 'generate $out')
end
rules=(rhs) click to toggle source

The default rule set is empty, which defaults to +%w[cc cxx]+.

# File tools/compdb.rb, line 28
def rules=(rhs)
  raise 'compdb.rules= expects an Array' unless rhs.is_a?(Array)
end