Skip to content

Commit 602c490

Browse files
authored
savetemp
1 parent c95e1ae commit 602c490

File tree

19 files changed

+135
-31
lines changed

19 files changed

+135
-31
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu",
2+
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu-24.04",
33
"features": {
44
"ghcr.io/devcontainers/features/rust": {},
55
"ghcr.io/devcontainers/features/python": {}

.devcontainer/updateContentCommand.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ set -ex
44
cargo install mdbook
55
cargo install mdbook-cmdrun mdbook-codename
66

7-
(
8-
cd "$(mktemp -d)"
9-
# wget doesn't work for some reason. 🤷‍♀️
10-
curl -LO https://apt.kitware.com/kitware-archive.sh
11-
chmod +x ./kitware-archive.sh
12-
sudo ./kitware-archive.sh
13-
rm -rf "$PWD"
14-
)
7+
curl https://apt.kitware.com/kitware-archive.sh | sudo sh
8+
sudo apt-get update
159
sudo apt-get install -y cmake
1610

11+
sudo apt-get update
12+
sudo apt-get install -y lsb-release wget software-properties-common gnupg
13+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" bash all
14+
1715
sudo apt-get update
1816
sudo apt-get install -y clang-format
1917

@@ -25,8 +23,11 @@ pipx install cmakelang
2523
cd cosmocc
2624
wget https://cosmo.zip/pub/cosmocc/cosmocc.zip
2725
unzip cosmocc.zip
26+
echo 'export PATH="$PATH:$HOME/cosmocc/bin"' >> ~/.bashrc
2827
rm cosmocc.zip
2928
)
29+
# https://github.com/jart/cosmopolitan/issues/1325
30+
chmod +x ~/cosmocc/bin/cosmoranlib
3031

3132
curl -sS https://webi.sh/zig | sh
3233
source ~/.config/envman/PATH.env

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ To create a new example ("Cool feature" in this example):
2626
3. Create your example in `src/cool-feature/`. Add a bunch of comments _in the code files_ so that they are visible on the website and when viewing the file in an IDE.
2727
4. `{{#include filename.txt}}` any interesting files in `src/cool-feature/README.md`.
2828
5. Add any shell commands to interact with the example to the `src/cool-feature/README.md`. Make sure to document them.
29-
6. (Optional) Use `<!-- cmdrun cmake ... -->` or similar inside a `` ``` `` code block to run that command and use its output at build time.
29+
6. (Optional) Use `<!-- cmdrun cmake ... -->` or similar inside a `` ``` `` code block to run that command and use its output at build time. Remember to add `--fresh` and `--clean-first` to CMake commands so that the output is reproducable. Also add `exec 2>&1 && ...` so that stderr is redirected to stdout (which is what `mdbook-cmdrun` captures).
3030
7. Create a corresponding `.devcontainer/cool-feature/devcontainer.json` that will open the example's folder. Add any necessary dependencies to the dev container.
3131
8. Add an "Open in Codespaces" button to the `src/cool-feature/README.md`.

src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ CMake is an open source cross-platform meta build system that works on Windows,
44

