Skip to content

Generate docs for core and alloc locally #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 15 additions & 6 deletions rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ extra-$(CONFIG_RUST) += bindings_generated.rs libmodule.so
extra-$(CONFIG_RUST) += exports_core_generated.h exports_alloc_generated.h
extra-$(CONFIG_RUST) += exports_kernel_generated.h

# `$(rustc_flags)` is passed in case the user added `--sysroot`.
rustc_sysroot = $(shell $(RUSTC) $(rustc_flags) --print sysroot)
rustc_src = $(rustc_sysroot)/lib/rustlib/src/rust

RUSTDOC = rustdoc

quiet_cmd_rustdoc = RUSTDOC $<
Expand All @@ -14,9 +18,13 @@ quiet_cmd_rustdoc = RUSTDOC $<
$(RUSTDOC) $(filter-out --emit=%, $(rustc_flags)) \
$(rustdoc_target_flags) -L $(objtree)/rust/ \
--output $(objtree)/rust/doc --crate-name $(subst rustdoc-,,$@) \
-Fmissing-docs @$(objtree)/include/generated/rustc_cfg $<
@$(objtree)/include/generated/rustc_cfg $<

rustdoc: rustdoc-module rustdoc-compiler_builtins rustdoc-kernel
rustdoc: rustdoc-core rustdoc-module rustdoc-compiler_builtins rustdoc-alloc rustdoc-kernel

rustdoc-core: private skip_clippy = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip_clippy is not used for rustdoc. Did you add it for a particular reason?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didnt aware that. Fixed it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to say sorry! Thanks for working on this! :-)

rustdoc-core: $(rustc_src)/library/core/src/lib.rs FORCE
$(call if_changed,rustdoc)

rustdoc-module: private rustdoc_target_flags = --crate-type proc-macro \
--extern proc_macro
Expand All @@ -26,6 +34,11 @@ rustdoc-module: $(srctree)/rust/module.rs FORCE
rustdoc-compiler_builtins: $(srctree)/rust/compiler_builtins.rs FORCE
$(call if_changed,rustdoc)

rustdoc-alloc: private skip_clippy = 1
rustdoc-alloc: $(rustc_src)/library/alloc/src/lib.rs \
$(objtree)/rust/compiler_builtins.o FORCE
$(call if_changed,rustdoc)

rustdoc-kernel: private rustdoc_target_flags = --extern alloc \
--extern module=$(objtree)/rust/libmodule.so
rustdoc-kernel: $(srctree)/rust/kernel/lib.rs rustdoc-module \
Expand Down Expand Up @@ -115,10 +128,6 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
sed -i '/^\#/d' $(depfile) \
$(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@)

# `$(rustc_flags)` is passed in case the user added `--sysroot`.
rustc_sysroot = $(shell $(RUSTC) $(rustc_flags) --print sysroot)
rustc_src = $(rustc_sysroot)/lib/rustlib/src/rust

.SECONDEXPANSION:
$(objtree)/rust/core.o: private skip_clippy = 1
$(objtree)/rust/core.o: $$(rustc_src)/library/core/src/lib.rs FORCE
Expand Down
1 change: 1 addition & 0 deletions rust/compiler_builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#![deny(clippy::correctness)]
#![deny(clippy::perf)]
#![deny(clippy::style)]
#![deny(missing_docs)]

macro_rules! define_panicking_intrinsics(
($reason: tt, { $($ident: ident, )* }) => {
Expand Down
1 change: 1 addition & 0 deletions rust/kernel/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![deny(clippy::correctness)]
#![deny(clippy::perf)]
#![deny(clippy::style)]
#![deny(missing_docs)]

// Ensure conditional compilation based on the kernel configuration works;
// otherwise we may silently break things like initcall handling.
Expand Down
1 change: 1 addition & 0 deletions rust/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![deny(clippy::correctness)]
#![deny(clippy::perf)]
#![deny(clippy::style)]
#![deny(missing_docs)]

use proc_macro::{token_stream, Delimiter, Group, TokenStream, TokenTree};

Expand Down