public static void 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:"); } } }
public static void 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( 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 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 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) { var frameworkFileRefPath = framework; var isAbsolute = System.IO.Path.IsPathRooted(frameworkFileRefPath.Parse()); 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)); } 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) { option.Add(path.Parse()); } configuration["FRAMEWORK_SEARCH_PATHS"] = option; } if (null != settings.InstallName) { if (module is C.IDynamicLibrary) { configuration["LD_DYLIB_INSTALL_NAME"] = new XcodeBuilder.UniqueConfigurationValue(settings.InstallName.Parse()); } } // settings.MinimumVersionSupported is dealt with in XcodeBuilder as there is not a difference // between compiler and linker setting in the project }
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 ClangCommon.ICommonCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { if (settings.AllWarnings.HasValue) { if (settings.AllWarnings.Value) { var warnings = new XcodeBuilder.MultiConfigurationValue(); warnings.Add("-Wall"); configuration["WARNING_CFLAGS"] = warnings; } } if (settings.ExtraWarnings.HasValue) { if (settings.ExtraWarnings.Value) { var warnings = new XcodeBuilder.MultiConfigurationValue(); warnings.Add("-Wextra"); 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"); } }
XcodeProjectProcessor.IConvertToProject.Convert( Bam.Core.Module module, XcodeBuilder.Configuration configuration) { XcodeProjectProcessor.Conversion.Convert(typeof(ClangCommon.XcodeCompilerImplementation), this, module, configuration); }
Convert( this C.IObjectiveCxxOnlyCompilerSettings settings, Bam.Core.Module module, XcodeBuilder.Configuration configuration) { }
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.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.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.LanguageStandard.HasValue) { switch (settings.LanguageStandard.Value) { case C.Cxx.ELanguageStandard.Cxx98: configuration["CLANG_CXX_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("c++98"); break; case C.Cxx.ELanguageStandard.GnuCxx98: configuration["CLANG_CXX_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("gnu++98"); break; case C.Cxx.ELanguageStandard.Cxx11: configuration["CLANG_CXX_LANGUAGE_STANDARD"] = new XcodeBuilder.UniqueConfigurationValue("c++11"); break; default: throw new Bam.Core.Exception("Invalid C++ language standard, {0}", settings.LanguageStandard.Value.ToString()); } } 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()); } } }