コード例 #1
0
 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;
 }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
 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
 }
コード例 #4
0
        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
        }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
 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");
     }
 }
コード例 #7
0
        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?
            }
        }
コード例 #8
0
        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;
            }
        }