Exemplo n.º 1
0
        void CreateWatchOSContainerProject()
        {
            var csproj = new XmlDocument();

            csproj.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSContainerTemplate, "Container.csproj"));

            csproj.FindAndReplace("%CONTAINER_PATH%", Path.GetFullPath(Harness.WatchOSContainerTemplate).Replace('/', '\\') + "\\");
            csproj.FindAndReplace("%WATCHAPP_CSPROJ%", Path.GetFileName(WatchOSAppProjectPath));
            csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSAppProjectPath), "Name", Path.GetFileNameWithoutExtension(WatchOSAppProjectPath));
            WatchOSGuid = "{" + Helpers.GenerateStableGuid().ToString().ToUpper() + "}";
            csproj.SetProjectGuid(WatchOSGuid);
            csproj.FixInfoPListInclude(Suffix);
            if (MonoNativeInfo != null)
            {
                csproj.AddAdditionalDefines("MONO_NATIVE_WATCH");
                MonoNativeHelper.AddProjectDefines(csproj, MonoNativeInfo.Flavor);
                MonoNativeHelper.RemoveSymlinkMode(csproj);
            }
            csproj.Save(WatchOSProjectPath, (l, m) => Harness.Log(l, m));

            XmlDocument info_plist        = new XmlDocument();
            var         target_info_plist = Path.Combine(TargetDirectory, $"Info{Suffix}.plist");

            info_plist.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSContainerTemplate, "Info.plist"));
            info_plist.SetCFBundleIdentifier(BundleIdentifier);
            info_plist.SetCFBundleName(Name);
            info_plist.SetMinimumOSVersion("9.0");
            info_plist.Save(target_info_plist, (l, m) => Harness.Log(l, m));
        }
Exemplo n.º 2
0
        void CreateWatchOSAppProject()
        {
            var csproj = new XmlDocument();
            var suffix = Suffix + "-app";

            csproj.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSAppTemplate, "App.csproj"));
            csproj.FindAndReplace("%WATCHAPP_PATH%", Path.GetFullPath(Harness.WatchOSAppTemplate).Replace('/', '\\') + "\\");
            csproj.FindAndReplace("%WATCHEXTENSION_CSPROJ%", Path.GetFileName(WatchOSExtensionProjectPath));
            csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSExtensionProjectPath), "Project", WatchOSExtensionGuid);
            csproj.SetProjectReferenceValue(Path.GetFileName(WatchOSExtensionProjectPath), "Name", Path.GetFileNameWithoutExtension(WatchOSExtensionProjectPath));
            WatchOSAppGuid = "{" + Helpers.GenerateStableGuid().ToString().ToUpper() + "}";
            csproj.SetProjectGuid(WatchOSAppGuid);
            csproj.FixInfoPListInclude(suffix);
            if (MonoNativeInfo != null)
            {
                csproj.AddAdditionalDefines("MONO_NATIVE_WATCH");
                MonoNativeHelper.AddProjectDefines(csproj, MonoNativeInfo.Flavor);
                MonoNativeHelper.RemoveSymlinkMode(csproj);
            }
            csproj.Save(WatchOSAppProjectPath, (l, m) => Harness.Log(l, m));

            XmlDocument info_plist        = new XmlDocument();
            var         target_info_plist = Path.Combine(TargetDirectory, $"Info{Suffix}-app.plist");

            info_plist.LoadWithoutNetworkAccess(Path.Combine(Harness.WatchOSAppTemplate, "Info.plist"));
            info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp");
            info_plist.SetPListStringValue("WKCompanionAppBundleIdentifier", BundleIdentifier);
            info_plist.SetPListStringValue("CFBundleName", Name);
            info_plist.SetMinimumOSVersion(GetMinimumOSVersion(info_plist.GetMinimumOSVersion()));
            info_plist.Save(target_info_plist, (l, m) => Harness.Log(l, m));
        }
Exemplo n.º 3
0
 protected override string GetMinimumOSVersion(string templateMinimumOSVersion)
 {
     if (MonoNativeInfo == null)
     {
         return(templateMinimumOSVersion);
     }
     return(MonoNativeHelper.GetMinimumOSVersion(DevicePlatform.iOS, MonoNativeInfo.Flavor));
 }
Exemplo n.º 4
0
 protected override string GetMinimumOSVersion(string templateMinimumOSVersion)
 {
     if (MonoNativeInfo == null)
     {
         return(Xamarin.SdkVersions.MinTVOS);
     }
     return(MonoNativeHelper.GetMinimumOSVersion(DevicePlatform.tvOS, MonoNativeInfo.Flavor));
 }
Exemplo n.º 5
0
        protected override void ProcessProject()
        {
            base.ProcessProject();

            if (MonoNativeInfo != null)
            {
                inputProject.AddAdditionalDefines("MONO_NATIVE_TV");
                MonoNativeHelper.AddProjectDefines(inputProject, MonoNativeInfo.Flavor);
                MonoNativeHelper.RemoveSymlinkMode(inputProject);
            }

            var srcDirectory = Path.Combine(HarnessConfiguration.RootDirectory, "..", "src");

            string project_guid;
            var    mt_nunitlite_project_path = Path.GetFullPath(Path.Combine(srcDirectory, "MonoTouch.NUnitLite.tvos.csproj"));

            if (!project_guids.TryGetValue(mt_nunitlite_project_path, out project_guid))
            {
                XmlDocument mt_nunitlite_project = new XmlDocument();
                mt_nunitlite_project.LoadWithoutNetworkAccess(mt_nunitlite_project_path);
                project_guid = mt_nunitlite_project.GetProjectGuid();
                project_guids [mt_nunitlite_project_path] = project_guid;
            }
            inputProject.CreateProjectReferenceValue("MonoTouch.NUnitLite", mt_nunitlite_project_path, project_guid, "MonoTouch.NUnitLite");

            inputProject.AddExtraMtouchArgs("--bitcode:asmonly", "iPhone", "Release");
            inputProject.SetMtouchUseLlvm(true, "iPhone", "Release");

            // Remove bitcode from executables, since we don't need it for testing, and it makes test apps bigger (and the Apple TV might refuse to install them).
            var configurations = new string [] { "Debug", "Debug64", "Release", "Release64" };

            foreach (var c in configurations)
            {
                inputProject.AddExtraMtouchArgs($"--gcc_flags=-fembed-bitcode-marker", "iPhone", c);
            }
        }
Exemplo n.º 6
0
        void CreateWatchOSExtensionProject()
        {
            var csproj = inputProject;
            var suffix = Suffix + "-extension";

            // Remove unused configurations
            csproj.DeleteConfiguration("iPhone", "Release-bitcode");
            csproj.DeleteConfiguration("iPhone", "Release64");
            csproj.DeleteConfiguration("iPhone", "Debug64");

            csproj.FixArchitectures("i386", "ARMv7k", "iPhone", "Release32");
            csproj.FixArchitectures("i386", "ARMv7k", "iPhone", "Debug32");

            // add Release64_32 and set the correct architecture
            csproj.CloneConfiguration("iPhone", "Release", "Release64_32");
            csproj.FixArchitectures("i386", "ARM64_32", "iPhone", "Release64_32");

            // add Debug64_32 and set the correct architecture
            csproj.CloneConfiguration("iPhone", "Debug", "Debug64_32");
            csproj.FixArchitectures("i386", "ARM64_32", "iPhone", "Debug64_32");

            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhoneSimulator", "Debug");
            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhoneSimulator", "Release");
            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhone", "Debug");
            csproj.FixArchitectures(SimulatorArchitectures, DeviceArchitectures, "iPhone", "Release");

            csproj.SetProjectTypeGuids("{1E2E965C-F6D2-49ED-B86E-418A60C69EEF};" + LanguageGuid);
            csproj.SetOutputPath("bin\\$(Platform)\\$(Configuration)" + suffix);
            csproj.SetIntermediateOutputPath("obj\\$(Platform)\\$(Configuration)" + suffix);
            csproj.RemoveTargetFrameworkIdentifier();
            csproj.SetPlatformAssembly("Xamarin.WatchOS");
            csproj.SetImport(IsFSharp ? "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.FSharp.targets" : "$(MSBuildExtensionsPath)\\Xamarin\\WatchOS\\Xamarin.WatchOS.AppExtension.CSharp.targets");
            csproj.FixProjectReferences("-watchos");

            csproj.FixInfoPListInclude(suffix);
            csproj.SetOutputType("Library");
            csproj.AddAdditionalDefines("BITCODE", "iPhone", "Release");
            csproj.AddAdditionalDefines("XAMCORE_3_0;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH;");
            csproj.RemoveReferences("OpenTK-1.0");
            var ext = IsFSharp ? "fs" : "cs";

            csproj.AddCompileInclude("InterfaceController." + ext, Path.Combine(Harness.WatchOSExtensionTemplate, "InterfaceController." + ext));
            csproj.SetExtraLinkerDefs("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
            csproj.SetMtouchUseBitcode(true, "iPhone", "Release");
            csproj.SetMtouchUseLlvm(true, "iPhone", "Release");

            if (MonoNativeInfo != null)
            {
                csproj.AddAdditionalDefines("MONO_NATIVE_WATCH");
                MonoNativeHelper.AddProjectDefines(csproj, MonoNativeInfo.Flavor);
                MonoNativeHelper.RemoveSymlinkMode(csproj);
            }

            // Not linking a watch extensions requires passing -Os to the native compiler.
            // https://github.com/mono/mono/issues/9867
            var configurations = new string [] { "Debug", "Debug32", "Debug64_32", "Release", "Release32", "Release64_32" };

            foreach (var c in configurations)
            {
                var flags = "-fembed-bitcode-marker";
                if (csproj.GetMtouchLink("iPhone", c) == "None")
                {
                    flags += " -Os";
                }

                csproj.AddExtraMtouchArgs($"--gcc_flags='{flags}'", "iPhone", c);
            }

            csproj.Save(WatchOSExtensionProjectPath, (l, m) => Harness.Log(l, m));

            WatchOSExtensionGuid = csproj.GetProjectGuid();

            XmlDocument info_plist        = new XmlDocument();
            var         target_info_plist = Path.Combine(TargetDirectory, $"Info{Suffix}-extension.plist");

            info_plist.LoadWithoutNetworkAccess(Path.Combine(TargetDirectory, "Info.plist"));
            BundleIdentifier = info_plist.GetCFBundleIdentifier() + "_watch";
            if (BundleIdentifier.Length >= 58)
            {
                BundleIdentifier = BundleIdentifier.Substring(0, 57);                  // If the main app's bundle id is 58 characters (or sometimes more), then the watch extension crashes at launch. radar #29847128.
            }
            info_plist.SetCFBundleIdentifier(BundleIdentifier + ".watchkitapp.watchkitextension");
            info_plist.SetMinimumOSVersion(GetMinimumOSVersion("2.0"));
            info_plist.SetUIDeviceFamily(4);
            info_plist.AddPListStringValue("RemoteInterfacePrincipleClass", "InterfaceController");
            info_plist.AddPListKeyValuePair("NSExtension", "dict", string.Format(
                                                @"
    <key>NSExtensionAttributes</key>
    <dict>
    <key>WKAppBundleIdentifier</key>
    <string>{0}.watchkitapp</string>
    </dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.watchkit</string>
", BundleIdentifier));
            if (!info_plist.ContainsKey("NSAppTransportSecurity"))
            {
                info_plist.AddPListKeyValuePair("NSAppTransportSecurity", "dict",
                                                @"
		  <key>NSAllowsArbitraryLoads</key>
		  <true/>
		"        );
            }
            info_plist.Save(target_info_plist, (l, m) => Harness.Log(l, m));
        }
Exemplo n.º 7
0
        public IEnumerable <T> CreateTestVariations <T> (IEnumerable <T> tests, Func <MSBuildTask, T, IEnumerable <IDevice>, T> creator) where T : RunTestTask
        {
            foreach (var task in tests)
            {
                if (string.IsNullOrEmpty(task.Variation))
                {
                    task.Variation = task.ProjectConfiguration.Contains("Debug") ? "Debug" : "Release";
                }

                if (task.TestProject.IsDotNetProject)
                {
                    task.Variation += " [dotnet]";
                }
            }

            var rv = new List <T> (tests);

            foreach (var task in tests.ToArray())
            {
                foreach (var test_data in GetTestData(task))
                {
                    var variation           = test_data.Variation;
                    var mtouch_extra_args   = test_data.MTouchExtraArgs;
                    var bundling_extra_args = test_data.MonoBundlingExtraArgs;
                    var configuration       = test_data.Debug ? task.ProjectConfiguration : task.ProjectConfiguration.Replace("Debug", "Release");
                    var debug             = test_data.Debug;
                    var profiling         = test_data.Profiling;
                    var link_mode         = test_data.LinkMode;
                    var defines           = test_data.Defines;
                    var undefines         = test_data.Undefines;
                    var ignored           = test_data.Ignored;
                    var known_failure     = test_data.KnownFailure;
                    var candidates        = test_data.Candidates;
                    var use_mono_runtime  = test_data.UseMonoRuntime;
                    var xammac_arch       = test_data.XamMacArch;
                    var runtime_identifer = test_data.RuntimeIdentifier;
                    var use_llvm          = test_data.UseLlvm;

                    if (task.TestProject.IsDotNetProject)
                    {
                        variation += " [dotnet]";
                    }

                    if (known_failure is not null)
                    {
                        ignored = true;
                    }

                    var clone      = task.TestProject.Clone();
                    var clone_task = Task.Run(async() => {
                        await task.BuildTask.InitialTask;                         // this is the project cloning above

                        await clone.CreateCopyAsync(jenkins.MainLog, processManager, task, HarnessConfiguration.RootDirectory);

                        var isMac      = task.Platform.IsMac();
                        var canSymlink = task.Platform.CanSymlink();

                        if (!string.IsNullOrEmpty(mtouch_extra_args))
                        {
                            clone.Xml.AddExtraMtouchArgs(mtouch_extra_args, task.ProjectPlatform, configuration);
                        }
                        if (!string.IsNullOrEmpty(bundling_extra_args))
                        {
                            clone.Xml.AddMonoBundlingExtraArgs(bundling_extra_args, task.ProjectPlatform, configuration);
                        }
                        if (!string.IsNullOrEmpty(link_mode))
                        {
                            clone.Xml.SetNode(isMac ? "LinkMode" : "MtouchLink", link_mode, task.ProjectPlatform, configuration);
                        }
                        if (!string.IsNullOrEmpty(defines))
                        {
                            clone.Xml.AddAdditionalDefines(defines, task.ProjectPlatform, configuration);
                            if (clone.ProjectReferences != null)
                            {
                                foreach (var pr in clone.ProjectReferences)
                                {
                                    pr.Xml.AddAdditionalDefines(defines, task.ProjectPlatform, configuration);
                                    pr.Xml.Save(pr.Path);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(undefines))
                        {
                            clone.Xml.RemoveDefines(undefines, task.ProjectPlatform, configuration);
                            if (clone.ProjectReferences != null)
                            {
                                foreach (var pr in clone.ProjectReferences)
                                {
                                    pr.Xml.RemoveDefines(undefines, task.ProjectPlatform, configuration);
                                    pr.Xml.Save(pr.Path);
                                }
                            }
                        }
                        clone.Xml.SetNode(isMac ? "Profiling" : "MTouchProfiling", profiling ? "True" : "False", task.ProjectPlatform, configuration);
                        if (test_data.MonoNativeLinkMode != MonoNativeLinkMode.None)
                        {
                            var mono_native_link = test_data.MonoNativeLinkMode;
                            if (!canSymlink && mono_native_link == MonoNativeLinkMode.Symlink)
                            {
                                mono_native_link = MonoNativeLinkMode.Static;
                            }
                            MonoNativeHelper.AddProjectDefines(clone.Xml, mono_native_link);
                        }
                        if (test_data.EnableSGenConc)
                        {
                            clone.Xml.SetTopLevelPropertyGroupValue("EnableSGenConc", "true");
                        }
                        if (test_data.UseThumb)                         // no need to check the platform, already done at the data iterator
                        {
                            clone.Xml.SetNode("MtouchUseThumb", "true", task.ProjectPlatform, configuration);
                        }
                        if (use_llvm)
                        {
                            clone.Xml.SetTopLevelPropertyGroupValue("MtouchUseLlvm", "true");
                        }

                        if (!debug && !isMac)
                        {
                            clone.Xml.SetMtouchUseLlvm(true, task.ProjectPlatform, configuration);
                        }
                        if (use_mono_runtime.HasValue)
                        {
                            clone.Xml.SetTopLevelPropertyGroupValue("UseMonoRuntime", use_mono_runtime.Value ? "true" : "false");
                        }
                        if (!string.IsNullOrEmpty(xammac_arch))
                        {
                            clone.Xml.SetNode("XamMacArch", xammac_arch, task.ProjectPlatform, configuration);
                        }
                        if (!string.IsNullOrEmpty(runtime_identifer))
                        {
                            clone.Xml.SetTopLevelPropertyGroupValue("RuntimeIdentifier", runtime_identifer);
                        }
                        clone.Xml.Save(clone.Path);
                    });

                    ignored |= clone.IsDotNetProject && !jenkins.IncludeDotNet;

                    var build = new MSBuildTask(jenkins: jenkins, testProject: clone, processManager: processManager);
                    build.ProjectConfiguration = configuration;
                    build.ProjectPlatform      = task.ProjectPlatform;
                    build.Platform             = task.Platform;
                    build.InitialTask          = clone_task;
                    build.TestName             = clone.Name;

                    T newVariation = creator(build, task, candidates);
                    newVariation.Variation         = variation;
                    newVariation.Ignored           = ignored ?? task.Ignored;
                    newVariation.BuildOnly         = task.BuildOnly;
                    newVariation.TimeoutMultiplier = task.TimeoutMultiplier;
                    newVariation.KnownFailure      = known_failure;
                    rv.Add(newVariation);
                }
            }

            return(rv);
        }