Ejemplo n.º 1
0
        private void TestInvariantGlobalization(BuildArgs buildArgs, bool?invariantGlobalization,
                                                RunHost host, string id, string extraProperties = "", bool?dotnetWasmFromRuntimePack = null)
        {
            string projectName = $"invariant_{invariantGlobalization?.ToString() ?? "unset"}";

            if (invariantGlobalization != null)
            {
                extraProperties = $"{extraProperties}<InvariantGlobalization>{invariantGlobalization}</InvariantGlobalization>";
            }

            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs, extraProperties);

            if (dotnetWasmFromRuntimePack == null)
            {
                dotnetWasmFromRuntimePack = !(buildArgs.AOT || buildArgs.Config == "Release");
            }

            string programText = @"
                using System;
                using System.Globalization;

                // https://github.com/dotnet/runtime/blob/main/docs/design/features/globalization-invariant-mode.md#cultures-and-culture-data
                try
                {
                    CultureInfo culture = new (""es-ES"", false);
                    Console.WriteLine($""es-ES: Is Invariant LCID: {culture.LCID == CultureInfo.InvariantCulture.LCID}, NativeName: {culture.NativeName}"");
                }
                catch (CultureNotFoundException cnfe)
                {
                    Console.WriteLine($""Could not create es-ES culture: {cnfe.Message}"");
                }

                Console.WriteLine($""CurrentCulture.NativeName: {CultureInfo.CurrentCulture.NativeName}"");
                return 42;
            ";

            BuildProject(buildArgs,
                         initProject: () => File.WriteAllText(Path.Combine(_projectDir !, "Program.cs"), programText),
                         id: id,
                         dotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack,
                         hasIcudt: invariantGlobalization == null || invariantGlobalization.Value == false);

            if (invariantGlobalization == true)
            {
                string output = RunAndTestWasmApp(buildArgs, expectedExitCode: 42, host: host, id: id);
                Assert.Contains("Could not create es-ES culture", output);
                Assert.Contains("CurrentCulture.NativeName: Invariant Language (Invariant Country)", output);
            }
            else
            {
                string output = RunAndTestWasmApp(buildArgs, expectedExitCode: 42, host: host, id: id);
                Assert.Contains("es-ES: Is Invariant LCID: False, NativeName: es (ES)", output);

                // ignoring the last line of the output which prints the current culture
            }
        }
    }
Ejemplo n.º 2
0
        public void ConsoleBuildAndRun(string config)
        {
            string id          = $"{config}_{Path.GetRandomFileName()}";
            string projectFile = CreateWasmTemplateProject(id, "wasmconsole");
            string projectName = Path.GetFileNameWithoutExtension(projectFile);

            updateProgramCS();

            var buildArgs = new BuildArgs(projectName, config, false, id, null);

            buildArgs = ExpandBuildArgs(buildArgs);

            BuildProject(buildArgs,
                         id: id,
                         new BuildProjectOptions(
                             DotnetWasmFromRuntimePack: true,
                             CreateProject: false,
                             HasV8Script: false,
                             MainJS: "main.mjs",
                             Publish: false,
                             TargetFramework: "net7.0"
                             ));

            AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: true);

            (int exitCode, string output) = RunProcess(s_buildEnv.DotNet, _testOutput, args: $"run --no-build -c {config} x y z", workingDir: _projectDir);
            Assert.Equal(0, exitCode);
            Assert.Contains("args[0] = x", output);
            Assert.Contains("args[1] = y", output);
            Assert.Contains("args[2] = z", output);
        }
Ejemplo n.º 3
0
        public Export(IProject project, IFuse fuse, BuildArgs args)
        {
            var output = new Subject <string>();

            LogMessages = output;

            var isMac = fuse.Platform == OS.Mac;

            ExportForAndroid = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                              Command.Enabled(
                                                                  action: () => fuse.RunFuse(
                                                                      "build",
                                                                      new[] { path.NativePath, "-t=android", "--run" }.Concat(allArgs).ToArray(),
                                                                      Observer.Create <string>(output.OnNext))))
                               .Switch();

            ExportForIos = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                          Command.Create(
                                                              isEnabled: isMac,
                                                              action: () => fuse.RunFuse(
                                                                  "build",
                                                                  new[] { path.NativePath, "-t=ios", "--run" }.Concat(allArgs).ToArray(),
                                                                  Observer.Create <string>(output.OnNext))))
                           .Switch();

            Menu = Menu.Item("Export for Android", ExportForAndroid)
                   + Menu.Item("Export for iOS" + (!isMac ? " (Mac only)" : ""), ExportForIos);
        }
