Sway编程语言-更新中(The Sway Programming Language-Updatin
  • Sway编程语言(The Sway Programming Language)
  • 1. 导言(Introduction)
    • 1.1 安装(Installation)
    • 1.2 Sway快速入门 (Sway Quickstart)
    • 1.3 Fuel工具链 (The Fuel Toolchain)
    • 1.4 一个Forc项目 (A Forc Project)
    • 1.5 标准库 (Standard Library)
  • 2. 示例(Example)
    • 2.1计数器(Counter)
    • 2.2子货币(Subcurrency)
    • 2.3 FizzBuzz
    • 2.4 钱包智能合约(Wallet Smart Contract)
  • 3.Sway编程类型(Sway Program Types)
    • 3.1 合约(Contracts)
    • 3.2 库 (Libraries)
    • 3.3 脚本(Scripts)
    • 3.4 谓词 (Predicates)
  • 4. Sway语言基础 (Sway Language basics)
    • 4.1 变量 (Variables)
    • 4.2 内置类型(Built-in Types)
    • 4.3 常用库类型(Commonly Used Library Types)
    • 4.4 区块链类 (Blockchain Types)
    • 4.5 函数 (Functions)
    • 4.6 结构、元祖和穷举 (Structs, Tuples, and Enums)
    • 4.7 方法和关联函数 (Methods and Associated Functions)
    • 4.8 注释和日志 (Comments and Logging)
    • 4.9 控制流 (Control Flow)
  • 5. 用Sway部署区块链 (Blockchain Development with Sway)
    • 5.1 哈希和加密学 (Hashing and Cryptography)
    • 5.2 合约存储(Contract Storage)
    • 5.3 函数纯度 (Function Purity)
    • 5.4 标识符(Identifiers)
    • 5.5 原生资产(Native Assets)
    • 5.6 访问控制 (Access Control)
    • 5.7 调用合约(Calling Contracts)
  • 6. 高级概念 (Advanced Concepts)
    • 6.1 高级类型 (Advanced Types)
    • 6.2 通用类型 (Generic Types)
    • 6.3 特征 (Traits)
    • 6.4 集 (Assembly)
  • 7. 一般集聚 (Common Collections)
    • 7.1 堆上的向量(Vectors on the Heap)
    • 7.2 存储向量 (Storage Vectors)
    • 7.3 存储映射 (Storage Maps)
  • 8.测试(Testing)
    • 8.1 单元测试(Unit Testing)
    • 8.2 用Rust来测试 (Testing with Rust)
  • 9.应用前端开发 (Application Frontend Development)
    • 9.1 TypeScript SDK
  • 10.Sway应用(Sway Reference)
    • 10.1 编译器内部函数(Compiler Intrinsics)
    • 10.2 属性(Attributes)
    • 10.3 风格向导(Style Guide)
    • 10.4 已知各类问题(Known Issues and Workarounds)
    • 10.5 与Solidity的不同之处 (Differences From Solidity)
    • 10.6 与Rust的不同之处 (Differences From Rust)
    • 10.7 向Sway贡献 (Contributing To Sway)
  • 11. Forc引用 (Forc Reference)
    • 11.1清单参考 (Manifest Reference)
    • 11.2 工作区(Workspaces)
    • 11.3 依赖(Dependencies)
    • 11.4 命令(Commands)
      • 11.4.1 forc-addr2line
      • 11.4.2 forc-build
      • 11.4.3 forc-check
Powered by GitBook
On this page
  • 成员 members 字段(The members field)
  • [patch 补丁] 部分 (The [patch] section)
  • 一些支持工作区的forc命令 (Some forc commands that support workspaces)
  1. 11. Forc引用 (Forc Reference)

11.2 工作区(Workspaces)

A workspace is a collection of one or more packages, namely workspace members, that are managed together.

workspace 是一个或多个包的集合,即一起进行管理的 workspace 成员。

The key points for workspaces are: 工作区的要点是:

  • Common forc commands available for a single package can also be used for a workspace, like forc build or forc deploy. 适用于单个包的常见forc命令也可用于工作区,例如forc build或forc deploy。

  • All packages share a common Forc.lock file which resides in the root directory of the workspace. 所有包共享一个通用的Forc.lock文件,该文件位于工作区的根目录中。

Workspace manifests are declared within Forc.toml files and support the following fields:

工作区清单在Forc.toml文件中声明并支持以下字段:

  • members - Packages to include in the workspace. members - 要包含在工作区中的包。

  • [patch] - Defines the patches. [patch] - 定义补丁。

An empty workspace can be created with forc new --workspace or forc init --workspace.

可以使用forc new --workspace或forc init --workspace创建空工作区。

成员 members 字段(The members field)

The members field defines which packages are members of the workspace:

members字段定义哪些包是工作区的成员:

[workspace]
members = ["member1", "path/to/member2"]

The members field accepts entries to be given in relative path with respect to the workspace root. Packages that are located within a workspace directory but are not contained within the members set are ignored.

members字段接受,相对于工作区根的相对路径而给出的条目。位于工作区目录中但 不 包含在members 成员集中的包将被忽略。

[patch 补丁] 部分 (The [patch] section)

It is not allowed to declare patch table in member of a workspace if the workspace manifest file contains a patch table.

如果工作区清单文件包含补丁表,则不允许在工作区成员中声明补丁表。

Example 举例:

[workspace]
members = ["member1", "path/to/member2"]


[patch.'https://github.com/fuellabs/sway']
std = { git = "https://github.com/fuellabs/sway", branch = "test" }

In the above example each occurance of std as a dependency in the workspace will be changed with std from test branch of sway repo.

在上面的示例中,工作区中作为依赖项出现的每次std都将被 sway 存储库的test分支中的std更改。

一些支持工作区的forc命令 (Some forc commands that support workspaces)

  • forc build - Builds an entire workspace. forc build - 构建整个工作区。

  • forc deploy - Builds and deploys all deployable members (i.e, contracts) of the workspace in the correct order. forc deploy - 按正确的顺序构建和部署工作区的所有可部署成员(即合约)

  • forc run - Builds and runs all scripts of the workspace. forc run - 构建并运行工作区的所有脚本。

  • forc check - Checks all members of the workspace. forc check - 检查工作区的所有成员。

  • forc update - Checks and updates workspace level Forc.lock file that is shared between workspace members. forc update - 检查并更新在工作区成员之间,共享的工作区级别Forc.lock文件。

  • forc clean - Cleans all output artifacts for each member of the workspace. forc clean - 清除工作区每个成员的所有输出工件。

  • forc fmt - Formats all members of a workspace. forc fmt - 格式化工作区的所有成员。

Previous11.1清单参考 (Manifest Reference)Next11.3 依赖(Dependencies)

Last updated 1 year ago

The [patch] section can be used to override any dependency in the workspace dependency graph. The usage is the same with package level [patch] section and details can be seen .

[patch]部分可用于覆盖工作区依赖关系图中的任何依赖。用法与包级别的[patch]部分相同,详细信息可以参见。

here
此处