Module: Tooling

Extended by:
Rake::DSL
Defined in:
lib/tasks/tooling.rb

Defined Under Namespace

Classes: Task

Constant Summary collapse

XCODE_TOOLCHAIN_PATH =
'/Applications/Xcode.app/Contents/Developer' \
'/Toolchains/XcodeDefault.xctoolchain'
PRE_COMPILE_FLAGS =
%w(-x c -std=c99).freeze
POST_COMPILE_FLAGS =
%W(
  -isystem
  /usr/local/include
  -isystem
  /usr/include
  -isystem
  /Library/Developer/CommandLineTools/usr/include
  -isystem
  #{XCODE_TOOLCHAIN_PATH}/usr/include
  -isystem
  /System/Library/Frameworks
  -isystem
  /Library/Frameworks
  -isystem
  #{XCODE_TOOLCHAIN_PATH}/usr/lib/clang/8.0.0/include
  -fspell-checking
).freeze

Class Method Summary collapse

Class Method Details

.add_cc_json(text) ⇒ Object



17
18
19
# File 'lib/tasks/tooling.rb', line 17

def add_cc_json(text)
  cc_jsons << JSON.parse(text)
end

.add_task(*args, ext:, **opts) ⇒ Object



35
36
37
# File 'lib/tasks/tooling.rb', line 35

def add_task(*args, ext:, **opts)
  Tooling::Task.new(ext, *args, **opts)
end

.cc_json(as: :hash) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/tasks/tooling.rb', line 21

def cc_json(as: :hash)
  result = []
  cc_jsons.each { |json| result += json }
  return result if :hash == as

  JSON.pretty_generate(result)
end

.cc_jsonsObject



13
14
15
# File 'lib/tasks/tooling.rb', line 13

def cc_jsons
  @cc_jsons ||= []
end

.color_coded_commandsObject



29
30
31
32
33
# File 'lib/tasks/tooling.rb', line 29

def color_coded_commands
  @color_coded_commands ||= [Tooling::PRE_COMPILE_FLAGS,
                             inner_cc_commands,
                             Tooling::POST_COMPILE_FLAGS].uniq
end

.define(name = :tooling) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/tasks/tooling.rb', line 43

def define(name = :tooling)
  desc 'Prerequisites for compile_commands.json'
  task "#{name}:pre_compile_commands" => pre_compile_commands

  define_ccjson(name)
  # define_color_coded

  # CLEAN.include('.color_coded')
  CLEAN.include('compile_commands.json')

  desc 'Default vim tooling task'
  task "#{name}:default" => ['compile_commands.json']

  desc 'Generate vim tooling'
  task name => [:compile, "#{name}:default"]
end

.tasksObject



39
40
41
# File 'lib/tasks/tooling.rb', line 39

def tasks
  @tasks ||= []
end