Ejemplo n.º 4
0
        static void Build(BuildTarget target, bool isDebug = false)
        {
            BuildArgs args = new BuildArgs();

            args.target  = target;
            args.isDebug = isDebug;

            bool wait = false;
            var  type = System.Reflection.Assembly.GetExecutingAssembly().GetType("CKEditor." + "ClientMacro");

            if (type != null)
            {
                type.InvokeMember("SetPlatform", System.Reflection.BindingFlags.InvokeMethod |
                                  System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public, null, null, null);
            }

            if (EditorApplication.isCompiling)
            {
                var str = JsonUtility.ToJson(args);
                EditorPrefs.SetString("BuildParams", str);
                wait = true;
            }

            if (!wait)
            {
                AfterBuild(target, isDebug);
            }
        }
Ejemplo n.º 5
0
        private void InjectTableVariables(StringBuilder sql, BuildArgs buildArgs, bool skipTimestampColumn)
        {
            if (buildArgs.Executable == null)
            {
                Throw(QueryTalkExceptionType.NullExecutableInnerException, null, null);
            }

            foreach (var argument in (buildArgs.Executable.Arguments).Where(a => a.DT.IsTableVariable()))
            {
                var view = (View)argument.Value;

                sql.NewLine(Text.Declare).S()
                .Append(argument.ParamName)
                .Append(Text._As_)
                .Append(Text.Table).S()
                .NewLine(Text.LeftBracket);

                BeginTableChainer.BuildFromView(sql, view, skipTimestampColumn);

                sql.NewLine(Text.RightBracket)
                .Terminate();

                if (view.RowCount > 0)
                {
                    BeginTableChainer.Fill(sql, argument.ParamName, view);
                }
            }
        }
Ejemplo n.º 6
0
        public void GenerateCode()
        {
            buildArgs = new BuildArgs();

            // load target type
            var classType = BindingEditorUtility.GetClassByName(settings.className).FirstOrDefault();

            if (classType == null)
            {
                Debug.LogErrorFormat("Invalid class name {0}", settings.className);
                return;
            }

            // set target class
            buildArgs.type = classType;

            // get bindable properties
            var outputList = CodeTool.GetBindableProperties();

            if (outputList == null)
            {
                Debug.LogError("Get bindable properties failed.");
                return;
            }

            SetupBuildArgs(outputList);

            WriteCode();
        }
Ejemplo n.º 7
0
    private static BuildArgs ParseCommandArgs(string[] args)
    {
        BuildArgs buildArgs = new BuildArgs();

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i] == "-outputPath")
            {
                buildArgs.OutputPath = args[i + 1];
            }
            if (args[i] == "-revision")
            {
                buildArgs.Vision = args[i + 1];
            }
            if (args[i] == "-buildType")
            {
                buildArgs.BuildType = args[i + 1];
            }
            if (args[i] == "-FastBuild")
            {
                buildArgs.FastBuild = args[i + 1];
            }
        }

        return(buildArgs);
    }
Ejemplo n.º 8
0
        public PreviewOnDevice(IFuse fuse, IProject project, BuildArgs args)
        {
            var output = new Subject <string>();

            LogMessages = output;

            var isMac = fuse.Platform == OS.Mac;
            var startedAndroidPreview = new Subject <Unit>();

            MissingAndroidNotification.Create(fuse, startedAndroidPreview);

            PreviewAndroidApp = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                               Command.Enabled(
                                                                   action: () =>
            {
                startedAndroidPreview.OnNext(Unit.Default);
                fuse.RunFuse(
                    "preview",
                    new[] { path.NativePath, "-t=android", "--quit-after-apk-launch" }.Concat(allArgs).ToArray(),
                    Observer.Create <string>(output.OnNext));
            }))
                                .Switch();

            PreviewIosApp = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                           Command.Create(
                                                               isEnabled: isMac,
                                                               action: () => fuse.RunFuse(
                                                                   "preview",
                                                                   new[] { path.NativePath, "-t=ios" }.Concat(allArgs).ToArray(),
                                                                   Observer.Create <string>(output.OnNext))))
                            .Switch();

            Menu = Menu.Item("Preview on Android", PreviewAndroidApp)
                   + Menu.Item("Preview on iOS" + (!isMac ? " (Mac only)" : ""), PreviewIosApp);
        }
