Skip to content

Instantly share code, notes, and snippets.

@pulsejet
Created May 5, 2018 02:29
Show Gist options
  • Save pulsejet/7b3ccb77c0f67e0f268fc5b43b0ff4cc to your computer and use it in GitHub Desktop.
Save pulsejet/7b3ccb77c0f67e0f268fc5b43b0ff4cc to your computer and use it in GitHub Desktop.
Toolchain for building mruby with emscripten
# Sample usage
MRuby::CrossBuild.new('emscripten') do |conf|
toolchain :emscripten
# conf.gem :github => 'mattn/mruby-onig-regexp'
# conf.gem :github => 'take-cheeze/mruby-marshal'
conf.gembox 'default'
conf.cc do |cc|
cc.flags = [ENV['CFLAGS'] || %w()]
cc.compile_options = "%{flags} -O3 -MMD -o %{outfile} -c %{infile} -I$HOME/dev/onig/src"
# cc.defines = %w(MRB_INTEGER_DIVISION)
end
# conf.cxx.defines = %w(MRB_INTEGER_DIVISION)
conf.linker.command = 'emcc'
end
MRuby::Toolchain.new(:emscripten) do |conf|
toolchain :clang
conf.compilers.each do |cc|
cc.command = "emcc"
cc.flags.flatten!
cc.flags.reject! { |v| v =~ /^-g/ }
end
conf.archiver.command = "emar"
conf.cxx.command = "em++"
conf.linker.command = "emcc"
conf.linker.libraries.reject! { |v| v == 'm' }
conf.exts do |v|
v.executable = '.js'
v.library = '.a'
v.object = '.o.bc'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment