Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Programmatically adding additional include paths for indexer

Btw, I got around the issue as following:

1) I start eclipse with env var:
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/home/lufimtse/git/LDT/include
eclipse

2) Then in my user folder: ~/git/LDT/include I have soft-links to various include paths like:
lrwxrwxrwx. 1 lufimtse lufimtse 41 Oct 24 15:37 gdk -> /home/lufimtse/jhbuild/checkout/gtk+/gdk/
lrwxrwxrwx. 1 lufimtse lufimtse 40 Nov 17 12:13 gio -> /home/lufimtse/jhbuild/checkout/glib/gio
lrwxrwxrwx. 1 lufimtse lufimtse 46 Nov 17 12:13 gio.h -> /home/lufimtse/jhbuild/checkout/glib/gio/gio.h
lrwxrwxrwx. 1 lufimtse lufimtse 41 Nov 17 12:11 glib -> /home/lufimtse/jhbuild/checkout/glib/glib
lrwxrwxrwx. 1 lufimtse lufimtse 41 Oct 24 15:36 gtk -> /home/lufimtse/jhbuild/checkout/gtk+/gtk/
lrwxrwxrwx. 1 lufimtse lufimtse 42 Nov 11 16:55 _javascript_Core -> /usr/include/webkitgtk-4.0/_javascript_Core/
lrwxrwxrwx. 1 lufimtse lufimtse 31 Nov 10 14:02 jni.h -> /usr/lib/jvm/java/include/jni.h
lrwxrwxrwx. 1 lufimtse lufimtse 40 Nov 10 14:03 jni_md.h -> /usr/lib/jvm/java/include/linux/jni_md.h
.......

The problem with the above approach is that it doesn't change the Eclipse project, but instead applies to all 'C' eclipse projects.

I.e, it's not really a full blown solution, but kinda works for me. Just thought I'd share.





On Fri, Mar 24, 2017 at 8:00 PM, Memory, Richard <Richard_Memory@xxxxxxxxxx> wrote:

Hi All,


I am attempting to programmatically add additional header files paths to a project. Ideally I'd like the added paths to appear in the UI (i.e. properties->C/C++ General->Paths and Symbols->Includes), but even if not, at least I'd like to make the indexer happy. Without the additional paths, it currently shows the "Unresolved inclusion" marker. 


Here is the code I am using at the moment, which I found from a post a few years ago which seems to be happy, but so far the indexer is still showing the same marker.


IPath someHeaderFilePath = new Path("/some/absolute/path");
IPath someOtherHeaderFilePath = new Path("/some/other/workspaceRelative/path");

ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(getProject(), true);
ICConfigurationDescription configDecriptions[] = projectDescription.getConfigurations();
for (ICConfigurationDescription configDescription : configDecriptions) {
    ICFolderDescription projectRoot = configDescription.getRootFolderDescription();
    ICLanguageSetting[] settings = projectRoot.getLanguageSettings();
    for (ICLanguageSetting setting : settings) {
        List<ICLanguageSettingEntry> includes = new ArrayList<ICLanguageSettingEntry>();

        includes.addAll(setting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH));
        includes.add(new CIncludePathEntry(someHeaderFilePath, ICSettingEntry.LOCAL));
        includes.add(new CIncludePathEntry(someOtherHeaderFilePath, ICSettingEntry.LOCAL));
        setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, includes);

        // Set information to project description
        ManagedBuildManager.saveBuildInfo(getProject(), true);
    }
}


Thanks,

Richard


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev



--
Leo Ufimtsev
Software Engineer, Eclipse team.
Toronto, Canada

Red Hat, Inc.
Leonidas@xxxxxxxxxx | http://DeveloperBlog.RedHat.com/

Back to the top