esruby 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -12
- data/lib/esruby/build.rb +5 -15
- data/lib/esruby/build/configuration.rb +1 -8
- data/resources/build_config.eruby +4 -4
- data/resources/project_template/config.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d89614de5a1ee1efad1386baf4ca5a949f3449e8
|
4
|
+
data.tar.gz: 432fc37ab54c1d7506b299183be1a8726f7f5137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b010a206ab65ce6b5775d6ac12d93bb75781362e8be7c0befeff49c1059b97b6a15e184b86fd7470528b0852150c6da16a4791a8083fc50a6ea24ae088ca6c
|
7
|
+
data.tar.gz: 13ca29a12ce4dc90b028479a152022d2d7da7cb1a088fb512d6581c50d6b444f7649c8a70050a5cba2e468c1de5384999543fe7ead0293a1489a47eb75f11466
|
data/README.md
CHANGED
@@ -3,20 +3,36 @@ This project brings *mruby* to the browser. It uses *emscripten*
|
|
3
3
|
(https://github.com/kripken/emscripten) to compile the mruby source code into
|
4
4
|
JavaScript (ECMAScript) and runs in the browser. It is heavily based off *webruby* (https://github.com/xxuejie/webruby) but has been adjusted to work with the updates to *emscripten* and *mruby*.
|
5
5
|
|
6
|
-
#
|
6
|
+
# Install
|
7
|
+
*ESRuby* depends on [emsdk](http://kripken.github.io/emscripten-site/index.html) to provide a tool chain consisting of *emscripten* and *LLVM*. Although the tool chain is available from `apt-get` we will need to build emscripten from source using my branch as I have introduced some new features that have not made it into the release yet.
|
7
8
|
|
8
|
-
*
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
* we will start with a clean instance of Ubuntu 16.04 with ruby MRI installed
|
10
|
+
* `cd` to a directory where you want *emsdk* downloaded
|
11
|
+
* `git clone https://github.com/juj/emsdk.git`
|
12
|
+
* `cd emsdk`
|
13
|
+
* `git reset --hard 313d5ef` # optional, but it may help if you find that `master` is too new for my fork
|
14
|
+
* as per the [documentation](http://kripken.github.io/emscripten-site/docs/building_from_source/building_emscripten_from_source_using_the_sdk.html) we will first install from the main repositories then replace *emscripten* with my fork:
|
15
|
+
* `./emsdk install sdk-incoming-64bit`
|
16
|
+
* `./emsdk activate sdk-incoming-64bit`
|
17
|
+
* `cd emscripten/incoming`
|
18
|
+
* `git remote add fork https://github.com/robfors/emscripten.git`
|
19
|
+
* `git fetch fork esruby`
|
20
|
+
* `git checkout -b esruby fork/esruby`
|
21
|
+
* `cd ../..`
|
22
|
+
* `source ./emsdk_env.sh` # calling this will add necessary paths to bash
|
23
|
+
* optional: make the last command persistent by adding\
|
24
|
+
`[ -f /path_to_emsdk/emsdk_env.sh ] && source /path_to_emsdk/emsdk_env.sh > /dev/null 2>&1`\
|
25
|
+
to your `.bashrc` and `.profile`
|
26
|
+
* verify emsdk is working with `emcc -v`
|
27
|
+
* install this gem with `gem install esruby`
|
19
28
|
|
29
|
+
# Try
|
30
|
+
* create a new esruby project with `esruby new project`
|
31
|
+
* `cd project`
|
32
|
+
* build the project with `esruby build config.rb`
|
33
|
+
* you will now have `www/app.js` and `www/index.html`
|
34
|
+
* a simple way to serve these files would be `ruby -run -e httpd www -p 4444`
|
35
|
+
* the app with be available at http://localhost:4444
|
20
36
|
# License
|
21
37
|
|
22
38
|
This project is distributed under the MIT License. See LICENSE for further details.
|
data/lib/esruby/build.rb
CHANGED
@@ -14,7 +14,7 @@ module ESRuby
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def_delegators :@configuration, :root_directory, :ruby_sources, :build_directory,
|
17
|
-
:build_mode, :output, :
|
17
|
+
:build_mode, :output, :mruby_directory, :gems
|
18
18
|
|
19
19
|
def initialize(&block)
|
20
20
|
@configuration = Configuration.new
|
@@ -58,20 +58,10 @@ module ESRuby
|
|
58
58
|
js_files
|
59
59
|
end
|
60
60
|
|
61
|
-
def emcc
|
62
|
-
"#{emsdk_directory}/emscripten/incoming/emcc"
|
63
|
-
end
|
64
|
-
|
65
|
-
def emar
|
66
|
-
"#{emsdk_directory}/emscripten/incoming/emar"
|
67
|
-
end
|
68
|
-
|
69
61
|
def build_mruby_config
|
70
62
|
template = File.read("#{gem_directory}/resources/build_config.eruby")
|
71
63
|
eruby = Erubis::Eruby.new(template)
|
72
64
|
config = {}
|
73
|
-
config[:emcc] = emcc
|
74
|
-
config[:emar] = emar
|
75
65
|
config[:prepended_js_sources] = prepended_js_sources
|
76
66
|
config[:appended_js_sources] = appended_js_sources
|
77
67
|
config[:optimization_argument] = optimization_argument
|
@@ -124,10 +114,10 @@ module ESRuby
|
|
124
114
|
js_arguments = prepended_js_sources.map { |path| "--pre-js #{path}" }.join(" ")
|
125
115
|
js_arguments += appended_js_sources.map { |path| "--post-js #{path}" }.join(" ")
|
126
116
|
RakeFileUtils.sh "#{mrbc} -B app -o #{build_directory}/app.c #{ruby_sources.join(" ")}"
|
127
|
-
RakeFileUtils.sh "
|
128
|
-
RakeFileUtils.sh "
|
129
|
-
RakeFileUtils.sh "
|
130
|
-
RakeFileUtils.sh "
|
117
|
+
RakeFileUtils.sh "emcc --bind -I #{mruby_directory}/include #{build_directory}/app.c -o #{build_directory}/app.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}"
|
118
|
+
RakeFileUtils.sh "emcc -std=c++11 --bind -I #{mruby_directory}/include #{gem_directory}/resources/cpp/esruby.cpp -o #{build_directory}/esruby.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}"
|
119
|
+
RakeFileUtils.sh "emcc -std=c++11 --bind -I #{mruby_directory}/include #{gem_directory}/resources/cpp/main.cpp -o #{build_directory}/main.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}"
|
120
|
+
RakeFileUtils.sh "emcc --bind -I #{mruby_directory}/include -o #{build_directory}/output.js #{build_directory}/app.o #{build_directory}/esruby.o #{build_directory}/main.o #{build_directory}/emscripten/lib/libmruby.a -lm #{js_arguments} #{optimization_argument} #{closure_argument} #{debug_argument}"
|
131
121
|
#if build.build_mode == 'production'
|
132
122
|
# sh "java -jar #{PROJECT_DIRECTORY}/emsdk/emscripten/incoming/third_party/closure-compiler/compiler.jar --js #{build.absolute_build_directory}/output.js --js_output_file #{build.absolute_output}"
|
133
123
|
#else
|
@@ -3,12 +3,11 @@ module ESRuby
|
|
3
3
|
class Configuration
|
4
4
|
|
5
5
|
attr_reader :ruby_sources, :prepended_js_sources, :appended_js_sources,
|
6
|
-
:build_directory, :build_mode, :gems, :
|
6
|
+
:build_directory, :build_mode, :gems, :mruby_directory,
|
7
7
|
:output
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@root_directory = nil
|
11
|
-
@emsdk_directory = 'emsdk'
|
12
11
|
@mruby_directory = "#{ESRuby.gem_directory}/resources/mruby"
|
13
12
|
@output = 'output.js'
|
14
13
|
@ruby_sources = []
|
@@ -54,12 +53,6 @@ module ESRuby
|
|
54
53
|
@output = File.expand_path(new_output, root_directory)
|
55
54
|
end
|
56
55
|
|
57
|
-
def emsdk_directory=(new_emsdk_directory)
|
58
|
-
emsdk_directory = File.expand_path(new_emsdk_directory, root_directory)
|
59
|
-
raise "'emsdk_directory' not found" unless File.directory?(emsdk_directory)
|
60
|
-
@emsdk_directory = emsdk_directory
|
61
|
-
end
|
62
|
-
|
63
56
|
def mruby_directory=(new_mruby_directory)
|
64
57
|
mruby_directory = File.expand_path(new_mruby_directory, root_directory)
|
65
58
|
raise "'mruby_directory' not found" unless File.directory?(mruby_directory)
|
@@ -31,10 +31,10 @@ MRuby::Toolchain.new('emscripten') do |conf|
|
|
31
31
|
c.flags << "<%= debug_argument %>"
|
32
32
|
end
|
33
33
|
|
34
|
-
conf.cc.command = "
|
35
|
-
conf.cxx.command = "
|
36
|
-
conf.linker.command = "
|
37
|
-
conf.archiver.command = "
|
34
|
+
conf.cc.command = "emcc"
|
35
|
+
conf.cxx.command = "emcc"
|
36
|
+
conf.linker.command = "emcc"
|
37
|
+
conf.archiver.command = "emar"
|
38
38
|
|
39
39
|
end
|
40
40
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Fors
|
@@ -442,7 +442,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
442
442
|
version: '0'
|
443
443
|
requirements: []
|
444
444
|
rubyforge_project:
|
445
|
-
rubygems_version: 2.
|
445
|
+
rubygems_version: 2.4.8
|
446
446
|
signing_key:
|
447
447
|
specification_version: 4
|
448
448
|
summary: Ruby running in the browser
|