Skip to content

Commit bb89adb

Browse files
committed
zephyr: docgen
Add a small docgen crate. To help facilitate checking the docs, this project can be built, and then `cargo doc` run there. This includes the symlink for the config file, because that is needed in order for this to be able to build. Signed-off-by: David Brown <[email protected]>
1 parent 9f89617 commit bb89adb

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

docgen/.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../zephyr/build/rust/sample-cargo-config.toml

docgen/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# In this case, we do want the symlink checked in. We'll assume we have the module in the standard
2+
# module place.
3+
#
4+
# On Windows, this symlink will just get checked out as a regular file and will have to be replaced
5+
# with a copy (or real symlinks enabled). But, this shouldn't affect CI runs of the documentation,
6+
# which are done on Linux.
7+
!.cargo/

docgen/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
7+
project(hello_rust_world)
8+
rust_cargo_application()

docgen/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2024 Linaro LTD
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
[package]
5+
# This must be rustapp for now.
6+
name = "rustapp"
7+
version = "3.7.0"
8+
edition = "2021"
9+
description = "A small application to generate documentation"
10+
license = "Apache-2.0 or MIT"
11+
12+
[lib]
13+
crate-type = ["staticlib"]
14+
15+
[dependencies]
16+
zephyr = "3.7.0"

docgen/prj.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 Linaro LTD
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_RUST=y
5+
CONFIG_RUST_ALLOC=y

docgen/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2024 Linaro LTD
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#![no_std]
5+
6+
use zephyr::printkln;
7+
8+
// Reference the Zephyr crate so that the panic handler gets used. This is only needed if no
9+
// symbols from the crate are directly used.
10+
extern crate zephyr;
11+
12+
#[no_mangle]
13+
extern "C" fn rust_main() {
14+
printkln!("Hello world from Rust on {}",
15+
zephyr::kconfig::CONFIG_BOARD);
16+
}

0 commit comments

Comments
 (0)