@@ -16,25 +16,33 @@ require 'rdoc/task'
1616
1717task :default => [ :clean , :compile_ffi , :spec ]
1818
19- desc " clean, make and run specs"
20- task :spec do
19+ desc ' clean, make and run specs'
20+ task :spec do
2121 RSpec ::Core ::RakeTask . new
2222end
2323
24- desc " FFI compiler"
25- namespace " ffi-compiler" do
24+ desc ' FFI compiler'
25+ namespace ' ffi-compiler' do
2626 FFI ::Compiler ::CompileTask . new ( 'ext/scrypt/scrypt_ext' ) do |t |
27- t . cflags << "-Wall -std=c99"
28- t . cflags << "-msse -msse2" if t . platform . arch . include? "86"
29- t . cflags << "-D_GNU_SOURCE=1" if RbConfig ::CONFIG [ "host_os" ] . downcase =~ /mingw/
30- t . cflags << "-D_POSIX_C_SOURCE=199309L" if RbConfig ::CONFIG [ 'host_os' ] . downcase =~ /linux/
31- t . cflags << "-arch x86_64 -arch i386" if t . platform . mac?
32- t . ldflags << "-arch x86_64 -arch i386" if t . platform . mac?
27+ target_cpu = RbConfig ::CONFIG [ 'target_cpu' ]
28+
29+ t . cflags << '-Wall -std=c99'
30+ t . cflags << '-msse -msse2' if t . platform . arch . include? '86'
31+ t . cflags << '-D_GNU_SOURCE=1' if RbConfig ::CONFIG [ 'host_os' ] . downcase =~ /mingw/
32+ t . cflags << '-D_POSIX_C_SOURCE=199309L' if RbConfig ::CONFIG [ 'host_os' ] . downcase =~ /linux/
33+
34+ if 1 . size == 4 && target_cpu =~ /i386|x86_32/ && t . platform . mac?
35+ t . cflags << '-arch i386'
36+ t . ldflags << '-arch i386'
37+ elsif 1 . size == 8 && target_cpu =~ /i686|x86_64/ && t . platform . mac?
38+ t . cflags << '-arch x86_64'
39+ t . ldflags << '-arch x86_64'
40+ end
3341
3442 t . add_define 'WINDOWS_OS' if FFI ::Platform . windows?
3543 end
3644end
37- task :compile_ffi => [ " ffi-compiler:default" ]
45+ task :compile_ffi => [ ' ffi-compiler:default' ]
3846
3947CLEAN . include ( 'ext/scrypt/*{.o,.log,.so,.bundle}' )
4048CLEAN . include ( 'lib/**/*{.o,.log,.so,.bundle}' )
@@ -47,10 +55,9 @@ rd = Rake::RDocTask.new do |rdoc|
4755 rdoc . rdoc_files . include ( 'COPYING' , 'lib/**/*.rb' )
4856end
4957
50-
51- desc "Run all specs"
52- RSpec ::Core ::RakeTask . new do |t |
53- rspec_opts = [ '--colour' , '--backtrace' ]
58+ desc 'Run all specs'
59+ RSpec ::Core ::RakeTask . new do |_t |
60+ rspec_opts = [ '--colour' , '--backtrace' ]
5461end
5562
5663def gem_spec
0 commit comments