示例#1
0
    public static void DoSDKMigration()
    {
        Debug.Log(MigrationBegin);

        if (DoesExist(RedundantDir))
        {
            OS.RmDir(RedundantDir);
        }
        if (DoesExist(RedundantLib))
        {
            OS.Rm(RedundantLib);
            var redundantJarDir         = RedundantLib.Remove(RedundantLib.LastIndexOf("/", StringComparison.Ordinal)) + "/";
            var redundantJarDirContents = OS.GetFileSystemEntries(redundantJarDir);
            if (!redundantJarDirContents.Any())
            {
                OS.RmDir(redundantJarDir);
            }
        }

        foreach (var jar in RedundantJars.Where(DoesExist))
        {
            OS.Rm(jar);
        }

        var allSucceeded = true;

        foreach (var entry in LocationMapping)
        {
            var source = Path.Combine("Assets", entry.Key);
            var dest   = Path.Combine("Assets", entry.Value);
            if (!DoesExist(source))
            {
                continue;
            }
            allSucceeded &= OS.Mv(source, dest);
        }

        var showNote      = false;
        var migrationNote = new StringBuilder(ManualMigrationNote);

        foreach (var entry in ManualMapping)
        {
            if (DoesExist(Path.Combine("Assets", entry.Key)))
            {
                showNote = true;
                migrationNote.AppendFormat("'{0}' to '{1}'\n", entry.Key, entry.Value);
            }
        }
        if (showNote)
        {
            Debug.LogWarning(migrationNote);
        }

        if (!allSucceeded)
        {
            Debug.LogWarning(ManualFollowUpWarning);
        }
        AssetDatabase.Refresh();
        Debug.Log(MigrationEnd);
    }
    // Build the platform MoPub SDK using its native build system.
    private static bool BuildPlatformSdk(BuildTarget buildTarget, bool internalSdkBuild, bool debug)
    {
        Debug.LogFormat("Building MoPub platform SDK for {0} (internal: {1}, debug: {2})", buildTarget, internalSdkBuild, debug);
        switch (buildTarget)
        {
        case BuildTarget.Android:
#if UNITY_EDITOR_OSX
            const string cmd     = "bash";
            const string gradlew = "gradlew";
#elif UNITY_EDITOR_WIN
            const string cmd     = "cmd";
            const string gradlew = "/c gradlew.bat";
#endif // UNITY_EDITOR_OSX
            var sdkDir = GetSdkSubdir(buildTarget, internalSdkBuild);
            return(OS.Run(cmd, string.Format("{0} clean assemble{1}", gradlew, debug ? "Debug" : "Release"),
                          GetFullPath("mopub-android-sdk-unity"),
                          "SDK_DIR=" + Path.GetFileName(sdkDir),
                          "ANDROID_HOME=" + EditorPrefs.GetString("AndroidSdkRoot")));

#if UNITY_EDITOR_OSX
        case BuildTarget.iOS:
            var project = "mopub-ios-sdk-unity.xcodeproj";
            if (internalSdkBuild)
            {
                project = "internal-" + project;
            }
            var jsfile = GetFullPath("mopub-ios-sdk-unity/bin/MoPubSDKFramework.framework/MRAID.bundle/mraid.js");
            return(OS.Run("xcrun",
                          "xcodebuild"
                          + " -project " + project
                          + " -scheme \"MoPub for Unity\""
                          + " -configuration \"" + (debug ? "Debug" : "Release") + "\""
                          + " OTHER_CFLAGS=\"-fembed-bitcode -w\""
                          + " BITCODE_GENERATION_MODE=bitcode"
                          + " clean build",
                          GetFullPath("mopub-ios-sdk-unity"))
                   // Have to rename the .js file inside the framework so that Unity doesn't try to compile it...
                   // This rename is reverted in the MoPubPostBuildiOS script during an app build.
                   && OS.Mv(jsfile, jsfile + ".prevent_unity_compilation"));
#endif // UNITY_EDITOR_OSX
        default:
            Debug.LogError("Invalid build target: " + buildTarget);
            return(false);
        }
    }
示例#3
0
    public static void DoMigration()
    {
        Debug.Log(MigrationBegin);

        if (Directory.Exists(RedundantDir))
        {
            OS.RmDir(RedundantDir);
        }

        var allSucceeded = true;

        foreach (var entry in LocationMapping)
        {
            var source = Path.Combine("Assets", entry.Key);
            var dest   = Path.Combine("Assets", entry.Value);
            if (!DoesExist(source))
            {
                continue;
            }
            allSucceeded &= OS.Mv(source, dest);
        }

        bool showNote      = false;
        var  migrationNote = new StringBuilder(ManualMigrationNote);

        foreach (var entry in ManualMapping)
        {
            if (DoesExist(Path.Combine("Assets", entry.Key)))
            {
                showNote = true;
                migrationNote.Append(string.Format("'{0}' to '{1}'\n", entry.Key, entry.Value));
            }
        }
        if (showNote)
        {
            Debug.LogWarning(migrationNote);
        }

        if (!allSucceeded)
        {
            Debug.LogWarning(ManualFollowUpWarning);
        }
        AssetDatabase.Refresh();
        Debug.Log(MigrationEnd);
    }