6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Symbol-SDK(JavaScript/TypeScript) ビルド

Last updated at Posted at 2024-10-09

まだ公開されていない SDK 使いたくなりますよね。

実行した環境

  • Ubuntu 22
  • Symbol サーバがビルドできる環境

準備

必要なパッケージをインストール

lark インストール

pip install --user lark

Rust インストール

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

インストール方法を聞かれたら 1 を選択する。

source "$HOME/.cargo/env"
rustc --version

wasm-pack インストール

cargo install wasm-pack

Symbol-SDK ビルド

クローン

git clone https://github.com/symbol/symbol.git

ビルド

cd symbol/sdk/javascript/
npm i
./scripts/ci/build.sh

rustc 1.82.0 だと失敗する

Error: failed to execute `wasm-opt`: exited with exit status: 1
  full command: "/home/harvestasya/.cache/.wasm-pack/wasm-opt-1ceaaea8b7b5f7e0/bin/wasm-opt" "/home/harvestasya/symbol-repo/symbol_dev/sdk/javascript/_build/wasm/node/symbol_crypto_wasm_bg.wasm" "-o" "/home/harvestasya/symbol-repo/symbol_dev/sdk/javascript/_build/wasm/node/symbol_crypto_wasm_bg.wasm-opt.wasm" "-O"
To disable `wasm-opt`, add `wasm-opt = false` to your package metadata in your `Cargo.toml`.

1.81.0に変更する。

toolchain listを確認する。

$ rustup toolchain list
stable-x86_64-unknown-linux-gnu (default)

1.81.0をインストールしてデフォルトを変更する。

rustup toolchain add 1.81.0
rustup default 1.81.0-x86_64-unknown-linux-gnu

デフォルトが1.81.0になったことを確認する。

$ rustup toolchain list
stable-x86_64-unknown-linux-gnu
1.81.0-x86_64-unknown-linux-gnu (default)

このままだと、またstableに戻されるのでscripts/ci/build.shを編集する。
rustup default stableをコメントアウト。

scripts/ci/build.sh
#!/bin/bash

set -ex

bash scripts/run_catbuffer_generator.sh dryrun
bash scripts/run_catbuffer_generator_ts.sh dryrun

# build wasm variants
cd wasm
#rustup default stable
wasm-pack build --release --no-typescript --target nodejs --out-dir ../_build/wasm/node
wasm-pack build --release --no-typescript --target web --out-dir ../_build/wasm/web
cd ..

# build frontend webpack
npm run bundle

# build TS bindings
npx tsc -p ./tsconfig/build-bindings.json
npx tsc -p ./tsconfig/check-bindings.json
npx tsc -p ./tsconfig/check-examples.json

再度、scripts/ci/build.shを実行する。

使いたいプロジェクトにインストール

npm i symbol/sdk/javascript/

or

yarn add symbol/sdk/javascript/
6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?