-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
64 lines (55 loc) · 1.75 KB
/
Rakefile
File metadata and controls
64 lines (55 loc) · 1.75 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
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
# Compile the C extension
desc "Compile the native extension"
task :compile do
build_dir = 'build'
FileUtils.rm_rf(build_dir)
FileUtils.mkdir_p(build_dir)
# Copy source files to build directory
FileUtils.cp_r('ext/thaw/.', build_dir)
Dir.chdir(build_dir) do
sh 'ruby extconf.rb'
sh 'make'
# Copy compiled extension to lib directory for development
extension_files = Dir['thaw_native.{bundle,so,dll}']
if extension_files.empty?
puts "Warning: No compiled extension found"
else
extension_file = extension_files.first
target_dir = '../lib/thaw'
FileUtils.mkdir_p(target_dir)
FileUtils.cp(extension_file, target_dir)
puts "Copied #{extension_file} to #{target_dir}/"
end
end
end
# Clean compiled files
desc "Clean compiled extension files"
task :clean do
# Clean build directory
FileUtils.rm_rf('build')
# Clean lib directory of copied extensions
FileUtils.rm_f(Dir['lib/thaw/thaw_native.{bundle,so,dll}'])
# Clean built gems
FileUtils.rm_f(Dir['*.gem'])
# Clean any stray build artifacts in ext/ (shouldn't exist now, but just in case)
Dir.chdir('ext/thaw') do
FileUtils.rm_f(Dir['thaw_native.{bundle,so,dll,o}'])
FileUtils.rm_f(Dir['*.{bundle,so,dll,o,def}'])
FileUtils.rm_f('Makefile')
FileUtils.rm_f('mkmf.log')
end
puts "Cleaned all build artifacts"
end
# Deep clean - like autotools distclean
desc "Clean all generated files (including development gems)"
task :distclean => :clean do
FileUtils.rm_rf('vendor/bundle')
FileUtils.rm_f('Gemfile.lock')
puts "Deep clean completed"
end
# Make tests depend on compilation
task :spec => :compile
task :default => :spec