Sha256: abd7a02cb592d01cd60acca92dcdd352a2c110dbc3605824aef44990a4c19a42

Contents?: true

Size: 882 Bytes

Versions: 2

Compression:

Stored size: 882 Bytes

Contents

require "ffi"

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

desc "Compile shared library"
task :compile_shared 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}"
  cwd = ::File.expand_path(::File.dirname(__FILE__))

  ::Dir.chdir(cwd) do
    # main.o: main.c
    #   $(CC) -c $(CFLAGS) $< -o $@
    sys("cc -c #{cflags} main.c -o main.o")

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

task :default => [:compile_shared]

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffi-hydrogen-0.1.3 ext/ffi/hydrogen/Rakefile
ffi-hydrogen-0.1.2 ext/ffi/hydrogen/Rakefile