Skip to content

Commit a854c6c

Browse files
committed
Update.
1 parent 70f2c3d commit a854c6c

File tree

2 files changed

+127
-4
lines changed

2 files changed

+127
-4
lines changed

.github/workflows/build.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: XRobot Module Build Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 3 1 * *' # 每月1日凌晨3点(UTC)自动触发
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
container:
13+
image: ghcr.io/xrobot-org/docker-image-linux:main
14+
options: --user 0
15+
16+
env:
17+
XR_MODULE_NAME: ${{ github.event.repository.name }}
18+
19+
steps:
20+
- name: Checkout current module repo to ./Modules/${{ env.XR_MODULE_NAME }}
21+
uses: actions/checkout@v4
22+
with:
23+
path: Modules/${{ env.XR_MODULE_NAME }}
24+
25+
- name: Create main.cpp
26+
run: |
27+
cat > main.cpp <<'EOF'
28+
#include <iostream>
29+
#include "xrobot_main.hpp"
30+
#include "libxr.hpp"
31+
32+
int main() {
33+
LibXR::PlatformInit();
34+
LibXR::STDIO::Printf("This is XRobot Module Template Test\n");
35+
LibXR::HardwareContainer hw;
36+
XRobotMain(hw);
37+
return 0;
38+
}
39+
EOF
40+
41+
- name: Create minimal CMakeLists.txt
42+
run: |
43+
cat > CMakeLists.txt <<'EOF'
44+
project(xrobot_mod_test CXX)
45+
set(CMAKE_CXX_STANDARD 17)
46+
add_executable(xr_test main.cpp)
47+
add_subdirectory(libxr)
48+
target_include_directories(xr_test PUBLIC $<TARGET_PROPERTY:xr,INTERFACE_INCLUDE_DIRECTORIES> ${CMAKE_SOURCE_DIR}/User)
49+
target_link_libraries(xr_test PUBLIC xr)
50+
include(Modules/CMakeLists.txt)
51+
EOF
52+
53+
- name: Pull libxr to ./libxr
54+
run: git clone --depth=1 https://github.com/Jiu-xiao/libxr ./libxr
55+
56+
- name: Setup Python & Install deps
57+
run: |
58+
python3 -m pip install --upgrade pip
59+
pip3 install pyyaml requests
60+
61+
- name: Add XRobot tools to PATH
62+
run: |
63+
echo "$HOME/.local/bin" >> $GITHUB_PATH
64+
65+
- name: Install xrobot toolchain (assumes pyproject/tar.gz/pip install .)
66+
run: |
67+
pip3 install xrobot libxr
68+
69+
- name: Run xrobot_setup
70+
run: |
71+
xrobot_setup || true
72+
73+
- name: Run xrobot_init_mod
74+
run: |
75+
xrobot_init_mod
76+
77+
- name: Add BlinkLED module
78+
run: |
79+
xrobot_add_mod BlinkLED --instance-id BlinkLED_0
80+
81+
- name: Add this repo module
82+
run: |
83+
xrobot_add_mod ${{ env.XR_MODULE_NAME }} && cat User/xrobot.yaml
84+
85+
- name: Generate main again
86+
run: |
87+
xrobot_setup
88+
89+
- name: Build
90+
run: |
91+
mkdir -p build
92+
cd build
93+
cmake ..
94+
make
95+
96+
- name: Create Tag via GitHub API
97+
if: ${{ success() && github.event_name != 'pull_request' }}
98+
uses: actions/github-script@v7
99+
with:
100+
github-token: ${{ secrets.GITHUB_TOKEN }}
101+
script: |
102+
const tagPrefix = 'auto-'
103+
const date = new Date();
104+
const yyyy = date.getUTCFullYear();
105+
const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
106+
const dd = String(date.getUTCDate()).padStart(2, '0');
107+
const HH = String(date.getUTCHours()).padStart(2, '0');
108+
const MM = String(date.getUTCMinutes()).padStart(2, '0');
109+
const SS = String(date.getUTCSeconds()).padStart(2, '0');
110+
const tagName = `${tagPrefix}${yyyy}${mm}${dd}-${HH}${MM}${SS}`;
111+
112+
// 获取当前 commit sha
113+
const sha = process.env.GITHUB_SHA;
114+
115+
// 创建 tag reference
116+
await github.rest.git.createRef({
117+
owner: context.repo.owner,
118+
repo: context.repo.repo,
119+
ref: `refs/tags/${tagName}`,
120+
sha: sha
121+
});
122+
console.log(`Created tag: ${tagName} on sha: ${sha}`);

SharedTopic.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
22

33
// clang-format off
4-
/* === MODULE MANIFEST ===
5-
module_name: SharedTopic
4+
/* === MODULE MANIFEST V2 ===
65
module_description: No description provided
76
constructor_args:
87
- uart_name: "usart1"
@@ -11,7 +10,9 @@ module_description: No description provided
1110
- topic_name:
1211
- "topic1"
1312
- "topic2"
13+
template_args: []
1414
required_hardware: uart_name, ramfs
15+
depends: []
1516
=== END MANIFEST === */
1617
// clang-format on
1718

@@ -60,8 +61,8 @@ class SharedTopic : public LibXR::Application {
6061
while (true) {
6162
auto size = LibXR::max(
6263
sizeof(LibXR::Topic::PackedDataHeader),
63-
LibXR::min(self->uart_->read_port_.Size(), self->rx_buffer_.size_));
64-
auto ans = self->uart_->read_port_(
64+
LibXR::min(self->uart_->read_port_->Size(), self->rx_buffer_.size_));
65+
auto ans = self->uart_->Read(
6566
LibXR::RawData{self->rx_buffer_.addr_, size}, op);
6667

6768
if (ans == ErrorCode::OK) {

0 commit comments

Comments
 (0)