Skip to content

Commit 5906cb2

Browse files
committed
refactor build process: use custom build.py instead of Make
1 parent 5e6c390 commit 5906cb2

File tree

10 files changed

+727
-220
lines changed

10 files changed

+727
-220
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ jobs:
3939
- name: Set up Gradle
4040
uses: gradle/actions/setup-gradle@v4
4141

42-
# 7. Make just the files needed to cargo cache
43-
- name: Make Gen Files
44-
run: make gen-files
42+
# 7. make just the files needed to cargo cache
43+
- name: Gen Files
44+
run: python3 build.py gen-files
4545

4646
# 8. Cargo Caching (Crucial for speed)
4747
- name: Cache cargo dependencies
4848
uses: Swatinem/rust-cache@v2
4949

50-
# 9. Build using the CI-specific make target
50+
# 9. Build using the CI-specific target
5151
- name: Build CI Target
52-
run: make ci # Use your optimized CI build command
52+
run: python3 build.py ci
5353

5454
# 10. Run tests
5555
- name: Run integration tests (debug mode)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
**/.gradle/*
66
**/build/*
77
**/.kotlin/*
8+
library/gradle/**
89

910
# Files generated by Tester.py
1011
**/*.generated

GenerateFiles.py

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

Makefile

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

Readme.md

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -99,43 +99,49 @@ All examples live in `tests/binary` and are compiled to JVM bytecode & run/teste
9999
git clone https://github.com/IntegralPilot/rustc_codegen_jvm.git
100100
cd rustc_codegen_jvm
101101

102-
# Build everything
103-
make all
102+
# Build all components using the build script.
103+
# This single command handles all dependencies and recompiles only what's necessary.
104+
105+
# On Linux or macOS:
106+
./build.py all
107+
108+
# On Windows, or if the above gives a "permission denied" error:
109+
python3 build.py all
104110
```
105111

106-
This will compile:
112+
This will intelligently build all necessary components in the correct order:
107113

108-
- `rustc_codegen_jvm` backend library
109-
- `java-linker`
110-
- Kotlin shim for `core` (once core support is reached, this will no longer be needed)
111-
- Generate `config.toml` & `jvm-unknown-unknown.json`
114+
- The Kotlin library shim (`library/`)
115+
- The shim metadata file (`core.json`)
116+
- The `java-linker` executable
117+
- The `rustc_codegen_jvm` backend library
118+
- Configuration files (`config.toml`, `jvm-unknown-unknown.json`)
119+
- Vendored dependencies like R8
112120

113-
If you relocate the repo, re-run:
114-
```bash
115-
make gen-files
116-
```
121+
The script uses timestamp checking, so subsequent runs of `./build.py` will be very fast, only rebuilding parts of the project that have changed.
117122

118123
---
119124

120125
## 🚀 Usage
121126

122-
1. **Configure your project**
123-
In *your* Rust project directory, create or update `.cargo/config.toml` by copying the generated template (will be at the root of this repo after running make). Also, your `Cargo.toml` needs to contain the following (used to pass flags differentiating between debug and release builds to the linker):
127+
1. **Configure your project**
128+
In *your* Rust project directory, create or update `.cargo/config.toml` by copying the generated template (it will be at the root of this repository after running the build script). Also, your `Cargo.toml` needs to contain the following (used to pass flags differentiating between debug and release builds to the linker):
124129

125-
```toml
126-
cargo-features = ["profile-rustflags"]
127-
```
130+
```toml
131+
cargo-features = ["profile-rustflags"]
132+
```
128133

129-
2. **Build with Cargo**
130-
```bash
131-
cargo build # debug
132-
cargo build --release # optimized
133-
```
134+
2. **Build with Cargo**
135+
```bash
136+
cargo build # debug
137+
cargo build --release # optimized
138+
```
134139

135-
3. **Run the `.jar`**
136-
```bash
137-
java -jar target/debug/deps/your_crate*.jar
138-
```
140+
3. **Run the `.jar`**
141+
```bash
142+
java -jar target/debug/deps/your_crate*.jar # debug
143+
java -jar target/release/deps/your_crate*.jar # release
144+
```
139145

140146
---
141147

@@ -144,16 +150,21 @@ make gen-files
144150
Ensure the toolchain is built:
145151

146152
```bash
147-
make all
148-
# If you moved the repo:
149-
make gen-files
153+
# On Linux/macOS:
154+
./build.py all
155+
156+
# On Windows:
157+
python3 build.py all
150158
```
151159

152-
Then:
160+
Then, run the test suite:
153161

154162
```bash
163+
# Run tests in debug mode
155164
python3 Tester.py
156-
# or with --release for release‑mode tests
165+
166+
# Run tests in release mode
167+
python3 Tester.py --release
157168
```
158169

159170
Look for `✅ All tests passed!` or inspect `.generated` files on failure.
@@ -164,21 +175,20 @@ Look for `✅ All tests passed!` or inspect `.generated` files on failure.
164175

165176
```
166177
.
167-
├── src/ # rustc_codegen_jvm backend
178+
├── src/ # rustc_codegen_jvm backend
168179
│ ├── lib.rs
169-
│ ├── lower1.rs # MIR → OOMIR
170-
│ ├── lower2.rs # OOMIR → JVM bytecode
171-
│ └── oomir.rs # OOMIR definitions
172-
├── java-linker/ # Bundles .class files into .jar
173-
├── tests/binary/ # Integration tests
174-
├── library/ # Kotlin shim for Rust core library
175-
├── shim-metadata-gen/ # Generates core.json metadata
176-
├── proguard/ # .pro rules used for r8
177-
├── Makefile # build & gen-files
180+
│ ├── lower1.rs # MIR → OOMIR
181+
│ ├── lower2.rs # OOMIR → JVM bytecode
182+
│ └── oomir.rs # OOMIR definitions
183+
├── java-linker/ # Bundles .class files into .jar
184+
├── tests/binary/ # Integration tests
185+
├── library/ # Kotlin shim for Rust core library
186+
├── shim-metadata-gen/ # Generates core.json metadata
187+
├── proguard/ # .pro rules used for r8
188+
├── build.py # Main build script (replaces Makefile)
178189
├── config.toml.template
179190
├── jvm-unknown-unknown.json.template
180-
├── Tester.py # test runner
181-
├── GenerateFiles.py # regenerates config & target spec
191+
├── Tester.py # Test runner script
182192
└── LICENSE, LICENSE-Apache
183193
```
184194

@@ -192,6 +202,6 @@ Contributions, issues & PRs welcome! :)
192202

193203
## 📄 License
194204

195-
Dual‑licensed under **MIT** OR **Apache 2.0** at your option:
196-
<https://opensource.org/licenses/MIT>
197-
<https://www.apache.org/licenses/LICENSE-2.0>
205+
Dual‑licensed under **MIT** OR **Apache 2.0** at your option:
206+
<https://opensource.org/licenses/MIT>
207+
<https://www.apache.org/licenses/LICENSE-2.0>

0 commit comments

Comments
 (0)