简体   繁体   English

如何以编程方式解决CDT构建变量$ {ProjName}?

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

How to resolve the CDT build variable {ProjName} programmatically? 如何以编程方式解决CDT构建变量{ProjName}? 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. 我试图获取配置的artifactName,然后用项目名称替换其中的{ProjName}。 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. PS:我发布了该问题的答案,以供将来参考。

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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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