[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Create CDT Project programmatically with multiple files
|
You can also check how the Core Build projects are created. For example from the ArduinoProjectGenerator:
CoreModel.getDefault().create(project).setRawPathEntries(new IPathEntry[] {
CoreModel.newSourceEntry(project.getFullPath())
}, monitor);
HTH,
Doug.
> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On
> Behalf Of Jonah Graham
> Sent: Tuesday, August 29, 2017 7:28 AM
> To: CDT General developers list. <cdt-dev@xxxxxxxxxxx>
> Subject: Re: [cdt-dev] Create CDT Project programmatically with multiple files
>
> Hi Muhammad,
>
> I don't have an immediate answer to your problem. But I can signpost you to an
> example in the tests that uses getSourceRoots and creates a project
> programatically:
> org.eclipse.cdt.internal.index.tests.IndexUpdateTests.testDependentProjectGets
> Updated_Bug310837()
>
> HTH,
> Jonah
>
> ~~~
> Jonah Graham
> Kichwa Coders Ltd.
> www.kichwacoders.com
>
>
> On 29 August 2017 at 12:23, Muhammad Hamiz Ahmed
> <hamizahmed93@xxxxxxxxx> wrote:
> > I am trying to get source root by cproject.getSourceRoots(). This is
> > giving me an empty array. Any help would be much appreciated.
> > Thanks.
> >
> > On Tue, Aug 29, 2017 at 1:04 PM, Muhammad Hamiz Ahmed
> > <hamizahmed93@xxxxxxxxx> wrote:
> >>
> >> Hello.
> >> I have been trying to create CDT Project programmatically with
> >> multiple files and trying to get translation unit out of it. However,
> >> I always get an empty list in return, while extracting the
> >> translation units out of the project.Can someone guide me, what is
> >> the correct way of creating a CDT project with multiple files in it.
> >>
> >> Currently I am using the following code which is not giving me
> >> correct
> >> results:
> >>
> >> private ICProject createCDTProjectFromFiles(final File[] files)
> >> throws OperationCanceledException, CoreException,
> >> FileNotFoundException { final IProject proj = createCDTProject("Test
> >> Project 10"); mCdtProject = proj; mLogger.info("Created temporary CDT
> >> project at " + getFullPath(mCdtProject));
> >>
> >> final IFolder sourceFolder = mCdtProject.getFolder("src");
> >> sourceFolder.create(true, true, NULL_MONITOR); final ICSourceEntry
> >> entrySrc = new CSourceEntry(sourceFolder, null,
> >> ICSettingEntry.RESOLVED); // CDataUtil.createEntry(CDataUtil., String
> >> name, String value, IPath[] exclusionPatterns, int flags) //
> >> CDataUtil // entrySrc.
> >> for (final File file : files) {
> >> createCopyOfFileInProject(mCdtProject, sourceFolder, file); }
> >>
> >> final CoreModel model = CoreModel.getDefault(); final ICProject
> >> icdtProject = model.create(mCdtProject); return icdtProject; }
> >>
> >> private static IProject createCDTProject(final String projectName)
> >> throws OperationCanceledException, CoreException { final CCorePlugin
> >> cdtCorePlugin = CCorePlugin.getDefault(); final IWorkspace workspace
> >> = ResourcesPlugin.getWorkspace(); final IWorkspaceRoot root =
> >> workspace.getRoot();
> >>
> >> IProject project = root.getProject(projectName);
> >> IndexerPreferences.set(project,
> >> IndexerPreferences.KEY_INDEX_ALL_FILES,
> >> IPDOMManager.ID_FAST_INDEXER);
> >>
> >> final IProjectDescription prjDescription =
> >> workspace.newProjectDescription(projectName);
> >>
> >> project = cdtCorePlugin.createCDTProject(prjDescription, project,
> >> NULL_MONITOR); waitForProjectRefreshToFinish(); //
> >> Assert.assertNotNull(project);
> >>
> >> project.open(null);
> >>
> >> // Assert.assertTrue(project.isOpen());
> >>
> >> return project;
> >> }
> >>
> >> Thanks.
> >>
> >> Regards,
> >> Muhammad Hamiz Ahmed
> >
> >
> >
> > _______________________________________________
> > 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
> _______________________________________________
> 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