Ejemplo n.º 9
0
        public void NativeLibraryWithVariadicFunctions(BuildArgs buildArgs, RunHost host, string id)
        {
            string code = @"
                using System;
                using System.Runtime.InteropServices;
                public class Test
                {
                    public static int Main(string[] args)
                    {
                        Console.WriteLine($""Main running"");
                        if (args.Length > 0)
                        {
                            // We don't want to run this, because we can't call variadic functions
                            Console.WriteLine($""sum_three: {sum_three(7, 14, 21)}"");
                            Console.WriteLine($""sum_two: {sum_two(3, 6)}"");
                            Console.WriteLine($""sum_one: {sum_one(5)}"");
                        }
                        return 42;
                    }

                    [DllImport(""variadic"", EntryPoint=""sum"")] public static extern int sum_one(int a);
                    [DllImport(""variadic"", EntryPoint=""sum"")] public static extern int sum_two(int a, int b);
                    [DllImport(""variadic"", EntryPoint=""sum"")] public static extern int sum_three(int a, int b, int c);
                }";

            (buildArgs, string output) = BuildForVariadicFunctionTests(code,
                                                                       buildArgs with {
                ProjectName = $"variadic_{buildArgs.Config}_{id}"
            },
Ejemplo n.º 10
0
        public void ProjectWithNativeReference(BuildArgs buildArgs, RunHost host, string id)
        {
            string projectName = $"AppUsingNativeLib-a";

            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs, extraItems: "<NativeFileReference Include=\"native-lib.o\" />");

            if (!_buildContext.TryGetBuildFor(buildArgs, out BuildProduct? _))
            {
                InitPaths(id);
                if (Directory.Exists(_projectDir))
                {
                    Directory.Delete(_projectDir, recursive: true);
                }

                Utils.DirectoryCopy(Path.Combine(BuildEnvironment.TestAssetsPath, "AppUsingNativeLib"), _projectDir);
                File.Copy(Path.Combine(BuildEnvironment.TestAssetsPath, "native-libs", "native-lib.o"), Path.Combine(_projectDir, "native-lib.o"));
            }

            BuildProject(buildArgs,
                         id: id,
                         new BuildProjectOptions(DotnetWasmFromRuntimePack: false));

            string output = RunAndTestWasmApp(buildArgs, buildDir: _projectDir, expectedExitCode: 0,
                                              test: output => {},
                                              host: host, id: id);

            Assert.Contains("print_line: 100", output);
            Assert.Contains("from pinvoke: 142", output);
        }
Ejemplo n.º 11
0
        public void CheckThatSatelliteAssembliesAreNotAOTed(BuildArgs buildArgs, string id)
        {
            string projectName = $"check_sat_asm_not_aot";

            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs,
                                        projectTemplate: s_resourcesProjectTemplate,
                                        extraProperties: $@"
                                            <EmccCompileOptimizationFlag>-O0</EmccCompileOptimizationFlag>
                                            <EmccLinkOptimizationFlag>-O0</EmccLinkOptimizationFlag>",
                                        extraItems: $"<EmbeddedResource Include=\"{BuildEnvironment.RelativeTestAssetsPath}resx\\*\" />");

            BuildProject(buildArgs,
                         id: id,
                         new BuildProjectOptions(
                             InitProject: () => CreateProgramForCultureTest(_projectDir !, $"{projectName}.words", "TestClass"),
                             DotnetWasmFromRuntimePack: false));

            var bitCodeFileNames = Directory.GetFileSystemEntries(Path.Combine(_projectDir !, "obj"), "*.dll.bc", SearchOption.AllDirectories)
                                   .Select(path => Path.GetFileName(path))
                                   .ToArray();

            // sanity check, in case we change file extensions
            Assert.Contains($"{projectName}.dll.bc", bitCodeFileNames);

            Assert.Empty(bitCodeFileNames.Where(file => file.EndsWith(".resources.dll.bc")));
        }
