Sha256: 85f71ee12e32818d62497ba7328aa716ea7b09a36abfce84df1a61a8b1a5ad67
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
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" rbconfig = RbConfig::CONFIG cpuflag = if rbconfig["host_cpu"] =~ /arm64/ && rbconfig["host_os"] =~ /darwin/ "-mcpu=apple-m1" else "-march=native" end cflags = "-O3 #{cpuflag} -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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffi-hydrogen-0.1.5 | ext/ffi/hydrogen/Rakefile |