Skip to content

Commit a70d520

Browse files
committed
Initial commit
This is a prototype, capable of compiling Hello World. Please expect this commit to be heavily rebased, until the project is more mature.
0 parents  commit a70d520

34 files changed

Lines changed: 4002 additions & 0 deletions

.cargo/config.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: © 2026 Iain Nicol
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
[target.'cfg(all(windows, target_env = "msvc"))']
6+
# Using lld is convenient because if we use Bash on GitHub Actions,
7+
# MinGW link.exe takes precedence over MSVC link.exe. This is due to PATH.
8+
# The two links are incompatible, and Cargo would fail to link our application.
9+
#
10+
# Besides, lld may be faster than MSVC link.exe.
11+
linker = "rust-lld"

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: © 2026 Iain Nicol
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
* text=auto eol=lf

.github/workflows/ci.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# SPDX-FileCopyrightText: © 2026 Iain Nicol
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
on:
6+
pull_request:
7+
push:
8+
branches: ["main"]
9+
tags: ["v*.*.*"]
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
env:
16+
RUST_VERSION: 1.94.0
17+
LLVM_VERSION: 21.1.8
18+
CARGO_TERM_COLOR: always
19+
20+
jobs:
21+
build:
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
runner: [ubuntu-24.04, macos-26, windows-2025-vs2026]
26+
runs-on: ${{ matrix.runner }}
27+
28+
permissions:
29+
contents: write # For creating/uploading the release
30+
31+
steps:
32+
- uses: actions/checkout@v6
33+
34+
- name: Activate MSVC environment (Windows)
35+
if: ${{ runner.os == 'Windows' }}
36+
uses: TheMrMilchmann/setup-msvc-dev@v4
37+
with:
38+
arch: ${{ runner.arch }}
39+
40+
- name: Set Rust version
41+
run: rustup default ${{ env.RUST_VERSION }}
42+
43+
- name: Download LLVM binaries
44+
run: |
45+
url="$(echo "https://github.com/brainsick-dev/llvm-build/releases/download/v${{ env.LLVM_VERSION }}/llvm-${{ runner.os }}-${{ runner.arch }}-v${{ env.LLVM_VERSION }}.tar.zst" | tr '[:upper:]' '[:lower:]')"
46+
archivePath="$(basename "$url")"
47+
curl --proto '=https' --tlsv1.2 --fail --silent --show-error --location "$url" -o "$archivePath"
48+
mkdir llvm/
49+
tar -x -f "$archivePath" -C llvm/
50+
51+
- name: Add llvm-config to PATH
52+
run: echo "${{ github.workspace }}/llvm/bin" >> $GITHUB_PATH
53+
54+
- name: Install GTK (Linux)
55+
if: ${{ runner.os == 'Linux' }}
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get install -y libgtk-4-dev
59+
60+
- name: Build
61+
run: cargo build --locked --release
62+
63+
# - name: Run tests
64+
# # TODO: cargo nextest?
65+
# run: cargo test --locked
66+
67+
- name: Archive
68+
id: archive
69+
run: |
70+
if [ "${{ github.ref_type }}" == "tag" ]; then
71+
VERSION="${{ github.ref_name }}"
72+
else
73+
VERSION="$(git rev-parse --short HEAD)"
74+
fi
75+
ARCHIVE_FILENAME="$(echo "bscc-${{ runner.os }}-${{ runner.arch }}-$VERSION.tar.xz" | tr '[:upper:]' '[:lower:]')"
76+
cp "llvm/bin/${{ env.LLD_BASENAME }}${{ env.EXE_EXT }}" "brainsick-${{ env.LLD_BASENAME }}${{ env.EXE_EXT }}"
77+
tar --create --file - "brainsick-${{ env.LLD_BASENAME }}${{ env.EXE_EXT }}" -C target/release/ bscc${{ env.EXE_EXT }} | xz -2 > "$ARCHIVE_FILENAME"
78+
echo "ARCHIVE_FILENAME=$ARCHIVE_FILENAME" >> "$GITHUB_ENV"
79+
env:
80+
EXE_EXT: ${{ case(runner.os == 'Windows', '.exe', '') }}
81+
LLD_BASENAME: ${{ case(runner.os == 'Linux', 'ld.lld', runner.os == 'macOS', 'ld64.lld', runner.os == 'Windows', 'lld-link', 'unknown-lld') }}${{ env.EXE_EXT }}
82+
83+
- uses: actions/upload-artifact@v7
84+
name: Upload artifacts
85+
if: ${{ github.ref_type != 'tag' }}
86+
with:
87+
path: ${{ env.ARCHIVE_FILENAME }}
88+
if-no-files-found: error
89+
archive: false
90+
91+
- name: Upload to release
92+
if: ${{ github.ref_type == 'tag' }}
93+
uses: ncipollo/release-action@v1
94+
with:
95+
draft: true
96+
allowUpdates: true
97+
updateOnlyUnreleased: true
98+
artifacts: ${{ env.ARCHIVE_FILENAME }}
99+
artifactErrorsFailBuild: true
100+
101+
publish:
102+
if: ${{ github.ref_type == 'tag' }}
103+
needs: build
104+
105+
runs-on: ubuntu-24.04
106+
107+
permissions:
108+
contents: write # For publishing the release
109+
110+
steps:
111+
- name: Publish release
112+
uses: ncipollo/release-action@v1
113+
with:
114+
draft: false
115+
allowUpdates: true
116+
updateOnlyUnreleased: true
117+
body: ${{ github.ref_name }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: © 2026 Iain Nicol
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
target/
6+
*.o
7+
hello

0 commit comments

Comments
 (0)