예제 #1
0
VCProject* SBWorkspace::generateGlueProject() const
{
  // Get a set of all configurations appearing in all projects
  StringSet slnConfigs;
  for (auto project : m_openProjects) {
    const StringSet& configs = project.second->getSelectedConfigurations();
    slnConfigs.insert(configs.begin(), configs.end());
  }

  // Get the template
  VSTemplate* vstemplate = VSTemplate::getTemplate("WinRT");
  sbAssertWithTelemetry(vstemplate, "Failed to get WinRT VS template");

  // Set up basis template parameters
  string projectName = getName() + "WinRT";
  VSTemplateParameters templateParams;
  templateParams.setProjectName(projectName);

  // Expand the template and get the template project
  vstemplate->expand(sb_dirname(getPath()), templateParams);
  const VSTemplateProjectVec& projTemplates = vstemplate->getProjects();
  sbAssertWithTelemetry(projTemplates.size() == 1, "Unexpected WinRT template size");

  // Create the glue project and add it to the solution
  VCProject* glueProject = new VCProject(projTemplates.front());

  // Get path to WinObjC SDK
  BuildSettings globalBS(NULL);
  String useRelativeSdkPath = globalBS.getValue("VSIMPORTER_RELATIVE_SDK_PATH");
  String sdkDir = globalBS.getValue("WINOBJC_SDK_ROOT");

  // Try to create a relative path to the SDK, if requested
  if (strToUpper(useRelativeSdkPath) == "YES") {
    String projectDir = sb_dirname(projTemplates.front()->getPath());
    sdkDir = getRelativePath(projectDir, sdkDir);
  }
  glueProject->addGlobalProperty("WINOBJC_SDK_ROOT", platformPath(sdkDir), "'$(WINOBJC_SDK_ROOT)' == ''");

  // Set configuration properties
  for (auto configName : slnConfigs) {
    VCProjectConfiguration *projConfig = glueProject->addConfiguration(configName);
    projConfig->setProperty("TargetName", getName());
  }

  // Set RootNamespace
  glueProject->addGlobalProperty("RootNamespace", getName());

  return glueProject;
}
예제 #2
0
VCProject* SBWorkspace::generateGlueProject(bool packageable) const {
    // Get a set of all configurations appearing in all projects
    StringSet slnConfigs;
    for (auto project : m_openProjects) {
        const StringSet& configs = project.second->getSelectedConfigurations();
        slnConfigs.insert(configs.begin(), configs.end());
    }

    // Get the template
    VSTemplate* vstemplate = VSTemplate::getTemplate("WinRT");
    sbAssertWithTelemetry(vstemplate, "Failed to get WinRT VS template");

    // Set up basis template parameters
    string projectName = getName() + "WinRT";
    VSTemplateParameters templateParams;
    templateParams.setProjectName(projectName);
    templateParams.setIsPackageable(packageable);

    // Expand the template and get the template project
    vstemplate->expand(sb_dirname(getPath()), templateParams);
    const VSTemplateProjectVec& projTemplates = vstemplate->getProjects();
    sbAssertWithTelemetry(projTemplates.size() == 1, "Unexpected WinRT template size");

    // Create the glue project and add it to the solution
    VCProject* glueProject = new VCProject(projTemplates.front());

    // Set configuration properties
    for (auto configName : slnConfigs) {
        VCProjectConfiguration* projConfig = glueProject->addConfiguration(configName);
        projConfig->setProperty("TargetName", getName());
    }

    // Set RootNamespace
    glueProject->addGlobalProperty("RootNamespace", getName());

    return glueProject;
}