|
1 | | -require "rake" |
2 | 1 | require_relative "./product" |
3 | 2 |
|
4 | 3 | module RubyWasm |
5 | 4 | class WasiVfsProduct < BuildProduct |
6 | | - attr_reader :install_task, :cli_install_task |
7 | | - |
8 | 5 | WASI_VFS_VERSION = "0.1.1" |
9 | 6 |
|
10 | 7 | def initialize(build_dir) |
@@ -43,29 +40,25 @@ def name |
43 | 40 | lib_product_build_dir |
44 | 41 | end |
45 | 42 |
|
46 | | - def define_task |
47 | | - file(lib_wasi_vfs_a) do |
48 | | - require "tmpdir" |
49 | | - lib_wasi_vfs_url = |
50 | | - "https://github.com/kateinoigakukun/wasi-vfs/releases/download/v#{WASI_VFS_VERSION}/libwasi_vfs-wasm32-unknown-unknown.zip" |
51 | | - Dir.mktmpdir do |tmpdir| |
52 | | - sh "curl -L #{lib_wasi_vfs_url} -o #{tmpdir}/libwasi_vfs.zip" |
53 | | - sh "unzip #{tmpdir}/libwasi_vfs.zip -d #{tmpdir}" |
54 | | - mkdir_p File.dirname(lib_wasi_vfs_a) |
55 | | - mv File.join(tmpdir, "libwasi_vfs.a"), lib_wasi_vfs_a |
56 | | - end |
| 43 | + def build |
| 44 | + return if !@need_fetch_lib && File.exist?(lib_wasi_vfs_a) |
| 45 | + require "tmpdir" |
| 46 | + lib_wasi_vfs_url = |
| 47 | + "https://github.com/kateinoigakukun/wasi-vfs/releases/download/v#{WASI_VFS_VERSION}/libwasi_vfs-wasm32-unknown-unknown.zip" |
| 48 | + Dir.mktmpdir do |tmpdir| |
| 49 | + system "curl -L #{lib_wasi_vfs_url} -o #{tmpdir}/libwasi_vfs.zip" |
| 50 | + system "unzip #{tmpdir}/libwasi_vfs.zip -d #{tmpdir}" |
| 51 | + FileUtils.mkdir_p File.dirname(lib_wasi_vfs_a) |
| 52 | + FileUtils.mv File.join(tmpdir, "libwasi_vfs.a"), lib_wasi_vfs_a |
57 | 53 | end |
58 | | - lib_install_deps = @need_fetch_lib ? [lib_wasi_vfs_a] : [] |
59 | | - @install_task = task "wasi-vfs:install" => lib_install_deps |
| 54 | + end |
60 | 55 |
|
61 | | - file(cli_bin_path) do |
62 | | - mkdir_p cli_product_build_dir |
63 | | - zipfiel = File.join(cli_product_build_dir, "wasi-vfs-cli.zip") |
64 | | - sh "curl -L -o #{zipfiel} #{self.cli_download_url}" |
65 | | - sh "unzip #{zipfiel} -d #{cli_product_build_dir}" |
66 | | - end |
67 | | - cli_install_deps = @need_fetch_cli ? [cli_bin_path] : [] |
68 | | - @cli_install_task = task "wasi-vfs-cli:install" => cli_install_deps |
| 56 | + def install_cli |
| 57 | + return if !@need_fetch_cli && File.exist?(cli_bin_path) |
| 58 | + FileUtils.mkdir_p cli_product_build_dir |
| 59 | + zipfile = File.join(cli_product_build_dir, "wasi-vfs-cli.zip") |
| 60 | + system "curl -L -o #{zipfile} #{self.cli_download_url}" |
| 61 | + system "unzip #{zipfile} -d #{cli_product_build_dir}" |
69 | 62 | end |
70 | 63 |
|
71 | 64 | def cli_download_url |
|
0 commit comments