55
*CMake by Example* is a hands-on introduction to how to use CMake to build C/C++ projects using annotated example projects. Make sure you have [installed the latest version of CMake on your system](https://cmake.org/download/). Check out the first [Hello world](hello-world.md) example to get started.
66

7-
<!-- cmdrun grep '^- ' SUMMARY.md | sed 's/README\.md/index.html/' -->
7+
<!-- cmdrun exec 2>&1 && grep '^- ' SUMMARY.md | sed 's/README\.md/index.html/' -->

src/SUMMARY.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
- [Arrays]()
1717
- [Functions]()
1818
- [Macros]()
19-
- [Set C/C++ standard]()
19+
- [Set C/C++ standard](set-c-cxx-standard/README.md)
2020
- [Toolchain files]()
2121
- [Custom targets]()
2222
- [Post-build commands]()
@@ -27,7 +27,6 @@
2727
- [Xrepo dependency]()
2828
- [Testing-only dependencies]()
2929
- [cosmocc toolchain](cosmocc-toolchain/README.md)
30-
- [Zig toolchain](zig-toolchain/README.md)
3130
- [Spawning processes]()
3231
- [HTTP requests]()
3332
- [String functions]()

src/cosmocc-toolchain/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ cmake --toolchain ./cmake/cosmocc.cmake -B ./build/
2727
```
2828

2929
```
30-
<!-- cmdrun cmake --fresh --toolchain ./cmake/cosmocc.cmake -B ./build/ -->
30+
<!-- cmdrun exec 2>&1 && cmake --fresh --toolchain ./cmake/cosmocc.cmake -B ./build/ -->
3131
```
3232

3333
```sh:
3434
cmake --build ./build/
3535
```
3636

3737
```
38-
<!-- cmdrun cmake --build ./build/ --clean-first -->
38+
<!-- cmdrun exec 2>&1 && cmake --build ./build/ --clean-first -->
3939
```
4040

4141
<details>
@@ -45,7 +45,7 @@ cmake --build ./build/
4545
```
4646

4747
```
48-
<!-- cmdrun ./build/cosmocc-toolchain -->
48+
<!-- cmdrun exec 2>&1 && ./build/cosmocc-toolchain -->
4949
```
5050

5151
</details>
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
set(CMAKE_SYSTEM_NAME Generic)
22
unset(CMAKE_SYSTEM_PROCESSOR)
3-
set(CMAKE_ASM_COMPILER cosmocc)
4-
set(CMAKE_C_COMPILER cosmocc)
5-
set(CMAKE_CXX_COMPILER cosmoc++)
3+
4+
set(CMAKE_ASM_COMPILER "cosmocc")
5+
6+
set(CMAKE_C_COMPILER "cosmocc")
7+
8+
set(CMAKE_CXX_COMPILER "cosmoc++")
9+
10+
find_program(CMAKE_AR "cosmoar" REQUIRED)
11+
12+
find_program(CMAKE_RANLIB "cosmoranlib" REQUIRED)
13+
614
set(CMAKE_USER_MAKE_RULES_OVERRIDE
715
"${CMAKE_CURRENT_LIST_DIR}/cosmocc-override.cmake")
8-
find_program(CMAKE_AR cosmoar REQUIRED)
9-
find_program(CMAKE_RANLIB cosmoranlib REQUIRED)
16+

src/hello-world/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cmake -B ./build/
2626
```
2727

2828
```
29-
<!-- cmdrun cmake --fresh -B ./build/ -->
29+
<!-- cmdrun exec 2>&1 && cmake --fresh -B ./build/ -->
3030
```
3131

3232
```sh:
@@ -40,7 +40,7 @@ cmake --build ./build/
4040
```
4141

4242
```
43-
<!-- cmdrun cmake --build ./build/ --clean-first -->
43+
<!-- cmdrun exec 2>&1 && cmake --build ./build/ --clean-first -->
4444
```
4545

4646
```sh:
@@ -52,5 +52,5 @@ cmake --build ./build/
5252
```
5353

5454
```
55-
<!-- cmdrun ./build/hello-world -->
55+
<!-- cmdrun exec 2>&1 && ./build/hello-world -->
5656
```

src/logging/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cmake -B ./build/
2020
```
2121

2222
```
23-
<!-- cmdrun cmake --fresh -B ./build/ -->
23+
<!-- cmdrun exec 2>&1 && cmake --fresh -B ./build/ -->
2424
```
2525

2626
```sh:
@@ -29,5 +29,5 @@ cmake --build ./build/
2929
```
3030

3131
```
32-
<!-- cmdrun cmake --build ./build/ --clean-first -->
32+
<!-- cmdrun exec 2>&1 && cmake --build ./build/ --clean-first -->
3333
```

src/scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ cmake -P ./cat.cmake ./raven.txt
2727
```
2828

2929
```
30-
<!-- cmdrun ./cat.cmake ./raven.txt -->
30+
<!-- cmdrun exec 2>&1 && ./cat.cmake ./raven.txt -->
3131
```

0 commit comments

Comments
 (0)