项目构建
在了解了默认配置和代码并启动好本地 ICP 网络后,接下来学习如何把示例程序编译为可执行的 WebAssembly 模块
构建步骤:
在命令行中进入 explore_hello 项目目录。
运行下面的命令
dfx build
输出信息如下
Building canisters... Building frontend...
dfx build
命令会在项目的.dfx/local/目录下添加 canisters 目录运行下面的命令检查 dfx build 命令创建的 .dfx/local/canisters/explore_hello 目录包含 WebAssembly 和相关应用文件。
ls -l .dfx/local/canisters/explore_hello/
命令输出
-rw-r--r-- 1 pubs staff 178 Apr 6 14:25 explore_hello.d.ts
-rw-r--r-- 1 pubs staff 41 Apr 6 14:25 explore_hello.did
-rw-r--r-- 1 pubs staff 155 Apr 6 14:25 explore_hello.did.js
-rw-r--r-- 1 pubs staff 142 Apr 6 14:25 explore_hello.js
-rw-r--r-- 1 pubs staff 157613 Apr 6 14:25 explore_hello.wasm
canisters/explore_hello 目录包含如下关键文件:
explore_hello.did 文件包含 main 程序的接口描述
The explore_hello.did.js 文件包含用 JavaScript 描述的程序 Canister 函数接口
The explore_hello.js 文件包含用 JavaScript 描述的程序 Canister 接口
The explore_hello.wasm 包含编译后的 WebAssembly
canisters/explore_hello_assets 目录包含相似的文件,用于描述项目的前端资源。
除了这些目录,dfx build 命令还会创建 idl 目录。
最后更新于
这有帮助吗?