mwc 0.2.0
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 +7 -0
- data/.gitignore +11 -0
- data/.overcommit.yml +34 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +65 -0
- data/LICENSE.txt +21 -0
- data/README.md +110 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/mwc +6 -0
- data/lib/mwc.rb +56 -0
- data/lib/mwc/command.rb +25 -0
- data/lib/mwc/commands/compile.rb +26 -0
- data/lib/mwc/commands/init.rb +72 -0
- data/lib/mwc/commands/server.rb +26 -0
- data/lib/mwc/compile_options.rb +94 -0
- data/lib/mwc/config.rb +81 -0
- data/lib/mwc/mruby.rb +14 -0
- data/lib/mwc/project.rb +25 -0
- data/lib/mwc/server.rb +32 -0
- data/lib/mwc/tasks.rb +83 -0
- data/lib/mwc/templates/.gitignore +11 -0
- data/lib/mwc/templates/config/build.rb +44 -0
- data/lib/mwc/templates/mwcrc.erb +12 -0
- data/lib/mwc/utils/command.rb +110 -0
- data/lib/mwc/utils/command_registry.rb +45 -0
- data/lib/mwc/version.rb +5 -0
- data/mwasm.gemspec +43 -0
- metadata +189 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
MRuby::Build.new do |conf|
|
4
|
+
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
|
5
|
+
toolchain :visualcpp
|
6
|
+
else
|
7
|
+
toolchain :gcc
|
8
|
+
end
|
9
|
+
|
10
|
+
conf.gembox 'default'
|
11
|
+
end
|
12
|
+
|
13
|
+
MRuby::CrossBuild.new('wasm') do |conf|
|
14
|
+
toolchain :clang
|
15
|
+
|
16
|
+
# C compiler settings
|
17
|
+
conf.cc do |cc|
|
18
|
+
cc.command = 'emcc'
|
19
|
+
cc.compile_options = '%<flags>s -s WASM=1 -o %<outfile>s ' \
|
20
|
+
'-c %<infile>s -Oz --llvm-opts 3'
|
21
|
+
end
|
22
|
+
|
23
|
+
# Linker settings
|
24
|
+
conf.linker do |linker|
|
25
|
+
linker.command = 'emcc'
|
26
|
+
linker.link_options = '%<flags>s -o %<outfile>s %<objs>s %<libs>s'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Archiver settings
|
30
|
+
conf.archiver do |archiver|
|
31
|
+
archiver.command = 'emcc'
|
32
|
+
archiver.archive_options = '%<objs>s -s WASM=1 -o %<outfile>s'
|
33
|
+
end
|
34
|
+
|
35
|
+
# file extensions
|
36
|
+
conf.exts do |exts|
|
37
|
+
exts.object = '.bc'
|
38
|
+
exts.executable = '' # '.exe' if Windows
|
39
|
+
exts.library = '.bc'
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: Allow specify customize gembox
|
43
|
+
conf.gembox 'default'
|
44
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# vim: set filetype=ruby
|
2
|
+
|
3
|
+
# Project settings
|
4
|
+
project.name = '<%= name %>'
|
5
|
+
# project.shell = 'src/shell.html'
|
6
|
+
# project.source_map = true
|
7
|
+
|
8
|
+
# -s ALLOW_MEMORY_GROWTH=1
|
9
|
+
# project.option 'ALLOW_MEMORY_GROWTH', '1'
|
10
|
+
|
11
|
+
# mruby settings
|
12
|
+
mruby.version = '2.1.0'
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mwc'
|
4
|
+
|
5
|
+
module Mwc
|
6
|
+
module Utils
|
7
|
+
# The command extensions
|
8
|
+
module Command
|
9
|
+
# :nodoc:
|
10
|
+
def self.included(base)
|
11
|
+
base.extend ClassMethods
|
12
|
+
end
|
13
|
+
|
14
|
+
# :nodoc:
|
15
|
+
module ClassMethods
|
16
|
+
# Get or set command name
|
17
|
+
#
|
18
|
+
# @param name [String] the command name
|
19
|
+
#
|
20
|
+
# @since 0.1.0
|
21
|
+
# @api private
|
22
|
+
def name(name = nil)
|
23
|
+
return @name || self.name.split('::').last.downcase if name.nil?
|
24
|
+
|
25
|
+
@name = name
|
26
|
+
end
|
27
|
+
|
28
|
+
# Set command usage
|
29
|
+
#
|
30
|
+
# @param name [String] the command usage
|
31
|
+
#
|
32
|
+
# @since 0.1.0
|
33
|
+
# @api private
|
34
|
+
def usage(usage = nil)
|
35
|
+
return @usage || name if usage.nil?
|
36
|
+
|
37
|
+
@usage = usage
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get or set command description
|
41
|
+
#
|
42
|
+
# @param desc [String] the command description
|
43
|
+
#
|
44
|
+
# @since 0.1.0
|
45
|
+
# @api private
|
46
|
+
def description(desc = nil)
|
47
|
+
return @description || name if desc.nil?
|
48
|
+
|
49
|
+
@description = desc
|
50
|
+
end
|
51
|
+
|
52
|
+
# The command should display or not
|
53
|
+
#
|
54
|
+
# @return [TrueClass,FalseClass] display on command
|
55
|
+
#
|
56
|
+
# @since 0.1.0
|
57
|
+
# @api private
|
58
|
+
def display?
|
59
|
+
return true if @display.nil?
|
60
|
+
|
61
|
+
@display.call
|
62
|
+
end
|
63
|
+
|
64
|
+
# Define the command display policy
|
65
|
+
#
|
66
|
+
# @param proc [Proc] the display policy block
|
67
|
+
#
|
68
|
+
# @since 0.1.0
|
69
|
+
# @api private
|
70
|
+
def display_on(&block)
|
71
|
+
return unless block_given?
|
72
|
+
|
73
|
+
@display = block
|
74
|
+
end
|
75
|
+
|
76
|
+
# The thor template source root
|
77
|
+
#
|
78
|
+
# @see Mwc.source_root
|
79
|
+
#
|
80
|
+
# @return [String] the source root path
|
81
|
+
#
|
82
|
+
# @since 0.1.0
|
83
|
+
# @api private
|
84
|
+
def source_root
|
85
|
+
Mwc.source_root
|
86
|
+
end
|
87
|
+
|
88
|
+
# The command options
|
89
|
+
#
|
90
|
+
# @since 0.1.0
|
91
|
+
# @api private
|
92
|
+
def options
|
93
|
+
@options ||= []
|
94
|
+
end
|
95
|
+
|
96
|
+
# Add command options
|
97
|
+
#
|
98
|
+
# @param name [String|Symbol] the option name
|
99
|
+
# @param options [Hash] the option options
|
100
|
+
#
|
101
|
+
# @since 0.1.0
|
102
|
+
# @api private
|
103
|
+
def add_option(name, options = {})
|
104
|
+
@options ||= []
|
105
|
+
@options.push([name, options])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mwc
|
4
|
+
module Utils
|
5
|
+
# The helper to register command on thor
|
6
|
+
module CommandRegistry
|
7
|
+
# :nodoc:
|
8
|
+
def self.included(base)
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
# :nodoc:
|
13
|
+
module ClassMethods
|
14
|
+
# Add command to thor
|
15
|
+
#
|
16
|
+
# @param command [Class] the command to add
|
17
|
+
#
|
18
|
+
# @since 0.1.0
|
19
|
+
# @api private
|
20
|
+
def add_command(command)
|
21
|
+
return unless command.display?
|
22
|
+
|
23
|
+
command.options.each { |args| method_option(*args) }
|
24
|
+
register command,
|
25
|
+
command.name,
|
26
|
+
command.usage,
|
27
|
+
command.description
|
28
|
+
end
|
29
|
+
|
30
|
+
# Add subcommand to thor
|
31
|
+
#
|
32
|
+
# @param command [Class] the subcommand
|
33
|
+
#
|
34
|
+
# @since 0.1.0
|
35
|
+
# @api private
|
36
|
+
def add_subcommand(command)
|
37
|
+
return unless command.display?
|
38
|
+
|
39
|
+
desc command.usage, command.description
|
40
|
+
subcommand command.name, command
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/mwc/version.rb
ADDED
data/mwasm.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'mwc/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'mwc'
|
9
|
+
spec.version = Mwc::VERSION
|
10
|
+
spec.authors = ['蒼時弦也']
|
11
|
+
spec.email = ['contact0@frost.tw']
|
12
|
+
|
13
|
+
spec.summary = 'The command line tool to compile mruby to WebAssembly'
|
14
|
+
spec.description = 'The command line tool to compile mruby to WebAssembly'
|
15
|
+
spec.homepage = 'https://github.com/elct9620/mwc'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/elct9620/mwc'
|
20
|
+
# spec.metadata["changelog_uri"] = "TODO"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files
|
24
|
+
# in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`
|
27
|
+
.split("\x0")
|
28
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
spec.add_runtime_dependency 'rack', '~> 2.0.7'
|
35
|
+
spec.add_runtime_dependency 'rake', '~> 10.0'
|
36
|
+
spec.add_runtime_dependency 'thor', '~> 0.20.3'
|
37
|
+
|
38
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
39
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.6.1'
|
40
|
+
spec.add_development_dependency 'overcommit', '~> 0.51.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
+
spec.add_development_dependency 'rubocop', '~> 0.76.0'
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mwc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 蒼時弦也
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.20.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.20.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler-audit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.6.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.6.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: overcommit
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.51.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.51.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.76.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.76.0
|
125
|
+
description: The command line tool to compile mruby to WebAssembly
|
126
|
+
email:
|
127
|
+
- contact0@frost.tw
|
128
|
+
executables:
|
129
|
+
- mwc
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".overcommit.yml"
|
135
|
+
- ".rspec"
|
136
|
+
- ".travis.yml"
|
137
|
+
- CODE_OF_CONDUCT.md
|
138
|
+
- Gemfile
|
139
|
+
- Gemfile.lock
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/console
|
144
|
+
- bin/setup
|
145
|
+
- exe/mwc
|
146
|
+
- lib/mwc.rb
|
147
|
+
- lib/mwc/command.rb
|
148
|
+
- lib/mwc/commands/compile.rb
|
149
|
+
- lib/mwc/commands/init.rb
|
150
|
+
- lib/mwc/commands/server.rb
|
151
|
+
- lib/mwc/compile_options.rb
|
152
|
+
- lib/mwc/config.rb
|
153
|
+
- lib/mwc/mruby.rb
|
154
|
+
- lib/mwc/project.rb
|
155
|
+
- lib/mwc/server.rb
|
156
|
+
- lib/mwc/tasks.rb
|
157
|
+
- lib/mwc/templates/.gitignore
|
158
|
+
- lib/mwc/templates/config/build.rb
|
159
|
+
- lib/mwc/templates/mwcrc.erb
|
160
|
+
- lib/mwc/utils/command.rb
|
161
|
+
- lib/mwc/utils/command_registry.rb
|
162
|
+
- lib/mwc/version.rb
|
163
|
+
- mwasm.gemspec
|
164
|
+
homepage: https://github.com/elct9620/mwc
|
165
|
+
licenses:
|
166
|
+
- MIT
|
167
|
+
metadata:
|
168
|
+
homepage_uri: https://github.com/elct9620/mwc
|
169
|
+
source_code_uri: https://github.com/elct9620/mwc
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubygems_version: 3.0.3
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: The command line tool to compile mruby to WebAssembly
|
189
|
+
test_files: []
|