|
| 1 | +# Contributing |
| 2 | + |
| 3 | +## Commits |
| 4 | + |
| 5 | +Commits must follow the [Conventional Commits] specification. |
| 6 | +If you're developing on IntelliJ IDEA or Android Studio, |
| 7 | +you can use the [Conventional Commit plugin]. |
| 8 | + |
| 9 | +[Conventional Commits]: https://www.conventionalcommits.org/en/v1.0.0/ |
| 10 | +[Conventional Commit plugin]: https://plugins.jetbrains.com/plugin/13389-conventional-commit |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- JDK 17+ |
| 15 | +- Android SDK & NDK |
| 16 | +- CMake |
| 17 | +- C compiler |
| 18 | + |
| 19 | +## Building |
| 20 | + |
| 21 | +### Clone the repository |
| 22 | + |
| 23 | +```shell |
| 24 | +git clone https://github.com/tree-sitter/kotlin-tree-sitter |
| 25 | +cd kotlin-tree-sitter |
| 26 | +``` |
| 27 | + |
| 28 | +### Build the JNI libraries |
| 29 | + |
| 30 | +*This step is only necessary for JVM or Android development.* |
| 31 | + |
| 32 | +Generate the grammar files: |
| 33 | + |
| 34 | +```shell |
| 35 | +./gradlew generateGrammarFiles |
| 36 | +``` |
| 37 | + |
| 38 | +Set the `CMAKE_INSTALL_LIBDIR` environment variable. |
| 39 | +The value depends on your system: |
| 40 | + |
| 41 | +- `lib/linux/x64` |
| 42 | +- `lib/linux/aarch64` |
| 43 | +- `lib/macos/x64` |
| 44 | +- `lib/macos/aarch64` |
| 45 | +- `lib/windows/x64` |
| 46 | + |
| 47 | +Build the libraries (change `.sh` to `.ps1` on Windows): |
| 48 | + |
| 49 | +```shell |
| 50 | +./.github/scripts/build-jni.sh |
| 51 | +``` |
| 52 | + |
| 53 | +### Run the tests |
| 54 | + |
| 55 | +#### JVM |
| 56 | + |
| 57 | +```shell |
| 58 | +./gradlew :ktreesitter:jvmTest |
| 59 | +``` |
| 60 | + |
| 61 | +#### Android |
| 62 | + |
| 63 | +*Requires a connected device.* |
| 64 | + |
| 65 | +```shell |
| 66 | +./gradlew :ktreesitter:connectedDebugAndroidTest |
| 67 | +``` |
| 68 | + |
| 69 | +#### Native |
| 70 | + |
| 71 | +Linux: |
| 72 | + |
| 73 | +```shell |
| 74 | +./gradlew :ktreesitter:linuxX64Test |
| 75 | +``` |
| 76 | + |
| 77 | +macOS: |
| 78 | + |
| 79 | +```shell |
| 80 | +# x64 |
| 81 | +./gradlew :ktreesitter:macosX64Test |
| 82 | +# arm64 |
| 83 | +./gradlew :ktreesitter:macosArm64Test |
| 84 | +``` |
| 85 | + |
| 86 | +Windows: |
| 87 | + |
| 88 | +```shell |
| 89 | +./gradlew :ktreesitter:mingwX64Test |
| 90 | +``` |
| 91 | + |
| 92 | +## Linting |
| 93 | + |
| 94 | +Code linting is performed using [Ktlint] and [detekt]. |
| 95 | +Configuration for IntelliJ IDEA and Android Studio is included |
| 96 | +(requires the [Ktlint][Ktlint plugin] and [detekt][detekt plugin] plugins). |
| 97 | + |
| 98 | +[Ktlint]: https://pinterest.github.io/ktlint/latest/ |
| 99 | +[detekt]: https://detekt.dev/ |
| 100 | +[Ktlint plugin]: https://plugins.jetbrains.com/plugin/15057-ktlint |
| 101 | +[detekt plugin]: https://plugins.jetbrains.com/plugin/10761-detekt |
0 commit comments