Exemplo n.º 1
0
    private static bool ProcessGradleProject()
    {
        DateTime syncStartTime = System.DateTime.Now;
        DateTime syncEndTime   = System.DateTime.MinValue;

        try
        {
            var ps = System.Text.RegularExpressions.Regex.Escape("" + Path.DirectorySeparatorChar);
            // ignore files .gradle/** build/** foo/.gradle/** and bar/build/**
            var ignorePattern = string.Format("^([^{0}]+{0})?(\\.gradle|build){0}", ps);

            var syncer = new DirectorySyncer(gradleTempExport,
                                             gradleExport, ignorePattern);

            syncCancelToken = new DirectorySyncer.CancellationTokenSource();
            var syncResult = syncer.Synchronize(syncCancelToken.Token);
            syncEndTime = System.DateTime.Now;
        }
        catch (Exception e)
        {
            UnityEngine.Debug.Log("OVRBuild: Processing gradle project failed with exception: " +
                                  e.Message);
            return(false);
        }

        if (syncCancelToken.IsCancellationRequested)
        {
            return(false);
        }

        return(true);
    }
Exemplo n.º 2
0
    public void StartBuild()
    {
        showCancel      = false;
        buildInProgress = true;

        InitializeProgressBar(NUM_BUILD_AND_RUN_STEPS);
        IncrementProgressBar("Exporting Unity Project . . .");

        apkOutputSuccessful = null;
        syncCancelToken     = null;
        gradleBuildProcess  = null;

        UnityEngine.Debug.Log("OVRBuild: Starting Unity build ...");

        SetupDirectories();

        // 1. Get scenes to build in Unity, and export gradle project
        var buildResult = UnityBuildPlayer();

        if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
        {
            // Set static variables so build thread has updated data
            showCancel            = true;
            gradlePath            = OVRConfig.Instance.GetGradlePath();
            jdkPath               = OVRConfig.Instance.GetJDKPath();
            androidSdkPath        = OVRConfig.Instance.GetAndroidSDKPath();
            applicationIdentifier = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
            isDevelopmentBuild    = EditorUserBuildSettings.development;
#if UNITY_2019_3_OR_NEWER
            productName = "launcher";
#else
            productName = Application.productName;
#endif
            dataPath = Application.dataPath;

            buildThread = new Thread(delegate()
            {
                OVRBuildRun();
            });
            buildThread.Start();
            return;
        }
        else if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Cancelled)
        {
            UnityEngine.Debug.Log("Build cancelled.");
        }
        else
        {
            UnityEngine.Debug.Log("Build failed.");
        }
        OnBuildComplete();
    }
Exemplo n.º 3
0
    private static bool ProcessGradleProject()
    {
        DateTime syncStartTime = System.DateTime.Now;
        DateTime syncEndTime   = System.DateTime.MinValue;

        try
        {
            var ps = System.Text.RegularExpressions.Regex.Escape("" + Path.DirectorySeparatorChar);
            // ignore files .gradle/** build/** foo/.gradle/** and bar/build/**
            var ignorePattern = string.Format("^([^{0}]+{0})?(\\.gradle|build){0}", ps);

            var syncer = new DirectorySyncer(gradleTempExport,
                                             gradleExport, ignorePattern);

            syncCancelToken = new DirectorySyncer.CancellationTokenSource();
            var syncResult = syncer.Synchronize(syncCancelToken.Token);
            syncEndTime = System.DateTime.Now;
        }
        catch (Exception e)
        {
            UnityEngine.Debug.Log("OVRBuild: Processing gradle project failed with exception: " +
                                  e.Message);
            return(false);
        }

        if (syncCancelToken.IsCancellationRequested)
        {
            return(false);
        }

        // Record time it takes to sync gradle projects only if the sync was successful
        double syncTime = (syncEndTime - syncStartTime).TotalSeconds;

        if (syncTime > 0)
        {
            OVRPlugin.SendEvent("build_step_sync_gradle_project", syncTime.ToString(), "ovrbuild");
            totalBuildTime += syncTime;
        }

        return(true);
    }
