webruby 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8db4715b363fbfb76c0443e048f891961f4522d8
4
- data.tar.gz: 93babadac10f7e24a1529a38f37438c6adb0073c
3
+ metadata.gz: a820a2ac9abf12cba9386374ef4770f5483ef9ee
4
+ data.tar.gz: 528292cd94b2d6924caa37314ad6d3106f4815da
5
5
  SHA512:
6
- metadata.gz: 840d18408d4b1c20d7a3f2ba9ff7f34d79ebac03c31a130fb7ee52973d15e7dd32812945910212e8c22531d849f9463cc5a4334ce8b0a81322c8dd55c89caa57
7
- data.tar.gz: 9527854eee57e89652f6db80c47ce6a2200b623dfe3b31f40cc9be937845d9dcbf5f3885645f59a7145513dedfa9915b8b9702b0fb54a1d7bb3749d920dab1de
6
+ metadata.gz: 1fa9b17c31996090696a77d49293978d3a35a09a436ae367f2c85975e7769a3f520d90a547548d611f9a22fc64fee09d2ddbe5c9f40939f67cfea5a88a8696d6
7
+ data.tar.gz: baff4144d8e107f68c8fcfe5ed5417a95b00628f240bef27a2feb66aa4789203d38022a804ec093e813d519a2fef583f096f5d595d7b8fbf361d2bcc46a2ba6a
@@ -16,15 +16,15 @@ module Webruby
16
16
  end
17
17
 
18
18
  def is_release_mode
19
- @compile_mode == 'release'
19
+ compile_mode == 'release'
20
20
  end
21
21
 
22
22
  def cflags
23
- "-Wall -Werror-implicit-function-declaration -Wno-warn-absolute-paths #{optimization_flag}"
23
+ %w(-Wall -Werror-implicit-function-declaration -Wno-warn-absolute-paths) + [optimization_flag]
24
24
  end
25
25
 
26
26
  def ldflags
27
- optimization_flag
27
+ [optimization_flag]
28
28
  end
29
29
 
30
30
  def optimization_flag
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  file "#{Webruby.build_dir}/app.o" => "#{Webruby.build_dir}/app.c" do |t|
30
30
  require_flag = (Webruby::App.config.source_processor == :gen_require) ? ("-DHAS_REQUIRE") : ("")
31
- sh "#{EMCC} #{EMCC_CFLAGS} #{require_flag} #{Webruby::App.config.cflags} #{Webruby.build_dir}/app.c -o #{Webruby.build_dir}/app.o"
31
+ sh "#{EMCC} #{EMCC_CFLAGS} #{require_flag} #{Webruby::App.config.cflags.join(' ')} #{Webruby.build_dir}/app.c -o #{Webruby.build_dir}/app.o"
32
32
  end
33
33
 
34
34
  file "#{Webruby.build_dir}/link.js" =>
@@ -38,7 +38,7 @@ file "#{Webruby.build_dir}/link.js" =>
38
38
  Webruby::App.config.loading_mode,
39
39
  [])
40
40
 
41
- sh "#{EMLD} #{Webruby.build_dir}/app.o #{Webruby.build_dir}/#{LIBMRUBY} -o #{Webruby.build_dir}/link.js #{Webruby.gem_js_flags} #{func_arg} #{Webruby::App.config.ldflags}"
41
+ sh "#{EMLD} #{Webruby.build_dir}/app.o #{Webruby.build_dir}/#{LIBMRUBY} -o #{Webruby.build_dir}/link.js #{Webruby.gem_js_flags} #{func_arg} #{Webruby::App.config.ldflags.join(' ')}"
42
42
  end
43
43
 
44
44
  append_file_deps = Webruby::App.config.append_file ?
@@ -62,5 +62,5 @@ file "#{Webruby.build_dir}/mrbtest.js" =>
62
62
  func_arg = Webruby.get_exported_arg("#{Webruby.build_dir}/functions",
63
63
  0, ['main'])
64
64
 
65
- sh "#{EMLD} #{Webruby.build_dir}/mrbtest.bc -o #{Webruby.build_dir}/mrbtest.js -s TOTAL_MEMORY=33554432 #{Webruby.gem_test_js_flags} #{func_arg} #{Webruby::App.config.ldflags}"
65
+ sh "#{EMLD} #{Webruby.build_dir}/mrbtest.bc -o #{Webruby.build_dir}/mrbtest.js -s TOTAL_MEMORY=33554432 #{Webruby.gem_test_js_flags} #{func_arg} #{Webruby::App.config.ldflags.join(' ')}"
66
66
  end
@@ -15,7 +15,7 @@ MRuby::Toolchain.new(:emscripten) do |conf|
15
15
 
16
16
  conf.cc do |cc|
17
17
  cc.command = '#{EMCC}'
18
- cc.flags = '#{Webruby::App.config.cflags}'
18
+ cc.flags.push(*#{Webruby::App.config.cflags.inspect})
19
19
  end
20
20
 
21
21
  conf.linker.command = '#{EMLD}'
@@ -72,6 +72,7 @@ RUBY_SOURCE_PATH = "#{OUTPUT_PATH}.tmp"
72
72
  File.open(RUBY_SOURCE_PATH, "w") do |f|
73
73
  f.puts <<END
74
74
  module Kernel
75
+ @@REQUIRED_PATH = ""
75
76
  @@REQUIRED_MODULES = {
76
77
  END
77
78
 
@@ -84,10 +85,27 @@ END
84
85
 
85
86
  def require(name)
86
87
  return false unless @@REQUIRED_MODULES.include?(name)
88
+ @@REQUIRED_PATH = name[0, name.rindex('/') || 0]
87
89
  require_internal(@@REQUIRED_MODULES[name])
88
90
  @@REQUIRED_MODULES.delete(name)
89
91
  true
90
92
  end
93
+
94
+ def require_relative(path)
95
+ current_path = @@REQUIRED_PATH
96
+ path.split('/').each do |fragment|
97
+ case fragment
98
+ when '.'
99
+ # Doing nothing, current path
100
+ when '..'
101
+ current_path = current_path[0, current_path.rindex('/') || 0]
102
+ else
103
+ current_path = current_path.empty? ? fragment :
104
+ "\#{current_path}/\#{fragment}"
105
+ end
106
+ end
107
+ require(current_path)
108
+ end
91
109
  end
92
110
  END
93
111
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xuejie Xiao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-26 00:00:00.000000000 Z
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: compile your favourite Ruby source code for the browser!
14
14
  email: xxuejie@gmail.com
@@ -1537,9 +1537,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1537
1537
  version: '0'
1538
1538
  requirements: []
1539
1539
  rubyforge_project:
1540
- rubygems_version: 2.0.2
1540
+ rubygems_version: 2.0.14
1541
1541
  signing_key:
1542
1542
  specification_version: 4
1543
1543
  summary: webruby
1544
1544
  test_files: []
1545
- has_rdoc: