wasify 0.1.1 → 0.1.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 +4 -4
- data/exe/wasify +4 -1
- data/lib/wasify/cmd_runner.rb +1 -1
- data/lib/wasify/deps_manager.rb +69 -29
- data/lib/wasify/version.rb +1 -1
- metadata +3 -4
- data/wasify.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 956439b8cb59f80aaf152c60599eea4fb4946edf6269f61c6ca457fdeef5650f
|
4
|
+
data.tar.gz: 72b83e12f5517a817d74445d94ce62073dd588d6266e70331175e3c9dee04e10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3261f2ad61f94f8cbdcd947f6e4db72735d12ff337a487f3ab7b941a18905e7ba860a8b5e968389572747a53e81e3f6e3a6ae43a15459e3817938667b888f351
|
7
|
+
data.tar.gz: 0c58d216c5d11b85d40107b7e0f5a0593e8cdbf96c246fa8946b858ee578569630b89a1fb73bdc4f2ef7989e28c51d70b23268a917cf7c934adf309456401e11
|
data/exe/wasify
CHANGED
@@ -5,7 +5,10 @@ require 'wasify'
|
|
5
5
|
|
6
6
|
raise 'Wrong number of arguments! Usage: wasify entrypoint.rb' if ARGV.length != 1
|
7
7
|
|
8
|
-
if ARGV[0] ==
|
8
|
+
if ARGV[0] == "-v"
|
9
|
+
require "wasify/version"
|
10
|
+
puts "Wasify version #{Wasify::VERSION}"
|
11
|
+
elsif ARGV[0] == 'prepack'
|
9
12
|
Wasify.prepack
|
10
13
|
else
|
11
14
|
Wasify.pack
|
data/lib/wasify/cmd_runner.rb
CHANGED
data/lib/wasify/deps_manager.rb
CHANGED
@@ -1,52 +1,92 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "fileutils"
|
4
|
+
|
3
5
|
class Wasify
|
4
6
|
# methods finding and copying dependecies
|
5
7
|
class DepsManager
|
6
8
|
def self.get_specs(deps)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
9
|
+
# Bundler internals are annoying to look through. And mostly undocumented.
|
10
|
+
# It's amazing what you can find via "bundle exec irb" and then "Bundler.load".
|
11
|
+
bundler_specs = Bundler.load.requested_specs.to_a
|
12
|
+
|
13
|
+
# By default, Bundler only "installs" git: gems and path: gems partway.
|
14
|
+
# The specification remains dynamic. So if you require "lib/scarpe/version"
|
15
|
+
# in the gemspec, it breaks when vendored, because the specification is
|
16
|
+
# separated from the gem source (like lib/scarpe/version.rb). When
|
17
|
+
# a gem is built and installed, the gemspec is "baked" to a static version,
|
18
|
+
# either Ruby or YAML. But git: and path: gems don't do that. So we
|
19
|
+
# need to bake them ourselves using spec.to_ruby.
|
20
|
+
# (Thanks to Benedikt Deicke, who pointed out to_ruby.)
|
21
|
+
|
22
|
+
spec_contents = {}
|
23
|
+
bundler_specs.each do |spec|
|
24
|
+
next if ["bundler", "wasify"].include?(spec.name)
|
25
|
+
|
26
|
+
spec_contents["#{spec.full_name}.gemspec"] = spec.to_ruby
|
23
27
|
end
|
24
|
-
|
28
|
+
spec_contents
|
25
29
|
end
|
26
30
|
|
27
31
|
def self.get_deps
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
return @all_gems if @all_gems
|
33
|
+
|
34
|
+
@all_gems = {}
|
35
|
+
|
36
|
+
# We don't want to copy random files (e.g. .git directories, .bundle) in a path: or git: gem dir.
|
37
|
+
# But also, Bundler has multiple kinds of specs. Installed baked specs often omit the file list
|
38
|
+
# or cut it down to just executables and top-level README-type files. So we have to do things
|
39
|
+
# differently for installed and non-installed specs :-(
|
40
|
+
specs = Bundler.load.requested_specs.to_a
|
41
|
+
specs.each do |spec|
|
42
|
+
root_path = File.expand_path spec.full_gem_path # Pretty sure the expand is unneeded
|
43
|
+
|
44
|
+
files = case spec
|
45
|
+
when Gem::Specification
|
46
|
+
#puts "#{spec.full_name} is a git: or path: gem"
|
47
|
+
spec.files
|
48
|
+
when Bundler::StubSpecification
|
49
|
+
# The specification file is wrong, but there should be only the right files already installed...
|
50
|
+
#puts "#{spec.full_name} is locally installed"
|
51
|
+
files = :all
|
52
|
+
else
|
53
|
+
raise "Not implemented! Figure out how to get Bundler data from a #{spec.class}!"
|
54
|
+
end
|
55
|
+
|
56
|
+
@all_gems[spec.full_name] = {
|
57
|
+
root: root_path,
|
58
|
+
files: files,
|
59
|
+
}
|
32
60
|
end
|
33
|
-
|
61
|
+
|
62
|
+
@all_gems
|
34
63
|
end
|
35
64
|
|
36
65
|
def self.copy_deps
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
66
|
+
get_deps.each do |gem_name, dep|
|
67
|
+
dest_dir = "./3_2-wasm32-unknown-wasi-full-js/usr/local/lib/ruby/gems/3.2.0/gems/#{gem_name}"
|
68
|
+
if dep[:files] == :all
|
69
|
+
FileUtils.cp_r dep[:root], dest_dir
|
70
|
+
elsif dep[:files].respond_to?(:each)
|
71
|
+
dep[:files].each do |file|
|
72
|
+
src = "#{dep[:root]}/#{file}"
|
73
|
+
dest = "#{dest_dir}/#{file}"
|
74
|
+
FileUtils.mkdir_p File.dirname(dest)
|
75
|
+
#STDERR.puts "cp: #{src.inspect} #{dest.inspect}"
|
76
|
+
FileUtils.cp src, dest
|
77
|
+
end
|
78
|
+
else
|
79
|
+
raise "Unexpected file list object!"
|
80
|
+
end
|
41
81
|
end
|
42
82
|
end
|
43
83
|
|
44
84
|
def self.copy_specs
|
45
85
|
deps = get_deps
|
46
86
|
specs = get_specs(deps)
|
47
|
-
|
48
|
-
|
49
|
-
|
87
|
+
FileUtils.mkdir_p "./3_2-wasm32-unknown-wasi-full-js/usr/local/lib/ruby/gems/3.2.0/specifications/"
|
88
|
+
specs.each do |name, contents|
|
89
|
+
File.write("./3_2-wasm32-unknown-wasi-full-js/usr/local/lib/ruby/gems/3.2.0/specifications/#{name}", contents)
|
50
90
|
end
|
51
91
|
end
|
52
92
|
|
data/lib/wasify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wasify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Borgh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -32,7 +32,6 @@ files:
|
|
32
32
|
- lib/wasify/template.erb
|
33
33
|
- lib/wasify/version.rb
|
34
34
|
- sig/wasify.rbs
|
35
|
-
- wasify.gemspec
|
36
35
|
homepage: https://github.com/AlawysDelta/wasify
|
37
36
|
licenses:
|
38
37
|
- MIT
|
@@ -57,5 +56,5 @@ requirements: []
|
|
57
56
|
rubygems_version: 3.4.1
|
58
57
|
signing_key:
|
59
58
|
specification_version: 4
|
60
|
-
summary: Packs and
|
59
|
+
summary: Packs and runs Ruby code on WASM
|
61
60
|
test_files: []
|
data/wasify.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/wasify/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'wasify'
|
7
|
-
spec.version = Wasify::VERSION
|
8
|
-
spec.authors = ['Giovanni Borgh']
|
9
|
-
spec.email = ['gio96b@gmail.com']
|
10
|
-
|
11
|
-
spec.summary = 'Packs and run Ruby code on WASM'
|
12
|
-
spec.license = 'MIT'
|
13
|
-
spec.homepage = 'https://github.com/AlawysDelta/wasify'
|
14
|
-
spec.required_ruby_version = '>= 3.2.0'
|
15
|
-
|
16
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
-
spec.metadata['source_code_uri'] = 'https://github.com/AlawysDelta/wasify'
|
18
|
-
|
19
|
-
# Specify which files should be added to the gem when it is released.
|
20
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files = Dir.chdir(__dir__) do
|
22
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
23
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
24
|
-
end
|
25
|
-
end
|
26
|
-
spec.bindir = 'exe'
|
27
|
-
spec.executables = ['wasify']
|
28
|
-
spec.require_paths = ['lib']
|
29
|
-
|
30
|
-
# Uncomment to register a new dependency of your gem
|
31
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
32
|
-
|
33
|
-
# For more information and examples about making a new gem, check out our
|
34
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
35
|
-
end
|