Exemplo n.º 4
0
    static void StartBuildAndRun()
    {
        EditorWindow.GetWindow(typeof(OculusBuildApp));

        showCancel     = false;
        buildFailed    = false;
        totalBuildTime = 0;

        InitializeProgressBar(NUM_BUILD_AND_RUN_STEPS);
        IncrementProgressBar("Exporting Unity Project . . .");

        OVRPlugin.SetDeveloperMode(OVRPlugin.Bool.True);
        OVRPlugin.AddCustomMetadata("build_type", "ovr_build_and_run");

        if (!CheckADBDevices())
        {
            buildFailed = true;
            return;
        }

        // Record OVR Build and Run start event
        OVRPlugin.SendEvent("ovr_build_and_run_start", "", "ovrbuild");

        apkOutputSuccessful = null;
        syncCancelToken     = null;
        gradleBuildProcess  = null;

        UnityEngine.Debug.Log("OVRBuild: Starting Unity build ...");

        SetupDirectories();

        // 1. Get scenes to build in Unity, and export gradle project
        var buildResult = UnityBuildPlayer();

        if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
        {
            foreach (var step in buildResult.steps)
            {
                // Only log top level build steps & specific nested steps to reduce the number of events sent
                if (step.depth == 1 ||
                    (step.name.StartsWith("Packaging assets") && step.name.EndsWith(".assets")) ||
                    step.name.Equals("Managed Stripping: (Mono)") ||
                    step.name.Equals("Splitting assets") ||
                    step.name.Equals("IL2CPP") ||
                    step.name.Equals("Exporting project")
                    )
                {
                    OVRPlugin.SendEvent($"build_step_unity_build_player {step.name}", step.duration.TotalSeconds.ToString(), "ovrbuild");
                }
            }

            OVRPlugin.SendEvent("build_step_unity_export", buildResult.summary.totalTime.TotalSeconds.ToString(), "ovrbuild");
            totalBuildTime += buildResult.summary.totalTime.TotalSeconds;

            // Set static variables so build thread has updated data
            showCancel            = true;
            gradlePath            = OVRConfig.Instance.GetGradlePath();
            jdkPath               = OVRConfig.Instance.GetJDKPath();
            androidSdkPath        = OVRConfig.Instance.GetAndroidSDKPath();
            applicationIdentifier = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
#if UNITY_2019_3_OR_NEWER
            productName = "launcher";
#else
            productName = Application.productName;
#endif
            dataPath = Application.dataPath;

            buildThread = new Thread(delegate()
            {
                OVRBuildRun();
            });
            buildThread.Start();
            return;
        }
        else if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Cancelled)
        {
            UnityEngine.Debug.Log("Build cancelled.");
        }
        else
        {
            UnityEngine.Debug.Log("Build failed.");
        }
        buildFailed = true;
    }
Exemplo n.º 5
0
    static void StartBuildAndRun()
    {
        EditorWindow.GetWindow(typeof(OculusBuildApp));

        showCancel     = false;
        buildFailed    = false;
        totalBuildTime = 0;

        InitializeProgressBar(NUM_BUILD_AND_RUN_STEPS);
        IncrementProgressBar("Exporting Unity Project . . .");

        OVRPlugin.SetDeveloperMode(OVRPlugin.Bool.True);
        OVRPlugin.AddCustomMetadata("build_type", "ovr_build_and_run");

        if (!CheckADBDevices())
        {
            return;
        }

        // Record OVR Build and Run start event
        OVRPlugin.SendEvent("ovr_build_and_run_start", "", "ovrbuild");

        apkOutputSuccessful = null;
        syncCancelToken     = null;
        gradleBuildProcess  = null;

        UnityEngine.Debug.Log("OVRBuild: Starting Unity build ...");

        SetupDirectories();

        // 1. Get scenes to build in Unity, and export gradle project
        List <string> sceneList        = GetScenesToBuild();
        DateTime      unityExportStart = DateTime.Now;
        var           buildResult      = BuildPipeline.BuildPlayer(sceneList.ToArray(), gradleTempExport, BuildTarget.Android,
                                                                   BuildOptions.AcceptExternalModificationsToPlayer |
                                                                   BuildOptions.Development |
                                                                   BuildOptions.AllowDebugging);

        if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
        {
            double unityExportTime = (DateTime.Now - unityExportStart).TotalSeconds;
            OVRPlugin.SendEvent("build_step_unity_export", unityExportTime.ToString(), "ovrbuild");
            totalBuildTime += unityExportTime;

            // Set static variables so build thread has updated data
            showCancel            = true;
            gradlePath            = OVRConfig.Instance.GetGradlePath();
            jdkPath               = OVRConfig.Instance.GetJDKPath();
            androidSdkPath        = OVRConfig.Instance.GetAndroidSDKPath();
            applicationIdentifier = PlayerSettings.applicationIdentifier;
            productName           = Application.productName;
            dataPath              = Application.dataPath;

            buildThread = new Thread(delegate()
            {
                OVRBuildRun();
            });
            buildThread.Start();
            return;
        }
        else if (buildResult.summary.result == UnityEditor.Build.Reporting.BuildResult.Cancelled)
        {
            UnityEngine.Debug.Log("Build cancelled.");
        }
        else
        {
            UnityEngine.Debug.Log("Build failed.");
        }
        buildFailed = true;
    }