From c0c5bff8fb9487dcf89d1d96d53968bdb5b12dcd Mon Sep 17 00:00:00 2001 From: Tom Beadman Date: Fri, 21 Jun 2024 16:31:24 +0100 Subject: [PATCH] Adding the ability to bypass reconciliation and compilation phases. --- .../itemis/mps/gradle/generate/GenerateArgs.kt | 2 ++ .../de/itemis/mps/gradle/generate/Helper.kt | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/GenerateArgs.kt b/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/GenerateArgs.kt index 8fb356f..e815e96 100644 --- a/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/GenerateArgs.kt +++ b/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/GenerateArgs.kt @@ -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 bypassReconciliation by parser.flagging("--bypass-reconciliation", help = "bypasses reconciliation") + val bypassCompilation by parser.flagging("--bypass-compilation", help = "bypasses compilation") 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" diff --git a/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/Helper.kt b/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/Helper.kt index 63f6247..fd65671 100644 --- a/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/Helper.kt +++ b/execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/Helper.kt @@ -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 @@ -163,7 +165,7 @@ private fun getFacetsForLanguages(facetRegistry: FacetRegistry, languages: Set): Iterable = facetRegistry.javaClass.getMethod("getFacetsForLanguages", java.lang.Iterable::class.java).invoke(facetRegistry, allUsedLanguages) as Iterable -private fun makeModels(proj: Project, models: List): GenerationResult { +private fun makeModels(proj: Project, models: List, bypassReconcile: Boolean = false, bypassCompilation: Boolean = false): GenerationResult { val session = MakeSession(proj, MsgHandler(), true) val res = ModelsToResources(models).resources().toList() val makeService = BuildMakeService() @@ -173,7 +175,14 @@ private fun makeModels(proj: Project, models: List): 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") @@ -233,5 +242,5 @@ fun generateProject(parsed: GenerateArgs, project: Project): GenerationResult { IconLoader.activate() } - return makeModels(project, modelsToGenerate) + return makeModels(project, modelsToGenerate, parsed.bypassReconciliation, parsed.bypassCompilation) }