Skip to content

Commit 6ece892

Browse files
authored
save
1 parent 93a97f9 commit 6ece892

File tree

26 files changed

+488
-49
lines changed

26 files changed

+488
-49
lines changed

.devcontainer/devcontainer.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/cpp",
3-
"updateContentCommand": "cargo install mdbook mdbook-cmdrun"
2+
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu",
3+
"features": {
4+
"ghcr.io/devcontainers/features/rust": {},
5+
"ghcr.io/devcontainers/features/python": {}
6+
},
7+
"updateContentCommand": "./.devcontainer/updateContentCommand.sh",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"dnut.rewrap-revived",
12+
"xaver.clang-format",
13+
"twxs.cmake"
14+
]
15+
}
16+
}
417
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"name": "Hello world",
3-
"image": "mcr.microsoft.com/devcontainers/cpp",
4-
"workspaceFolder": "${localWorkspaceFolder}/src/hello-world"
2+
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu",
3+
"workspaceMount": "source=${localWorkspaceFolder}/src/hello-world,target=/workspace,type=bind,consistency=cached",
4+
"workspaceFolder": "/workspaces/hello-world",
5+
"updateContentCommand": "curl -fsSL https://apt.kitware.com/kitware-archive.sh | sh"
56
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu",
3+
"workspaceMount": "source=${localWorkspaceFolder}/src/logging,target=/workspace,type=bind,consistency=cached",
4+
"workspaceFolder": "/workspaces/logging",
5+
"updateContentCommand": "curl -fsSL https://apt.kitware.com/kitware-archive.sh | sh"
6+
}

.devcontainer/updateContentCommand.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
(
5+
cd "$(mktemp -d)"
6+
wget https://apt.kitware.com/kitware-archive.sh
7+
chmod +x ./kitware-archive.sh
8+
./kitware-archive.sh
9+
rm -rf "$PWD"
10+
)
11+
sudo apt-get install -y cmake
12+
13+
cargo install mdbook
14+
cargo install mdbook-cmdrun mdbook-codename
15+
16+
(
17+
cd ~
18+
mkdir -p cosmocc
19+
cd cosmocc
20+
wget https://cosmo.zip/pub/cosmocc/cosmocc.zip
21+
unzip cosmocc.zip
22+
rm cosmocc.zip
23+
)
24+
25+
curl -sS https://webi.sh/zig | sh
26+
source ~/.config/envman/PATH.env
27+
28+
sudo apt-get update
29+
sudo apt-get install -y clang-format
30+
31+
pipx install cmakelang

.github/workflows/mdbook.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ jobs:
3333

3434
- name: Setup mdBook
3535
uses: peaceiris/actions-mdbook@v2
36-
# https://github.com/FauconFan/mdbook-cmdrun
37-
- run: cargo install mdbook-cmdrun
36+
- run: cargo install mdbook-cmdrun mdbook-codename
3837
# Included CMake version is OK.
3938
# Included GCC version is OK.
39+
- uses: bjia56/setup-cosmocc@main
40+
- uses: mlugg/setup-zig@v1
4041

4142
- name: Setup Pages
4243
id: pages

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"dnut.rewrap-revived",
4+
"xaver.clang-format",
5+
"twxs.cmake"
6+
]
7+
}

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
![mdBook](https://img.shields.io/static/v1?style=for-the-badge&message=mdBook&color=000000&logo=mdBook&logoColor=FFFFFF&label=)
88
![CMake](https://img.shields.io/static/v1?style=for-the-badge&message=CMake&color=064F8C&logo=CMake&logoColor=FFFFFF&label=)
99

10-
Make sure you've installed [mdBook](https://rust-lang.github.io/mdBook/guide/installation.html) and [CMake](https://cmake.org/download/). You'll also need to install [mdbook-cmdrun](https://github.com/FauconFan/mdbook-cmdrun). Run `mdbook serve` to see the live preview.
10+
Make sure you've installed:
1111

12-
The custom `theme/highlight.js` is needed because the default mdBook `highlight.js` doesn't include the `cmake` language. The current custom build includes [all of the mdBook defaults](https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages) plus `cmake`. Generate it using https://highlightjs.org/download and use the `./highlight.min.js` file from the resulting `.zip` download.
12+
- [CMake](https://cmake.org/download/)
13+
- [mdBook](https://rust-lang.github.io/mdBook/)
14+
- [mdbook-cmdrun](https://github.com/FauconFan/mdbook-cmdrun)
15+
- [mdbook-codename](https://github.com/smallkirby/mdbook-codename)
16+
- clang-format
17+
18+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/jcbhmr/cmakebyexample.jcbhmr.com?quickstart=1&devcontainer_path=.devcontainer%2Fdevcontainer.json)
19+
20+
The custom `theme/highlight.js` is needed because the default mdBook `highlight.js` doesn't include the some languages. To regenerate a custom build of `theme/highlight.js` use `./task.cmake generate`.
1321

1422
To create a new example ("Cool feature" in this example):
1523

book.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ edit-url-template = "https://github.com/jcbhmr/cmakebyexample.jcbhmr.com/edit/ma
1111

1212
# https://github.com/FauconFan/mdbook-cmdrun
1313
[preprocessor.cmdrun]
14+
15+
# https://github.com/smallkirby/mdbook-codename
16+
[preprocessor.codename]

src/SUMMARY.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
- [Arrays]()
1717
- [Functions]()
1818
- [Macros]()
19+
- [Set C/C++ standard]()
1920
- [Toolchain files]()
2021
- [Custom targets]()
2122
- [Post-build commands]()
2223
- [FetchContent dependency]()
24+
- [FindPackage dependency]()
2325
- [Conan dependency]()
2426
- [Vcpkg dependency]()
2527
- [Xrepo dependency]()
26-
- [FindPackage dependency]()
27-
- [cosmocc toolchain]()
28-
- [Zig toolchain]()
28+
- [Testing-only dependencies]()
29+
- [cosmocc toolchain](cosmocc-toolchain/README.md)
30+
- [Zig toolchain](zig-toolchain/README.md)
2931
- [Spawning processes]()
3032
- [HTTP requests]()
3133
- [String functions]()
@@ -43,4 +45,4 @@
4345
- [Packaging]()
4446
- [Release GitHub Actions]()
4547
- [Install target]()
46-
- [Scripts]()
48+
- [Scripts](scripts/README.md)

src/cosmocc-toolchain/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
3+
project(cosmocc-toolchain)
4+
5+
add_executable(cosmocc-toolchain main.c)

0 commit comments

Comments
 (0)