Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-core-dev] Missing <buildCommand> section

> 
> Thanks for the reply Alain.  I am new to Eclipse and CDT, and I'm having
> trouble finding the right level of documentation for me.  I'm mostly just
> reading the source code at this point.
> 
> I am successfully calling createCProject() now, so I feel much better
> about this.  But I noticed that if I run the Wizard and manually create my
> project, then on the Project->Properties page, I can view and modify the
> buildArguments, like the path to nmake.exe and the targets in my existing
> Makefile.  However, when I create the project programatically by calling
> createCProject(), then the panel for setting the buildArguments is not
> present in Project->Properties.
> 
> I see in the .project file that an entire <buildCommand> section is
> missing when I create the project programmatically.  So I know that I
> am missing a step in the creation process.
> 
> I think that the step I'm missing is to invoke the createBuildInfo()
> method on my newly-created project.  But I can't find the right level of
> documentation to guide me, so I'm uncertain.  Here is some code that I
> wrote that I thought should have enabled me to add to the project
> settings:
> 
>   // get defaults
>   IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(
> 	MakeCorePlugin.getDefault().getPluginPreferences(),
> 	MakeBuilder.BUILDER_ID, false);
> 
>   // add the <buildCommand> section to the .project file
>   MakeProjectNature.addToBuildSpec(newProject, MakeBuilder.BUILDER_ID, null);
>   IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(
> 	newProject, MakeBuilder.BUILDER_ID);
> 
> 
> With calls like these...
> 
>   projectInfo.setStopOnError(...);
>   projectInfo.setFullBuildEnable(...);
> 
> ...I expect to be able to choose the values that will be stored in the
> .project file.  I would either copy the default value from info, or I
> would supply my own desired value.
> 
> Unfortunately, I'm getting a CoreException on the second call to
> createBuildInfo(), and I don't yet understand why.
> 
> Any pointers would be greatly appreciated.
> 

You were on the right track.  You need to add the Standard Make Nature
to your project, something like:

	IProgressMonitor monitor = ...;
	String projectName = ...;

	// get a project handle.
	IProject myProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

	// Add the C Nature or the C++ Nature with CCProjectNature
	CProjectNature.addCNature(myProject, monitor);

	// Add the Standard Make builder Nature
	// this will configure the builders etc ...
	MakeProjectNature.addNature(myProject, monitor);

	// You may also want the autodiscovery scanner configurations.
	ScannerConfigNature.addScannerConfigNature(myProject);


Take a look at articles and documentation(on Eclipse) explaining the relation between nature vs Builder
Also look at IProjectNature class.



Back to the top