问题
I'm trying to play with Eclipse (C) project template. I found this very descriptive answer of how to work with Eclipse project template from @Jonah Graham and went through Eclipse documentation - How to add project templates to CDT
I'm able to create the project template and setup some settings by "SetMBSStringOptionValue"
<!-- Set TMP setting by adding textual build settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.misc\.other*" />
<simple name="value" value="TMP_SETTING_RELEASE" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
My question is how do I differentiate between build configurations? E.g. I want to setup different settings for "Debug" and "Release" build configuration. How should I do that?
回答1:
AFAIK no one has provided a "process runner" that allows the configuration to be specified when setting the options.
What you can do is add your own subclass of org.eclipse.cdt.core.templateengine.process.ProcessRunner, basing it on org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue that additionally lets you specify the configuration to apply it to. The Eclipse extension point you need is org.eclipse.cdt.core.templateProcessTypes.
Keep in mind when you do that users do a new project wizard they can choose to have/not have Debug/Release configs as shown in this screenshot:
来源:https://stackoverflow.com/questions/45232211/how-to-differentiate-between-build-configurations-in-eclipse-c-project-templat