-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Rakefile
64 lines (51 loc) · 1.6 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
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubygems/package_task'
require 'rake/extensiontask'
CXX_FILES = FileList['ext/**/*.{c,cc,cpp,cxx,h}']
RSpec::Core::RakeTask.new(:spec)
task default: %i[clobber compile spec lint]
spec = Gem::Specification.load(File.expand_path('mini_phone.gemspec', __dir__))
Gem::PackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
Rake::ExtensionTask.new('mini_phone', spec) do |ext|
ext.lib_dir = 'lib/mini_phone'
end
task bench: %i[clobber compile] do
Dir['bench/**/*'].each do |f|
require_relative f
end
end
task :lint do
require 'mkmf'
sh 'bundle exec rubocop'
sh 'clang-format', '--dry-run', '-i', *CXX_FILES if find_executable('clang-format')
end
task :format do
sh 'bundle exec rubocop -A'
sh 'clang-format', '--dry-run', '-i', *CXX_FILES
end
task deploy: :default do
sh 'code -w ./lib/mini_phone/version.rb'
version = `ruby -r ./lib/mini_phone/version.rb -e 'print MiniPhone::VERSION'`.strip
sh "git commit -am 'Bump to v#{version} :confetti_ball:'"
sh 'bundle exec rake release'
end
namespace :debug do
desc 'Plot memory'
task :memory do
sh 'debug/memory_plot/plot.sh'
end
desc 'Run valgrind test'
task :valgrind do
sh 'docker build --tag mini_phone_dev -f Dockerfile.dev .'
args = '--tool=memcheck --num-callers=15 --partial-loads-ok=yes --undef-value-errors=no'
script = 'ruby debug/memory_plot/memory.rb --once'
cmd = "docker run -it --rm -v #{Dir.pwd}:/app -w /app mini_phone_dev valgrind #{args} #{script}"
puts cmd
system cmd
end
end