From 717052f81bb02f423561bfd9be2acd43840c8791 Mon Sep 17 00:00:00 2001 From: "hongwei.li" Date: Wed, 6 Jul 2022 15:02:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/compile.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 doc/compile.md diff --git a/doc/compile.md b/doc/compile.md new file mode 100644 index 0000000..824e539 --- /dev/null +++ b/doc/compile.md @@ -0,0 +1,43 @@ +# 编译指南 + +## 1. 编译环境准备 + +1. 安装 `Rust`。通过 `rustup` 下载 `Rust`,这是一个管理 `Rust` 版本和相关工具的命令行工具。 +2. 安装 `Rust` 编译器 。本项目采用的编译器是 `rustc 1.61.0-nightly` 。这里需要强调的是 `nightly` 版本的是官方用来实验新功能的 **不稳定版本** 。此项目用到了很多 `Rust` 的 **不稳定特性**,因此只能选择 `nightly`。 +3. 安装 `Cargo`,这是 `Rust` 的构建系统和包管理器,大多数 `Rustacean` 们使用 `Cargo` 来管理他们的 `Rust` 项目,它可以帮你处理很多任务,比如构建代码,下载依赖库并编译这些库。 +4. 使用 `Cargo` 编译本项目。`cargo build` 编译一个包,`cargo check` 检查本地包及其所有依赖项是否有错误,`cargo clean` 删除 `Cargo` 过去生成的文件。`cargo build --release` 表示构建带有优化的包。 + +## 2. 项目目录结构说明 + +- `async-task` + - `src` 异步任务抽象实现 + +## 3. 条件编译 + +### 3.1. 通过配置 `Cargo.toml` 配置文件可以实现条件编译 + +``` toml +[features] +# default 字段配置了默认启动哪些 feature。每一个 feature 都是一个列表,列表中的项表示将依赖于哪些 feature。 +# default = ["signle_thread", "alloc"] 表示默认依赖于 alloc 和 signle_thread 。而 alloc 又依赖于 stdlib/alloc 库,默认为 NO-STD 编译。 +# 若将 default = ["alloc"] 修改为 default = ["std"] 则表示依赖依赖项中包含 rust STD。 +# 注意事项:不能同时开启 alloc 和 std。编译时只能选择其中一个。即 default = ["alloc","std"] 是错误的,无法编译。 +default = ["signle_thread", "alloc"] +alloc = ["stdlib/alloc"] +std = ["stdlib/std"] +multiple_thread = [] +signle_thread = [] +``` + +### 3.2. 通过`Cargo`命令实现条件编译 + +```shell +# 注意事项:不能同时开启 alloc 和 std。编译时只能选择其中一个。即 cargo build --no-default-features --features "signle_thread alloc std" 是错误的,无法编译。 +# STD 编译 +# --no-default-features 表示不开启默认 features ,--features "std" 会依赖用户列出的 features,也就是 std。 +cargo build --no-default-features --features "std" +# NO-STD +# --no-default-features 表示不开启默认 features ,--features "signle_thread alloc" 会依赖用户列出的 features,也就是signle_thread 和 alloc。 +cargo build --no-default-features --features "signle_thread alloc" +``` + -- Gitee From e2b8e8a7864fd167a13d5d8f20e666ada78ffff1 Mon Sep 17 00:00:00 2001 From: "hongwei.li" Date: Wed, 6 Jul 2022 17:07:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?Cargo.toml=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=B0=86=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E7=9B=B8=E5=AF=B9=E5=9C=B0=E5=9D=80=E4=BE=9D=E8=B5=96=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAgit=E5=9C=B0=E5=9D=80=E3=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0c03bc3..ebac0eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ debug = [] [dependencies] cfg-if = "1.0.0" -stdlib = { path = "../stdlib", default-features = false } +stdlib = { git = "https://gitee.com/iot-ua/stdlib", default-features = false,branch="develop"} [profile.dev] panic = "abort" [profile.release] -- Gitee From 277b8d242c88c0c713aa25a5549b70d0ad7b19d1 Mon Sep 17 00:00:00 2001 From: "hongwei.li" Date: Wed, 6 Jul 2022 17:18:01 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Cargo.toml=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=B0=86=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E7=9B=B8=E5=AF=B9=E5=9C=B0=E5=9D=80=E4=BE=9D=E8=B5=96=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAgit=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++++- doc/compile.md | 43 ------------------------------------------- 3 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 doc/compile.md diff --git a/Cargo.toml b/Cargo.toml index ebac0eb..49aef4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ debug = [] [dependencies] cfg-if = "1.0.0" -stdlib = { git = "https://gitee.com/iot-ua/stdlib", default-features = false,branch="develop"} +stdlib = { git = "https://gitee.com/iot-ua/stdlib.git", default-features = false,branch="develop"} [profile.dev] panic = "abort" [profile.release] diff --git a/README.md b/README.md index cf01200..c04ffd3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,48 @@ # async-task -#### 介绍 +#### 1. 介绍 构建执行器的任务抽象,代表异步任务的运行状态。 +#### 2. 编译指南 + +##### 2.1. 编译环境准备 + +1. 安装 `Rust`。通过 `rustup` 下载 `Rust`,这是一个管理 `Rust` 版本和相关工具的命令行工具。 +2. 安装 `Rust` 编译器 。本项目采用的编译器是 `rustc 1.61.0-nightly` 。这里需要强调的是 `nightly` 版本的是官方用来实验新功能的 **不稳定版本** 。此项目用到了很多 `Rust` 的 **不稳定特性**,因此只能选择 `nightly`。 +3. 安装 `Cargo`,这是 `Rust` 的构建系统和包管理器,大多数 `Rustacean` 们使用 `Cargo` 来管理他们的 `Rust` 项目,它可以帮你处理很多任务,比如构建代码,下载依赖库并编译这些库。 +4. 使用 `Cargo` 编译本项目。`cargo build` 编译一个包,`cargo check` 检查本地包及其所有依赖项是否有错误,`cargo clean` 删除 `Cargo` 过去生成的文件。`cargo build --release` 表示构建带有优化的包。 + +##### 2.2. 项目目录结构说明 + +- `async-task` + - `src` 异步任务抽象实现 + +##### 2.3. 条件编译 + +###### 2.3.1. 通过配置 `Cargo.toml` 配置文件可以实现条件编译 + +``` toml +[features] +# default 字段配置了默认启动哪些 feature。每一个 feature 都是一个列表,列表中的项表示将依赖于哪些 feature。 +# default = ["signle_thread", "alloc"] 表示默认依赖于 alloc 和 signle_thread 。而 alloc 又依赖于 stdlib/alloc 库,默认为 NO-STD 编译。 +# 若将 default = ["alloc"] 修改为 default = ["std"] 则表示依赖依赖项中包含 rust STD。 +# 注意事项:不能同时开启 alloc 和 std。编译时只能选择其中一个。即 default = ["alloc","std"] 是错误的,无法编译。 +default = ["signle_thread", "alloc"] +alloc = ["stdlib/alloc"] +std = ["stdlib/std"] +multiple_thread = [] +signle_thread = [] +``` + +###### 2.3.2. 通过`Cargo`命令实现条件编译 + +```shell +# 注意事项:不能同时开启 alloc 和 std。编译时只能选择其中一个。即 cargo build --no-default-features --features "signle_thread alloc std" 是错误的,无法编译。 +# STD 编译 +# --no-default-features 表示不开启默认 features ,--features "std" 会依赖用户列出的 features,也就是 std。 +cargo build --no-default-features --features "std" +# NO-STD +# --no-default-features 表示不开启默认 features ,--features "signle_thread alloc" 会依赖用户列出的 features,也就是signle_thread 和 alloc。 +cargo build --no-default-features --features "signle_thread alloc" +``` + diff --git a/doc/compile.md b/doc/compile.md deleted file mode 100644 index 824e539..0000000 --- a/doc/compile.md +++ /dev/null @@ -1,43 +0,0 @@ -# 编译指南 - -## 1. 编译环境准备 - -1. 安装 `Rust`。通过 `rustup` 下载 `Rust`,这是一个管理 `Rust` 版本和相关工具的命令行工具。 -2. 安装 `Rust` 编译器 。本项目采用的编译器是 `rustc 1.61.0-nightly` 。这里需要强调的是 `nightly` 版本的是官方用来实验新功能的 **不稳定版本** 。此项目用到了很多 `Rust` 的 **不稳定特性**,因此只能选择 `nightly`。 -3. 安装 `Cargo`,这是 `Rust` 的构建系统和包管理器,大多数 `Rustacean` 们使用 `Cargo` 来管理他们的 `Rust` 项目,它可以帮你处理很多任务,比如构建代码,下载依赖库并编译这些库。 -4. 使用 `Cargo` 编译本项目。`cargo build` 编译一个包,`cargo check` 检查本地包及其所有依赖项是否有错误,`cargo clean` 删除 `Cargo` 过去生成的文件。`cargo build --release` 表示构建带有优化的包。 - -## 2. 项目目录结构说明 - -- `async-task` - - `src` 异步任务抽象实现 - -## 3. 条件编译 - -### 3.1. 通过配置 `Cargo.toml` 配置文件可以实现条件编译 - -``` toml -[features] -# default 字段配置了默认启动哪些 feature。每一个 feature 都是一个列表,列表中的项表示将依赖于哪些 feature。 -# default = ["signle_thread", "alloc"] 表示默认依赖于 alloc 和 signle_thread 。而 alloc 又依赖于 stdlib/alloc 库,默认为 NO-STD 编译。 -# 若将 default = ["alloc"] 修改为 default = ["std"] 则表示依赖依赖项中包含 rust STD。 -# 注意事项:不能同时开启 alloc 和 std。编译时只能选择其中一个。即 default = ["alloc","std"] 是错误的,无法编译。 -default = ["signle_thread", "alloc"] -alloc = ["stdlib/alloc"] -std = ["stdlib/std"] -multiple_thread = [] -signle_thread = [] -``` - -### 3.2. 通过`Cargo`命令实现条件编译 - -```shell -# 注意事项:不能同时开启 alloc 和 std。编译时只能选择其中一个。即 cargo build --no-default-features --features "signle_thread alloc std" 是错误的,无法编译。 -# STD 编译 -# --no-default-features 表示不开启默认 features ,--features "std" 会依赖用户列出的 features,也就是 std。 -cargo build --no-default-features --features "std" -# NO-STD -# --no-default-features 表示不开启默认 features ,--features "signle_thread alloc" 会依赖用户列出的 features,也就是signle_thread 和 alloc。 -cargo build --no-default-features --features "signle_thread alloc" -``` - -- Gitee