Skip to content

Commit

Permalink
Persist output for incremental targets
Browse files Browse the repository at this point in the history
Summary:
[Doc](https://docs.google.com/document/d/1-zhGPkmt3I2os-kcIaFk9SvT6odt2AJWswSY-J_6AWs/edit?usp=sharing)

### Context
We are exploring the integration of the Kotlin Incremental Compiler into Buck for the incremental compilation of Kotlin source files. The goal is to improve build speed by only recompiling modified source files within a target, rather than rebuilding the entire target as is currently done.

### This stack
Integration of the Kotlin Incremental Compiler using [Build Tools Api](https://github.com/JetBrains/kotlin/blob/master/compiler/build-tools/kotlin-build-tools-api/README.md).

### This diff
The Kotlin incremental compiler only recompiles files that have been modified, so it is necessary to have the output from the previous run available for any source files that have not changed.

On the Buck side, there is a `no_outputs_cleanup` (see [doc](https://buck2.build/docs/rule_authors/incremental_actions/?fbclid=IwZXh0bgNhZW0CMTEAAR1QpI3cFfO1VAW6ZfNgTmEsnNv3Fyz_2avbYVi53B8a3DD7-vM85pknSRg_aem_tm96x-AUtgMU1AaGZEh-Cg)) flag that can be used to prevent Buck2 from deleting old outputs for an action. This can be useful in situations where it is important to preserve the output directories.

When using Buck to delete output directories, it may be possible to achieve the same result by using `MkdirIsolatedStep` (which creates a directory if it does not already exist) instead of `MakeCleanDirectoryIsolatedStep`, as long as it is not expected that a folder will need to be recreated within the process.

Thus I replaced `MakeCleanDirectoryIsolatedStep` by `MkdirIsolatedStep` for non KSP and KAPT directories. KSP and KAPT need extra investigation.

Differential Revision: D61284158

fbshipit-source-id: eaae8dd3e9210cd84d5f2c34c5d9b644a3edaa4e
  • Loading branch information
Iveta Jurčíková authored and facebook-github-bot committed Aug 15, 2024
1 parent c0eab66 commit 01f485f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions prelude/kotlin/kotlincd_jar_creator.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def create_jar_artifact_kotlincd(
low_pass_filter = False,
weight = 2,
error_handler = kotlin_toolchain.kotlin_error_handler,
no_outputs_cleanup = incremental,
)

library_classpath_jars_tag = actions.artifact_tag()
Expand Down

0 comments on commit 01f485f

Please sign in to comment.