Convert( this C.ICOnlyCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.LanguageStandard.HasValue) { switch (settings.LanguageStandard.Value) { case C.ELanguageStandard.C89: configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("c89"); break; case C.ELanguageStandard.GNU89: configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("gnu89"); break; case C.ELanguageStandard.C99: configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("c99"); break; case C.ELanguageStandard.GNU99: configuration["GCC_C_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("gnu99"); break; default: throw new Bam.Core.Exception("Invalid C language standard, {0}", settings.LanguageStandard.Value.ToString()); } } }
Convert( System.Type conversionClass, Bam.Core.Settings toolSettings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { var moduleType = typeof(Bam.Core.Module); var xcodeConfigurationType = typeof(XcodeBuilder.Configuration); foreach (var i in toolSettings.Interfaces()) { var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, xcodeConfigurationType }); if (null == method) { throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})", conversionClass.ToString(), i.ToString(), moduleType, xcodeConfigurationType); } try { method.Invoke(null, new object[] { toolSettings, module, configuration }); } catch (System.Reflection.TargetInvocationException exception) { throw new Bam.Core.Exception(exception.InnerException, "Xcode conversion error:"); } } }
Convert( this C.IAdditionalSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { var extraSettings = new XcodeBuilder.MultiConfigurationValue(); foreach (var extra in settings.AdditionalSettings) { // any extra arguments separated by spaces splits them onto separate lines in the project file var split = extra.Split(' '); foreach (var s in split) { extraSettings.Add(s); } } if (settings is Clang.CxxCompilerSettings) { configuration["OTHER_CPLUSPLUSFLAGS"] = extraSettings; } else { configuration["OTHER_CFLAGS"] = extraSettings; } }
Convert( this C.IObjectiveCOnlyCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (!System.String.IsNullOrEmpty(settings.ConstantStringClass)) { // TODO } }
Convert( this C.IAdditionalSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { var extraSettings = new XcodeBuilder.MultiConfigurationValue(); foreach (var extra in settings.AdditionalSettings) { extraSettings.Add(extra); } configuration["OTHER_LDFLAGS"] = extraSettings; }
Convert( this C.ICommonLinkerSettingsOSX settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.Frameworks.Count > 0) { var target = module.MetaData as XcodeBuilder.Target; var project = target.Project; foreach (var framework in settings.Frameworks.ToEnumerableWithoutDuplicates()) { var frameworkFileRefPath = framework; var isAbsolute = System.IO.Path.IsPathRooted(frameworkFileRefPath.ToString()); if (!isAbsolute) { // TODO: change to a positional token // assume it's a system framework frameworkFileRefPath = Bam.Core.TokenizedString.Create("/System/Library/Frameworks/$(0).framework", null, new Bam.Core.TokenizedStringArray(framework)); if (!frameworkFileRefPath.IsParsed) { frameworkFileRefPath.Parse(); } } var buildFile = target.EnsureFrameworksBuildFileExists( frameworkFileRefPath, XcodeBuilder.FileReference.EFileType.WrapperFramework); project.MainGroup.AddChild(buildFile.FileRef); } } if (settings.FrameworkSearchPaths.Count > 0) { var option = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.FrameworkSearchPaths.ToEnumerableWithoutDuplicates()) { option.Add(path.ToString()); } configuration["FRAMEWORK_SEARCH_PATHS"] = option; } if (null != settings.InstallName) { if (module is C.IDynamicLibrary) { configuration["LD_DYLIB_INSTALL_NAME"] = new XcodeBuilder.UniqueConfigurationValue(settings.InstallName.ToString()); } } // settings.MinimumVersionSupported is dealt with in XcodeBuilder as there is not a difference // between compiler and linker setting in the project }
Convert( this C.ICommonAssemblerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { configuration["GCC_GENERATE_DEBUGGING_SYMBOLS"] = new XcodeBuilder.UniqueConfigurationValue(settings.DebugSymbols ? "YES" : "NO"); if (settings.IncludePaths.Count > 0) { var paths = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.IncludePaths) { var fullPath = path.Parse(); var relPath = Bam.Core.RelativePathUtilities.GetPath(fullPath, configuration.Project.SourceRoot); if (Bam.Core.RelativePathUtilities.IsPathAbsolute(relPath)) { paths.Add(fullPath); } else { paths.Add(System.String.Format("$(SRCROOT)/{0}", relPath)); } } configuration["USER_HEADER_SEARCH_PATHS"] = paths; } if (settings.PreprocessorDefines.Count > 0) { var defines = new XcodeBuilder.MultiConfigurationValue(); foreach (var define in settings.PreprocessorDefines) { if (System.String.IsNullOrEmpty(define.Value)) { defines.Add(define.Key); } else { var value = define.Value; if (value.Contains("\"")) { // note the number of back slashes here // required to get \\\" for each " in the original value value = value.Replace("\"", "\\\\\\\""); } defines.Add(System.String.Format("{0}={1}", define.Key, value)); } } configuration["GCC_PREPROCESSOR_DEFINITIONS"] = defines; } configuration["GCC_TREAT_WARNINGS_AS_ERRORS"] = new XcodeBuilder.UniqueConfigurationValue(settings.WarningsAsErrors ? "YES" : "NO"); }
Convert( this ICommonLinkerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.RPath.Count > 0) { var option = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.RPath) { option.Add(path.Parse()); } configuration["LD_RUNPATH_SEARCH_PATHS"] = option; } }
Convert( this C.ICommonCompilerSettingsOSX settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (null != settings.FrameworkSearchPaths) { var paths = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.FrameworkSearchPaths) { paths.Add(path.ToString()); } configuration["FRAMEWORK_SEARCH_PATHS"] = paths; } // settings.MinimumVersionSupported is dealt with in XcodeBuilder as there is not a difference // between compiler and linker setting in the project }
Convert( this ClangCommon.ICommonCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.AllWarnings.HasValue) { var warnings = new XcodeBuilder.MultiConfigurationValue(); if (settings.AllWarnings.Value) { warnings.Add("-Wall"); } else { warnings.Add("-Wno-all"); } configuration["WARNING_CFLAGS"] = warnings; } if (settings.ExtraWarnings.HasValue) { var warnings = new XcodeBuilder.MultiConfigurationValue(); if (settings.ExtraWarnings.Value) { warnings.Add("-Wextra"); } else { warnings.Add("-Wno-extra"); } configuration["WARNING_CFLAGS"] = warnings; } if (settings.Pedantic.HasValue) { configuration["GCC_WARN_PEDANTIC"] = new XcodeBuilder.UniqueConfigurationValue(settings.Pedantic.Value ? "YES" : "NO"); } if (settings.Visibility.HasValue) { configuration["GCC_SYMBOLS_PRIVATE_EXTERN"] = new XcodeBuilder.UniqueConfigurationValue((settings.Visibility.Value == EVisibility.Default) ? "NO" : "YES"); } if (settings.StrictAliasing.HasValue) { configuration["GCC_STRICT_ALIASING"] = new XcodeBuilder.UniqueConfigurationValue(settings.StrictAliasing.Value ? "YES" : "NO"); } }
Convert( this C.IAdditionalSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { var extraSettings = new XcodeBuilder.MultiConfigurationValue(); foreach (var extra in settings.AdditionalSettings) { extraSettings.Add(extra); } if (settings is Clang.CxxCompilerSettings) { configuration["OTHER_CPLUSPLUSFLAGS"] = extraSettings; } else { configuration["OTHER_CFLAGS"] = extraSettings; } }
Convert( this C.ICxxOnlyLinkerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { switch (settings.StandardLibrary) { case C.Cxx.EStandardLibrary.NotSet: break; case C.Cxx.EStandardLibrary.libstdcxx: configuration["CLANG_CXX_LIBRARY"] = new XcodeBuilder.UniqueConfigurationValue("libstdc++"); break; case C.Cxx.EStandardLibrary.libcxx: configuration["CLANG_CXX_LIBRARY"] = new XcodeBuilder.UniqueConfigurationValue("libc++"); break; default: throw new Bam.Core.Exception("Invalid C++ standard library {0}", settings.StandardLibrary.ToString()); } }
Convert( this C.ICommonCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.Bits.HasValue) { switch (settings.Bits.Value) { case C.EBit.ThirtyTwo: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("i386"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_32_BIT)"); } break; case C.EBit.SixtyFour: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("x86_64"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_64_BIT)"); } break; default: throw new Bam.Core.Exception("Unknown bit depth, {0}", settings.Bits.Value); } } if (settings.DebugSymbols.HasValue) { configuration["GCC_GENERATE_DEBUGGING_SYMBOLS"] = new XcodeBuilder.UniqueConfigurationValue(settings.DebugSymbols.Value ? "YES" : "NO"); } if (settings.DisableWarnings.Count > 0) { var warnings = new XcodeBuilder.MultiConfigurationValue(); foreach (var warning in settings.DisableWarnings) { warnings.Add(System.String.Format("-Wno-{0}", warning)); } configuration["WARNING_CFLAGS"] = warnings; } if (settings.IncludePaths.Count > 0) { var paths = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.IncludePaths) { paths.Add(path.ToString()); } configuration["USER_HEADER_SEARCH_PATHS"] = paths; } if (settings.OmitFramePointer.HasValue) { var arg = settings.OmitFramePointer.Value ? "-fomit-frame-pointer" : "-fno-omit-frame-pointer"; configuration["OTHER_CFLAGS"] = new XcodeBuilder.MultiConfigurationValue(arg); } if (settings.Optimization.HasValue) { switch (settings.Optimization.Value) { case C.EOptimization.Off: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("0"); break; case C.EOptimization.Size: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("s"); break; case C.EOptimization.Speed: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("1"); break; case C.EOptimization.Full: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("3"); break; default: throw new Bam.Core.Exception("Unsupported optimization, {0}", settings.Optimization.Value); } } if (settings.PreprocessorDefines.Count > 0) { var defines = new XcodeBuilder.MultiConfigurationValue(); foreach (var define in settings.PreprocessorDefines) { if (System.String.IsNullOrEmpty(define.Value)) { defines.Add(define.Key); } else { var value = define.Value; if (value.Contains("\"")) { // note the number of back slashes here // required to get \\\" for each " in the original value value = value.Replace("\"", "\\\\\\\""); } defines.Add(System.String.Format("{0}={1}", define.Key, value)); } } configuration["GCC_PREPROCESSOR_DEFINITIONS"] = defines; } if (settings.PreprocessorUndefines.Count > 0) { var undefines = new XcodeBuilder.MultiConfigurationValue(); foreach (var undefine in settings.PreprocessorUndefines) { undefines.Add(System.String.Format("-U{0}", undefine)); } configuration["OTHER_CFLAGS"] = undefines; } if (settings.SystemIncludePaths.Count > 0) { var paths = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.SystemIncludePaths) { paths.Add(path.ToString()); } configuration["HEADER_SEARCH_PATHS"] = paths; } if (settings.TargetLanguage.HasValue) { switch (settings.TargetLanguage.Value) { case C.ETargetLanguage.Default: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("automatic"); break; case C.ETargetLanguage.C: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.c.c"); break; case C.ETargetLanguage.Cxx: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.cpp.cpp"); break; case C.ETargetLanguage.ObjectiveC: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.c.objc"); break; case C.ETargetLanguage.ObjectiveCxx: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.cpp.objcpp"); break; default: throw new Bam.Core.Exception("Unsupported target language, {0}", settings.TargetLanguage.Value); } } if (settings.WarningsAsErrors.HasValue) { configuration["GCC_TREAT_WARNINGS_AS_ERRORS"] = new XcodeBuilder.UniqueConfigurationValue(settings.WarningsAsErrors.Value ? "YES" : "NO"); } if (settings.OutputType.HasValue) { // TODO: anything? } }
Convert( this C.ICommonCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.Bits.HasValue) { switch (settings.Bits.Value) { case C.EBit.ThirtyTwo: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("i386"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_32_BIT)"); } break; case C.EBit.SixtyFour: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("x86_64"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_64_BIT)"); } break; default: throw new Bam.Core.Exception("Unknown bit depth, {0}", settings.Bits.Value); } } if (settings.DebugSymbols.HasValue) { configuration["GCC_GENERATE_DEBUGGING_SYMBOLS"] = new XcodeBuilder.UniqueConfigurationValue(settings.DebugSymbols.Value ? "YES" : "NO"); } if (settings.DisableWarnings.Count > 0) { var warnings = new XcodeBuilder.MultiConfigurationValue(); foreach (var warning in settings.DisableWarnings) { warnings.Add(System.String.Format("-Wno-{0}", warning)); } configuration["WARNING_CFLAGS"] = warnings; } if (settings.IncludePaths.Count > 0) { var paths = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.IncludePaths.ToEnumerableWithoutDuplicates()) { var fullPath = path.ToString(); var relPath = Bam.Core.RelativePathUtilities.GetPath(fullPath, configuration.Project.SourceRoot); // spaces need to be double escaped if (Bam.Core.RelativePathUtilities.IsPathAbsolute(relPath)) { if (fullPath.Contains(" ")) { fullPath = fullPath.Replace(" ", "\\\\ "); } paths.Add(fullPath); } else { if (relPath.Contains(" ")) { relPath = relPath.Replace(" ", "\\\\ "); } paths.Add(System.String.Format("$(SRCROOT)/{0}", relPath)); } } configuration["USER_HEADER_SEARCH_PATHS"] = paths; } if (settings.Optimization.HasValue) { switch (settings.Optimization.Value) { case C.EOptimization.Off: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("0"); break; case C.EOptimization.Size: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("s"); break; case C.EOptimization.Speed: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("2"); break; case C.EOptimization.Custom: // do nothing - defer to compiler specific optimizations break; default: throw new Bam.Core.Exception("Unsupported optimization, {0}", settings.Optimization.Value); } } if (settings.OmitFramePointer.HasValue) { var arg = settings.OmitFramePointer.Value ? "-fomit-frame-pointer" : "-fno-omit-frame-pointer"; configuration["OTHER_CFLAGS"] = new XcodeBuilder.MultiConfigurationValue(arg); } if (settings.PreprocessorDefines.Count > 0) { var defines = new XcodeBuilder.MultiConfigurationValue(); foreach (var define in settings.PreprocessorDefines) { if (null == define.Value) { defines.Add(define.Key); } else { var defineValue = define.Value.ToString(); if (defineValue.Contains(" ")) { defineValue = defineValue.Replace(" ", "\\\\ "); } if (defineValue.Contains("\"")) { // note the number of back slashes here // required to get \\\" for each " in the original value defineValue = defineValue.Replace("\"", "\\\\\\\""); } defines.Add(System.String.Format("{0}={1}", define.Key, defineValue)); } } configuration["GCC_PREPROCESSOR_DEFINITIONS"] = defines; } if (settings.PreprocessorUndefines.Count > 0) { var undefines = new XcodeBuilder.MultiConfigurationValue(); foreach (var undefine in settings.PreprocessorUndefines) { undefines.Add(System.String.Format("-U{0}", undefine)); } configuration["OTHER_CFLAGS"] = undefines; } if (settings.SystemIncludePaths.Count > 0) { var paths = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.SystemIncludePaths.ToEnumerableWithoutDuplicates()) { var full_path = path.ToString(); if (full_path.Contains(" ")) { full_path = full_path.Replace(" ", "\\\\ "); } paths.Add(full_path); } configuration["HEADER_SEARCH_PATHS"] = paths; } if (settings.TargetLanguage.HasValue) { switch (settings.TargetLanguage.Value) { case C.ETargetLanguage.Default: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("automatic"); break; case C.ETargetLanguage.C: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.c.c"); break; case C.ETargetLanguage.Cxx: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.cpp.cpp"); break; case C.ETargetLanguage.ObjectiveC: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.c.objc"); break; case C.ETargetLanguage.ObjectiveCxx: configuration["GCC_INPUT_FILETYPE"] = new XcodeBuilder.UniqueConfigurationValue("sourcecode.cpp.objcpp"); break; default: throw new Bam.Core.Exception("Unsupported target language, {0}", settings.TargetLanguage.Value); } } if (settings.WarningsAsErrors.HasValue) { configuration["GCC_TREAT_WARNINGS_AS_ERRORS"] = new XcodeBuilder.UniqueConfigurationValue(settings.WarningsAsErrors.Value ? "YES" : "NO"); } if (settings.OutputType.HasValue) { // TODO: anything? } if (settings.NamedHeaders.Count > 0) { var namedHeaders = new XcodeBuilder.MultiConfigurationValue(); foreach (var header in settings.NamedHeaders) { // have to split this into two, or Xcode does not recognise it namedHeaders.Add("-include"); namedHeaders.Add(header); } configuration["OTHER_CFLAGS"] = namedHeaders; } }
Convert( this C.ICommonLinkerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { switch (settings.Bits) { case C.EBit.ThirtyTwo: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("i386"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_32_BIT)"); } break; case C.EBit.SixtyFour: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("x86_64"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_64_BIT)"); } break; default: throw new Bam.Core.Exception("Unknown bit depth, {0}", settings.Bits.ToString()); } switch (settings.OutputType) { case C.ELinkerOutput.Executable: { configuration["EXECUTABLE_PREFIX"] = new XcodeBuilder.UniqueConfigurationValue(string.Empty); var ext = module.CreateTokenizedString("$(exeext)").Parse().TrimStart(new [] { '.' }); configuration["EXECUTABLE_EXTENSION"] = new XcodeBuilder.UniqueConfigurationValue(ext); } break; case C.ELinkerOutput.DynamicLibrary: { if ((module is C.Plugin) || (module is C.Cxx.Plugin)) { var prefix = module.CreateTokenizedString("$(pluginprefix)").Parse(); configuration["EXECUTABLE_PREFIX"] = new XcodeBuilder.UniqueConfigurationValue(prefix); var ext = module.CreateTokenizedString("$(pluginext)").Parse().TrimStart(new [] { '.' }); configuration["EXECUTABLE_EXTENSION"] = new XcodeBuilder.UniqueConfigurationValue(ext); } else { var prefix = module.CreateTokenizedString("$(dynamicprefix)").Parse(); configuration["EXECUTABLE_PREFIX"] = new XcodeBuilder.UniqueConfigurationValue(prefix); var ext = module.CreateTokenizedString("$(dynamicextonly)").Parse().TrimStart(new [] { '.' }); configuration["EXECUTABLE_EXTENSION"] = new XcodeBuilder.UniqueConfigurationValue(ext); } configuration["MACH_O_TYPE"] = new XcodeBuilder.UniqueConfigurationValue("mh_dylib"); var versionString = module.CreateTokenizedString("$(MajorVersion).$(MinorVersion)#valid(.$(PatchVersion))").Parse(); configuration["DYLIB_CURRENT_VERSION"] = new XcodeBuilder.UniqueConfigurationValue(versionString); configuration["DYLIB_COMPATIBILITY_VERSION"] = new XcodeBuilder.UniqueConfigurationValue(versionString); } break; } if (settings.LibraryPaths.Count > 0) { var option = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.LibraryPaths) { var fullPath = path.Parse(); var relPath = Bam.Core.RelativePathUtilities.GetPath(fullPath, configuration.Project.SourceRoot); if (Bam.Core.RelativePathUtilities.IsPathAbsolute(relPath)) { option.Add(fullPath); } else { option.Add(System.String.Format("$(SRCROOT)/{0}", relPath)); } } configuration["LIBRARY_SEARCH_PATHS"] = option; } foreach (var path in settings.Libraries) { var workspace = Bam.Core.Graph.Instance.MetaData as XcodeBuilder.WorkspaceMeta; var encapsulating = module.GetEncapsulatingReferencedModule(); var target = workspace.EnsureTargetExists(encapsulating); var libname = path.Replace("-l", string.Empty); // need to find where this library is because Xcode requires a path to it // first check all of the library paths var buildFile = FindLibraryInLibrarySearchPaths(target, settings, libname); if (null == buildFile) { // no match, so try the current SDK path buildFile = FindLibraryInSDKSearchPaths(target, settings, libname); if (null == buildFile) { throw new Bam.Core.Exception("Unable to find library {0} on any search path or in the SDK", path); } } } if (settings.DebugSymbols) { var option = new XcodeBuilder.MultiConfigurationValue(); option.Add("-g"); configuration["OTHER_LDFLAGS"] = option; } }
XcodeProjectProcessor.IConvertToProject.Convert( Bam.Core.Module module, XcodeBuilder.Configuration configuration) { XcodeProjectProcessor.Conversion.Convert(typeof(ClangCommon.XcodeCompilerImplementation), this, module, configuration); }
public static void Convert( this ClangCommon.ICommonCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.AllWarnings.HasValue) { var warnings = new XcodeBuilder.MultiConfigurationValue(); if (settings.AllWarnings.Value) { warnings.Add("-Wall"); } else { warnings.Add("-Wno-all"); } configuration["WARNING_CFLAGS"] = warnings; } if (settings.ExtraWarnings.HasValue) { var warnings = new XcodeBuilder.MultiConfigurationValue(); if (settings.ExtraWarnings.Value) { warnings.Add("-Wextra"); } else { warnings.Add("-Wno-extra"); } configuration["WARNING_CFLAGS"] = warnings; } if (settings.Pedantic.HasValue) { configuration["GCC_WARN_PEDANTIC"] = new XcodeBuilder.UniqueConfigurationValue(settings.Pedantic.Value ? "YES" : "NO"); } if (settings.Visibility.HasValue) { configuration["GCC_SYMBOLS_PRIVATE_EXTERN"] = new XcodeBuilder.UniqueConfigurationValue((settings.Visibility.Value == EVisibility.Default) ? "NO" : "YES"); } if (settings.StrictAliasing.HasValue) { configuration["GCC_STRICT_ALIASING"] = new XcodeBuilder.UniqueConfigurationValue(settings.StrictAliasing.Value ? "YES" : "NO"); } if (settings.Optimization.HasValue) { var common_optimization = (settings as C.ICommonCompilerSettings).Optimization; if (common_optimization.HasValue && common_optimization.Value != C.EOptimization.Custom) { throw new Bam.Core.Exception("Compiler specific optimizations can only be set when the common optimization is C.EOptimization.Custom"); } switch (settings.Optimization.Value) { case EOptimization.O1: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("1"); break; case EOptimization.O3: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("3"); break; case EOptimization.Ofast: configuration["GCC_OPTIMIZATION_LEVEL"] = new XcodeBuilder.UniqueConfigurationValue("fast"); break; default: throw new Bam.Core.Exception("Unsupported Clang specific optimization, {0}", settings.Optimization.Value); } } }
Convert( this ClangCommon.ICommonAssemblerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { }
Convert( this C.ICommonLinkerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { switch (settings.Bits) { case C.EBit.ThirtyTwo: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("i386"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_32_BIT)"); } break; case C.EBit.SixtyFour: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("x86_64"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_64_BIT)"); } break; default: throw new Bam.Core.Exception("Unknown bit depth, {0}", settings.Bits.ToString()); } switch (settings.OutputType) { case C.ELinkerOutput.Executable: { configuration["EXECUTABLE_PREFIX"] = new XcodeBuilder.UniqueConfigurationValue(string.Empty); var ext = module.CreateTokenizedString("$(exeext)").Parse().TrimStart(new [] { '.' }); configuration["EXECUTABLE_EXTENSION"] = new XcodeBuilder.UniqueConfigurationValue(ext); } break; case C.ELinkerOutput.DynamicLibrary: { if ((module is C.Plugin) || (module is C.Cxx.Plugin)) { var prefix = module.CreateTokenizedString("$(pluginprefix)").Parse(); configuration["EXECUTABLE_PREFIX"] = new XcodeBuilder.UniqueConfigurationValue(prefix); var ext = module.CreateTokenizedString("$(pluginext)").Parse().TrimStart(new [] { '.' }); configuration["EXECUTABLE_EXTENSION"] = new XcodeBuilder.UniqueConfigurationValue(ext); } else { var prefix = module.CreateTokenizedString("$(dynamicprefix)").Parse(); configuration["EXECUTABLE_PREFIX"] = new XcodeBuilder.UniqueConfigurationValue(prefix); var ext = module.CreateTokenizedString("$(dynamicextonly)").Parse().TrimStart(new [] { '.' }); configuration["EXECUTABLE_EXTENSION"] = new XcodeBuilder.UniqueConfigurationValue(ext); } configuration["MACH_O_TYPE"] = new XcodeBuilder.UniqueConfigurationValue("mh_dylib"); var versionString = module.CreateTokenizedString("$(MajorVersion).$(MinorVersion)#valid(.$(PatchVersion))").Parse(); configuration["DYLIB_CURRENT_VERSION"] = new XcodeBuilder.UniqueConfigurationValue(versionString); configuration["DYLIB_COMPATIBILITY_VERSION"] = new XcodeBuilder.UniqueConfigurationValue(versionString); } break; } if (settings.LibraryPaths.Count > 0) { var option = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.LibraryPaths) { option.Add(path.Parse()); } configuration["LIBRARY_SEARCH_PATHS"] = option; } if (settings.DebugSymbols) { var option = new XcodeBuilder.MultiConfigurationValue(); option.Add("-g"); configuration["OTHER_LDFLAGS"] = option; } }
Convert( this C.IObjectiveCxxOnlyCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { }
Convert( this C.ICxxOnlyCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.ExceptionHandler.HasValue) { switch (settings.ExceptionHandler.Value) { case C.Cxx.EExceptionHandler.Disabled: configuration["GCC_ENABLE_CPP_EXCEPTIONS"] = new XcodeBuilder.UniqueConfigurationValue("NO"); break; case C.Cxx.EExceptionHandler.Asynchronous: case C.Cxx.EExceptionHandler.Synchronous: configuration["GCC_ENABLE_CPP_EXCEPTIONS"] = new XcodeBuilder.UniqueConfigurationValue("YES"); break; default: throw new Bam.Core.Exception("Unrecognized exception handler option, {0}", settings.ExceptionHandler.Value.ToString()); } } if (settings.EnableRunTimeTypeInfo.HasValue) { configuration["GCC_ENABLE_CPP_RTTI"] = new XcodeBuilder.UniqueConfigurationValue(settings.EnableRunTimeTypeInfo.Value ? "YES" : "NO"); } if (settings.LanguageStandard.HasValue) { XcodeBuilder.UniqueConfigurationValue standard = null; switch (settings.LanguageStandard.Value) { case C.Cxx.ELanguageStandard.Cxx98: standard = new XcodeBuilder.UniqueConfigurationValue("c++98"); break; case C.Cxx.ELanguageStandard.GnuCxx98: standard = new XcodeBuilder.UniqueConfigurationValue("gnu++98"); break; case C.Cxx.ELanguageStandard.Cxx03: standard = new XcodeBuilder.UniqueConfigurationValue("c++03"); break; case C.Cxx.ELanguageStandard.GnuCxx03: throw new Bam.Core.Exception("Clang does not support the language standard gnu++03"); case C.Cxx.ELanguageStandard.Cxx11: standard = new XcodeBuilder.UniqueConfigurationValue("c++11"); break; case C.Cxx.ELanguageStandard.GnuCxx11: standard = new XcodeBuilder.UniqueConfigurationValue("gnu++11"); break; case C.Cxx.ELanguageStandard.Cxx14: standard = new XcodeBuilder.UniqueConfigurationValue("c++14"); break; case C.Cxx.ELanguageStandard.GnuCxx14: standard = new XcodeBuilder.UniqueConfigurationValue("gnu++14"); break; default: throw new Bam.Core.Exception("Invalid C++ language standard, {0}", settings.LanguageStandard.Value.ToString()); } configuration["CLANG_CXX_LANGUAGE_STANDARD"] = standard; } if (settings.StandardLibrary.HasValue) { switch (settings.StandardLibrary.Value) { case C.Cxx.EStandardLibrary.NotSet: break; case C.Cxx.EStandardLibrary.libstdcxx: configuration["CLANG_CXX_LIBRARY"] = new XcodeBuilder.UniqueConfigurationValue("libstdc++"); break; case C.Cxx.EStandardLibrary.libcxx: configuration["CLANG_CXX_LIBRARY"] = new XcodeBuilder.UniqueConfigurationValue("libc++"); break; default: throw new Bam.Core.Exception("Invalid C++ standard library, {0}", settings.StandardLibrary.Value.ToString()); } } }
Convert( this C.ICommonAssemblerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { switch (settings.Bits.Value) { case C.EBit.ThirtyTwo: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("i386"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_32_BIT)"); } break; case C.EBit.SixtyFour: { configuration["VALID_ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("x86_64"); configuration["ARCHS"] = new XcodeBuilder.UniqueConfigurationValue("$(ARCHS_STANDARD_64_BIT)"); } break; default: throw new Bam.Core.Exception("Unknown bit depth, {0}", settings.Bits.Value); } configuration["GCC_GENERATE_DEBUGGING_SYMBOLS"] = new XcodeBuilder.UniqueConfigurationValue(settings.DebugSymbols ? "YES" : "NO"); if (settings.IncludePaths.Count > 0) { var paths = new XcodeBuilder.MultiConfigurationValue(); foreach (var path in settings.IncludePaths.ToEnumerableWithoutDuplicates()) { path.Parse(); var fullPath = path.ToString(); var relPath = Bam.Core.RelativePathUtilities.GetPath(fullPath, configuration.Project.SourceRoot); if (Bam.Core.RelativePathUtilities.IsPathAbsolute(relPath)) { paths.Add(fullPath); } else { paths.Add(System.String.Format("$(SRCROOT)/{0}", relPath)); } } configuration["USER_HEADER_SEARCH_PATHS"] = paths; } if (settings.PreprocessorDefines.Count > 0) { var defines = new XcodeBuilder.MultiConfigurationValue(); foreach (var define in settings.PreprocessorDefines) { if (null == define.Value) { defines.Add(define.Key); } else { var defineValue = define.Value.ToString(); if (defineValue.Contains("\"")) { // note the number of back slashes here // required to get \\\" for each " in the original value defineValue = defineValue.Replace("\"", "\\\\\\\""); } defineValue = Bam.Core.IOWrapper.EncloseSpaceContainingPathWithDoubleQuotes(defineValue); defines.Add(System.String.Format("{0}={1}", define.Key, defineValue)); } } configuration["GCC_PREPROCESSOR_DEFINITIONS"] = defines; } configuration["GCC_TREAT_WARNINGS_AS_ERRORS"] = new XcodeBuilder.UniqueConfigurationValue(settings.WarningsAsErrors ? "YES" : "NO"); }