Skip to content

Commit

Permalink
Adding the ability to bypass reconciliation and compilation phases.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Beadman committed Jul 2, 2024
1 parent 09f8f72 commit 6b95fbe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.16.0

### Added

* `execute-generators`: added `--skip-reconciliation` and `--skip-compilation` options to reduce the total build time for certain large model use cases.

## 1.15.1

### Changed
Expand Down
5 changes: 5 additions & 0 deletions execute-generators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ optional arguments:
--parallel-generation-threads THREADS Number of threads to use for parallel generation. Value
of 0 means that parallel generation is disabled.
Default: 0
--skip-reconciliation skips the Make.reconcile target.
--skip-compilation skips the Javacompile.compile target.
```

## Error exit codes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class GenerateArgs(parser: ArgParser) : Args(parser) {
val modules by parser.adding("--module", help = "list of modules to generate")
val excludeModels by parser.adding("--exclude-model", help = "list of models to exclude from generation")
val excludeModules by parser.adding("--exclude-module", help = "list of modules to exclude from generation")
val skipReconciliation by parser.flagging("--skip-reconciliation", help = "skips the Make.reconcile target")
val skipCompilation by parser.flagging("--skip-compilation", help = "skips the JavaCompile.compile target")
val noStrictMode by parser.flagging(
"--no-strict-mode",
help = "Disable strict generation mode. Strict mode places additional limitations on generators, but is required for parallel generation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import com.intellij.openapi.util.IconLoader
import de.itemis.mps.gradle.logging.detectLogging
import de.itemis.mps.gradle.project.loader.EnvironmentKind
import de.itemis.mps.gradle.project.loader.ModuleAndModelMatcher
import jetbrains.mps.generator.GenerationOptions
import jetbrains.mps.generator.GenerationSettingsProvider
import jetbrains.mps.generator.runtime.TemplateModule
import jetbrains.mps.internal.make.cfg.JavaCompileFacetInitializer
import jetbrains.mps.internal.make.cfg.MakeFacetInitializer
import jetbrains.mps.make.MakeSession
import jetbrains.mps.make.facet.FacetRegistry
import jetbrains.mps.make.facet.IFacet
import jetbrains.mps.make.facet.ITarget
import jetbrains.mps.make.script.IScript
import jetbrains.mps.make.script.IScriptController
import jetbrains.mps.make.script.ScriptBuilder
import jetbrains.mps.messages.IMessage
import jetbrains.mps.messages.IMessageHandler
Expand Down Expand Up @@ -163,7 +165,7 @@ private fun getFacetsForLanguages(facetRegistry: FacetRegistry, languages: Set<S
private fun getFacetsForLanguagesMps20213(facetRegistry: FacetRegistry, allUsedLanguages: Set<SLanguage>): Iterable<IFacet> =
facetRegistry.javaClass.getMethod("getFacetsForLanguages", java.lang.Iterable::class.java).invoke(facetRegistry, allUsedLanguages) as Iterable<IFacet>

private fun makeModels(proj: Project, models: List<SModel>): GenerationResult {
private fun makeModels(proj: Project, models: List<SModel>, bypassReconcile: Boolean = false, bypassCompilation: Boolean = false): GenerationResult {
val session = MakeSession(proj, MsgHandler(), true)
val res = ModelsToResources(models).resources().toList()
val makeService = BuildMakeService()
Expand All @@ -173,7 +175,14 @@ private fun makeModels(proj: Project, models: List<SModel>): GenerationResult {
return GenerationResult.NothingToGenerate
}
logger.info("starting generation")
val future = makeService.make(session, res, createScript(proj, models))

val scriptController = IScriptController.Stub2(session,
MakeFacetInitializer().skipReconcile(bypassReconcile),
JavaCompileFacetInitializer().skipCompilation(bypassCompilation)
)

val future = makeService.make(session, res, createScript(proj, models), scriptController)

try {
val result = future.get()
logger.info("generation finished")
Expand Down Expand Up @@ -233,5 +242,5 @@ fun generateProject(parsed: GenerateArgs, project: Project): GenerationResult {
IconLoader.activate()
}

return makeModels(project, modelsToGenerate)
return makeModels(project, modelsToGenerate, parsed.skipReconciliation, parsed.skipCompilation)
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version.backend=1.15.1
version.backend=1.16.0
version.project-loader=2.3.0

0 comments on commit 6b95fbe

Please sign in to comment.