Ejemplo n.º 12
0
    static public void buildAfterTagetSwitch(BuildArgs args)
    {
        Debug.Log("buildAfterTagetSwitch");
        buildOption = BuildOptions.None;
        //PlayerSettings.bundleIdentifier = args._bundleId;
        //PlayerSettings.bundleVersion = args._applicationVer;
        //PlayerSettings.shortBundleVersion = args._shortBundleVersion;

        EditorUserBuildSettings.development = args._isDevMode;
        if (args._isDevMode)
        {
            buildOption |= BuildOptions.Development;
        }
        Debug.Log("BuildAssetBundles");
        //AssetBundleBuildPanel.BuildAssetBundles();

        if (args._buildTarget == UnityEditor.BuildTarget.Android)
        {
            Publish.BuildAPK(false, false, false, args._package_filename + ".apk");
        }
        else if (args._buildTarget == UnityEditor.BuildTarget.iOS)
        {
            BuildForIPhone();
        }
    }
        public void ResourcesFromProjectReference(BuildArgs buildArgs,
                                                  bool nativeRelink,
                                                  string?argCulture,
                                                  string expectedOutput,
                                                  RunHost host,
                                                  string id)
        {
            string projectName = $"sat_asm_proj_ref";
            bool   dotnetWasmFromRuntimePack = !nativeRelink && !buildArgs.AOT;

            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs,
                                        projectTemplate: s_resourcesProjectTemplate,
                                        extraProperties: $"<WasmBuildNative>{(nativeRelink ? "true" : "false")}</WasmBuildNative>",
                                        extraItems: $"<ProjectReference Include=\"..\\LibraryWithResources\\LibraryWithResources.csproj\" />");

            BuildProject(buildArgs,
                         initProject: () => CreateProgramForCultureTest("LibraryWithResources.words", "LibraryWithResources.Class1"),
                         dotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack,
                         id: id);

            string output = RunAndTestWasmApp(buildArgs,
                                              expectedExitCode: 42,
                                              args: argCulture,
                                              host: host, id: id);

            Assert.Contains(expectedOutput, output);
        }
Ejemplo n.º 14
0
 public void GetArgumentList()
 {
     for (var i = 0; i < _argStrings.Length; ++i)
     {
         CollectionAssert.AreEqual(_argLists[i], BuildArgs.GetArgumentList(_argStrings[i]));
     }
 }
Ejemplo n.º 15
0
        protected void TestMain(string projectName,
                                string programText,
                                BuildArgs buildArgs,
                                RunHost host,
                                string id,
                                string extraProperties         = "",
                                bool?dotnetWasmFromRuntimePack = null)
        {
            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs, extraProperties);

            if (dotnetWasmFromRuntimePack == null)
            {
                dotnetWasmFromRuntimePack = !(buildArgs.AOT || buildArgs.Config == "Release");
            }

            BuildProject(buildArgs,
                         id: id,
                         new BuildProjectOptions(
                             InitProject: () => File.WriteAllText(Path.Combine(_projectDir !, "Program.cs"), programText),
                             DotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack));

            RunAndTestWasmApp(buildArgs, expectedExitCode: 42,
                              test: output => Assert.Contains("Hello, World!", output), host: host, id: id);
        }
    }
        public void ResourcesFromMainAssembly(BuildArgs buildArgs,
                                              bool nativeRelink,
                                              string?argCulture,
                                              string expectedOutput,
                                              RunHost host,
                                              string id)
        {
            string projectName = $"sat_asm_from_main_asm";
            bool   dotnetWasmFromRuntimePack = !nativeRelink && !buildArgs.AOT;

            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs,
                                        projectTemplate: s_resourcesProjectTemplate,
                                        extraProperties: $"<WasmBuildNative>{(nativeRelink ? "true" : "false")}</WasmBuildNative>",
                                        extraItems: $"<EmbeddedResource Include=\"..\\resx\\*\" />");

            BuildProject(buildArgs,
                         initProject: () => CreateProgramForCultureTest($"{projectName}.words", "TestClass"),
                         dotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack,
                         id: id);

            string output = RunAndTestWasmApp(
                buildArgs, expectedExitCode: 42,
                args: argCulture,
                host: host, id: id);

            Assert.Contains(expectedOutput, output);
        }
Ejemplo n.º 17
0
    static public void buildFromArgs(BuildArgs args)
    {
        Debug.Log("buildFromArgs");

        if (args._buildTarget == EditorUserBuildSettings.activeBuildTarget)
        {
            buildAfterTagetSwitch(args);
        }
        else
        {
#if UNITY_2017_1_OR_NEWER
            _isCanBuildAfterChangeBuildTarget = true;
            _args = args;
#else
            EditorUserBuildSettings.activeBuildTargetChanged = delegate()
            {
                buildAfterTagetSwitch(args);
            };
#endif
            if (args._buildTarget == BuildTarget.Android)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, args._buildTarget);
            }
            else if (args._buildTarget == BuildTarget.iOS)
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, args._buildTarget);
            }
        }
    }
Ejemplo n.º 18
0
        public void PropertiesFromCsproj(BuildArgs buildArgs, RunHost host, string id)
        {
            buildArgs = buildArgs with {
                ProjectName = $"runtime_config_csproj_{buildArgs.Config}_{buildArgs.AOT}"
            };
            buildArgs = ExpandBuildArgs(buildArgs, extraProperties: "<ThreadPoolMaxThreads>20</ThreadPoolMaxThreads>");

            string programText = @"
                using System;
                using System.Runtime.CompilerServices;

                var config = AppContext.GetData(""System.Threading.ThreadPool.MaxThreads"");
                Console.WriteLine ($""System.Threading.ThreadPool.MaxThreads: {(string)config}"");
                return 42;
            ";

            BuildProject(buildArgs,
                         id: id,
                         new BuildProjectOptions(
                             InitProject: () =>
            {
                File.WriteAllText(Path.Combine(_projectDir !, "Program.cs"), programText);
            },
                             DotnetWasmFromRuntimePack: !(buildArgs.AOT || buildArgs.Config == "Release")));

            RunAndTestWasmApp(buildArgs, expectedExitCode: 42,
                              test: output => Assert.Contains("System.Threading.ThreadPool.MaxThreads: 20", output), host: host, id: id);
        }
    }
Ejemplo n.º 19
0
        protected string Rebuild(bool nativeRelink, bool invariant, BuildArgs buildArgs, string id, string extraProperties = "", string extraBuildArgs = "", string?verbosity = null)
        {
            if (!_buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product))
            {
                throw new XunitException($"Test bug: could not get the build product in the cache");
            }

            File.Move(product !.LogFile, Path.ChangeExtension(product.LogFile !, ".first.binlog"));

            buildArgs = buildArgs with {
                ExtraBuildArgs = $"{buildArgs.ExtraBuildArgs} {extraBuildArgs}"
            };
            var newBuildArgs = GenerateProjectContents(buildArgs, nativeRelink, invariant, extraProperties);

            // key(buildArgs) being changed
            _buildContext.RemoveFromCache(product.ProjectDir);
            _buildContext.CacheBuild(newBuildArgs, product);

            if (buildArgs.ProjectFileContents != newBuildArgs.ProjectFileContents)
            {
                File.WriteAllText(Path.Combine(_projectDir !, $"{buildArgs.ProjectName}.csproj"), buildArgs.ProjectFileContents);
            }
            buildArgs = newBuildArgs;

            _testOutput.WriteLine($"{Environment.NewLine}Rebuilding with no changes ..{Environment.NewLine}");
            (_, string output) = BuildProject(buildArgs,
                                              id: id,
                                              dotnetWasmFromRuntimePack: false,
                                              hasIcudt: !invariant,
                                              createProject: false,
                                              useCache: false,
                                              verbosity: verbosity);

            return(output);
        }
Ejemplo n.º 20
0
        public void ResourcesFromMainAssembly(BuildArgs buildArgs,
                                              bool nativeRelink,
                                              string?argCulture,
                                              string expectedOutput,
                                              RunHost host,
                                              string id)
        {
            string projectName = $"sat_asm_from_main_asm";
            // Release+publish defaults to native relinking
            bool dotnetWasmFromRuntimePack = !nativeRelink && !buildArgs.AOT && buildArgs.Config != "Release";

            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs,
                                        projectTemplate: s_resourcesProjectTemplate,
                                        extraProperties: nativeRelink ? $"<WasmBuildNative>true</WasmBuildNative>" : string.Empty);

            BuildProject(buildArgs,
                         id: id,
                         new BuildProjectOptions(
                             InitProject: () =>
            {
                Utils.DirectoryCopy(Path.Combine(BuildEnvironment.TestAssetsPath, "resx"), Path.Combine(_projectDir !, "resx"));
                CreateProgramForCultureTest(_projectDir !, $"{projectName}.resx.words", "TestClass");
            },
                             DotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack));

            string output = RunAndTestWasmApp(
                buildArgs, expectedExitCode: 42,
                args: argCulture,
                host: host, id: id);

            Assert.Contains(expectedOutput, output);
        }
