Created
February 27, 2018 05:56
-
-
Save kaffepanna/54e32075735d9c5dc729e98cbf681634 to your computer and use it in GitHub Desktop.
mruby build test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :mruby do | |
ENV['MRUBY_CONFIG'] = File.join(Dir.pwd, 'build_config') | |
load 'mruby/Rakefile' | |
end | |
LIB_MRUBY = File.join(MRUBY_ROOT, 'build/host/lib/libmruby.a') | |
LIB_MRUBY_FLAGS = File.join(MRUBYT_ROOT, 'build/host/lib/libmruby.flags.mak') | |
MRBC = File.join(MRUBY_ROOT, 'bin/mrbc') | |
CC = ENV['CC'] || 'cc' | |
CC_FLAGS = %W[-I#{MRUBY_ROOT}/include] | |
LD_FLAGS = %W[-static -L#{MRUBY_ROOT}/build/host/lib] | |
LIBS = %W[mruby m] | |
RUBY_SRC = FileList['*.rb'] | |
SRC = (FileList['*.c'] + RUBY_SRC.ext('.c')).uniq | |
OBJS = SRC.ext('.o') | |
desc "Build project" | |
task :main => [*OBJS, LIB_MRUBY] do |t| | |
sh CC, *LD_FLAGS, '-o', t.name, *OBJS, *LIBS.map {|l| "-l#{l}"} | |
end | |
task :clean do | |
rm_f RUBY_SRC.ext('.c') | |
rm_f OBJS | |
rm_f 'main' | |
end | |
file MRBC => MRUBY_CONFIG | |
file LIB_MRUBY => MRUBY_CONFIG | |
rule '.o' => '.c' do |t| | |
sh CC, *CC_FLAGS, '-c', '-o', t.name, t.source | |
end | |
rule '.c' => ['.rb', MRBC] do |t| | |
symbol = t.name.gsub(/\..*$/, '_symbol') | |
sh MRBC, '-B', symbol, t.source | |
end | |
task :default => :main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment