예제 #1
0
        static string MakeMacUnifiedTargetName(MacTarget target, MacTargetNameType type)
        {
            var make_escaped_suffix = target.Platform.Replace(" ", "\\ ");
            var make_escaped_name   = target.SimplifiedName.Replace(" ", "\\ ");

            var sb = new StringBuilder();

            sb.Append(type.ToString().ToLowerInvariant());
            sb.Append('-');
            sb.Append(make_escaped_suffix);
            sb.Append('-');
            if (!string.IsNullOrEmpty(target.MakefileWhereSuffix))
            {
                sb.Append(target.MakefileWhereSuffix);
                sb.Append('-');
            }
            sb.Append(make_escaped_name);
            return(sb.ToString());
        }
예제 #2
0
        int AutoConfigureMac(bool generate_projects)
        {
            int rv = 0;

            var test_suites = new [] {
                new { Directory = "apitest", ProjectFile = "apitest", Name = "apitest", Flavors = MacFlavors.Full | MacFlavors.Modern },
                new { Directory = "linker/mac/dont link", ProjectFile = "dont link-mac", Name = "dont link", Flavors = MacFlavors.Modern | MacFlavors.Full | MacFlavors.System },
            };

            foreach (var p in test_suites)
            {
                MacTestProjects.Add(new MacTestProject(Path.GetFullPath(Path.Combine(RootDirectory, p.Directory, p.ProjectFile + ".csproj")))
                {
                    Name = p.Name,
                    TargetFrameworkFlavors = p.Flavors,
                });
            }

            MacTestProjects.Add(new MacTestProject(Path.GetFullPath(Path.Combine(RootDirectory, "introspection", "Mac", "introspection-mac.csproj")), targetFrameworkFlavor: MacFlavors.Modern)
            {
                Name = "introspection"
            });

            var hard_coded_test_suites = new [] {
                new { Directory = "mmptest", ProjectFile = "mmptest", Name = "mmptest", IsNUnit = true, Configurations = (string[])null, Platform = "x86", Flavors = MacFlavors.Console, },
                new { Directory = "msbuild-mac", ProjectFile = "msbuild-mac", Name = "MSBuild tests", IsNUnit = true, Configurations = (string[])null, Platform = "x86", Flavors = MacFlavors.Console, },
                new { Directory = "xammac_tests", ProjectFile = "xammac_tests", Name = "xammac tests", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "AnyCPU", Flavors = MacFlavors.Modern, },
                new { Directory = "linker/mac/link all", ProjectFile = "link all-mac", Name = "link all", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "x86", Flavors = MacFlavors.Modern, },
                new { Directory = "linker/mac/link sdk", ProjectFile = "link sdk-mac", Name = "link sdk", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "x86", Flavors = MacFlavors.Modern, },
            };

            foreach (var p in hard_coded_test_suites)
            {
                MacTestProjects.Add(new MacTestProject(Path.GetFullPath(Path.Combine(RootDirectory, p.Directory, p.ProjectFile + ".csproj")), targetFrameworkFlavor: p.Flavors)
                {
                    Name           = p.Name,
                    IsNUnitProject = p.IsNUnit,
                    SolutionPath   = Path.GetFullPath(Path.Combine(RootDirectory, "tests-mac.sln")),
                    Configurations = p.Configurations,
                    Platform       = p.Platform,
                });
            }

            foreach (var flavor in new MonoNativeFlavor [] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified })
            {
                var monoNativeInfo = new MacMonoNativeInfo(this, flavor);
                var macTestProject = new MacTestProject(monoNativeInfo.ProjectPath, targetFrameworkFlavor: MacFlavors.Modern | MacFlavors.Full)
                {
                    MonoNativeInfo = monoNativeInfo,
                    Name           = monoNativeInfo.ProjectName,
                    Platform       = "AnyCPU",
                };

                MacTestProjects.Add(macTestProject);
            }

            var monoImportTestFactory = new BCLTestImportTargetFactory(this);

            MacTestProjects.AddRange(monoImportTestFactory.GetMacBclTargets());

            // Generate test projects from templates (bcl/mono-native templates)
            if (generate_projects)
            {
                foreach (var mtp in MacTestProjects.Where(x => x.MonoNativeInfo != null).Select(x => x.MonoNativeInfo))
                {
                    mtp.Convert();
                }
            }

            // All test projects should be either Modern projects or NUnit/console executables at this point.
            // If we need to generate Full/System variations, we do that here.
            var unified_targets = new List <MacTarget> ();

            Action <MacTarget, string, bool, bool> configureTarget = (MacTarget target, string file, bool isNUnitProject, bool skip_generation) => {
                target.TemplateProjectPath = file;
                target.Harness             = this;
                target.IsNUnitProject      = isNUnitProject;
                if (!generate_projects || skip_generation)
                {
                    target.ShouldSkipProjectGeneration = true;
                }
                target.Execute();
            };

            foreach (var proj in MacTestProjects)
            {
                var target = new MacTarget(MacFlavors.Modern);
                target.MonoNativeInfo = proj.MonoNativeInfo;
                configureTarget(target, proj.Path, proj.IsNUnitProject, true);
                unified_targets.Add(target);
            }

            foreach (var proj in MacTestProjects.Where((v) => v.GenerateVariations).ToArray())
            {
                var file = proj.Path;
                if (!File.Exists(file))
                {
                    Console.WriteLine($"Can't find the project file {file}.");
                    rv = 1;
                    continue;
                }

                // Generate variations if requested
                if (proj.GenerateFull)
                {
                    var target = new MacTarget(MacFlavors.Full);
                    target.MonoNativeInfo = proj.MonoNativeInfo;
                    configureTarget(target, file, proj.IsNUnitProject, false);
                    unified_targets.Add(target);

                    var cloned_project = (MacTestProject)proj.Clone();
                    cloned_project.TargetFrameworkFlavors = MacFlavors.Full;
                    cloned_project.Path = target.ProjectPath;
                    MacTestProjects.Add(cloned_project);
                }

                if (proj.GenerateSystem)
                {
                    var target = new MacTarget(MacFlavors.System);
                    target.MonoNativeInfo = proj.MonoNativeInfo;
                    configureTarget(target, file, proj.IsNUnitProject, false);
                    unified_targets.Add(target);

                    var cloned_project = (MacTestProject)proj.Clone();
                    cloned_project.TargetFrameworkFlavors = MacFlavors.System;
                    cloned_project.Path = target.ProjectPath;
                    MacTestProjects.Add(cloned_project);
                }

                // We're done generating now
                // Re-use the existing TestProject instance instead of creating a new one.
                proj.TargetFrameworkFlavors = MacFlavors.Modern;                 // the default/template flavor is 'Modern'
            }

            if (generate_projects)
            {
                MakefileGenerator.CreateMacMakefile(this, unified_targets);
            }

            return(rv);
        }