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 Jun 21, 2024
1 parent 09f8f72 commit c0c5bff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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 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"
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.bypassReconciliation, parsed.bypassCompilation)
}

0 comments on commit c0c5bff

Please sign in to comment.