Ejemplo n.º 21
0
        public void PropertiesFromRuntimeConfigJson(BuildArgs buildArgs, RunHost host, string id)
        {
            buildArgs = buildArgs with {
                ProjectName = $"runtime_config_{buildArgs.Config}_{buildArgs.AOT}"
            };
            buildArgs = ExpandBuildArgs(buildArgs);

            string programText = @"
                using System;
                using System.Runtime.CompilerServices;

                var config = AppContext.GetData(""test_runtimeconfig_json"");
                Console.WriteLine ($""test_runtimeconfig_json: {(string)config}"");
                return 42;
            ";

            string runtimeConfigTemplateJson = @"
            {
                ""configProperties"": {
                  ""abc"": ""4"",
                  ""test_runtimeconfig_json"": ""25""
                }
            }";

            BuildProject(buildArgs,
                         initProject: () =>
            {
                File.WriteAllText(Path.Combine(_projectDir !, "Program.cs"), programText);
                File.WriteAllText(Path.Combine(_projectDir !, "runtimeconfig.template.json"), runtimeConfigTemplateJson);
            },
Ejemplo n.º 22
0
    static public void buildAfterTagetSwitch(BuildArgs args)
    {
        Debug.Log("buildAfterTagetSwitch");

        PlayerSettings.applicationIdentifier = args._bundleId;
        PlayerSettings.bundleVersion         = args._applicationVer;
        //PlayerSettings.shortBundleVersion = args._shortBundleVersion;


        if (args._buildTarget == UnityEditor.BuildTarget.Android)
        {
            EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
            {
                //buildAB

                Publish.BuildAPK(false, true, false, args._package_filename + ".apk");
            }
        }
        else if (args._buildTarget == UnityEditor.BuildTarget.iOS)
        {
            EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS);
            //ExportAssetBundles.Publish_Dev_OnKeyAB(BuildTarget.iOS, false);
            BuildForIPhone();
        }
    }
Ejemplo n.º 23
0
        public void IntermediateBitcodeToObjectFilesAreNotLLVMIR(BuildArgs buildArgs, string id)
        {
            string printFileTypeTarget = @"
                <Target Name=""PrintIntermediateFileType"" AfterTargets=""WasmNestedPublishApp"">
                    <Exec Command=""wasm-dis $(_WasmIntermediateOutputPath)System.Private.CoreLib.dll.o -o $(_WasmIntermediateOutputPath)wasm-dis-out.txt""
                          EnvironmentVariables=""@(EmscriptenEnvVars)""
                          IgnoreExitCode=""true"">

                        <Output TaskParameter=""ExitCode"" PropertyName=""ExitCode"" />
                    </Exec>

                    <Message Text=""
                    ** wasm-dis exit code: $(ExitCode)
                    "" Importance=""High"" />
                </Target>
                ";
            string projectName         = $"bc_to_o_{buildArgs.Config}";

            buildArgs = buildArgs with {
                ProjectName = projectName
            };
            buildArgs = ExpandBuildArgs(buildArgs, insertAtEnd: printFileTypeTarget);

            (_, string output) = BuildProject(buildArgs,
                                              id: id,
                                              new BuildProjectOptions(
                                                  InitProject: () => File.WriteAllText(Path.Combine(_projectDir !, "Program.cs"), s_mainReturns42),
                                                  DotnetWasmFromRuntimePack: false));

            if (!output.Contains("** wasm-dis exit code: 0"))
            {
                throw new XunitException($"Expected to successfully run wasm-dis on System.Private.CoreLib.dll.o ."
                                         + " It might fail if it was incorrectly compiled to a bitcode file, instead of wasm.");
            }
        }
Ejemplo n.º 24
0
    static void commandLineBuild()
    {
        BuildArgs ba = parseCommandLine();

        buildFromArgs(ba);
        EditorApplication.Exit(0);
    }
Ejemplo n.º 25
0
        public static void PullFromDevon()
        {
            Console.WriteLine("DevonCommandLine PullFromDevon");

            var buildArgs = new BuildArgs("Devon", 0, 0);

            if (buildArgs.CmdLineArgs.ContainsKey("devonOAuth"))
            {
                bool done = false;

                DevonAPI.PullFromDevon(Game.ForceVision.ToString(), buildArgs.CmdLineArgs["devonOAuth"].ToString(), (result) =>
                {
                    Console.WriteLine("Pull Result: " + result);
                    done = true;
                });

                // need to wait for async operation above to finish because when run from command line Unity will exit after this command.
                while (!done)
                {
                    System.Threading.Thread.Sleep(10);
                    UnityEditor.EditorApplication.update();
                }
            }
            else
            {
                Console.WriteLine("Error: devonOAuth must be specified");
                throw new Exception("DevonCommandLine failure: -devonOAuth=<auth> must be specified");
            }
        }
Ejemplo n.º 26
0
        public void ConsolePublishAndRun(string config, bool aot)
        {
            string id          = $"{config}_{Path.GetRandomFileName()}";
            string projectFile = CreateWasmTemplateProject(id, "wasmconsole");
            string projectName = Path.GetFileNameWithoutExtension(projectFile);

            string programText = "" "
            using System;

            for (int i = 0; i < args.Length; i ++)
                Console.WriteLine ($" args[{ i }] = { args[i] } ");
            " "";

            File.WriteAllText(Path.Combine(_projectDir !, "Program.cs"), programText);
            if (aot)
            {
                AddItemsPropertiesToProject(projectFile, "<RunAOTCompilation>true</RunAOTCompilation>");
            }

            var buildArgs = new BuildArgs(projectName, config, aot, id, null);

            buildArgs = ExpandBuildArgs(buildArgs);

            bool expectRelinking = config == "Release" || aot;

            BuildProject(buildArgs,
                         id: id,
                         new BuildProjectOptions(
                             DotnetWasmFromRuntimePack: !expectRelinking,
                             CreateProject: false,
                             HasV8Script: false,
                             MainJS: "main.mjs",
                             Publish: true,
                             TargetFramework: "net7.0",
                             UseCache: false));

            AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !expectRelinking);

            // FIXME: pass envvars via the environment, once that is supported
            string runArgs = $"run --no-build -c {config}";

            if (aot)
            {
                runArgs += $" --setenv=MONO_LOG_MASK=aot --setenv=MONO_LOG_LEVEL=debug";
            }
            runArgs += " x y z";
            var res = new RunCommand(s_buildEnv, _testOutput, label: id)
                      .WithWorkingDirectory(_projectDir !)
                      .ExecuteWithCapturedOutput(runArgs)
                      .EnsureSuccessful();

            if (aot)
            {
                Assert.Contains($"AOT: image '{Path.GetFileNameWithoutExtension(projectFile)}' found", res.Output);
            }
            Assert.Contains("args[0] = x", res.Output);
            Assert.Contains("args[1] = y", res.Output);
            Assert.Contains("args[2] = z", res.Output);
        }
Ejemplo n.º 27
0
 public void ArgumentRoundTrip1()
 {
     foreach (var argList in _argLists)
     {
         var argString = BuildArgs.GetArgumentString(argList);
         CollectionAssert.AreEqual(argList, BuildArgs.GetArgumentList(argString));
     }
 }
Ejemplo n.º 28
0
        protected string RunAndTestWasmApp(BuildArgs buildArgs,
                                           RunHost host,
                                           string id,
                                           Action <string>?test = null,
                                           string?buildDir      = null,
                                           int expectedExitCode = 0,
                                           string?args          = null,
                                           Dictionary <string, string>?envVars = null)
        {
            buildDir ??= _projectDir;
            envVars ??= new();
            envVars["XHARNESS_DISABLE_COLORED_OUTPUT"] = "true";
            if (buildArgs.AOT)
            {
                envVars["EMSDK_PATH"]     = s_emsdkPath;
                envVars["MONO_LOG_LEVEL"] = "debug";
                envVars["MONO_LOG_MASK"]  = "aot";
            }

            string bundleDir = Path.Combine(GetBinDir(baseDir: buildDir, config: buildArgs.Config), "AppBundle");

            (string testCommand, string extraXHarnessArgs) = host switch
            {
                RunHost.V8 => ("wasm test", "--js-file=runtime.js --engine=V8 -v trace"),
                _ => ("wasm test-browser", $"-v trace -b {host}")
            };

            string testLogPath = Path.Combine(_logPath, host.ToString());
            string output      = RunWithXHarness(
                testCommand,
                testLogPath,
                buildArgs.ProjectName,
                bundleDir,
                _testOutput,
                envVars: envVars,
                expectedAppExitCode: expectedExitCode,
                extraXHarnessArgs: extraXHarnessArgs,
                appArgs: args);

            if (buildArgs.AOT)
            {
                Assert.Contains("AOT: image 'System.Private.CoreLib' found.", output);
                Assert.Contains($"AOT: image '{buildArgs.ProjectName}' found.", output);
            }
            else
            {
                Assert.DoesNotContain("AOT: image 'System.Private.CoreLib' found.", output);
                Assert.DoesNotContain($"AOT: image '{buildArgs.ProjectName}' found.", output);
            }

            if (test != null)
            {
                test(output);
            }

            return(output);
        }
Ejemplo n.º 29
0
        static void OnGloabalBuild(BuildArgs args)
        {
            var handler = GloabalBuild;

            if (handler != null)
            {
                handler(null, args);
            }
        }
