Sha256: f69c2c535cfc10fd31682e9d9a932c2bc901fde244aa0109bf264b37109efe7d

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require "bundler/gem_tasks"
require "ffi"
require "rspec/core/rake_task"
require "rubocop/rake_task"

def sys(cmd)
  puts "#{cmd}"
  ret = system(cmd)
  raise "ERROR: '#{cmd}' failed" unless ret
  ret
end

RSpec::Core::RakeTask.new(:spec)

desc "Run RuboCop"
task :rubocop do
  RuboCop::RakeTask.new
end

desc "Compile shared library"
task :compile do
  wflags = "-Wall -Wextra -Wmissing-prototypes -Wdiv-by-zero"\
    " -Wbad-function-cast -Wcast-align -Wcast-qual -Wfloat-equal"\
    " -Wmissing-declarations -Wnested-externs -Wno-unknown-pragmas"\
    " -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-enum"\
    " -Wno-type-limits"

  cflags = "-O3 -march=native -fPIC -fno-exceptions #{wflags}"

  # main.o: main.c
  #   $(CC) -c $(CFLAGS) $< -o $@
  sys("cc -c #{cflags} vendor/main.c -o vendor/main.o")

  # main.dylib: main.o
  # 	$(CC) $< -shared -o $@
  sys("cc vendor/main.o -shared -o vendor/main.#{::FFI::Platform::LIBSUFFIX}")
end

desc "Run all benchmarks"
task :bench do
  ruby "bench/both.rb"
  ruby "bench/encode.rb"
  ruby "bench/encrypt.rb"
end

task :default => [:compile, :rubocop, :spec]

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffi-hydrogen-0.1.1 Rakefile
ffi-hydrogen-0.1.0 Rakefile