Skip to content

Commit

Permalink
Add mdbook-xgettext skip for untranslatable codeblocks
Browse files Browse the repository at this point in the history
Closes google#1327

Signed-off-by: 0scvr <[email protected]>
  • Loading branch information
0scvr committed Oct 10, 2023
1 parent 2f50e8b commit a37ebef
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/bare-metal.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ nRF51822 microcontroller with some LEDs and buttons, an I2C-connected accelerome
an on-board SWD debugger.

To get started, install some tools we'll need later. On gLinux or Debian:

<!-- mdbook-xgettext: skip -->
```bash
sudo apt install gcc-aarch64-linux-gnu gdb-multiarch libudev-dev picocom pkg-config qemu-system-arm
rustup update
Expand All @@ -28,15 +28,15 @@ cargo install cargo-binutils cargo-embed
```

And give users in the `plugdev` group access to the micro:bit programmer:

<!-- mdbook-xgettext: skip -->
```bash
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0d28", MODE="0664", GROUP="plugdev"' |\
sudo tee /etc/udev/rules.d/50-microbit.rules
sudo udevadm control --reload-rules
```

On MacOS:

<!-- mdbook-xgettext: skip -->
```bash
xcode-select --install
brew install gdb picocom qemu
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To build a bare-metal Rust binary in AOSP, you need to use a `rust_ffi_static` Soong rule to build
your Rust code, then a `cc_binary` with a linker script to produce the binary itself, and then a
`raw_binary` to convert the ELF to a raw binary ready to be run.

<!-- mdbook-xgettext: skip -->
```soong
rust_ffi_static {
name: "libvmbase_example",
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/android/vmbase.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

For VMs running under crosvm on aarch64, the [vmbase][1] library provides a linker script and useful
defaults for the build rules, along with an entry point, UART console logging and more.

<!-- mdbook-xgettext: skip -->
```rust,compile_fail
#![no_main]
#![no_std]
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/aps/better-uart/registers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Multiple registers

We can use a struct to represent the memory layout of the UART's registers.

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
{{#include ../examples/src/pl011.rs:Registers}}
```
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/aps/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AArch64 defines an exception vector table with 16 entries, for 4 types of except
IRQ, FIQ, SError) from 4 states (current EL with SP0, current EL with SPx, lower EL using AArch64,
lower EL using AArch32). We implement this in assembly to save volatile registers to the stack
before calling into Rust code:

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
{{#include examples/src/exceptions.rs:exceptions}}
```
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/microcontrollers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Microcontrollers

The `cortex_m_rt` crate provides (among other things) a reset handler for Cortex M microcontrollers.

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
{{#include microcontrollers/examples/src/bin/minimal.rs:Example}}
```
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/microcontrollers/board-support.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Board support crates

Board support crates provide a further level of wrapping for a specific board for convenience.

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
{{#include examples/src/bin/board_support.rs:Example}}
```
Expand Down
8 changes: 5 additions & 3 deletions src/bare-metal/microcontrollers/debugging.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Debugging

_Embed.toml_:

<!-- mdbook-xgettext: skip -->
```toml
[default.general]
chip = "nrf52833_xxAA"
Expand All @@ -11,26 +11,28 @@ enabled = true
```

In one terminal under `src/bare-metal/microcontrollers/examples/`:

<!-- mdbook-xgettext: skip -->
```sh
cargo embed --bin board_support debug
```

In another terminal in the same directory:

On gLinux or Debian:
<!-- mdbook-xgettext: skip -->
```sh
gdb-multiarch target/thumbv7em-none-eabihf/debug/board_support --eval-command="target remote :1337"
```

On MacOS:
<!-- mdbook-xgettext: skip -->
```sh
arm-none-eabi-gdb target/thumbv7em-none-eabihf/debug/board_support --eval-command="target remote :1337"
```
<details>

In GDB, try running:

<!-- mdbook-xgettext: skip -->
```gdb
b src/bin/board_support.rs:29
b src/bin/board_support.rs:30
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/minimal.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A minimal `no_std` program

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
#![no_main]
#![no_std]
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/useful-crates/buddy_system_allocator.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It can be used both for [`LockedHeap`][2] implementing [`GlobalAlloc`][3] so you can use the
standard `alloc` crate (as we saw [before][4]), or for allocating other address space. For example,
we might want to allocate MMIO space for PCI BARs:

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
{{#include allocator-example/src/main.rs:main}}
```
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/useful-crates/spin.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
state between different CPUs?

The [`spin`][1] crate provides spinlock-based equivalents of many of these primitives.

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
use spin::mutex::SpinMutex;
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/useful-crates/tinyvec.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Sometimes you want something which can be resized like a `Vec`, but without heap
[`tinyvec`][1] provides this: a vector backed by an array or slice, which could be statically
allocated or on the stack, which keeps track of how many elements are used and panics if you try to
use more than are allocated.

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
use tinyvec::{array_vec, ArrayVec};
Expand Down
2 changes: 1 addition & 1 deletion src/bare-metal/useful-crates/zerocopy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The [`zerocopy`][1] crate (from Fuchsia) provides traits and macros for safely converting between
byte sequences and other types.

<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
{{#include zerocopy-example/src/main.rs:main}}
```
Expand Down
10 changes: 5 additions & 5 deletions src/exercises/bare-metal/compass.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,35 @@ use microbit::{hal::uarte::{Baudrate, Parity, Uarte}, Board};
_Cargo.toml_ (you shouldn't need to change this):

<!-- File Cargo.toml -->

<!-- mdbook-xgettext: skip -->
```toml
{{#include compass/Cargo.toml}}
```

_Embed.toml_ (you shouldn't need to change this):

<!-- File Embed.toml -->

<!-- mdbook-xgettext: skip -->
```toml
{{#include compass/Embed.toml}}
```

_.cargo/config.toml_ (you shouldn't need to change this):

<!-- File .cargo/config.toml -->

<!-- mdbook-xgettext: skip -->
```toml
{{#include compass/.cargo/config.toml}}
```

See the serial output on Linux with:

<!-- mdbook-xgettext: skip -->
```sh
picocom --baud 115200 --imap lfcrlf /dev/ttyACM0
```

Or on Mac OS something like (the device name may be slightly different):

<!-- mdbook-xgettext: skip -->
```sh
picocom --baud 115200 --imap lfcrlf /dev/tty.usbmodem14502
```
Expand Down
4 changes: 2 additions & 2 deletions src/exercises/bare-metal/rtc.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ _src/pl011.rs_ (you shouldn't need to change this):
_Cargo.toml_ (you shouldn't need to change this):

<!-- File Cargo.toml -->

<!-- mdbook-xgettext: skip -->
```toml
{{#include rtc/Cargo.toml}}
```
Expand Down Expand Up @@ -117,7 +117,7 @@ _Makefile_ (you shouldn't need to change this):
_.cargo/config.toml_ (you shouldn't need to change this):

<!-- File .cargo/config.toml -->

<!-- mdbook-xgettext: skip -->
```toml
{{#include rtc/.cargo/config.toml}}
```
Expand Down

0 comments on commit a37ebef

Please sign in to comment.