Check for debug build

Hello,

 

In my custom language plugin compilation is implemented as recommended - jps-based builder.

When building before run I want to call a compiler with different settings for run and run with debugging.

For this during build I need to determine which Executor was used for running - "Debug" or "Run". How this can be achieved?

Build process is called in CompileStepBeforeRun. Should I create my own BeforeRunTaskProvider and pass needed data there or there is other way?

2 comments
Comment actions Permalink

Hi George, 

there is a universal mechanism to pass key-value property pairs to a jps builder: everything that you put into com.intellij.openapi.compiler.CompileContext.getCompileScope().putUserData(key, value) on the IDE side,

will be transferred to a JPS process and made available to builders via org.jetbrains.jps.incremental.CompileContext.getBuilderParameter(key).

Your code inside the IDE can register a custom "beforeCompile" task with com.intellij.openapi.compiler.CompilerManager.addBeforeTask(). When run, the task may set any data via context.getCompileScope().putData()

The implementation of "compile before run" feature automatically provides several such properties:

RUN_CONFIGURATION, RUN_CONFIGURATION_TYPE_ID and EXECUTION_SESSION_ID_KEY

So if these parameters are set, your builder will know, that this compilation session is performed before executing a run configuration with particular name.

Theoretically the code that sets these properties may have set also the runner type (run, debug or something else), but currently it does not.

We can modify the code to provide more data describing the execution context, but the question is if it be of any value to your builder.

The problem is that currently build is incremental. This means that only changed classes are recompiled. Imagine the project is up to date and debug is invoked. If your builder behaves differently depending on what is executed run or debug, then the builder would have to initiate full project rebuild to make sure everything is compiled with proper parameters. If after that "run" is executed, the project has to be fully rebuilt again. And what parameters should the builder use, if build is invoked directly and not as a part of running/debugging some configuration?

0
Comment actions Permalink

Thank for the answer, Eugene.

It seems that info on runner type is inaccessible from a beforeCompile task so probably this will not help.

Concerning incremental building - in my case compiler is not using information from IDE (builder) which files it need to build but decides using it's own facilities. If compilation settings will change it should recompile all files. Probably, compilers of most non-jvm languages will do the same way.

If build is invoked directly it should use parameters for run.

So information on builder type will be useful.

Am I understood correctly that currently there is no relatively simple way to get this information (builder type) before a builder is called?

0

Please sign in to leave a comment.