Macros set in external settings provider not visible.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Macros set in external settings provider not visible.

Waterlander, Erwin
Hi,

I added an External Settings Provider to the CDT-plugin developers guide example. In the provider I add an include path and a macro. In the project properties " C/C++ General > Paths and Symbols" I can see the include but not the macro. The Symbols tab is not there at all. What do I need to add to get the macro visible?

plugin.xml:

   <extension
         id="org.eclipse.cdt.example.toolchain.externalprovider"
         name="Example external provider"
         point="org.eclipse.cdt.core.externalSettingsProvider">
      <provider
            class="org.eclipse.cdt.example.toolchain.MyExternalSettingProvider">
      </provider>
   </extension>


provider class:

public class MyExternalSettingProvider extends CExternalSettingProvider {

    public MyExternalSettingProvider() {
        super();
    }

    @Override
    public CExternalSetting[] getSettings(IProject project, ICConfigurationDescription cfg) {

        List<ICSettingEntry> entries;
        entries = new ArrayList<ICSettingEntry>();

        ICLanguageSettingEntry entry;
        entry = CDataUtil.createCIncludePathEntry("${HOME}/include2", ICSettingEntry.NONE);
        entries.add(entry);

        entry = CDataUtil.createCMacroEntry("EXTERNAL", "erwin", ICSettingEntry.NONE);
        entries.add(entry);

        List<CExternalSetting> settings = new ArrayList<CExternalSetting>();
        CExternalSetting externalSetting = new CExternalSetting(new String[] { "org.eclipse.cdt.core.gcc" }, null, null,
                entries.toArray(new ICSettingEntry[0]));
        settings.add(externalSetting);

        return settings.toArray(new CExternalSetting[0]);
    }

}

Adding the provider:

    public void addExternalProvider(IProject project, ICProjectDescription projectDescription,
            ICConfigurationDescription cfgDescription) throws CoreException {

        // Get existing list of external providers of the configuration.
        List<String> extProviderIds = new ArrayList<String>();
        String[] ids = cfgDescription.getExternalSettingsProviderIds();
        for (String id : ids) {
            extProviderIds.add(id);
        }
        // Add new external provider
        extProviderIds.add("org.eclipse.cdt.example.toolchain.externalprovider");
        cfgDescription.setExternalSettingsProviderIds(extProviderIds.toArray(new String[0]));

        CoreModel.getDefault().setProjectDescription(project, projectDescription);
        System.out.println("Added external provider.");
    }

--
Erwin

---------------------------------------------------------------------
Intel Benelux B.V.
Registered in The Netherlands under number 24134020
Statutory seat: Rotterdam
Registered address: Capronilaan 37, 1119NG Schiphol-Rijk

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
cdt-dev mailing list
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: Macros set in external settings provider not visible.

Waterlander, Erwin
The macro became visible when I added an option to the tool with valueType definedSymbols.

plugin.xml:

               <tool
                     command="gcc"
                     id="example.toolchain.compiler1"
                     isAbstract="false"
                     name="Compiler"
                     natureFilter="both"
                     outputFlag="-o">

                .....

                 <option
                        category="example.compiler.optionCategory.general1"
                        id="org.eclipse.cdt.example.toolchain.option1"
                        isAbstract="false"
                        name="Defined Symbols"
                        resourceFilter="all"
                        valueType="definedSymbols">
                  </option>
               </tool>

--
Erwin

-----Original Message-----
From: [hidden email] <[hidden email]> On Behalf Of Waterlander, Erwin
Sent: Friday, July 17, 2020 14:47
To: CDT General developers list. <[hidden email]>
Subject: [cdt-dev] Macros set in external settings provider not visible.

Hi,

I added an External Settings Provider to the CDT-plugin developers guide example. In the provider I add an include path and a macro. In the project properties " C/C++ General > Paths and Symbols" I can see the include but not the macro. The Symbols tab is not there at all. What do I need to add to get the macro visible?

plugin.xml:

   <extension
         id="org.eclipse.cdt.example.toolchain.externalprovider"
         name="Example external provider"
         point="org.eclipse.cdt.core.externalSettingsProvider">
      <provider
            class="org.eclipse.cdt.example.toolchain.MyExternalSettingProvider">
      </provider>
   </extension>


provider class:

public class MyExternalSettingProvider extends CExternalSettingProvider {

    public MyExternalSettingProvider() {
        super();
    }

    @Override
    public CExternalSetting[] getSettings(IProject project, ICConfigurationDescription cfg) {

        List<ICSettingEntry> entries;
        entries = new ArrayList<ICSettingEntry>();

        ICLanguageSettingEntry entry;
        entry = CDataUtil.createCIncludePathEntry("${HOME}/include2", ICSettingEntry.NONE);
        entries.add(entry);

        entry = CDataUtil.createCMacroEntry("EXTERNAL", "erwin", ICSettingEntry.NONE);
        entries.add(entry);

        List<CExternalSetting> settings = new ArrayList<CExternalSetting>();
        CExternalSetting externalSetting = new CExternalSetting(new String[] { "org.eclipse.cdt.core.gcc" }, null, null,
                entries.toArray(new ICSettingEntry[0]));
        settings.add(externalSetting);

        return settings.toArray(new CExternalSetting[0]);
    }

}

Adding the provider:

    public void addExternalProvider(IProject project, ICProjectDescription projectDescription,
            ICConfigurationDescription cfgDescription) throws CoreException {

        // Get existing list of external providers of the configuration.
        List<String> extProviderIds = new ArrayList<String>();
        String[] ids = cfgDescription.getExternalSettingsProviderIds();
        for (String id : ids) {
            extProviderIds.add(id);
        }
        // Add new external provider
        extProviderIds.add("org.eclipse.cdt.example.toolchain.externalprovider");
        cfgDescription.setExternalSettingsProviderIds(extProviderIds.toArray(new String[0]));

        CoreModel.getDefault().setProjectDescription(project, projectDescription);
        System.out.println("Added external provider.");
    }

--
Erwin

---------------------------------------------------------------------
Intel Benelux B.V.
Registered in The Netherlands under number 24134020 Statutory seat: Rotterdam Registered address: Capronilaan 37, 1119NG Schiphol-Rijk

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

_______________________________________________
cdt-dev mailing list
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev
---------------------------------------------------------------------
Intel Benelux B.V.
Registered in The Netherlands under number 24134020
Statutory seat: Rotterdam
Registered address: Capronilaan 37, 1119NG Schiphol-Rijk

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
cdt-dev mailing list
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev