Skip to content

Commit c4ade4e

Browse files
authored
Initial commit
0 parents  commit c4ade4e

File tree

22 files changed

+1605
-0
lines changed

22 files changed

+1605
-0
lines changed

.cargo/config.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[build]
2+
target-dir = "_build"
3+
4+
# FUCK YOU TO PEOPLE WITH OLD CPUS
5+
#rustflags = ["-Ctarget-cpu=x86-64-v2"]
6+
7+
target = "i686-pc-windows-msvc"
8+
9+
[env]
10+
CFLAGS_i686_pc_windows_msvc = "/Zi /FS"
11+
CXXFLAGS_i686_pc_windows_msvc = "/Zi /FS"
12+
CFLAGS_x86_64_pc_windows_msvc = "/Zi /FS"
13+
CXXFLAGS_x86_64_pc_windows_msvc = "/Zi /FS"
14+
15+
SRCWRTIMER_ROOT_DIR = { value = "../srcwrtimer", relative = true }
16+
17+
18+
[target.i686-unknown-linux-gnu]
19+
rustflags = [
20+
# 2025... we can rely on CPUs to be using SSE2... not that it will likely change much in codegen...
21+
"-Ctarget-feature=+sse2",
22+
# Yeah, we want frame pointers...
23+
"-Cforce-frame-pointers=yes",
24+
]
25+
[target.i686-pc-windows-msvc]
26+
rustflags = [
27+
# 2025... we can rely on CPUs to be using SSE2... not that it will likely change much in codegen...
28+
"-Ctarget-feature=+sse2",
29+
# TODO: Do we want static crt on Windows? I can't remember if there was a reason for this...
30+
"-Ctarget-feature=+crt-static",
31+
# Yeah, we want frame pointers...
32+
"-Cforce-frame-pointers=yes",
33+
]
34+
35+
36+
[target.x86_64-unknown-linux-gnu]
37+
rustflags = [
38+
# FUCK YOU TO PEOPLE WITH OLD CPUS
39+
"-Ctarget-cpu=x86-64-v2",
40+
# Yeah, we want frame pointers...
41+
"-Cforce-frame-pointers=yes",
42+
]
43+
[target.x86_64-pc-windows-msvc]
44+
rustflags = [
45+
# FUCK YOU TO PEOPLE WITH OLD CPUS
46+
"-Ctarget-cpu=x86-64-v2",
47+
# TODO: Do we want static crt on Windows? I can't remember if there was a reason for this...
48+
"-Ctarget-feature=+crt-static",
49+
# Yeah, we want frame pointers...
50+
"-Cforce-frame-pointers=yes",
51+
]

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
* text=auto
2+
*.inc diff=sourcepawn linguist-language=SourcePawn
3+
*.sp diff=sourcepawn linguist-language=SourcePawn
4+
*.txt diff
5+
*.cfg diff
6+
7+
*.smx binary
8+
*.mp3 binary
9+
*.vmt diff
10+
*.vtf binary
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copied mostly from https://github.com/srcwr/srcwrtimer/blob/main/.github/workflows/build-everything.yml
2+
3+
name: Build everything
4+
5+
# TODO: Print hashes to ghactions "summary" info and/or setup some of the ghactions attestation shit...
6+
# Steal from this maybe: https://github.com/zhongfly/mpv-winbuild/blob/main/.github/workflows/mpv.yml
7+
8+
# TODO: add another job that only builds sourcepawn files when only those are touched
9+
on:
10+
push:
11+
paths: ['**.rs', '**.h', '**.hpp', '**.c', '**.cpp', '**.sp', '**.inc', '**.toml', '**.lock', '**.yml']
12+
pull_request:
13+
paths: ['**.rs', '**.h', '**.hpp', '**.c', '**.cpp', '**.sp', '**.inc', '**.toml', '**.lock', '**.yml']
14+
workflow_dispatch:
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
build_everything:
21+
runs-on: windows-latest
22+
strategy:
23+
matrix:
24+
targetos: ["linux", "windows"]
25+
targetbits: ["x32", "x64"]
26+
27+
steps:
28+
- name: Prepare env
29+
shell: bash
30+
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
31+
# checkout current repo...
32+
- uses: actions/checkout@v4
33+
with:
34+
path: srcwrtimer_sample_extension
35+
# checkout srcwrtimer since we use it for shit...
36+
- uses: actions/checkout@v4
37+
with:
38+
repository: srcwr/srcwrtimer
39+
path: srcwrtimer
40+
- name: Install cargo-binstall
41+
uses: cargo-bins/cargo-binstall@v1.10.12
42+
- name: Install the cargo bins we use...
43+
shell: pwsh
44+
run: |
45+
cargo binstall -y cargo-make
46+
cargo binstall -y cargo-zigbuild
47+
# This is `cargo make full` but turned into steps so you can have better progress visibility
48+
- name: Install Rust toolchains
49+
working-directory: ./srcwrtimer_sample_extension
50+
run: |
51+
cargo make --profile ${{ matrix.targetbits }} rustup-${{ matrix.targetos }}
52+
- name: Clone alliedmodders repositories
53+
run: cargo make clone-alliedmodders
54+
working-directory: ./srcwrtimer_sample_extension
55+
- name: Setup SourcePawn Compiler
56+
uses: rumblefrog/setup-sp@v1.2.4
57+
with:
58+
version: '1.12.7193' ### UPDATE Makefile.toml whenever this is updated.
59+
- name: Setup Zig
60+
uses: mlugg/setup-zig@v1
61+
with:
62+
version: '0.13.0' ### UPDATE Makefile.toml whenever this is updated.
63+
- name: Build extensions
64+
working-directory: ./srcwrtimer_sample_extension
65+
run: cargo make --profile ${{ matrix.targetbits }} ${{ matrix.targetos }}
66+
- name: Copy things to _package
67+
working-directory: ./srcwrtimer_sample_extension
68+
run: |
69+
cargo make copy-srcwrtimer
70+
cargo make copy-extensions
71+
- name: Build plugins
72+
working-directory: ./srcwrtimer_sample_extension
73+
run: cargo make compile-srcwrtimer-scripts
74+
- name: Upload package
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: sample-${{ github.head_ref || github.ref_name }}-${{ env.GITHUB_SHA_SHORT }}-${{ matrix.targetos }}-${{ matrix.targetbits }}
78+
path: srcwrtimer_sample_extension/_package/srcwrtimer
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Post artifact link in pull request
2+
on:
3+
workflow_run:
4+
workflows: ['Build everything']
5+
types: [completed]
6+
jobs:
7+
pr_comment:
8+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/github-script@v6
12+
with:
13+
# This snippet is public-domain, taken from
14+
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
15+
script: |
16+
async function upsertComment(owner, repo, issue_number, purpose, body) {
17+
const {data: comments} = await github.rest.issues.listComments(
18+
{owner, repo, issue_number});
19+
20+
const marker = `<!-- bot: ${purpose} -->`;
21+
body = marker + "\n" + body;
22+
23+
const existing = comments.filter((c) => c.body.includes(marker));
24+
if (existing.length > 0) {
25+
const last = existing[existing.length - 1];
26+
core.info(`Updating comment ${last.id}`);
27+
await github.rest.issues.updateComment({
28+
owner, repo,
29+
body,
30+
comment_id: last.id,
31+
});
32+
} else {
33+
core.info(`Creating a comment in issue / PR #${issue_number}`);
34+
await github.rest.issues.createComment({issue_number, body, owner, repo});
35+
}
36+
}
37+
38+
const {owner, repo} = context.repo;
39+
const run_id = ${{github.event.workflow_run.id}};
40+
41+
const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }};
42+
if (!pull_requests.length) {
43+
return core.error("This workflow doesn't match any pull requests!");
44+
}
45+
46+
const artifacts = await github.paginate(
47+
github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id});
48+
if (!artifacts.length) {
49+
return core.error(`No artifacts found`);
50+
}
51+
let body = `Download the artifacts for this pull request:\n`;
52+
for (const art of artifacts) {
53+
body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
54+
}
55+
56+
core.info("Review thread message body:", body);
57+
58+
for (const pr of pull_requests) {
59+
await upsertComment(owner, repo, pr.number,
60+
"nightly-link", body);
61+
}

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
/_build
3+
/_package
4+
/_external
5+
6+
/target
7+
/debug
8+
/release
9+
10+
*secret*
11+
12+
*.ilk
13+
*.smx
14+
*.dll
15+
*.exe
16+
*.so
17+
*.pdb
18+
*.zip

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"rust-analyzer.cargo.target": "i686-pc-windows-msvc",
3+
"rust-analyzer.cargo.extraArgs": ["--release"],
4+
"rust-analyzer.check.allTargets": false,
5+
"rust-analyzer.checkOnSave.allTargets": false,
6+
"search.exclude": {
7+
"**/_build": true,
8+
"**/_package": true,
9+
"**/target": true
10+
}
11+
}

0 commit comments

Comments
 (0)