Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
037d177
docs: add gh-pages.mjs
Jan 22, 2024
bcf247e
test: remove react source in repo, using cdn resource
Jan 22, 2024
cf091b3
docs: update readme
Jan 22, 2024
3fc0da4
chore: add kover
Jan 22, 2024
1148987
chore: add kover token
Jan 22, 2024
a6229c9
chore: kover.yaml add distribution field
Jan 22, 2024
d8aa82a
Create gradle.properties
yidafu Jan 23, 2024
7290548
chore: gradle-wrapper.properties update distributionUrl
yidafu Jan 23, 2024
b98cd9f
chore: update java-version to 17
yidafu Jan 23, 2024
6a566d2
Update kover.yaml
yidafu Jan 23, 2024
2639d59
Update kover.yaml
yidafu Jan 23, 2024
70696d4
Update kover.yaml
yidafu Jan 23, 2024
a15972d
Update kover.yaml
yidafu Jan 23, 2024
a398fda
chore: update kover.yml
Jan 23, 2024
f0c5930
chore: update rust target
Jan 23, 2024
401117d
chore: update kover.yaml
Jan 23, 2024
e186097
chore: add rustup add targets
Jan 23, 2024
fce0eea
chore: apt add build-essential
Jan 23, 2024
f95b994
chore: sudo apt
Jan 23, 2024
0b9ed94
chore: update kover.yaml
Jan 23, 2024
6534295
chore: add setup-ubuntu.sh
Jan 23, 2024
f227271
chore: add release job
Jan 23, 2024
29edfa0
chore: add release job
Jan 23, 2024
aa93616
chore: x86_64-unknown-linux-gnu remove linker
Jan 23, 2024
4dc6571
chore: update kover.yaml
Jan 23, 2024
7be9f15
chore: update setup-ubuntu.sh
Jan 23, 2024
8d48c91
chore: update setup-ubuntu.sh
Jan 23, 2024
e50c0f7
chore: add llvm
Jan 23, 2024
d9ea8a8
chore: update kover.yaml
Jan 23, 2024
1017e48
chore: update build script
Jan 23, 2024
acad84a
chore: update build script
Jan 23, 2024
f82ded9
feat(swc-generator-kt): implement Kotlin generator with KotlinPoet an…
Oct 21, 2025
db7712c
test: add comprehensive test coverage for swc-binding module
Oct 21, 2025
278bdb6
refactor(swc-generator-kt): remove AST JSON generation and improve CLI
Oct 22, 2025
c71dfa4
feat: upgrade swc-jni dependencies to latest versions
Oct 22, 2025
a3f13ba
docs: update swc-jni README with latest dependency versions and enhan…
Oct 22, 2025
7cedc90
fix: resolve cargo clippy warnings
Oct 22, 2025
904275a
feat: unify project license to MIT
Oct 22, 2025
9af5ba1
fix: resolve swc-binding test failures
Oct 22, 2025
453fec1
fix: partial fix for AST compatibility issues with SWC 43.0.0
Oct 22, 2025
98ed4eb
fix: correct DSL generation directory path
Oct 22, 2025
0e9170b
Optimize build artifact directory structure and toolchain configuration
Oct 22, 2025
5a19fb5
Add build setup automation and fix Linux ARM64 cdylib support
Oct 22, 2025
3ac7328
Rename swc-generator-kt to swc-generator
Oct 22, 2025
ef5a708
refactor(swc-generator): restructure package hierarchy for better cod…
Oct 22, 2025
7d5262d
refactor: implement new architecture for swc-generator
Oct 23, 2025
15c7af0
feat: implement nullable properties and sealed interface generation
Oct 23, 2025
feaeae3
fix: set type property default value to interface name in implementat…
Oct 23, 2025
7da7843
fix: generate string literals for type property default values
Oct 23, 2025
2790b03
fix: ensure implementation classes inherit interfaces instead of classes
Oct 23, 2025
90b99c1
feat: optimize code generator performance and improve type handling
Oct 23, 2025
4d50308
refactor: major restructuring of swc-binding DSL architecture
Oct 23, 2025
ac81d93
Clean up swc-generator test outputs
yidafu Oct 24, 2025
eebb925
refactor: optimize swc-generator architecture and performance
yidafu Oct 25, 2025
a1c755d
feat: optimize swc-generator codebase for performance and maintainabi…
yidafu Oct 25, 2025
65b8fa5
feat: optimize swc-generator codebase for performance and maintainabi…
yidafu Oct 25, 2025
c92c673
fix: improve nested interface handling in code generator
yidafu Oct 25, 2025
ace5a6a
refactor: replace HashMap/HashSet with LinkedHashMap/LinkedHashSet fo…
yidafu Oct 25, 2025
670f973
fix: fix test compilation errors and improve test coverage
Nov 14, 2025
e0f5003
Merge branch 'feature/kotlin-generator-impl' of https://github.com/yi…
Nov 14, 2025
73d7c0d
refactor: restructure swc-generator architecture with Pipeline patter…
yidafu Nov 14, 2025
fb16041
refactor: finalize generator pipeline and add exhaustive tests
yidafu Nov 14, 2025
3835987
refactor: rework union API to drop legacy generated factories
yidafu Nov 14, 2025
321ef30
chore(gradle): centralize dependency versions via libs catalog
yidafu Nov 14, 2025
57619ea
Merge branch 'feature/kotlin-generator-impl' of https://github.com/yi…
yidafu Nov 14, 2025
ccc0bc8
chore(tests): drop redundant generator specs from merge
yidafu Nov 14, 2025
3e8f115
refactor(swc-jni): extract sync work functions and improve error hand…
yidafu Nov 15, 2025
6a22fe9
feat(swc-generator): generate per-Union with-serializers and refactor…
yidafu Nov 16, 2025
eeaf18d
test(swc-generator): add and update tests for union dedupe, DSL pipel…
yidafu Nov 16, 2025
c82e882
refactor(types)!: remove Booleanable; update Union/DSL/JSON; refresh …
yidafu Nov 16, 2025
e2b2112
test: replace custom test assertions with kotlin.test/kotest and remo…
yidafu Nov 16, 2025
4123c47
Resolve merge conflicts from feature/kover: gitignore, docs, gradle p…
yidafu Nov 16, 2025
e353d0b
feat(docs): standardize READMEs and add zh-CN mirrors
yidafu Nov 16, 2025
4b09190
feat(swc-generator): fix kotlinx.serialization polymorphism and discr…
yidafu Nov 16, 2025
f343b8a
feat(generator): introduce NameUtils and enhance Union serialization …
yidafu Nov 16, 2025
3da5a81
test(binding): add E2E pipeline and async file tests; extend options/…
yidafu Nov 16, 2025
68c2d14
refactor(swc-generator)!: remove *Impl generation and UnionFactory; r…
yidafu Nov 16, 2025
0c8fbbf
refactor(generator): streamline union serializer generation and modul…
yidafu Nov 16, 2025
a42b46f
feat(binding): improve SwcNative API; refine DSL/JSON; reorganize tests
yidafu Nov 16, 2025
5ad2262
feat(binding): expand SwcNative API; refine DSL/JSON; reorganize tests
yidafu Nov 16, 2025
5cd37a1
feat(generator): enhance type system with alias expansion and LCA det…
yidafu Nov 17, 2025
8679a02
refactor(generator): improve code maintainability and quality
yidafu Nov 17, 2025
cced169
refactor(swc-jni): remove debug code and translate comments to English
yidafu Nov 17, 2025
42e738c
feat: significantly increase test coverage and fix compilation errors
yidafu Nov 17, 2025
87127c1
refactor(generator): remove hardcoded configuration and improve code …
yidafu Nov 18, 2025
b1deb74
feat(binding): add custom type definitions and comprehensive AST seri…
yidafu Nov 18, 2025
84a40e2
refactor(swc-jni): remove debug code and eliminate duplicate code pat…
yidafu Nov 18, 2025
0c736d6
feat(binding): generate comprehensive AST node classes, DSL builders,…
yidafu Nov 18, 2025
b9738e1
refactor(generator): improve serialization configuration and file com…
yidafu Nov 18, 2025
bf2b8af
feat(generator): add default serializer support and refactor code str…
yidafu Nov 19, 2025
ddcb992
feat(binding): add TruePlusMinusSerializer and expand test coverage
yidafu Nov 19, 2025
c7f3c6d
feat(generator): add default serializer support and refactor code str…
yidafu Nov 19, 2025
90a0889
test(binding): add comprehensive ES feature tests for ES2015-ES2025
yidafu Nov 19, 2025
545d69f
refactor(generator): add CollectionUtils and unify collection initial…
yidafu Nov 19, 2025
b9d39e3
refactor(binding): unify code formatting and translate comments to En…
yidafu Nov 19, 2025
bd36b3c
ci(workflows): update kover workflow to report only swc-binding modul…
yidafu Nov 19, 2025
1bec05c
chore(binding): configure ktlint to exclude generated code directories
yidafu Nov 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
65 changes: 65 additions & 0 deletions .github/workflows/kover.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Measure coverage

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 需要完整历史记录以计算覆盖率差异

