-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
195 lines (156 loc) · 3.67 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Author: Chris Wailes <chris.wailes@gmail.com>
# Project: Ruby Code Generation Toolkit
# Date: 2015/05/05
# Description: This is RCGTK's Rakefile.
##############
# Rake Tasks #
##############
# Gems
require 'filigree/request_file'
# RCGTK
require File.expand_path("../lib/rcgtk/version", __FILE__)
###########
# Bundler #
###########
request_file('bundler', 'Bundler is not installed.') do
Bundler::GemHelper.install_tasks
end
########
# Flay #
########
request_file('flay', 'Flay is not installed.') do
desc 'Analyze code for similarities with Flay'
task :flay do
flay = Flay.new
flay.process(*Dir['lib/**/*.rb'])
flay.report
end
end
########
# Flog #
########
request_file('flog_cli', 'Flog is not installed.') do
desc 'Analyze code complexity with Flog'
task :flog do
whip = FlogCLI.new
whip.flog('lib')
whip.report
end
end
############
# MiniTest #
############
request_file('rake/testtask', 'Minitest is not installed.') do
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/ts_rcgtk.rb']
end
end
#########
# Notes #
#########
request_file('rake/notes/rake_task', 'Rake-notes is not installed.')
########
# Reek #
########
request_file('reek/rake/task', 'Reek is not installed.') do
Reek::Rake::Task.new do |t|
t.fail_on_error = false
end
end
##################
# Rubygems Tasks #
##################
request_file('rubygems/tasks', 'Rubygems-tasks is not installed.') do
Gem::Tasks.new do |t|
t.console.command = 'pry'
end
end
########
# YARD #
########
request_file('yard', 'Yard is not installed.') do
YARD::Rake::YardocTask.new do |t|
yardlib = File.join(File.dirname(__FILE__), 'yardlib/rcgtk.rb')
t.options = [
'-e', yardlib,
'--title', 'The Ruby Code Generation Toolkit',
'-m', 'markdown',
'-M', 'redcarpet',
'--private'
]
t.files = Dir['lib/**/*.rb']
end
end
##############
# RCGTK Tasks #
##############
desc 'Generate the bindings for LLVM.'
task :gen_bindings do
require 'ffi_gen'
# Generate the standard LLVM bindings.
deprecated = [
# BitReader.h
'LLVMGetBitcodeModuleProviderInContext',
'LLVMGetBitcodeModuleProvider',
# BitWriter.h
'LLVMWriteBitcodeToFileHandle',
# Core.h
'LLVMCreateFunctionPassManager',
# ExectionEngine.h
'LLVMCreateExecutionEngine',
'LLVMCreateInterpreter',
'LLVMCreateJITCompiler',
'LLVMAddModuleProvider',
'LLVMRemoveModuleProvider'
]
headers = [
'llvm-c/Core.h',
'llvm-c/Analysis.h',
'llvm-c/BitReader.h',
'llvm-c/BitWriter.h',
'llvm-c/Disassembler.h',
'llvm-c/ExecutionEngine.h',
'llvm-c/Initialization.h',
'llvm-c/IRReader.h',
'llvm-c/Linker.h',
'llvm-c/LinkTimeOptimizer.h',
'llvm-c/Object.h',
'llvm-c/Support.h',
'llvm-c/Target.h',
'llvm-c/TargetMachine.h',
'llvm-c/Transforms/IPO.h',
'llvm-c/Transforms/PassManagerBuilder.h',
'llvm-c/Transforms/Scalar.h',
'llvm-c/Transforms/Vectorize.h'
]
FFIGen.generate(
module_name: 'RCGTK::Bindings',
ffi_lib: "LLVM-#{RCGTK::LLVM_TARGET_VERSION}",
headers: headers,
cflags: `llvm-config --cflags`.split,
prefixes: ['LLVM'],
blacklist: deprecated,
output: "generated_bindings-#{RCGTK::LLVM_TARGET_VERSION}.rb"
)
end
desc 'Find LLVM bindings with a regular expression.'
task :find_bind, :part do |t, args|
# Get the task argument.
part = Regexp.new(args[:part])
# Require the Bindings module.
require 'rcgtk/bindings'
syms =
Symbol.all_symbols.select do |sym|
sym = sym.to_s.downcase
sym[0..3] == 'llvm' and sym[4..-1] =~ part
end.sort
puts
if not syms.empty?
puts "Matching bindings [#{syms.length}]:"
syms.each { |sym| puts "\t#{sym}" }
else
puts 'No matching bindings.'
end
puts
end