Skip to content

Commit 973f53f

Browse files
authored
Merge pull request #72 from pbhogan/develop
Resolve issue with macOS Mojave
2 parents 7b6419f + 8f94ec5 commit 973f53f

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

Rakefile

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,33 @@ require 'rdoc/task'
1616

1717
task :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
2222
end
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
3644
end
37-
task :compile_ffi => ["ffi-compiler:default"]
45+
task :compile_ffi => ['ffi-compiler:default']
3846

3947
CLEAN.include('ext/scrypt/*{.o,.log,.so,.bundle}')
4048
CLEAN.include('lib/**/*{.o,.log,.so,.bundle}')
@@ -47,10 +55,9 @@ rd = Rake::RDocTask.new do |rdoc|
4755
rdoc.rdoc_files.include('COPYING', 'lib/**/*.rb')
4856
end
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']
5461
end
5562

5663
def gem_spec

ext/scrypt/Rakefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
require 'ffi-compiler/compile_task'
22

3+
target_cpu = RbConfig::CONFIG['target_cpu']
4+
35
FFI::Compiler::CompileTask.new('scrypt_ext') do |t|
4-
t.cflags << "-Wall -std=c99"
5-
t.cflags << "-msse -msse2" if t.platform.arch.include? "86"
6-
t.cflags << "-D_GNU_SOURCE=1" if RbConfig::CONFIG["host_os"].downcase =~ /mingw/
7-
t.cflags << "-D_POSIX_C_SOURCE=199309L" if RbConfig::CONFIG['host_os'].downcase =~ /linux/
8-
t.cflags << "-arch x86_64 -arch i386" if t.platform.mac?
9-
t.ldflags << "-arch x86_64 -arch i386" if t.platform.mac?
6+
t.cflags << '-Wall -std=c99'
7+
t.cflags << '-msse -msse2' if t.platform.arch.include? '86'
8+
t.cflags << '-D_GNU_SOURCE=1' if RbConfig::CONFIG['host_os'].downcase =~ /mingw/
9+
t.cflags << '-D_POSIX_C_SOURCE=199309L' if RbConfig::CONFIG['host_os'].downcase =~ /linux/
10+
11+
if 1.size == 4 && target_cpu =~ /i386|x86_32/ && t.platform.mac?
12+
t.cflags << '-arch i386'
13+
t.ldflags << '-arch i386'
14+
elsif 1.size == 8 && target_cpu =~ /i686|x86_64/ && t.platform.mac?
15+
t.cflags << '-arch x86_64'
16+
t.ldflags << '-arch x86_64'
17+
end
18+
1019
t.export '../../lib/scrypt/scrypt_ext.rb'
1120

1221
t.add_define 'WINDOWS_OS' if FFI::Platform.windows?

0 commit comments

Comments
 (0)