Skip to content

Commit 1faa873

Browse files
committed
Merge branch 'master' into better-caching
2 parents 9ca9b04 + 0ca5f73 commit 1faa873

182 files changed

Lines changed: 18261 additions & 2866 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ jobs:
1717
working_directory: ~/repo/de.peeeq.wurstscript
1818

1919
environment:
20-
# Customize the JVM maximum heap limit
21-
JVM_OPTS: -Xmx3200m
20+
GRADLE_OPTS: -Dorg.gradle.parallel=false -Dorg.gradle.workers.max=2
2221
TERM: dumb
2322

2423
steps:
@@ -28,20 +27,18 @@ jobs:
2827
# Download and cache dependencies
2928
- restore_cache:
3029
keys:
31-
- v1-dependencies-{{ checksum "build.gradle" }}
30+
- v2-gradle-{{ checksum "build.gradle" }}-{{ checksum "gradle.properties" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
3231
# fallback to using the latest cache if no exact match is found
33-
- v1-dependencies-
34-
35-
- run: ./gradlew dependencies
32+
- v2-gradle-
3633

3734
- save_cache:
3835
paths:
3936
- ~/.gradle
40-
key: v1-dependencies-{{ checksum "build.gradle" }}
41-
42-
# run tests
43-
- run: ./gradlew test --info
37+
key: v2-gradle-{{ checksum "build.gradle" }}-{{ checksum "gradle.properties" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
4438

45-
# report tests results
46-
- run: ./gradlew jacocoTestReport coveralls
39+
# run tests and coverage in one invocation to avoid duplicate config/startup cost
40+
- run:
41+
name: Run tests and coverage
42+
command: ./gradlew --no-daemon --stacktrace test jacocoTestReport coveralls
43+
no_output_timeout: 30m
4744

.github/workflows/build.yml

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
permissions:
2222
contents: read
2323
env:
24+
JAVA_TOOL_OPTIONS: >-
25+
-XX:+UseCompactObjectHeaders
26+
-XX:+UseStringDeduplication
2427
GRADLE_OPTS: -Dorg.gradle.daemon=false
2528
defaults:
2629
run:
@@ -81,6 +84,14 @@ jobs:
8184
shell: bash
8285
run: ./gradlew packageSlimCompilerDist --no-daemon --stacktrace
8386

87+
- name: Prepare bundled Lua runtime (Linux)
88+
if: runner.os == 'Linux'
89+
shell: bash
90+
run: |
91+
if [[ -f src/test/resources/lua53 ]]; then
92+
chmod +x src/test/resources/lua53
93+
fi
94+
8495
- name: Run tests
8596
shell: bash
8697
run: ./gradlew test --no-daemon --stacktrace
@@ -104,6 +115,18 @@ jobs:
104115
permissions:
105116
contents: write
106117
steps:
118+
- name: Checkout (to update nightly tag)
119+
uses: actions/checkout@v4
120+
with:
121+
fetch-depth: 0
122+
123+
- name: Move 'nightly' tag to this commit
124+
run: |
125+
git config user.name "github-actions[bot]"
126+
git config user.email "github-actions[bot]@users.noreply.github.com"
127+
git tag -f nightly "$GITHUB_SHA"
128+
git push origin nightly --force
129+
107130
- name: Download all packaged artifacts
108131
uses: actions/download-artifact@v4
109132
with:
@@ -126,6 +149,7 @@ jobs:
126149
echo "ERROR: expected at least Win + Linux zips."
127150
exit 1
128151
fi
152+
129153
- name: Normalize nightly filenames
130154
shell: bash
131155
run: |
@@ -139,52 +163,13 @@ jobs:
139163
done
140164
echo "Renamed to:"; ls -alh upload
141165
142-
# Delete old release + tag, then create a fresh one at HEAD
143-
- name: Recreate nightly release and tag at HEAD
144-
uses: actions/github-script@v7
145-
with:
146-
script: |
147-
const { owner, repo } = context.repo;
148-
const tag = 'nightly';
149-
150-
// Delete existing release (if any)
151-
try {
152-
const rel = await github.rest.repos.getReleaseByTag({ owner, repo, tag });
153-
await github.rest.repos.deleteRelease({ owner, repo, release_id: rel.data.id });
154-
core.info(`Deleted release id=${rel.data.id}`);
155-
} catch (e) {
156-
core.info(`No previous release to delete: ${e.message}`);
157-
}
158-
159-
// Delete tag (if any)
160-
try {
161-
await github.rest.git.deleteRef({ owner, repo, ref: `tags/${tag}` });
162-
core.info('Deleted ref tags/nightly');
163-
} catch (e) {
164-
core.info(`No existing tag to delete: ${e.message}`);
165-
}
166-
167-
// Create fresh prerelease at the current commit
168-
const { data: rel2 } = await github.rest.repos.createRelease({
169-
owner, repo,
170-
tag_name: tag,
171-
target_commitish: context.sha,
172-
name: 'Nightly Build (master)',
173-
body: 'Nightly build for the latest commit on `master`.\nThis release is automatically updated on each push.',
174-
draft: false,
175-
prerelease: true,
176-
make_latest: 'false' // MUST be a string
177-
});
178-
core.setOutput('upload_url', rel2.upload_url);
179-
180166
- name: Publish Nightly Release (upload assets)
181167
uses: softprops/action-gh-release@v2
182168
with:
183169
tag_name: nightly
184-
target_commitish: ${{ github.sha }}
185170
prerelease: true
186171
draft: false
187-
make_latest: "false" # keep as string here too
172+
make_latest: "false"
188173
name: Nightly Build (master)
189174
body: |
190175
Nightly build for the latest commit on `master`.
@@ -193,5 +178,3 @@ jobs:
193178
fail_on_unmatched_files: false
194179
env:
195180
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196-
197-

AGENTS.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# AGENTS.md
2+
3+
This document defines how automated coding assistants (“agents”) should interact with this repository.
4+
5+
## 1. Repository Overview
6+
7+
This repository contains the **WurstScript compiler**. Its main code lives in:
8+
9+
```
10+
de.peeeq.wurstscript/
11+
```
12+
13+
Other directories like `WurstPack` and `HelperScripts` exist but are largely **deprecated** and should not be modified unless explicitly requested.
14+
15+
### Compiler layout
16+
17+
Inside `de.peeeq.wurstscript`:
18+
19+
* **`src/main/antlr/de/peeeq/wurstscript/antlr/`**
20+
Contains the **ANTLR grammars** (`.g4`) for Wurst and Jass.
21+
These produce concrete syntax trees (CSTs).
22+
23+
* **`parserspec/`**
24+
Contains **.parseq grammars** for `abstractsyntaxgen`
25+
([https://github.com/peterzeller/abstractsyntaxgen](https://github.com/peterzeller/abstractsyntaxgen)).
26+
These define the AST structure used by the compiler.
27+
Code is generated via the Gradle task:
28+
29+
```
30+
./gradlew :gen
31+
```
32+
33+
* **`src/main/java/de/peeeq/`**
34+
Main compiler sources:
35+
36+
* Parsing and AST infrastructure
37+
* Type checking
38+
* Intermediate language (**IM**)
39+
* Jass and Lua backends
40+
* Interpreter for executing IM at compile time
41+
(used for specific compile-time evaluations)
42+
43+
### Compilation pipeline (simplified)
44+
45+
1. Parse Wurst/Jass with ANTLR → CST
46+
2. Abstractsyntaxgen → AST
47+
3. Transform AST → IM
48+
4. Optionally: Run IM in the interpreter, Optimize
49+
5. Transform IM → Backend (Jass or Lua)
50+
51+
52+
### Language and tooling
53+
54+
* **Java 25**
55+
* **Gradle (9.2.1)**
56+
* Unit tests define many entry points and expected behaviors.
57+
58+
---
59+
60+
## 2. Agent Expectations
61+
62+
Changes made by agents must follow these principles:
63+
64+
### Compatibility first
65+
66+
* **All existing tests must continue to pass.**
67+
* If behavior changes intentionally, provide **new tests** that define the updated semantics.
68+
69+
### Minimal, well-scoped edits
70+
71+
Agents should:
72+
73+
* Fix concrete bugs with **small, local patches**.
74+
* Add missing null-checks, defensive checks, or diagnostics where appropriate.
75+
* Add tests when resolving issues or implementing requested features.
76+
77+
Agents should avoid:
78+
79+
* Large refactors (renaming packages, structural moves, mass rewrites).
80+
* Modifying deprecated folders unless explicitly instructed.
81+
* Altering public semantics or language rules without tests demonstrating the intended outcome.
82+
83+
### Test-driven
84+
85+
* Any new behavior requires tests showing failure before the change and success after.
86+
* Use existing test style and harnesses.
87+
88+
### Generated code
89+
90+
* Do **not** modify files generated by `:gen`.
91+
* If modifying `.parseq` files or grammars, regenerate via:
92+
93+
```
94+
./gradlew :gen
95+
```
96+
97+
---
98+
99+
## 3. Coding Guidelines
100+
101+
### Follow existing style
102+
103+
Use the conventions already present in the file you edit. Avoid introducing new patterns without reason.
104+
105+
### Compiler structure expectations
106+
107+
* The IM is the central intermediate representation.
108+
* Transformations should keep IM consistent and valid.
109+
* Backends (Jass/Lua) expect well-formed IM; avoid breaking invariants.
110+
* Interpreter should remain deterministic and side-effect free.
111+
112+
### Error handling
113+
114+
* Prefer explicit, descriptive diagnostic messages.
115+
* Avoid silent fallbacks or suppressed exceptions.
116+
* Don’t change the meaning of existing error messages unless required.
117+
118+
### Performance
119+
120+
* Avoid algorithmic regressions in parsing, type checking, or transforms.
121+
* Consider memory impact when manipulating large ASTs or IM graphs.
122+
123+
---
124+
125+
## 4. Allowed vs. Disallowed Changes
126+
127+
### Allowed
128+
129+
* Fix a crash or incorrect behavior in a specific compiler pass.
130+
* Add a regression test that demonstrates a known issue.
131+
* Improve clarity of error messages.
132+
* Add a small new feature when fully specified by the user and backed by tests.
133+
* Update Gradle/JDK usage only if part of a requested task.
134+
135+
### Disallowed
136+
137+
* Unsolicited rewrites of ANTLR grammars.
138+
* Modifying deprecated folders.
139+
* Changing code generation semantics without explicit tests.
140+
* Changing IM behavior without test coverage.
141+
* Introducing new external dependencies unless requested.
142+
143+
---
144+
145+
## 5. How to Run Tests and Code Generation
146+
147+
Inside
148+
149+
```
150+
de.peeeq.wurstscript/
151+
```
152+
153+
run:
154+
155+
### Run all tests
156+
157+
```
158+
./gradlew test
159+
```
160+
161+
### Run a specific test
162+
163+
```
164+
./gradlew test --tests "tests.wurstscript.tests.GenericsWithTypeclassesTests.identity"
165+
```
166+
167+
### Generate AST code via ANTLR & abstractsyntaxgen
168+
169+
```
170+
./gradlew :gen
171+
```
172+
173+
### Build the compiler
174+
175+
```
176+
./gradlew build
177+
```
178+
179+
---
180+
181+
## 6. Summary for Agents
182+
183+
* Keep changes **minimal**, **compatible**, and **tested**.
184+
* The authoritative behavior is defined by the **existing test suite**.
185+
* The compiler architecture relies on CST → AST → IM → Backend; treat each stage carefully.
186+
* Never modify generated files; modify the sources that generate them instead.
187+
* New behavior must be documented through tests.
188+
189+

Wurstpack/wurstscript/grill

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
java -jar ~/.wurst/WurstSetup.jar ${@:1:6}
4+
RUNTIME="$HOME/.wurst/wurst-runtime/bin/java"
5+
6+
# Resolve script dir (absolute)
7+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
9+
JAR="$DIR/grill/grill.jar"
10+
if [[ ! -f "$JAR" ]]; then
11+
JAR="$DIR/../grill/grill.jar"
12+
fi
13+
14+
if [[ ! -f "$JAR" ]]; then
15+
echo "[grill] ERROR: Missing jar. Searched:"
16+
echo " $DIR/grill/grill.jar"
17+
echo " $DIR/../grill/grill.jar"
18+
exit 2
19+
fi
20+
21+
if [[ ! -x "$RUNTIME" ]]; then
22+
echo "[grill] ERROR: Bundled runtime not found or not executable at:"
23+
echo " $RUNTIME"
24+
echo "Please reinstall wurstscript via the VSCode extension."
25+
exit 3
26+
fi
27+
28+
exec "$RUNTIME" -jar "$JAR" "$@"

0 commit comments

Comments
 (0)