Compare commits

...

6 Commits

Author SHA1 Message Date
FineFindus
2114872d2c Merge 5c3adee95b into 2b444d3262 2024-01-30 10:44:06 -08:00
Philipp Oppermann
2b444d3262 Merge pull request #1274 from acyanbird/main
change some format errors for chinese edition minimal kernel
2024-01-30 18:03:55 +01:00
acyanbird
b118828956 change some format errors 2024-01-28 23:59:17 +00:00
FineFindus
5c3adee95b feat(epub): use poper file name 2023-08-05 22:16:13 +02:00
FineFindus
fc8c87bee5 feat(epub): add cover image 2023-08-05 22:05:04 +02:00
FineFindus
e1c58bba97 feat: add script to generate epub 2023-08-05 14:38:08 +02:00
3 changed files with 38 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ translation_contributors = ["JiangengDong"]
在这篇文章中,我们将基于 **x86架构**the x86 architecture使用 Rust 语言,编写一个最小化的 64 位内核。我们将从上一章中构建的[独立式可执行程序][freestanding-rust-binary]开始,构建自己的内核;它将向显示器打印字符串,并能被打包为一个能够引导启动的**磁盘映像**disk image 在这篇文章中,我们将基于 **x86架构**the x86 architecture使用 Rust 语言,编写一个最小化的 64 位内核。我们将从上一章中构建的[独立式可执行程序][freestanding-rust-binary]开始,构建自己的内核;它将向显示器打印字符串,并能被打包为一个能够引导启动的**磁盘映像**disk image
[freestanding Rust binary]: @/edition-2/posts/01-freestanding-rust-binary/index.md [freestanding-rust-binary]: @/edition-2/posts/01-freestanding-rust-binary/index.md
<!-- more --> <!-- more -->
@@ -157,7 +157,9 @@ Nightly 版本的编译器允许我们在源码的开头插入**特性标签**
禁用 SIMD 产生的一个问题是,`x86_64` 架构的浮点数指针运算默认依赖于 SIMD 寄存器。我们的解决方法是,启用 `soft-float` 特征,它将使用基于整数的软件功能,模拟浮点数指针运算。 禁用 SIMD 产生的一个问题是,`x86_64` 架构的浮点数指针运算默认依赖于 SIMD 寄存器。我们的解决方法是,启用 `soft-float` 特征,它将使用基于整数的软件功能,模拟浮点数指针运算。
为了让读者的印象更清晰,我们撰写了一篇关于 [禁用 SIMD][disabling SIMD](@/edition-2/posts/02-minimal-rust-kernel/disable-simd/index.zh-CN.md) 的短文。 为了让读者的印象更清晰,我们撰写了一篇关于 [禁用 SIMD][disabling SIMD] 的短文。
[disabling SIMD]: @/edition-2/posts/02-minimal-rust-kernel/disable-simd/index.zh-CN.md
现在,我们将各个配置项整合在一起。我们的目标配置清单应该长这样: 现在,我们将各个配置项整合在一起。我们的目标配置清单应该长这样:
@@ -225,10 +227,10 @@ error[E0463]: can't find crate for `core`
#### `build-std` 选项 #### `build-std` 选项
此时就到了cargo中 [`build-std` 特性][`build-std` feature] 登场的时刻,该特性允许你按照自己的需要重编译 `core` 等标准crate而不需要使用Rust安装程序内置的预编译版本。 但是该特性是全新的功能,到目前为止尚未完全完成,所以它被标记为 "unstable" 且仅被允许在 [nightly Rust 编译器][nightly Rust compilers] 环境下调用。 此时就到了cargo中 [`build-std` 特性][`build-std` feature] 登场的时刻,该特性允许你按照自己的需要重编译 `core` 等标准crate而不需要使用Rust安装程序内置的预编译版本。 但是该特性是全新的功能,到目前为止尚未完全完成,所以它被标记为 "unstable" 且仅被允许在 [Nightly Rust 编译器][Nightly Rust compilers] 环境下调用。
[`build-std` feature]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std [`build-std` feature]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std
[nightly Rust compilers]: #安装 Nightly Rust [Nightly Rust compilers]:https://os.phil-opp.com/zh-CN/minimal-rust-kernel/#an-zhuang-nightly-rust
要启用该特性,你需要创建一个 [cargo 配置][cargo configuration] 文件,即 `.cargo/config.toml`,并写入以下语句: 要启用该特性,你需要创建一个 [cargo 配置][cargo configuration] 文件,即 `.cargo/config.toml`,并写入以下语句:

BIN
scripts/cover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

30
scripts/create-book.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# create working dir
rm -r book/
mkdir book/
# copy data to working dir
cat ../blog/content/edition-2/posts/*/index.md > book/book.md
find ../blog/content/edition-2/posts ! -name "*.md" -exec cp -t book/ {} +
# remove zola metadata
sed -i '/^+++/,/^+++/d' book/book.md
# remove br in table in 06, pandoc handles the layout
sed -i '/<br>/d' book/book.md
# details/summary breaks epub layout
sed -i '/^<details>/d' book/book.md
sed -i '/^<\/details>/d' book/book.md
sed -i '/^<summary>/d' book/book.md
# special fix for linking to different folder
sed -i 's|../paging-introduction/||g' book/book.md
# go to work dir and create epub
cd book/
pandoc book.md -o "Writing an OS in Rust.epub" --metadata cover-image="../cover.png" --metadata title="Writing an OS in Rust" --metadata author="Philipp Oppermann" --metadata description="This blog series creates a small operating system in the Rust programming language. Each post is a small tutorial and includes all needed code, so you can follow along if you like. The source code is also available in the corresponding Github repository."
#clean up
cd ..
mv "book/Writing an OS in Rust.epub" .
rm -rf book/