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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 925b00ab93076748302d2dad5679a40efb4f7591665573442575628968412b08
4
+ data.tar.gz: 262c0c7220decf69df1df2bb0caa03a27e1ad0acdfed47b9a00a41f0b9b327cd
5
+ SHA512:
6
+ metadata.gz: ac13dfcb13e3981b5921f2d164da25ea1b6c2ae8eb7e6e7ca4628b68374b268c916c5db0f38decaca63d864e3d335bdfa4faee01aff571c1a5e27e72bf17edac
7
+ data.tar.gz: 41ce0005d7968418b91462788ec2f29030d31f881ff9e8a273aa9ba8a28bfc431e4d12d8caca2d14b21fc4db80462688051504fde0a0f02f72c0f5cdabe0de89
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.overcommit.yml ADDED
@@ -0,0 +1,34 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/sds/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/sds/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+
18
+ PreCommit:
19
+ AuthorName:
20
+ enabled: false
21
+
22
+ RuboCop:
23
+ enabled: true
24
+ on_warn: fail # Treat all warnings as failures
25
+
26
+ TrailingWhitespace:
27
+ enabled: true
28
+
29
+ PostCheckout:
30
+ ALL: # Special hook name that customizes all hooks of this type
31
+ quiet: true # Change all post-checkout hooks to only display output on failure
32
+
33
+ IndexTags:
34
+ enabled: true # Generate a tags file with `ctags` each time HEAD changes
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at elct9620@frost.tw. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in mwc.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mwc (0.2.0)
5
+ rack (~> 2.0.7)
6
+ rake (~> 10.0)
7
+ thor (~> 0.20.3)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.0)
13
+ bundler-audit (0.6.1)
14
+ bundler (>= 1.2.0, < 3)
15
+ thor (~> 0.18)
16
+ childprocess (3.0.0)
17
+ diff-lcs (1.3)
18
+ iniparse (1.4.4)
19
+ jaro_winkler (1.5.4)
20
+ overcommit (0.51.0)
21
+ childprocess (>= 0.6.3, < 4)
22
+ iniparse (~> 1.4)
23
+ parallel (1.19.1)
24
+ parser (2.6.5.0)
25
+ ast (~> 2.4.0)
26
+ rack (2.0.7)
27
+ rainbow (3.0.0)
28
+ rake (10.5.0)
29
+ rspec (3.9.0)
30
+ rspec-core (~> 3.9.0)
31
+ rspec-expectations (~> 3.9.0)
32
+ rspec-mocks (~> 3.9.0)
33
+ rspec-core (3.9.0)
34
+ rspec-support (~> 3.9.0)
35
+ rspec-expectations (3.9.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.9.0)
38
+ rspec-mocks (3.9.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-support (3.9.0)
42
+ rubocop (0.76.0)
43
+ jaro_winkler (~> 1.5.1)
44
+ parallel (~> 1.10)
45
+ parser (>= 2.6)
46
+ rainbow (>= 2.2.2, < 4.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (>= 1.4.0, < 1.7)
49
+ ruby-progressbar (1.10.1)
50
+ thor (0.20.3)
51
+ unicode-display_width (1.6.0)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ bundler (~> 2.0)
58
+ bundler-audit (~> 0.6.1)
59
+ mwc!
60
+ overcommit (~> 0.51.0)
61
+ rspec (~> 3.0)
62
+ rubocop (~> 0.76.0)
63
+
64
+ BUNDLED WITH
65
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 蒼時弦也
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # Mwc
2
+
3
+ This is a small tool to help people play with mruby on WebAssembly, it let you directly setup a wasm project with mruby.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mwc'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mwc
20
+
21
+ ## Requirement
22
+
23
+ * Curl
24
+ * Tar
25
+ * Emscripten SDK
26
+ * Ruby 2.6+
27
+
28
+ > Please make sure you can execute `emcc` before use `mwc compile`
29
+
30
+ ## Usage
31
+
32
+ ### Create Project
33
+
34
+ Execute below command with your project name:
35
+
36
+ $ mwc init my_mrb
37
+
38
+ This gem will create a directory `my_mrb` with anything you need to play with mruby on WebAssembly.
39
+
40
+ ### Configure
41
+
42
+ We use the DSL to specify compile behavior, edit `.mwcrc` to change it.
43
+
44
+ ### Add some source code
45
+
46
+ ```c
47
+ // src/main.c
48
+
49
+ #include<mruby.h>
50
+ #include<mruby/compile.h>
51
+ #include<mruby/string.h>
52
+
53
+ int main() {
54
+ mrb_state* mrb = mrb_open();
55
+ mrb_load_string(mrb, "puts 'Hello World'");
56
+ mrb_close(mrb);
57
+
58
+ return 0;
59
+ }
60
+ ```
61
+
62
+ ### Source code detect
63
+
64
+ * `src/**/*.c` the normal c code
65
+ * `src/js/**/*.lib.js` the JavaScript library can call it inside C
66
+ * `src/js/**/*.pre.js` the JavaScript prepend WebAssembly JS
67
+ * `src/js/**/*.post.js` the JavaScript append WebAssembly JS
68
+
69
+ ### Compile
70
+
71
+ To compile `*.c` to `.wasm` you have to execute `compile` command:
72
+
73
+ $ mwc compile
74
+
75
+ To see more usage with `help` command:
76
+
77
+ $ mwc help compile
78
+
79
+ > Current only support minimal compile feature, the optimize and source map will be added soon.
80
+
81
+ ### Serve compiled files
82
+
83
+ The `mwc` has built-in static file server to help preview or debug:
84
+
85
+ $ mwc server
86
+
87
+ And then, open the `http://localhost:8080` you will see the Emscripten web shell and `Hello World` is printed.
88
+
89
+ ## Roadmap
90
+
91
+ * [ ] Refactor compile function
92
+ * [ ] Environment-based compile
93
+
94
+ ## Development
95
+
96
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
97
+
98
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
99
+
100
+ ## Contributing
101
+
102
+ Bug reports and pull requests are welcome on GitHub at https://github.com/elct9620/mwc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
103
+
104
+ ## License
105
+
106
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
107
+
108
+ ## Code of Conduct
109
+
110
+ Everyone interacting in the Mwc project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elct9620/mwc/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'mwc'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/mwc ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'mwc/command'
5
+
6
+ Mwc::Command.start(ARGV)
data/lib/mwc.rb ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ require 'mwc/version'
6
+ require 'mwc/config'
7
+
8
+ # WebAssembly compile tool for mruby
9
+ module Mwc
10
+ # The project root
11
+ #
12
+ # @return [Pathname] the root
13
+ #
14
+ # @since 0.1.0
15
+ # @api private
16
+ def self.root
17
+ return @root unless @root.nil?
18
+
19
+ @root ||= Pathname.pwd
20
+ @root ||= Bundler.root if defined?(::Bundler)
21
+ @root
22
+ end
23
+
24
+ # Set project root
25
+ #
26
+ # @param path [String|Pathname] the root path
27
+ #
28
+ # @since 0.1.0
29
+ # @api private
30
+ def self.root=(path)
31
+ @root = Pathname.new(path)
32
+ end
33
+
34
+ # The mwc config
35
+ #
36
+ # @return [Mwc::Config] the config
37
+ #
38
+ # @since 0.1.0
39
+ # @api private
40
+ def self.config
41
+ Mwc::Config.instance
42
+ end
43
+
44
+ # The thor template source root
45
+ #
46
+ # @return [String] the source root path
47
+ #
48
+ # @since 0.1.0
49
+ # @api private
50
+ def self.source_root
51
+ Pathname
52
+ .new(File.dirname(__FILE__))
53
+ .join('mwc', 'templates')
54
+ .to_s
55
+ end
56
+ end