public void EnsureProjectConfigurationExists( Bam.Core.Module module) { lock (this.ProjectConfigurations) { var config = module.BuildEnvironment.Configuration; if (this.ProjectConfigurations.ContainsKey(config)) { return; } // add configuration to project var projectConfig = new Configuration(config); projectConfig["USE_HEADERMAP"] = new UniqueConfigurationValue("NO"); projectConfig["COMBINE_HIDPI_IMAGES"] = new UniqueConfigurationValue("NO"); // TODO: needed to quieten Xcode 4 verification // reset SRCROOT, or it is taken to be where the workspace is projectConfig["SRCROOT"] = new UniqueConfigurationValue(this.SourceRoot); // all 'products' are relative to SYMROOT in the IDE, regardless of the project settings // needed so that built products are no longer 'red' in the IDE projectConfig["SYMROOT"] = new UniqueConfigurationValue(this.BuiltProductsDir); // all intermediate files generated are relative to this projectConfig["OBJROOT"] = new UniqueConfigurationValue("$(SYMROOT)/intermediates"); // would like to be able to set this to '$(SYMROOT)/$(TARGET_NAME)/$(CONFIGURATION)' // but TARGET_NAME is not defined in the Project configuration settings, and will end up collapsing // to an empty value // 'products' use the Project configuration value of CONFIGURATION_BUILD_DIR for their path, while // written target files use the Target configuration value of CONFIGURATION_BUILD_DIR // if these are inconsistent the IDE shows the product in red projectConfig["CONFIGURATION_BUILD_DIR"] = new UniqueConfigurationValue("$(SYMROOT)/$(CONFIGURATION)"); this.ConfigurationLists[0].AddConfiguration(projectConfig); this.AllConfigurations.Add(projectConfig); this.ProjectConfigurations.Add(config, projectConfig); } }
public Configuration EnsureTargetConfigurationExists( Bam.Core.Module module, ConfigurationList configList) { lock (configList) { var config = module.BuildEnvironment.Configuration; var existingConfig = configList.Where(item => item.Config == config).FirstOrDefault(); if (null != existingConfig) { return existingConfig; } // if a new target config is needed, then a new project config is needed too this.EnsureProjectConfigurationExists(module); var newConfig = new Configuration(module.BuildEnvironment.Configuration); this.AllConfigurations.Add(newConfig); configList.AddConfiguration(newConfig); var clangMeta = Bam.Core.Graph.Instance.PackageMetaData<Clang.MetaData>("Clang"); // set which SDK to build against newConfig["SDKROOT"] = new UniqueConfigurationValue(clangMeta.SDK); // set the minimum version of OSX/iPhone to run against var minVersionRegEx = new System.Text.RegularExpressions.Regex("^(?<Type>[a-z]+)(?<Version>[0-9.]+)$"); var match = minVersionRegEx.Match(clangMeta.MinimumVersionSupported); if (!match.Groups["Type"].Success) { throw new Bam.Core.Exception("Unable to extract SDK type from: '{0}'", clangMeta.MinimumVersionSupported); } if (!match.Groups["Version"].Success) { throw new Bam.Core.Exception("Unable to extract SDK version from: '{0}'", clangMeta.MinimumVersionSupported); } var optionName = System.String.Format("{0}_DEPLOYMENT_TARGET", match.Groups["Type"].Value.ToUpper()); newConfig[optionName] = new UniqueConfigurationValue(match.Groups["Version"].Value); return newConfig; } }
public void AddPreBuildCommands( Bam.Core.StringArray commands, Configuration configuration) { lock (this) { if (null == this.PreBuildBuildPhase) { var preBuildBuildPhase = new ShellScriptBuildPhase(this, "Pre Build", (target) => { var content = new System.Text.StringBuilder(); foreach (var config in target.ConfigurationList) { content.AppendFormat("if [ \\\"$CONFIGURATION\\\" = \\\"{0}\\\" ]; then\\n\\n", config.Name); foreach (var line in config.PreBuildCommands) { content.AppendFormat(" {0}\\n", line.Replace("\"", "\\\"")); } content.AppendFormat("fi\\n\\n"); } return content.ToString(); }); this.Project.ShellScriptsBuildPhases.Add(preBuildBuildPhase); this.PreBuildBuildPhase = preBuildBuildPhase; // do not add PreBuildBuildPhase to this.BuildPhases, so that it can be serialized in the right order } configuration.PreBuildCommands.AddRange(commands); } }