Skip to content

Commit

Permalink
Get everything building again
Browse files Browse the repository at this point in the history
  • Loading branch information
Widdershin committed Oct 7, 2019
1 parent c16c1d9 commit e90eac1
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ test.c
test.wasm
test.js

node_modules/
6 changes: 6 additions & 0 deletions .gitmodules
@@ -0,0 +1,6 @@
[submodule "emsdk"]
path = emsdk
url = https://github.com/emscripten-core/emsdk.git
[submodule "mruby"]
path = mruby
url = https://github.com/mruby/mruby.git
8 changes: 7 additions & 1 deletion Makefile
Expand Up @@ -3,7 +3,13 @@ PHONY: test.js
test.c: test.rb
mrbc -Btest test.rb

test.js: test.wasm test.c
mruby-build:
cd mruby && make

patch-mruby:
cd mruby && cat ../mruby.patch | git apply

test.js: mruby-build test.c
emcc -s WASM=1 -I mruby/include main.c mruby/build/emscripten/lib/libmruby.a -o test.js

clean:
Expand Down
22 changes: 0 additions & 22 deletions default.nix

This file was deleted.

1 change: 1 addition & 0 deletions emsdk
Submodule emsdk added at 9ed207
114 changes: 114 additions & 0 deletions mruby.patch
@@ -0,0 +1,114 @@
diff --git a/build_config.rb b/build_config.rb
index 751317c7..9d84f761 100644
--- a/build_config.rb
+++ b/build_config.rb
@@ -125,6 +125,15 @@ MRuby::Build.new('test') do |conf|
conf.gembox 'default'
end

+MRuby::CrossBuild.new('emscripten') do |conf|
+ toolchain :clang
+ conf.gembox 'wasm'
+ conf.cc.command = 'emcc'
+ conf.cc.flags = %W(-Os)
+ conf.linker.command = 'emcc'
+ conf.archiver.command = 'emar'
+end
+
#MRuby::Build.new('bench') do |conf|
# # Gets set by the VS command prompts.
# if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
diff --git a/mrbgems/wasm.gembox b/mrbgems/wasm.gembox
new file mode 100644
index 00000000..4aa8f0d2
--- /dev/null
+++ b/mrbgems/wasm.gembox
@@ -0,0 +1,88 @@
+MRuby::GemBox.new do |conf|
+ # Meta-programming features
+ conf.gem :core => "mruby-metaprog"
+
+ # Use standard Array#pack, String#unpack methods
+ conf.gem :core => "mruby-pack"
+
+ # Use standard Kernel#sprintf method
+ conf.gem :core => "mruby-sprintf"
+
+ # Use standard print/puts/p
+ conf.gem :core => "mruby-print"
+
+ # Use standard Math module
+ conf.gem :core => "mruby-math"
+
+ # Use standard Time class
+ conf.gem :core => "mruby-time"
+
+ # Use standard Struct class
+ conf.gem :core => "mruby-struct"
+
+ # Use Comparable module extension
+ conf.gem :core => "mruby-compar-ext"
+
+ # Use Enumerable module extension
+ conf.gem :core => "mruby-enum-ext"
+
+ # Use String class extension
+ conf.gem :core => "mruby-string-ext"
+
+ # Use Numeric class extension
+ conf.gem :core => "mruby-numeric-ext"
+
+ # Use Array class extension
+ conf.gem :core => "mruby-array-ext"
+
+ # Use Hash class extension
+ conf.gem :core => "mruby-hash-ext"
+
+ # Use Range class extension
+ conf.gem :core => "mruby-range-ext"
+
+ # Use Proc class extension
+ conf.gem :core => "mruby-proc-ext"
+
+ # Use Symbol class extension
+ conf.gem :core => "mruby-symbol-ext"
+
+ # Use Random class
+ conf.gem :core => "mruby-random"
+
+ # Use Object class extension
+ conf.gem :core => "mruby-object-ext"
+
+ # Use ObjectSpace class
+ conf.gem :core => "mruby-objectspace"
+
+ # Use Fiber class
+ conf.gem :core => "mruby-fiber"
+
+ # Use Enumerator class (require mruby-fiber)
+ conf.gem :core => "mruby-enumerator"
+
+ # Use Enumerator::Lazy class (require mruby-enumerator)
+ conf.gem :core => "mruby-enum-lazy"
+
+ # Use toplevel object (main) methods extension
+ conf.gem :core => "mruby-toplevel-ext"
+
+ # Generate mirb command
+ conf.gem :core => "mruby-bin-mirb"
+
+ # Generate mruby command
+ conf.gem :core => "mruby-bin-mruby"
+
+ # Generate mruby-strip command
+ conf.gem :core => "mruby-bin-strip"
+
+ # Use Kernel module extension
+ conf.gem :core => "mruby-kernel-ext"
+
+ # Use class/module extension
+ conf.gem :core => "mruby-class-ext"
+
+ # Use mruby-compiler to build other mrbgems
+ conf.gem :core => "mruby-compiler"
+end

0 comments on commit e90eac1

Please sign in to comment.