Sha256: 5d4a549f2b72cd0027ab97ac28a897022be59c7b4cc7f9b0265164fac9f80ad0
Contents?: true
Size: 1.71 KB
Versions: 3
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true require 'fileutils' require 'posix-spawn' require 'set' require_relative '../lib/sleeping_kangaroo12/build' platform = ::SleepingKangaroo12::Build::Platform.instance out_dir = "#{platform.arch}-#{platform.os}" lib_name = ::File.join(out_dir, platform.map_library_name('SleepingKangaroo12')) k12_prefix = 'k12/bin/' build_prefix = 'bin/.build/' feature_set = ::POSIX::Spawn::Child.new('gcc -march=native -dM -E - < /dev/null').then(&:out).then do |output| output.lines.select do |line| line.include?('AVX') || line.include?('SSE') || line.include?('64') end end.each_with_object(::Set.new) do |line, accumulator| matched = /(\S+)\s+1\s*\z/.match(line) next unless matched accumulator << matched[1] end static_target = if feature_set.include?('__LP64__') 'generic64/libk12.a' else 'generic32/libk12.a' end task default: [lib_name] file lib_name => FileList["#{build_prefix}sleeping_kangaroo12.o", "#{k12_prefix}#{static_target}"] do |t| ::FileUtils.mkdir_p(::File.dirname(t.name)) static_lib = t.prerequisites.last static_lib_dir = ::File.dirname(static_lib) static_lib_file = ::File.basename(static_lib) sh "gcc -shared -flto -o #{t.name} #{t.prerequisites.first} -L#{static_lib_dir} -l:#{static_lib_file} -lm -lc" end file "#{build_prefix}sleeping_kangaroo12.o" => FileList['binding/sleeping_kangaroo12.c', "#{k12_prefix}#{static_target}"] do |t| ::FileUtils.mkdir_p(::File.dirname(t.name)) sh "gcc -Wall -O3 -fPIC -flto -I#{::File.dirname(t.prerequisites.last)} -c #{t.prerequisites.first} -o #{t.name}" end file "#{k12_prefix}#{static_target}" => FileList['k12/Makefile'] do |_t| sh "cd k12 && (CFLAGS=\"-fPIC -flto\" ASMFLAGS=\"-fPIC -flto\" make #{static_target})" end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sleeping_kangaroo12-0.0.6 | ext/Rakefile |
sleeping_kangaroo12-0.0.5 | ext/Rakefile |
sleeping_kangaroo12-0.0.4 | ext/Rakefile |