Skip to content

Commit

Permalink
zephyr: docgen
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
d3zd3z committed Oct 17, 2024
1 parent 9f89617 commit bb89adb
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions docgen/.cargo/config.toml
7 changes: 7 additions & 0 deletions docgen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# In this case, we do want the symlink checked in. We'll assume we have the module in the standard
# module place.
#
# On Windows, this symlink will just get checked out as a regular file and will have to be replaced
# with a copy (or real symlinks enabled). But, this shouldn't affect CI runs of the documentation,
# which are done on Linux.
!.cargo/
8 changes: 8 additions & 0 deletions docgen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(hello_rust_world)
rust_cargo_application()
16 changes: 16 additions & 0 deletions docgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

[package]
# This must be rustapp for now.
name = "rustapp"
version = "3.7.0"
edition = "2021"
description = "A small application to generate documentation"
license = "Apache-2.0 or MIT"

[lib]
crate-type = ["staticlib"]

[dependencies]
zephyr = "3.7.0"
5 changes: 5 additions & 0 deletions docgen/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

CONFIG_RUST=y
CONFIG_RUST_ALLOC=y
16 changes: 16 additions & 0 deletions docgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2024 Linaro LTD
// SPDX-License-Identifier: Apache-2.0

#![no_std]

use zephyr::printkln;

// Reference the Zephyr crate so that the panic handler gets used. This is only needed if no
// symbols from the crate are directly used.
extern crate zephyr;

#[no_mangle]
extern "C" fn rust_main() {
printkln!("Hello world from Rust on {}",
zephyr::kconfig::CONFIG_BOARD);
}

0 comments on commit bb89adb

Please sign in to comment.