This commit is contained in:
parent
4024df72fd
commit
1076413d03
16 changed files with 259 additions and 56 deletions
236
.drone.yml
Normal file
236
.drone.yml
Normal file
|
@ -0,0 +1,236 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: build
|
||||
|
||||
steps:
|
||||
- name: restore ASDF cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
settings:
|
||||
restore: true
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .asdf
|
||||
|
||||
- name: restore bundle cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
settings:
|
||||
restore: true
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .bundle
|
||||
|
||||
- name: install dependencies
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
pull: "always"
|
||||
environment:
|
||||
ASDF_DATA_DIR: /drone/src/.asdf
|
||||
BUNDLE_CACHE_PATH: /drone/src/.bundle
|
||||
depends_on:
|
||||
- restore ASDF cache
|
||||
- restore bundle cache
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y wabt
|
||||
- rm -rf /var/cache/apt
|
||||
- mkdir -p bin
|
||||
- cp -v /usr/bin/wat2wasm bin/
|
||||
- cp -v /usr/bin/wasm-validate bin/
|
||||
- asdf_install
|
||||
- rm -rf .asdf/downloads
|
||||
- asdf bundle install
|
||||
|
||||
- name: store ASDF cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
depends_on:
|
||||
- install dependencies
|
||||
settings:
|
||||
rebuild: true
|
||||
override: false
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .asdf
|
||||
|
||||
- name: store bundle cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
depends_on:
|
||||
- install dependencies
|
||||
settings:
|
||||
rebuild: true
|
||||
override: false
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .bundle
|
||||
|
||||
- name: store WABT cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
depends_on:
|
||||
- install dependencies
|
||||
settings:
|
||||
rebuild: true
|
||||
override: false
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'wabt'
|
||||
mount:
|
||||
- bin
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: test
|
||||
|
||||
depends_on:
|
||||
- build
|
||||
|
||||
steps:
|
||||
- name: restore ASDF cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
settings:
|
||||
restore: true
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'asdf-{{ os }}-{{ arch }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .asdf
|
||||
|
||||
- name: restore bundle cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
settings:
|
||||
restore: true
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'bundle-{{ checksum "Gemfile.lock" }}-{{ checksum ".tool-versions" }}'
|
||||
mount:
|
||||
- .bundle
|
||||
|
||||
- name: restore WABT cache
|
||||
image: meltwater/drone-cache
|
||||
pull: "always"
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: SECRET_ACCESS_KEY
|
||||
AWS_PLUGIN_PATH_STYLE: true
|
||||
settings:
|
||||
restore: true
|
||||
endpoint:
|
||||
from_secret: S3_ENDPOINT
|
||||
bucket:
|
||||
from_secret: CACHE_BUCKET
|
||||
region: us-east-1
|
||||
path-style: true
|
||||
cache_key: 'wabt'
|
||||
mount:
|
||||
- bin
|
||||
|
||||
- name: rubocop
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
pull: "always"
|
||||
environment:
|
||||
BUNDLE_CACHE_PATH: /drone/src/.bundle
|
||||
ASDF_DATA_DIR: /drone/src/.asdf
|
||||
depends_on:
|
||||
- restore ASDF cache
|
||||
- restore bundle cache
|
||||
commands:
|
||||
- asdf bundle exec rubocop
|
||||
|
||||
- name: rspec
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
pull: "always"
|
||||
environment:
|
||||
BUNDLE_CACHE_PATH: /drone/src/.bundle
|
||||
ASDF_DATA_DIR: /drone/src/.asdf
|
||||
depends_on:
|
||||
- restore ASDF cache
|
||||
- restore bundle cache
|
||||
commands:
|
||||
- export PATH=/drone/src/bin:$PATH
|
||||
- asdf bundle exec rspec
|
|
@ -1,32 +0,0 @@
|
|||
image: ruby:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
|
||||
before_script:
|
||||
- apt-get update && apt-get install wabt && rm -rf /var/cache/apt
|
||||
- bundle install
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- bundle exec rspec
|
||||
|
||||
rubocop:
|
||||
stage: test
|
||||
script:
|
||||
- bundle exec rspec
|
||||
|
||||
release:
|
||||
stage: release
|
||||
only:
|
||||
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
||||
except:
|
||||
- branches
|
||||
script:
|
||||
- gem build
|
||||
artifacts:
|
||||
name: "wag-$CI_COMMIT_TAG.gem"
|
||||
paths:
|
||||
- wag-*.gem
|
1
.tool-versions
Normal file
1
.tool-versions
Normal file
|
@ -0,0 +1 @@
|
|||
ruby 3.1.2
|
|
@ -59,6 +59,7 @@ GEM
|
|||
unicode-display_width (2.4.2)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-22
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
|
|
12
README.md
12
README.md
|
@ -7,8 +7,8 @@ It is closely modeled after WAT, the WebAssembly text format, and at this stage
|
|||
generates WAT and compiles and validates it using [the WebAssembly Binary Toolkit][1].
|
||||
|
||||
Due to the flexibility of WAT this library is very flexible in what structures
|
||||
it allows you to create. Be aware that you can build modules which are not
|
||||
valid WASM. Always validate your modules by using `#to_wasm.valid?`.
|
||||
it allows you to create. Be aware that you can build modules which are not
|
||||
valid WASM. Always validate your modules by using `#to_wasm.valid?`.
|
||||
|
||||
## Keyword conflict
|
||||
|
||||
|
@ -20,7 +20,7 @@ of `public_send`, etc.
|
|||
## Folding
|
||||
|
||||
WAG supports generating both the "folded" and "unfolded" variants of the WAT
|
||||
language. As an example here are two implementations of Euclid's Greatest
|
||||
language. As an example here are two implementations of Euclid's Greatest
|
||||
Common Divisor algorithm:
|
||||
|
||||
### Example of unfolded generation
|
||||
|
@ -68,6 +68,7 @@ end
|
|||
```
|
||||
|
||||
### Example of folded generation
|
||||
|
||||
```ruby
|
||||
folded = WAG::Module.new.build do
|
||||
func(:gcd) do
|
||||
|
@ -154,7 +155,6 @@ Or install it yourself as:
|
|||
|
||||
$ gem install wag
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
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.
|
||||
|
@ -163,7 +163,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|||
|
||||
## Contributing
|
||||
|
||||
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/jimsy/wag.
|
||||
Bug reports and pull requests are welcome at https://code.harton.nz/james/wag.
|
||||
|
||||
## License
|
||||
|
||||
|
@ -172,7 +172,7 @@ This software is licensed under the terms of the
|
|||
this package for the terms.
|
||||
|
||||
This license actively proscribes this software being used by and for some
|
||||
industries, countries and activities. If your usage of this software doesn't
|
||||
industries, countries and activities. If your usage of this software doesn't
|
||||
comply with the terms of this license, then [contact me](mailto:james@harton.nz)
|
||||
with the details of your use-case to organise the purchase of a license - the
|
||||
cost of which may include a donation to a suitable charity or NGO.
|
||||
|
|
|
@ -26,7 +26,7 @@ module WAG
|
|||
@desc
|
||||
end
|
||||
|
||||
def table(number, type = :anyfunc, &block)
|
||||
def table(number, type = :funcref, &block)
|
||||
@desc = Table.new(number, type)
|
||||
@desc.instance_exec(&block) if block
|
||||
@desc
|
||||
|
|
|
@ -29,7 +29,7 @@ module WAG
|
|||
@desc
|
||||
end
|
||||
|
||||
def table(number, type = :anyfunc, &block)
|
||||
def table(number, type = :funcref, &block)
|
||||
@desc = Table.new(number, type)
|
||||
@desc.instance_exec(&block) if block
|
||||
@desc
|
||||
|
|
|
@ -76,7 +76,7 @@ module WAG
|
|||
func
|
||||
end
|
||||
|
||||
def table(elements, type = :anyfunc, &block)
|
||||
def table(elements, type = :funcref, &block)
|
||||
table = Table.new(elements, type)
|
||||
@tables << table
|
||||
table.instance_exec(&block) if block
|
||||
|
|
|
@ -5,7 +5,7 @@ module WAG
|
|||
include WAG::Encodable
|
||||
attr_reader :elements, :type
|
||||
|
||||
def initialize(elements, type = :anyfunc)
|
||||
def initialize(elements, type = :funcref)
|
||||
@elements = elements
|
||||
@type = type
|
||||
end
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"extends": ["gitlab>jimsy/renovate"]
|
||||
}
|
|
@ -45,7 +45,7 @@ RSpec.describe 'WAT code generation' do
|
|||
|
||||
memory(:mem, 1)
|
||||
|
||||
table(16, :anyfunc)
|
||||
table(16, :funcref)
|
||||
|
||||
elem(0, :dead, :dead, :dead, :alive, :dead, :dead, :dead, :dead,
|
||||
:dead, :dead, :dead, :alive, :alive, :dead, :dead, :dead,
|
||||
|
|
|
@ -19,12 +19,12 @@ RSpec.describe WAG::Export do
|
|||
|
||||
describe 'When exporting a table' do
|
||||
before do
|
||||
export.table(1, :anyfunc)
|
||||
export.table(1, :funcref)
|
||||
end
|
||||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:export, 'marty', [:table, 1, :anyfunc]] }
|
||||
it { is_expected.to eq [:export, 'marty', [:table, 1, :funcref]] }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@ RSpec.describe WAG::Import do
|
|||
|
||||
describe 'When importing a table' do
|
||||
before do
|
||||
import.table(1, :anyfunc)
|
||||
import.table(1, :funcref)
|
||||
end
|
||||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :anyfunc]] }
|
||||
it { is_expected.to eq [:import, 'marty', 'mcfly', [:table, 1, :funcref]] }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ RSpec.describe WAG::Module do
|
|||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:module, [:table, 16, :anyfunc]] }
|
||||
it { is_expected.to eq [:module, [:table, 16, :funcref]] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,6 @@ RSpec.describe WAG::Table do
|
|||
|
||||
describe '#to_sexpr' do
|
||||
subject { super().to_sexpr }
|
||||
it { is_expected.to eq [:table, elements, :anyfunc] }
|
||||
it { is_expected.to eq [:table, elements, :funcref] }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,19 +6,19 @@ Gem::Specification.new do |spec|
|
|||
spec.name = 'wag'
|
||||
spec.version = WAG::VERSION
|
||||
spec.authors = ['James Harton']
|
||||
spec.email = ['james@automat.nz']
|
||||
spec.email = ['james@harton.nz']
|
||||
|
||||
spec.summary = 'WebAssembly Generator'
|
||||
spec.description = 'Generate and compile WebAssembly code from Ruby'
|
||||
spec.homepage = 'https://gitlab.com/jimsy/wag'
|
||||
spec.homepage = 'https://code.harton.nz/james/wag'
|
||||
spec.license = 'Hippocratic'
|
||||
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
||||
|
||||
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
||||
|
||||
spec.metadata['homepage_uri'] = spec.homepage
|
||||
spec.metadata['source_code_uri'] = 'https://gitlab.com/jimsy/wag'
|
||||
spec.metadata['changelog_uri'] = 'https://gitlab.com/jimsy/wag'
|
||||
spec.metadata['source_code_uri'] = 'https://code.harton.nz/james/wag'
|
||||
spec.metadata['changelog_uri'] = 'https://code.harton.nz/james/wag'
|
||||
|
||||
# Specify which files should be added to the gem when it is released. The `git
|
||||
# ls-files -z` loads the files in the RubyGem that have been added into git.
|
||||
|
|
Loading…
Reference in a new issue