Ejemplo n.º 30
0
        protected virtual void OnDobuilding(BuildArgs args)
        {
            var handler = Dobuilding;

            if (handler != null)
            {
                handler(this, args);
            }
        }
        /// <summary>
        /// Handles the Selecting event of the tabControl1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.TabControlCancelEventArgs"/> instance containing the event data.</param>
        private void TabControl1_Selecting(object sender, TabControlCancelEventArgs e)
        {
            using(AdvancedMessageBox advbox = new AdvancedMessageBox("Are you sure you want to cancel current operation?", ReportStatus.Information, true))
            {
                if (DialogResult.OK == advbox.ShowDialog())
                {
                    this.ResetTreeViewNodes(this.tvCheckList.Nodes["10"]);
                    this.ResetTreeViewNodes(this.tvCheckList.Nodes["20"]);
                    this.progressBar.Value = this.progressBar.Minimum;
                    this.btnViewBuildLog.Enabled = this.btnViewDeployLog.Enabled = this.btnViewTFLog.Enabled = false;
                    this.toolStripStatusLabel.Text = string.Empty;
                    this.rollbackVersionToLog = string.Empty;
                    this.pkgNameForLocalDeployment = string.Empty;
                    this.buildArgs = null;

                    switch (e.TabPageIndex)
                    {
                        case 0:
                            this.txtConfigPath.Text = this.txtPackagePath.Text = string.Empty;
                            break;
                        case 1:
                            this.cbxServerName.SelectedIndex = -1;
                            txtTFSLabelName.Text = txtTFSDefaultCollection.Text = txtSolutionName.Text = string.Empty;
                            btnLoadSolutions.Enabled = false;
                            this.btnLoadTFSlabel.Enabled = false;
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    e.Cancel = true;
                }
            }
            this.BringToFront();
        }
        /// <summary>
        /// Handles the Click event of the btnDeploy control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnDeploy_Click(object sender, EventArgs e)
        {
            try
            {
                bool isLocalDeployment = this.tabControl1.SelectedTab.Name.Equals("tabLocalDeployment");

                this.Text = this.Text.Contains(this.txtSolutionName.Text) ? this.Text : string.Concat(this.Text, "-[", this.txtSolutionName.Text, "]");
                this.progressBar.Maximum = this.progressBar.Step * this.totalStepsIdentified;  // number of task
                this.btnViewBuildLog.Enabled = this.btnViewDeployLog.Enabled = this.btnViewTFLog.Enabled = false;

                if (!isLocalDeployment)
                {
                    this.buildArgs = this.PrepareBuildArgs();
                    this.buildArgs.Validate();

                    //replace with new name
                    this.buildArgs.ModifiedSolutionName = string.Concat(this.buildArgs.SolutionName, "-", this.buildArgs.Version);
                }
                else
                {
                    if (string.IsNullOrEmpty(this.txtPackagePath.Text) || !File.Exists(this.txtPackagePath.Text))
                    {
                        throw new ArgumentException("Invalid package file path", "Package Path");
                    }

                    if (string.IsNullOrEmpty(this.txtConfigPath.Text) || !File.Exists(this.txtConfigPath.Text))
                    {
                        throw new ArgumentException("Invalid configuration file path", "Config Path");
                    }

                    // save this in form variable to avoid STA
                    this.pkgNameForLocalDeployment = Path.GetFileNameWithoutExtension(this.txtPackagePath.Text);
                }

                this.cloudArgs = this.PrepareCloudArgs();

                // validate the publish setting path and subscriptions combo
                if (string.IsNullOrEmpty(this.txtPublishSettingsFilePath.Text) || !File.Exists(this.txtPublishSettingsFilePath.Text))
                {
                    throw new ArgumentException("Invalid publish settings file path", "Publish Settings File");
                }

                if (this.cbxSubscriptions.SelectedIndex == -1)
                {
                    throw new ArgumentException("Atleast one subscriptions should be selected", "Subscriptions");
                }

                this.cloudArgs.Validate();

                this.ResetTreeViewNodes(this.tvCheckList.Nodes["10"]);
                this.ResetTreeViewNodes(this.tvCheckList.Nodes["20"]);
                this.progressBar.Value = this.progressBar.Minimum;

                if (!this.backgroundWorker.IsBusy)
                {
                    this.SetUserActionOnFrom(false);
                    this.backgroundWorker.RunWorkerAsync(isLocalDeployment);
                }
            }
            catch (ArgumentNullException argEx)
            {
                argEx.ShowUIException();
            }
            catch (ArgumentException argEx)
            {
                argEx.ShowUIException();
            }
        }
 protected virtual void OnDobuilding(BuildArgs args)
 {
     var handler = Dobuilding;
     if(handler != null)
     {
         handler(this, args);
     }
 }
 static void OnGloabalBuild(BuildArgs args)
 {
     var handler = GloabalBuild;
     if(handler != null)
     {
         handler(null, args);
     }
 }
 void BobDobuilding(object sender, BuildArgs args)
 {
     _i++;
 }