- name: Set up Zig
uses: goto-bus-stop/setup-zig@v2

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: 'x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu,x86_64-pc-windows-msvc,x86_64-apple-darwin,aarch64-apple-darwin'

- name: Install system dependencies
run: bash ./setup-ubuntu.sh

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Set up Gradle
uses: gradle/gradle-build-action@v3
with:
cache-read-only: false

- name: Run tests with coverage for swc-binding module
run: ./gradlew :swc-binding:test :swc-binding:koverXmlReport --no-daemon

- name: Verify coverage report exists
run: |
if [ ! -f "swc-binding/build/reports/kover/report.xml" ]; then
echo "Error: Coverage report not found!"
exit 1
fi
echo "Coverage report found at swc-binding/build/reports/kover/report.xml"

- name: Add coverage report to PR
id: kover
uses: mi-kas/kover-report@v1
with:
path: |
${{ github.workspace }}/swc-binding/build/reports/kover/report.xml
title: 📊 Code Coverage Report
# 使用 github.token(已通过 permissions.pull-requests: write 授权)
# 如需使用自定义 token,可在仓库 Secrets 中设置 PR_TOKEN 并替换为 ${{ secrets.PR_TOKEN }}
token: ${{ secrets.PR_TOKEN || github.token }}
update-comment: true
min-coverage-overall: 80
min-coverage-changed-files: 80
coverage-counter-type: LINE
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,16 @@ gradle-app.setting

