Skip to content

Commit 1b712ed

Browse files
authored
Merge pull request #95 from kkebo/remove-makefile
build: remove make dependency
2 parents b986982 + fb1aaee commit 1b712ed

File tree

4 files changed

+96
-48
lines changed

4 files changed

+96
-48
lines changed

Makefile

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ An operating system written in Swift.
44

55
## Prerequisites
66

7-
- Make
8-
- Arch Linux: `sudo pacman -S make`
9-
- Fedora 40 or later: `sudo dnf install make`
10-
- Ubuntu 24.04/22.04: `sudo apt install make`
11-
- Debian 12: `sudo apt install make`
12-
- macOS 14: bulit-in (`/usr/bin/make`)
137
- QEMU 9.0 or later
148
- Arch Linux: `sudo pacman -S qemu-system-aarch64`
159
- Fedora 41 or later: `sudo dnf install qemu-system-aarch64-core`
@@ -24,20 +18,68 @@ An operating system written in Swift.
2418
swiftly install
2519
```
2620

27-
## Building
21+
## Building for emulators
22+
23+
On Linux,
2824

2925
```shell
30-
make
26+
swift build -c release --triple aarch64-none-none-elf --toolset toolsets/linux.json
3127
```
3228

33-
## Cleaning build outputs
29+
On macOS,
3430

3531
```shell
36-
make clean
32+
swift build -c release --triple aarch64-none-none-elf --toolset toolsets/macos.json
3733
```
3834

3935
## Running on QEMU
4036

37+
On Linux,
38+
39+
```shell
40+
swift run -c release --triple aarch64-none-none-elf --toolset toolsets/linux.json
41+
```
42+
43+
On macOS,
44+
45+
```shell
46+
swift run -c release --triple aarch64-none-none-elf --toolset toolsets/macos.json
47+
```
48+
49+
## Building for real hardwares
50+
51+
On Linux,
52+
53+
```shell
54+
swift build -c release --triple aarch64-none-none-elf --toolset toolsets/linux.json
55+
llvm-objcopy .build/release/Kernel -O binary .build/kernel8.img
56+
```
57+
58+
On macOS,
59+
60+
```shell
61+
swift build -c release --triple aarch64-none-none-elf --toolset toolsets/macos.json
62+
llvm-objcopy .build/release/Kernel -O binary .build/kernel8.img
63+
```
64+
65+
## Cleaning build outputs
66+
67+
```shell
68+
swift package clean
69+
```
70+
71+
## swift-format
72+
73+
This project is using [swift-format](https://github.com/swiftlang/swift-format) for formatting and linting.
74+
75+
Format:
76+
77+
```shell
78+
swift format format -rip .
79+
```
80+
81+
Lint:
82+
4183
```shell
42-
make run
84+
swift format lint -rp .
4385
```

toolset.json renamed to toolsets/linux.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"schemaVersion": "1.0",
33
"swiftCompiler": {
44
"extraCLIOptions": [
5+
"-Osize",
56
"-enable-experimental-feature", "Embedded",
67
"-Xfrontend", "-no-allocations",
78
"-Xfrontend", "-function-sections",
@@ -21,5 +22,13 @@
2122
"-T", "linker.ld",
2223
"-Map", ".build/kernel.map"
2324
]
25+
},
26+
"debugger": {
27+
"path": "/usr/bin/qemu-system-aarch64",
28+
"extraCLIOptions": [
29+
"-machine", "raspi4b",
30+
"-serial", "stdio",
31+
"-kernel"
32+
]
2433
}
2534
}

toolsets/macos.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"schemaVersion": "1.0",
3+
"swiftCompiler": {
4+
"extraCLIOptions": [
5+
"-Osize",
6+
"-enable-experimental-feature", "Embedded",
7+
"-Xfrontend", "-no-allocations",
8+
"-Xfrontend", "-function-sections",
9+
"-Xfrontend", "-disable-stack-protector",
10+
"-Xfrontend", "-mergeable-symbols",
11+
"-Xclang-linker", "-nostdlib",
12+
"-Xclang-linker", "-fuse-ld=lld"
13+
]
14+
},
15+
"linker": {
16+
"extraCLIOptions": [
17+
"-nostdlib",
18+
"-static",
19+
"--gc-sections",
20+
"--strip-all",
21+
"--orphan-handling=error",
22+
"-T", "linker.ld",
23+
"-Map", ".build/kernel.map"
24+
]
25+
},
26+
"debugger": {
27+
"path": "/opt/homebrew/bin/qemu-system-aarch64",
28+
"extraCLIOptions": [
29+
"-machine", "raspi4b",
30+
"-serial", "stdio",
31+
"-kernel"
32+
]
33+
}
34+
}

0 commit comments

Comments
 (0)