-
Notifications
You must be signed in to change notification settings - Fork 0
/
mrbgem.rake
45 lines (42 loc) · 1.55 KB
/
mrbgem.rake
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
MRuby::Gem::Specification.new('mruby-argon2') do |spec|
spec.license = 'Apache-2.0'
spec.author = 'Hendrik Beskow'
spec.summary = 'The password hash Argon2, winner of PHC for mruby'
spec.add_conflict 'mruby-libsodium'
spec.add_dependency 'mruby-sysrandom'
spec.add_dependency 'mruby-errno'
argon2_src = "#{spec.dir}/deps/phc-winner-argon2"
spec.cc.include_paths << "#{argon2_src}/src"
if build.kind_of?(MRuby::CrossBuild)
spec.objs += %W(
#{argon2_src}/src/argon2.c
#{argon2_src}/src/core.c
#{argon2_src}/src/blake2/blake2b.c
#{argon2_src}/src/thread.c
#{argon2_src}/src/encoding.c
#{argon2_src}/src/ref.c
).map { |f| f.relative_path_from(dir).pathmap("#{build_dir}/%X#{spec.exts.object}" ) }
spec.cc.defines << 'ARGON2_NO_THREADS'
else
if spec.build.toolchains.include? 'visualcpp'
ref = "#{argon2_src}/src/ref.c"
else
`#{spec.cc.command} -I#{argon2_src}/include -I#{argon2_src}/src -march=native #{argon2_src}/src/opt.c -c -o /dev/null 2>/dev/null`
if $?.exitstatus == 0
ref = "#{argon2_src}/src/opt.c"
spec.cc.flags << "-march=native"
else
ref = "#{argon2_src}/src/ref.c"
end
spec.linker.flags_before_libraries << "-pthread"
end
spec.objs += %W(
#{argon2_src}/src/argon2.c
#{argon2_src}/src/core.c
#{argon2_src}/src/blake2/blake2b.c
#{argon2_src}/src/thread.c
#{argon2_src}/src/encoding.c
#{ref}
).map { |f| f.relative_path_from(dir).pathmap("#{build_dir}/%X#{spec.exts.object}" ) }
end
end