Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,25 @@ jobs:
- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y cmake g++ ninja-build
sudo apt-get install -y cmake g++-14 ninja-build ccache
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-14 100
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 100

- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-host-${{ github.run_id }}
restore-keys: |
ccache-host-

- name: Build host examples
run: python3 scripts/build_examples.py --host
run: |
export CCACHE_DIR="$HOME/.cache/ccache"
mkdir -p "$CCACHE_DIR"
python3 scripts/build_examples.py --host

build-stm32:
name: STM32 Examples
Expand All @@ -45,7 +60,18 @@ jobs:
- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi ninja-build
sudo apt-get install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi ninja-build ccache

- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-stm32-${{ github.run_id }}
restore-keys: |
ccache-stm32-

- name: Build STM32 examples
run: python3 scripts/build_examples.py --stm32
run: |
export CCACHE_DIR="$HOME/.cache/ccache"
mkdir -p "$CCACHE_DIR"
python3 scripts/build_examples.py --stm32
15 changes: 0 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ build/
**/build/
*.build/

# CMake
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile
*.cmake
!CMakeLists.txt

# Compiled binaries
*.o
*.a
*.so
*.exe
*.out

# MkDocs build output
site/

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## 特色亮点

- **系统化学习路径** -- 8 卷从入门到高级,每卷有明确前置知识,循序渐进
- **系统化学习路径** -- 9 卷从入门到高级,每卷有明确前置知识,循序渐进
- **实战驱动** -- 每个概念配合可编译的 CMake 项目,而非孤立代码片段
- **多平台覆盖** -- STM32 / ESP32 / RP2040 嵌入式实战,不止于桌面端
- **标签导航** -- 按主题、C++ 标准、难度、平台等维度检索文章
Expand All @@ -32,6 +32,8 @@ graph LR
V2 --> V3["卷三 标准库"] & V4["卷四 高级"] & V5["卷五 并发"] & V6["卷六 性能"] & V7["卷七 工程"]
V2 --> V8["卷八 领域应用"]
V8 --> E["嵌入式"] & N["网络"] & G["GUI"] & D["数据"] & A["算法"]
V2 --> V9["卷九 开源项目学习"]
V9 --> OC["Chrome 代码研读"] & OS["其他开源项目"]
```

### 教程结构
Expand All @@ -46,6 +48,7 @@ graph LR
| 六 | [性能优化](documents/vol6-performance/) -- CPU 缓存、SIMD、汇编阅读、基准测试 | 18-22 | advanced | 规划中 |
| 七 | [软件工程实践](documents/vol7-engineering/) -- CMake、测试、静态分析、DevOps | 30-35 | intermediate | 规划中 |
| 八 | [领域应用](documents/vol8-domains/) -- 嵌入式 / 网络 / GUI / 数据存储 / 算法 | 80-100 | intermediate | 编写中 |
| 九 | [开源项目学习](documents/vol9-open-source-project-learn/) -- 开源项目代码研读 | 13+ | intermediate | 编写中 |
| - | [编译与链接深入](documents/compilation/) -- 预处理、汇编、链接、调试符号 | 10+ | intermediate | 已完成 |
| - | [贯穿式实战项目](documents/projects/) -- 手写 STL、迷你 HTTP 服务器、嵌入式 OS | - | advanced | 规划中 |

Expand Down Expand Up @@ -151,6 +154,7 @@ Tutorial_AwesomeModernCPP/
│ │ ├── gui-graphics/ # GUI 与图形
│ │ ├── data-storage/ # 数据存储
│ │ └── algorithms/ # 算法与数据结构
│ ├── vol9-open-source-project-learn/ # 卷九:开源项目学习
│ ├── compilation/ # 编译与链接深入
│ ├── projects/ # 贯穿式实战项目
│ └── index.md # 教程首页
Expand Down
14 changes: 14 additions & 0 deletions code/volumn_codes/vol9/chrome_design/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.20)

project(ChromeBase LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(cmake/CPM.cmake)

message("Processing the OnceCallback")
add_subdirectory(once_callback)

# Tests
enable_testing()
add_subdirectory(test)
18 changes: 18 additions & 0 deletions code/volumn_codes/vol9/chrome_design/cancel_token/cancel_token.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include <atomic>
#include <memory>

namespace tamcpp::chrome {
class CancelableToken {
struct Flag {
std::atomic<bool> valid{true};
};
// All token should share a simple flags
std::shared_ptr<Flag> flag_;

public:
CancelableToken() : flag_(std::make_shared<Flag>()) {}
void invalidate() { flag_->valid.store(false, std::memory_order_release); }
bool is_valid() const { return flag_->valid.load(std::memory_order_acquire); }
};
} // namespace tamcpp::chrome
Loading
Loading