예제 #1
0
 Defaults(
     this C.ICommonLinkerSettingsOSX settings,
     Bam.Core.Module module)
 {
     settings.Frameworks           = new Bam.Core.TokenizedStringArray();
     settings.FrameworkSearchPaths = new Bam.Core.TokenizedStringArray();
 }
 Defaults(
     this C.ICommonLinkerSettingsOSX settings,
     Bam.Core.Module module)
 {
     settings.Frameworks           = new Bam.Core.TokenizedStringArray();
     settings.FrameworkSearchPaths = new Bam.Core.TokenizedStringArray();
     // N.B. this default is set in the specific Clang version
     // as it's set on both compiler and linker
 }
        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.ICommonLinkerSettingsOSX settings,
            Bam.Core.StringArray commandLine)
        {
            var module = (settings as Bam.Core.Settings).Module;

            foreach (var framework in settings.Frameworks.ToEnumerableWithoutDuplicates())
            {
                var frameworkName = System.IO.Path.GetFileNameWithoutExtension(framework.ToString());
                commandLine.Add(System.String.Format("-framework {0}", frameworkName));
            }
            foreach (var path in settings.FrameworkSearchPaths.ToEnumerableWithoutDuplicates())
            {
                commandLine.Add(System.String.Format("-F {0}", path.ToString()));
            }
            if (null != settings.InstallName)
            {
                if (module is C.IDynamicLibrary)
                {
                    commandLine.Add(System.String.Format("-Wl,-dylib_install_name,{0}", settings.InstallName.ToString()));
                }
            }
            if (settings.MinimumVersionSupported != null)
            {
                var minVersionRegEx = new System.Text.RegularExpressions.Regex("^(?<Type>[a-z]+)(?<Version>[0-9.]+)$");
                var match           = minVersionRegEx.Match(settings.MinimumVersionSupported);
                if (!match.Groups["Type"].Success)
                {
                    throw new Bam.Core.Exception("Unable to extract SDK type from: '{0}'", settings.MinimumVersionSupported);
                }
                if (!match.Groups["Version"].Success)
                {
                    throw new Bam.Core.Exception("Unable to extract SDK version from: '{0}'", settings.MinimumVersionSupported);
                }
                commandLine.Add(System.String.Format("-m{0}-version-min={1}",
                                                     match.Groups["Type"].Value,
                                                     match.Groups["Version"].Value));
            }
        }