Skip to content

The useful template to get started with K2 Compiler Plugin development.

License

Notifications You must be signed in to change notification settings

kitakkun/k2-compiler-plugin-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K2 Compiler Plugin Template

This is a template project to get started with Kotlin Compiler Plugin development(K2).

Module setup

  • compiler: This module should contain the Kotlin Compiler Plugin implementation. It is where the core logic of the plugin is developed.
  • core: This is the runtime library required by the compiler plugin. It should contain annotation classes and any predefined declarations that the plugin will use.
  • test: This module is preconfigured to test the compiler plugin.

Getting Started

  1. Clone the repository: git clone [email protected]:kitakkun/k2-compiler-plugin-template.git
  2. Open the project with IDE (IntelliJ IDEA or Android Studio are recommended)
  3. Implement your plugin: See greeting-plugin to understand how to extend Kotlin Compiler.
  4. Build and Test:
    • Use the test module to check if your compiler plugin is working as expected. Note that FIR operations or IR operations can easily break the original source of programs. Therefore, you need to test more carefully than in normal Kotlin projects.

Predefined classes in compiler module

  • MyCompilerPluginRegistrar: This is preconfigured CompilerPluginRegistrar implementation. Generally, you may not need to edit this file.
  • MyFirExtensionRegistrar: Add factories of FirExtensions by using special syntax: +::MyFirExtension.
  • MyIrGenerationExtension: Transform or accept IrModuleFragment to modify or analyze IR nodes.

License

This project is licenced under the MIT license. See the LICENSE file for details.

About

The useful template to get started with K2 Compiler Plugin development.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages