コード例 #1
0
        public void ResponseFile()
        {
            var bgen = new BGenTool();

            bgen.CreateTemporaryBinding("");
            bgen.ResponseFile = Path.Combine(Cache.CreateTemporaryDirectory(), "rspfile");

            var arguments = new List <string> ();

#if NET
            var targetFramework = TargetFramework.DotNet_6_0_iOS_String;
            var tf = TargetFramework.Parse(targetFramework);
            arguments.Add($"--baselib={Configuration.GetBaseLibrary (tf)}");
            arguments.Add($"--attributelib={Configuration.GetBindingAttributePath (tf)}");
            arguments.AddRange(Directory.GetFiles(Configuration.DotNet6BclDir, "*.dll").Select(v => $"-r:{v}"));
#else
            var targetFramework = "Xamarin.iOS,v1.0";
#endif
            arguments.Add($"--target-framework={targetFramework}");

            File.WriteAllLines(bgen.ResponseFile, arguments.ToArray());
            bgen.AssertExecute("response file");
            bgen.AssertNoWarnings();
        }
コード例 #2
0
 public static ApplePlatform GetFramework(string targetFrameworkMoniker)
 {
     return(TargetFramework.Parse(targetFrameworkMoniker).Platform);
 }
コード例 #3
0
        string [] BuildArgumentArray()
        {
            var sb = new List <string> ();
            var targetFramework = (string)null;

#if NET
            switch (Profile)
            {
            case Profile.None:
                break;

            case Profile.iOS:
                targetFramework = TargetFramework.DotNet_6_0_iOS_String;
                break;

            case Profile.tvOS:
                targetFramework = TargetFramework.DotNet_6_0_tvOS_String;
                break;

            case Profile.watchOS:
                targetFramework = TargetFramework.DotNet_6_0_watchOS_String;
                break;

            case Profile.macOSMobile:
                targetFramework = TargetFramework.DotNet_6_0_macOS_String;
                break;

            case Profile.macOSFull:
            case Profile.macOSSystem:
                throw new InvalidOperationException($"Only the Mobile profile can be specified for .NET");

            default:
                throw new NotImplementedException($"Profile: {Profile}");
            }
#else
            switch (Profile)
            {
            case Profile.None:
                break;

            case Profile.iOS:
                targetFramework = "Xamarin.iOS,v1.0";
                break;

            case Profile.tvOS:
                targetFramework = "Xamarin.TVOS,v1.0";
                break;

            case Profile.watchOS:
                targetFramework = "Xamarin.WatchOS,v1.0";
                break;

            case Profile.macOSClassic:
                targetFramework = "XamMac,v1.0";
                break;

            case Profile.macOSFull:
                targetFramework = "Xamarin.Mac,Version=v4.5,Profile=Full";
                break;

            case Profile.macOSMobile:
                targetFramework = "Xamarin.Mac,Version=v2.0,Profile=Mobile";
                break;

            case Profile.macOSSystem:
                targetFramework = "Xamarin.Mac,Version=v4.5,Profile=System";
                break;

            default:
                throw new NotImplementedException($"Profile: {Profile}");
            }
#endif

#if NET
            if (CompileCommand is null)
            {
                if (!StringUtils.TryParseArguments(Configuration.DotNetCscCommand, out var args, out var ex))
                {
                    throw new InvalidOperationException($"Unable to parse the .NET csc command '{Configuration.DotNetCscCommand}': {ex.Message}");
                }

                CompileCommand = new List <string> (args);
            }

            if (CompileCommand.Count > 0)
            {
                sb.Add($"--compile-command");
                sb.Add(string.Join(" ", StringUtils.QuoteForProcess(CompileCommand.ToArray())));
            }
#endif

            TargetFramework?tf = null;
            if (targetFramework != null)
            {
                tf = TargetFramework.Parse(targetFramework);
            }

            if (BaseLibrary == null)
            {
                if (tf.HasValue)
                {
                    sb.Add($"--baselib={Configuration.GetBaseLibrary (tf.Value)}");
                }
            }
            else if (BaseLibrary != None)
            {
                sb.Add($"--baselib={BaseLibrary}");
            }

            if (AttributeLibrary == null)
            {
                if (tf.HasValue)
                {
                    sb.Add($"--attributelib={Configuration.GetBindingAttributePath (tf.Value)}");
                }
            }
            else if (AttributeLibrary != None)
            {
                sb.Add($"--attributelib={AttributeLibrary}");
            }

            if (!string.IsNullOrEmpty(targetFramework))
            {
                sb.Add($"--target-framework={targetFramework}");
            }

            foreach (var ad in ApiDefinitions)
            {
                sb.Add($"--api={ad}");
            }

            foreach (var s in Sources)
            {
                sb.Add($"-s={s}");
            }

            if (ReferenceBclByDefault)
            {
                if (tf == null)
                {
                    // do nothing
                }
                else if (tf.Value.IsDotNet == true)
                {
                    References.AddRange(Directory.GetFiles(Configuration.DotNet6BclDir, "*.dll"));
                }
                else
                {
                    throw new NotImplementedException("ReferenceBclByDefault");
                }
            }

            foreach (var r in References)
            {
                sb.Add($"-r={r}");
            }

            if (!string.IsNullOrEmpty(TmpDirectory))
            {
                sb.Add($"--tmpdir={TmpDirectory}");
            }

            if (!string.IsNullOrEmpty(ResponseFile))
            {
                sb.Add($"@{ResponseFile}");
            }

            if (!string.IsNullOrEmpty(Out))
            {
                sb.Add($"--out={Out}");
            }

            if (ProcessEnums)
            {
                sb.Add("--process-enums");
            }

            if (Defines != null)
            {
                foreach (var d in Defines)
                {
                    sb.Add($"-d={d}");
                }
            }

            if (WarnAsError != null)
            {
                var arg = "--warnaserror";
                if (WarnAsError.Length > 0)
                {
                    arg += ":" + WarnAsError;
                }
                sb.Add(arg);
            }

            if (NoWarn != null)
            {
                var arg = "--nowarn";
                if (NoWarn.Length > 0)
                {
                    arg += ":" + NoWarn;
                }
                sb.Add(arg);
            }
            if (Verbosity != 0)
            {
                sb.Add("-" + new string (Verbosity > 0 ? 'v' : 'q', Math.Abs(Verbosity)));
            }
            return(sb.ToArray());
        }