Skip to content

Commit

Permalink
[doc] support vcpkg, simply install document
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Feb 2, 2024
1 parent f49395f commit 7bbefb1
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 69 deletions.
100 changes: 61 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,67 @@ and the traditional Future/Promise.

We can try async_simple online in [compiler-explorer](compiler-explorer.com): https://compiler-explorer.com/z/Tdaesqsqj . Note that `Uthread` cannot be use in compiler-explorer since it requires installation.

# Install Dependencies
# Get Started

Our documents are hosted by GitHub Pages, [go to Get Started](https://alibaba.github.io/async_simple/docs.en/GetStarted.html).

After installing and reading [Lazy](./docs/docs.en/Lazy.md) to get familiar with API, here is a [demo](./docs/docs.en/GetStarted.md) use Lazy to count char in a file.

# Install async_simple

## By Vcpkg

vcpkg is a [cross-platform package manager](https://vcpkg.io/en/getting-started).

```
./vcpkg install async-simple
```

## By Cmake

```
git clone -b main --single-branch --depth 1 https://github.com/alibaba/async_simple.git
cd async_simple
mkdir build
cd build
cmake .. -DASYNC_SIMPLE_ENABLE_TESTS=OFF -DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF -DASYNC_SIMPLE_ENABLE_ASAN=OFF
cmake --build .
cmake --install . # --prefix ./user_defined_install_path
```

# Import async_simple

After install async_simple, you can import it to your project.

## By cmake find_package

please add those cmake codes:

```cmake
find_package(async_simple REQUIRED)
target_link_libraries(<your-target-name> PRIVATE async_simple::async_simple) # dynamic_link
# async_simple::async_simple_header_only
# async_simple::async_simple_static
```
`<your-target-name>` is the target name which want to use async_simple

## Manully

async_simple is almost header-only. So you can just pass the include path of the install position to your compiler.

But the uthread part of async_simple is not head-only. If you want to use uthread, You need link it manully. The library file is in the install path.

# Compiler Requirement

Required Compiler: clang (>= 10.0.0) or gcc (>= 10.3) or Apple-clang (>= 14)

Note that we need to add the `-Wno-maybe-uninitialized` option when we use gcc 12 due to a false positive diagnostic message by gcc 12

Note that when using clang 15 it may be necessary to add the `-Wno-unsequenced` option, which is a false positive of clang 15. See https://github.com/llvm/llvm-project/issues/56768 for details.

If you meet any problem about MSVC Compiler Error C4737. Try to add the /EHa option to fix the problem.

# Develop async_simple

The build of async_simple requires libaio, googletest and cmake. Both libaio and googletest
are optional. (Testing before using is highly suggested.)
Expand Down Expand Up @@ -113,15 +173,6 @@ mkdir build && cd build
cmake .. && sudo make install
```

## Compiler Requirement

Required Compiler: clang (>= 10.0.0) or gcc (>= 10.3) or Apple-clang (>= 14)

Note that we need to add the `-Wno-maybe-uninitialized` option when we use gcc 12 due to a false positive diagnostic message by gcc 12

Note that when using clang 15 it may be necessary to add the `-Wno-unsequenced` option, which is a false positive of clang 15. See https://github.com/llvm/llvm-project/issues/56768 for details.

If you meet any problem about MSVC Compiler Error C4737. Try to add the /EHa option to fix the problem.

## Demo example dependency

Expand Down Expand Up @@ -180,35 +231,6 @@ docker build . --no-cache -t async_simple:1.0
docker run -it --name async_simple async_simple:1.0 /bin/bash
```

# Import

After install async_simple, you can import it to your project.

## Manully

async_simple is almost header-only. So you can just pass the include path of the install position to your compiler.

But the uthread part of async_simple is not head-only. If you want to use uthread, You need link it manully. The library file is in the install path.

## By cmake find_package

please add those cmake codes:

```cmake
find_package(async_simple REQUIRED)
target_link_libraries(<your-target-name> PRIVATE async_simple::async_simple) # dynamic_link
# async_simple::async_simple_header_only
# async_simple::async_simple_static
```
`<your-target-name>` is the target name which want to use async_simple


# Get Started

Our documents are hosted by GitHub Pages, [go to Get Started](https://alibaba.github.io/async_simple/docs.en/GetStarted.html).

After installing and reading [Lazy](./docs/docs.en/Lazy.md) to get familiar with API, here is a [demo](./docs/docs.en/GetStarted.md) use Lazy to count char in a file.

# Performance

We also give a [Quantitative Analysis Report](docs/docs.en/QuantitativeAnalysisReportOfCoroutinePerformance.md) of
Expand Down
84 changes: 54 additions & 30 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,68 @@ async\_simple是阿里巴巴开源的轻量级C++异步框架。提供了基于C

我们可以在 [compiler-explorer](compiler-explorer.com) 中在线快速体验 async_simple: https://compiler-explorer.com/z/Tdaesqsqj . 注意 `Uthread` 在 compiler-explorer 中不能使用。

# 准备环境
# 快速入门

async\_simple 涉及 C++20 协程,对编译器版本有较高要求。需要 clang10 或 gcc10 或 Apple-clang14 及其以上版本。编译运行测试需要 gtest,使用`bazel`可自动拉取gtest。需要 libaio 的功能的需要依赖 libaio。
我们的文档托管在GitHub Pages上,[点击进入快速开始](https://alibaba.github.io/async_simple/docs.cn/GetStarted.html).

接下来可以阅读更多API文档,例如C++20协程([Lazy](./docs/docs.cn/Lazy.md))。熟悉async\_simple组件,可以先跟着[Demo](./docs/docs.cn/GetStarted.md)用C++20协程来实现异步统计文件字符数功能。

更多文档介绍见目录[docs](./docs/docs.cn)

# 安装async_simple

## 使用vcpkg安装

```
./vcpkg install async-simple
```

## 使用cmake安装

```
git clone -b main --single-branch --depth 1 https://github.com/alibaba/async_simple.git
cd async_simple
mkdir build
cd build
cmake .. -DASYNC_SIMPLE_ENABLE_TESTS=OFF -DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF -DASYNC_SIMPLE_ENABLE_ASAN=OFF
cmake --build .
cmake --install . # --prefix ./user_defined_install_path
```

# 导入

当你安装完async_simple以后,你可以在你的项目里导入async_simple。

## 通过cmake find_package
请在项目中添加以下cmake代码:
```cmake
find_package(async_simple REQUIRED)
target_link_libraries(<your-target-name> PRIVATE async_simple::async_simple) # dynamic_link
# async_simple::async_simple_header_only
# async_simple::async_simple_static
```
其中,`<your-target-name>` 是你需要使用async_simple的target名

## 手动导入

async_simple几乎是header-only的. 因此你只需要将安装的include路径传递给编译器即可。

但是async_simple的uthread模块不是header-only的,如果你要使用uthread,我们在安装路径下生成了编译好的库文件,你需要手动链接它。

# 编译器约束

async\_simple 涉及 C++20 协程,对编译器版本有较高要求。需要 clang10 或 gcc10 或 Apple-clang14 及其以上版本。

注意当使用 gcc12 时需要加上 `-Wno-maybe-uninitialized` 选项因为 gcc12 的一个误报。详情可见 https://github.com/alibaba/async_simple/issues/234。

注意当使用 clang15 时可能需要加上 `-Wno-unsequenced` 选项,这是clang15的一个误报。详情可见 https://github.com/llvm/llvm-project/issues/56768。

注意,如果使用msvc时遇到了C4737错误,请加上选项/EHa。

# 开发async_simple

本项目编译运行测试需要 gtest和gmock,需要 libaio 的示例代码则依赖 libaio。

## Debian/Ubuntu系列

- 安装clang11及其以上版本。安装方法见:[APT Packages](https://apt.llvm.org/)
Expand Down Expand Up @@ -173,34 +225,6 @@ docker build . --no-cache -t async_simple:1.0
docker run -it --name async_simple async_simple:1.0 /bin/bash
```

## 导入

当你安装完async_simple以后,你可以在你的项目里导入async_simple。

## 手动导入

async_simple几乎是header-only的. 因此你只需要将安装的include路径传递给编译器即可。

但是async_simple的uthread模块不是header-only的,如果你要使用uthread,我们在安装路径下生成了编译好的库文件,你需要手动链接它。

## 通过cmake find_package
请添加以下cmake代码:
```cmake
find_package(async_simple REQUIRED)
target_link_libraries(<your-target-name> PRIVATE async_simple::async_simple) # dynamic_link
# async_simple::async_simple_header_only
# async_simple::async_simple_static
```
其中,`<your-target-name>` 是你需要使用async_simple的target名

# 更多示例

我们的文档托管在GitHub Pages上,[点击进入快速开始](https://alibaba.github.io/async_simple/docs.cn/GetStarted.html).

接下来可以阅读更多API文档,例如C++20协程([Lazy](./docs/docs.cn/Lazy.md))。熟悉async\_simple组件,可以先跟着[Demo](./docs/docs.cn/GetStarted.md)用C++20协程来实现异步统计文件字符数功能。

更多文档介绍见目录[docs](./docs/docs.cn)

# 性能相关

关于基于C++20无栈协程(Lazy)和有栈协程(Uthread)的性能定量分析,详见[定量分析报告](./docs/docs.cn/基于async_simple的协程性能定量分析.md)
Expand Down

0 comments on commit 7bbefb1

Please sign in to comment.