-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
109 lines (89 loc) · 2.72 KB
/
Rakefile
File metadata and controls
109 lines (89 loc) · 2.72 KB
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
require 'fileutils'
# Load gem specification
require_relative 'lib/fastpbkdf2/version'
task :default => :test
desc "Set up development environment"
task :setup do
puts "Setting up fastpbkdf2-ruby development environment..."
# Initialize submodules
sh "git submodule update --init --recursive"
# Sync upstream source
Rake::Task['sync'].invoke
# Compile extension
Rake::Task['compile'].invoke
puts "✅ Development environment ready!"
end
desc "Sync upstream fastpbkdf2 source to ext/ directory"
task :sync do
upstream_dir = 'vendor/fastpbkdf2'
ext_dir = 'ext/fastpbkdf2'
unless Dir.exist?(upstream_dir) && File.exist?("#{upstream_dir}/fastpbkdf2.c")
puts "❌ Upstream submodule not found or empty. Run: rake setup"
exit 1
end
# Update submodule to latest
puts "🔄 Updating upstream submodule..."
sh "cd #{upstream_dir} && git pull origin master"
# Copy source files
puts "📋 Copying latest C source files..."
FileUtils.cp("#{upstream_dir}/fastpbkdf2.c", ext_dir)
FileUtils.cp("#{upstream_dir}/fastpbkdf2.h", ext_dir)
puts "✅ Upstream source synced!"
end
desc "Compile the C extension"
task :compile do
Dir.chdir('ext/fastpbkdf2') do
ruby 'extconf.rb'
sh 'make clean'
sh 'make'
end
# Copy compiled extension to lib directory
FileUtils.mkdir_p('lib/fastpbkdf2')
compiled_ext = Dir.glob('ext/fastpbkdf2/fastpbkdf2.{bundle,so}').first
if compiled_ext
FileUtils.cp(compiled_ext, 'lib/fastpbkdf2/')
puts "✅ Extension compiled and copied to lib/!"
else
puts "❌ Could not find compiled extension!"
exit 1
end
end
desc "Clean compiled files"
task :clean do
Dir.chdir('ext/fastpbkdf2') do
sh 'make clean' if File.exist?('Makefile')
FileUtils.rm_f(Dir.glob('*.{o,bundle,so}'))
end
puts "✅ Cleaned compiled files!"
end
desc "Run tests"
task :test => :compile do
sh "bundle exec rspec"
end
desc "Run tests including performance benchmarks"
task :test_performance => :compile do
sh "bundle exec rspec --tag performance"
end
desc "Run all tests including performance"
task :test_all => :compile do
sh "bundle exec rspec --tag performance --tag ~performance"
end
desc "Show upstream status"
task :upstream_status do
puts "📊 Upstream fastpbkdf2 status:"
if Dir.exist?('vendor/fastpbkdf2/.git')
sh "cd vendor/fastpbkdf2 && git log --oneline -5"
else
puts " (submodule not initialized)"
end
puts "\n📋 Current vendored files:"
%w[fastpbkdf2.c fastpbkdf2.h].each do |file|
vendor_path = "vendor/fastpbkdf2/#{file}"
if File.exist?(vendor_path)
mtime = File.mtime(vendor_path)
puts " #{file}: vendor copy (#{mtime.strftime('%Y-%m-%d %H:%M:%S')})"
else
puts " #{file}: ❌ MISSING in vendor"
end
end
end