Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] How to get the type of C/C++ project (ex. Static Library) having ICProject?

On Mon, 09 Jun 2008 17:25:39 +0400, Wieant Nielander <wieant@xxxxxxxxx> wrote:

Hello! I can't get answer for this question about CDT Model.

I'm developing plugin (actionSet) and I have ICProject of some project.
How can I check that it is Static Library?
P.S. Static library may use standard GNU GCC Toolchain or my Toolchain.

Perhaps you can reuse the code shown below to get the IProjectType for
the project's active configuration. Another method might be to match
the config.getArtifactExtension() against the static library
extension (="a"?), not sure how foolproof that is.

public static IConfiguration getActiveConfiguration( IProject project )
{
    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
    if ( info != null )
    {
        return info.getDefaultConfiguration();
    }
    return null;
}
public static IProjectType getProjectType( IProject project )
{
    IConfiguration config = getActiveConfiguration(project);
    if ( config != null )
    {
        while ( config.getParent() != null )
        {
            config = config.getParent();
        }
    }
    if ( config != null )
    {
        return config.getProjectType();
    }
    return null;
}

Thanks! getProjectType() whith cycle "while ( config.getParent() != null ) ..." returns null for GCC Toolchain, and for my Toolchain returns null even without this cycle. So I do following:

	public boolean isStaticLibrary(IProject project) {
IConfiguration config = ManagedBuildManager.getBuildInfo(project).getDefaultConfiguration();
	    if (config == null)
		    return false;
	    if (config.getArtifactExtension().equals("a"))
	    	return true;
	    else
	    	return false;
	}	


Back to the top