# End of https://www.toptal.com/developers/gitignore/api/kotlin,gradle,rust,node

.DS_Store
# swc/ directory (but not test files)
*.md
.gitignore
swc-generator/test-outputs/
backup-20251022-125828/
swc-jni/.cargo/
swc-jni/*.sh
swc-jni/coverage.json
swc-jni/build.sh
.DS_Store
test-outputs/
swc-binding/bin/
build-plugin/bin
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/swc-binding.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "disabled"
}
197 changes: 197 additions & 0 deletions BUILD_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
# SWC JNI Binding - Build Setup Guide

This guide explains how to set up the build environment for SWC JNI bindings across multiple platforms.

## 🚀 Quick Start

### 1. Run the setup script

```bash
./setup.sh
```

### 2. Build all platforms

```bash
cd swc-jni && ./build.sh
```

## 📋 Prerequisites

### Required Software

- **Rust** (latest stable version)
- **cargo-zigbuild** (for cross-compilation)
- **Git** (for version control)

### Platform-specific Requirements

- **macOS**: Xcode Command Line Tools
- **Linux**: Standard build tools (gcc, make)
- **Windows**: No additional requirements (cross-compiled from any platform)

## 🔧 Setup Script Features

The `setup.sh` script automatically:

1. **Verifies Rust installation**
2. **Installs required Rust targets**:
- `x86_64-apple-darwin` (macOS Intel)
- `aarch64-apple-darwin` (macOS ARM64)
- `x86_64-unknown-linux-musl` (Linux x64 static)
- `aarch64-unknown-linux-gnu` (Linux ARM64)
- `x86_64-pc-windows-gnu` (Windows x64)
- `aarch64-pc-windows-gnullvm` (Windows ARM64)

3. **Installs cargo-zigbuild** for cross-compilation
4. **Verifies build environment**
5. **Provides build configuration summary**

## 🏗️ Build Configuration

### Platform Support Matrix

| Platform | Architecture | Toolchain | Directory | Static Linking |
|----------|-------------|-----------|-----------|----------------|
| **macOS** | Intel | Apple | `darwin-x64-apple` | No |
| **macOS** | ARM64 | Apple | `darwin-arm64-apple` | No |
| **Linux** | x64 | musl | `linux-x64-musl` | ✅ Yes |
| **Linux** | ARM64 | GNU | `linux-arm64-gnu` | No |
| **Windows** | x64 | GNU | `windows-x64-gnu` | No |
| **Windows** | ARM64 | GNU | `windows-arm64-gnu` | No |

### Toolchain Selection Rationale

- **macOS**: Uses Apple native toolchain for optimal performance
- **Linux x64**: Uses musl for static linking and better compatibility
- **Linux ARM64**: Uses GNU toolchain (musl doesn't support cdylib)
- **Windows**: Uses GNU toolchain for better cross-platform compatibility

## 🛠️ Manual Setup (Alternative)

If you prefer manual setup:

### 1. Install Rust

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
```

### 2. Install Rust targets

```bash
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
rustup target add x86_64-unknown-linux-musl
rustup target add aarch64-unknown-linux-gnu
rustup target add x86_64-pc-windows-gnu
rustup target add aarch64-pc-windows-gnullvm
```

### 3. Install cargo-zigbuild

```bash
cargo install cargo-zigbuild
```

## 🧪 Testing the Setup

### Test build (recommended)

```bash
./setup.sh --test-build
```

### Manual verification

```bash
cd swc-jni
cargo check --target x86_64-apple-darwin
cargo check --target aarch64-apple-darwin
cargo check --target x86_64-unknown-linux-musl
cargo check --target aarch64-unknown-linux-gnu
cargo check --target x86_64-pc-windows-gnu
cargo check --target aarch64-pc-windows-gnullvm
```

## 📁 Output Structure

After successful build, libraries will be available in:

```
swc-binding/src/main/resources/
├── darwin-x64-apple/
│ └── libswc_jni.dylib
├── darwin-arm64-apple/
│ └── libswc_jni.dylib
├── linux-x64-musl/
│ └── libswc_jni.so
├── linux-arm64-gnu/
│ └── libswc_jni.so
├── windows-x64-gnu/
│ └── swc_jni.dll
└── windows-arm64-gnu/
└── swc_jni.dll
```

## 🔍 Troubleshooting

### Common Issues

1. **Rust not found**

```bash
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
```

2. **cargo-zigbuild installation failed**

```bash
# Try with specific version
cargo install cargo-zigbuild --version 0.18.0
```

3. **Target installation failed**

```bash
# Update Rust first
rustup update
# Then retry target installation
rustup target add <target-name>
```

4. **Build fails with "cdylib not supported"**
- This is expected for `aarch64-unknown-linux-musl`
- The build script uses `aarch64-unknown-linux-gnu` instead

### Environment Variables

Optional environment variables for debugging:

```bash
export RUST_LOG=debug # Enable debug logging
export CARGO_TARGET_DIR=custom_target # Custom target directory
export CC_aarch64_unknown_linux_gnu=zig # Use zig as linker
```

## 📚 Additional Resources

- [Rust Cross-compilation Guide](https://rust-lang.github.io/rustup/cross-compilation.html)
- [cargo-zigbuild Documentation](https://github.com/rust-cross/cargo-zigbuild)
- [SWC Documentation](https://swc.rs/)

## 🤝 Contributing

If you encounter issues or have suggestions:

1. Check the troubleshooting section
2. Review the build logs
3. Open an issue with detailed information
4. Include your platform and Rust version

---

**Happy building! 🎉**
Loading
Loading