简体   繁体   中英

How to resolve CDT build variable ${ProjName} programatically?

How to resolve the CDT build variable {ProjName} programmatically? Here is what I am trying to do:
I am trying to get the artifactName of a configuration and then replace the {ProjName} in it with the project name. Now, I don't want to replace just this variable by searching for it, because user may specify any other variable name there.

private String getResolvedArticatName(final IConfiguration configuration){
    String artifactName = configuration.getArtifactName();
    String resolvedArtifactName = resolve(artifactName);
    return resolvedArtifactName;
}

private String resolve(String artifactName){
    //resolve the parameter, artifactName, and return it;
}

PS: I posted answer to this question for my future reference.

This is how I got it done:

private String resolve(final String artifactName, final IConfiguration configuration) throws CdtVariableException{
        ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
        return mngr.resolveValue(artifactName, "", File.pathSeparator, ManagedBuildManager.getDescriptionForConfiguration(configuration));
}

private String getResolvedArticatName(final IConfiguration configuration) throws CdtVariableException{
    String artifactName = configuration.getArtifactName();
    return resolve(artifactName);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM