BuildPlayerOptions BuildType(AndroidBuildType type, AndroidArchitecture architecture)
    {
        BuildPlayerOptions options = new BuildPlayerOptions();

        string[] sc = (from scene in EditorBuildSettings.scenes where scene.enabled == true select scene.path).ToArray();
        options.scenes = sc;
        options.target = BuildTarget.Android;

        switch (type)
        {
        case AndroidBuildType.Debug:
            options.locationPathName = apkBuildName + $"-debug_{architecture}.apk";
            options.options          = BuildOptions.AllowDebugging | BuildOptions.Development;
            break;

        case AndroidBuildType.Development:
            break;

        case AndroidBuildType.Release:
            options.locationPathName = apkBuildName + $"-release_{architecture}.apk";
            break;

        default:
            break;
        }

        return(options);
    }
    public void Execute(string artifactPath, AndroidArchitecture architecture)
    {
        artifactPath = artifactPath.FixUnityPath();
        var target = SelectDebugSymbolsFile(artifactPath);

        if (string.IsNullOrEmpty(target))
        {
            Debug.LogWarning($"{nameof(RezipAndroidDebugSymbolsCommand)} EMPTY Debug Symbols For artofact {artifactPath}");
            return;
        }

        var debugSymbolsPath = target.ToAbsoluteProjectPath();

        try
        {
            AndroidSymbolShrinker.ShrinkSymbols(debugSymbolsPath, architecture);

            if (removeSourceDebugSymbols)
            {
                File.Delete(debugSymbolsPath);
            }
        }
        catch (Exception e)
        {
            return;
        }
    }
Exemple #3
0
    public static void CopyAndroidIL2CPPSymbols(string pathToBuiltProject, AndroidArchitecture targetDevice)
    {
        string   buildName  = Path.GetFileNameWithoutExtension(pathToBuiltProject);
        FileInfo fileInfo   = new FileInfo(pathToBuiltProject);
        string   symbolsDir = "IL2CPPSymbols";

        CreateDir(symbolsDir);

        switch (PlayerSettings.Android.targetArchitectures)
        {
        case AndroidArchitecture.All:
        {
            CopyARMSymbols(symbolsDir);
            CopyX86Symbols(symbolsDir);
            break;
        }

        case AndroidArchitecture.ARMv7:
        {
            CopyARMSymbols(symbolsDir);
            break;
        }

        // case AndroidArchitecture.X86:
        //     {
        //         CopyX86Symbols(symbolsDir);
        //         break;
        //     }
        default:
            break;
        }
    }
    public static bool ShrinkSymbols(string location, AndroidArchitecture supportedAndroidArchitecture = AndroidArchitecture.All)
    {
        if (string.IsNullOrEmpty(location) || File.Exists(location) == false)
        {
            return(false);
        }

        var targetDirectory  = Path.GetDirectoryName(location);
        var intermediatePath = Path.Combine(targetDirectory, IntermediatePathName);
        var newZip           = Path.Combine(targetDirectory, string.Format(NewDebugSymbolsNameTemplate, Path.GetFileNameWithoutExtension(location)));

        EditorPrefs.SetString(LastSymbolToShrinkLocation, targetDirectory);
        FileCommand.Cleanup(intermediatePath);
        ZipWorker.Unzip(location, intermediatePath);

        EditorUtility.DisplayProgressBar("Shrinking symbols", "Deleting/Renaming/Compressing symbol files", 0.5f);

        //remove unsupported AndroidArchitecture
        RemoveUnsupportedAndroidArchitecture(intermediatePath, supportedAndroidArchitecture);

        FileCommand.Cleanup(newZip);

        CleanUpDebugFiles(intermediatePath);

        ZipWorker.CreateZip(newZip, intermediatePath);

        EditorUtility.ClearProgressBar();

        FileCommand.Cleanup(intermediatePath);

        Debug.Log($"New small symbol package: {newZip}");

        return(true);
    }
Exemple #5
0
    private static void PrebuildProjectSettingUpdate()
    {
        appVersion            = PlayerSettings.bundleVersion;
        targetArchitecture    = PlayerSettings.Android.targetArchitectures;
        scriptBackend         = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup);
        managedStrippingLevel = PlayerSettings.GetManagedStrippingLevel(BuildTargetGroup.Android);
        stripEngineCode       = PlayerSettings.stripEngineCode;

        PlayerSettings.bundleVersion = SQP_APK_VERSION;

        if (targetArchitecture != AndroidArchitecture.ARMv7)
        {
            PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7;
        }

        if (scriptBackend != ScriptingImplementation.Mono2x)
        {
            PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup, ScriptingImplementation.Mono2x);
        }

        if (managedStrippingLevel != ManagedStrippingLevel.Disabled)
        {
            PlayerSettings.SetManagedStrippingLevel(BuildTargetGroup.Android, ManagedStrippingLevel.Disabled);
        }

        if (stripEngineCode)
        {
            PlayerSettings.stripEngineCode = false;
        }
    }
 //==============================================================================
 // 関数
 //==============================================================================
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public SetAndroidTargetArchitecturesCommand
 (
     AndroidArchitecture targetArchitectures
 )
 {
     m_targetArchitectures = targetArchitectures;
 }
Exemple #7
0
    public static AndroidArchitecture getAndroidArchitecture()
    {
        PropertyInfo targetArchitectures =
            typeof(UnityEditor.PlayerSettings.Android).GetProperty("targetArchitectures");
        AndroidArchitecture arch = AndroidArchitecture.invalid;

        //targetArch ARMv7 (armeabi-v7a), ARM64 (arm64-v8a), X86 (x86)
        if (targetArchitectures != null)
        {
            object armv7           = Enum.Parse(targetArchitectures.PropertyType, "ARMv7");
            int    armv7_int       = (int)Convert.ChangeType(armv7, typeof(int));
            object arm64           = Enum.Parse(targetArchitectures.PropertyType, "ARM64");
            int    arm64_int       = (int)Convert.ChangeType(arm64, typeof(int));
            object x64             = Enum.Parse(targetArchitectures.PropertyType, "X86");
            int    x64_int         = (int)Convert.ChangeType(x64, typeof(int));
            object currentArch     = targetArchitectures.GetValue(null, null);
            int    currentArch_int = (int)Convert.ChangeType(currentArch, typeof(int));
            if ((currentArch_int & armv7_int) == armv7_int)
            {
                arch |= AndroidArchitecture.armv7;
            }
            if ((currentArch_int & arm64_int) == arm64_int)
            {
                arch |= AndroidArchitecture.arm64;
            }
            if ((currentArch_int & x64_int) == x64_int)
            {
                arch |= AndroidArchitecture.x86;
            }
        }
        else
        {
            targetArchitectures = typeof(UnityEditor.PlayerSettings.Android).GetProperty("targetDevice");
            if (targetArchitectures != null)
            {
                object currentDevice = targetArchitectures.GetValue(null, null);
                object armv7         = Enum.Parse(targetArchitectures.PropertyType, "ARMv7");
                object x64           = Enum.Parse(targetArchitectures.PropertyType, "x86");
                object fat           = Enum.Parse(targetArchitectures.PropertyType, "FAT");
                if (currentDevice.Equals(armv7))
                {
                    arch = AndroidArchitecture.armv7;
                }
                else if (currentDevice.Equals(x64))
                {
                    arch = AndroidArchitecture.x86;
                }
                else if (currentDevice.Equals(fat))
                {
                    arch = AndroidArchitecture.armv7 | AndroidArchitecture.x86;
                }
            }
        }

        return(arch);
    }
Exemple #8
0
    private MobileAppendix BuildPlayer(ScriptingImplementation backend, AndroidArchitecture architecture, bool buildAab)
    {
        PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, backend);
        EditorUserBuildSettings.buildAppBundle     = buildAab;
        PlayerSettings.Android.targetArchitectures = architecture;
        var buildName = "test" + (buildAab ? ".aab" : string.Empty);
        var options   = new BuildPlayerOptions
        {
            target           = BuildTarget.Android,
            locationPathName = Path.Combine(m_BuildPath, buildName),
        };

        var report = BuildPipeline.BuildPlayer(options);

        return(MobileHelper.LoadMobileAppendix(report.summary.guid.ToString()));
    }
Exemple #9
0
    public static void PrebuildProjectSettingUpdate()
    {
        // Save existing settings as some modifications can change other settings
        projectDefaultAppIdentifier  = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
        projectDefaultVersion        = PlayerSettings.bundleVersion;
        projectAndroidArchitecture   = PlayerSettings.Android.targetArchitectures;
        projectScriptImplementation  = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup);
        projectManagedStrippingLevel = PlayerSettings.GetManagedStrippingLevel(BuildTargetGroup.Android);
        projectStripEngineCode       = PlayerSettings.stripEngineCode;

        // Modify application identifier for transition APK
        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android,
                                                projectDefaultAppIdentifier + GetTransitionApkOptionalIdentifier());

        // Set VersionCode as a unique identifier for transition APK
        PlayerSettings.bundleVersion = TRANSITION_APK_VERSION_NAME;

        // Modify Android target architecture as ARM64 does not support Mono.
        if (projectAndroidArchitecture != AndroidArchitecture.ARMv7)
        {
            // Show message in console to make it more clear to developers
            OVRBundleTool.PrintLog("Build will use ARMv7 as Android architecture.");
            PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7;
        }

        // Modify IL2CPP option as it strips script symbols that are necessary for the scenes at runtime
        if (projectScriptImplementation != ScriptingImplementation.Mono2x)
        {
            // Show message in console to make it more clear to developers
            OVRBundleTool.PrintLog("Build will use Mono as scripting backend.");
            PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup, ScriptingImplementation.Mono2x);
        }

        // Avoid stripping managed code that are necessary for the scenes at runtime
        if (projectManagedStrippingLevel != ManagedStrippingLevel.Disabled)
        {
            OVRBundleTool.PrintLog("Build will set Managed Stripping Level to Disabled.");
            PlayerSettings.SetManagedStrippingLevel(BuildTargetGroup.Android, ManagedStrippingLevel.Disabled);
        }

        if (projectStripEngineCode)
        {
            OVRBundleTool.PrintLog("Build will set Strip Engine Code to Disabled.");
            PlayerSettings.stripEngineCode = false;
        }
    }
        private void OnStartSetup()
        {
            BundleVersionCode = PlayerSettings.Android.bundleVersionCode;
            PackageName       = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
            ScriptingBackend  = PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android);

            BuildSystem         = EditorUserBuildSettings.androidBuildSystem;
            AndroidArchitecture = PlayerSettings.Android.targetArchitectures;
            SetSettings();

            if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
            {
                return;
            }

#if UNITY_2019
            if ((PlayerSettings.Android.keyaliasPass == "" || PlayerSettings.Android.keystorePass == "") && PlayerSettings.Android.useCustomKeystore == true)
            {
                string pass = PasswordManager.GetPassword("ALIAS_PASSWORD");
                PlayerSettings.Android.keystorePass = pass;
                string alias = PasswordManager.GetPassword("KEYSTORE_PASSWORD");
                PlayerSettings.Android.keyaliasPass = alias;
                Debug.Log("<b><color=red> Password has been updated.</color></b>");
            }
            else if (PlayerSettings.Android.useCustomKeystore == false)
            {
                Debug.Log("Custom key false");
                PasswordManager.GetPassword("");
            }
#else
            if ((PlayerSettings.Android.keyaliasPass == "" || PlayerSettings.Android.keystorePass == "") && (!PlayerSettings.Android.keyaliasName.Contains("debug") || PlayerSettings.Android.keyaliasName != ""))
            {
                string pass = PasswordManager.GetPassword("ALIAS_PASSWORD");
                PlayerSettings.Android.keystorePass = pass;
                string alias = PasswordManager.GetPassword("KEYSTORE_PASSWORD");
                PlayerSettings.Android.keyaliasPass = alias;
                Debug.Log("<b><color=red> Password has been updated.</color></b>");
            }
            else if (PlayerSettings.Android.keyaliasName.Contains("debug") || PlayerSettings.Android.keyaliasName == "")
            {
                Debug.Log("Custom key false");
                PasswordManager.GetPassword("");
            }
#endif
        }
    private static void Build()
    {
        SpecificDestinationLine();
        string destinationPath = Path.Combine(_destinationPath, PlayerSettings.productName);

        destinationPath += ".apk";
        PlayerSettings.Android.keystoreName = "yours.keystore";
        PlayerSettings.Android.keystorePass = "******";
        PlayerSettings.Android.keyaliasName = "yoursalias";
        PlayerSettings.Android.keyaliasPass = "******";

        PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.Mono2x);
        AndroidArchitecture androidArchitecture = AndroidArchitecture.ARMv7;

        PlayerSettings.Android.targetArchitectures  = androidArchitecture;
        PlayerSettings.Android.useAPKExpansionFiles = false;

        BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, destinationPath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
    }
Exemple #12
0
        public ScopeBuildSettings()
        {
            saveTarget = EditorUserBuildSettings.activeBuildTarget;
#if LOCAL_UNITY_2018_1_OR_NEWER
            buildTargetGroup = UnityEditorUserBuildSettings.activeBuildTargetGroup;
#endif

            scriptingImplementation     = B.scriptingBackend;
            il2CppCompilerConfiguration = B.il2CppCompilerConfiguration;
            compressionType             = B.compressionType;
            development             = B.development;
            buildAppBundle          = B.buildAppBundle;
            targetArchitectures     = B.targetArchitectures;
            androidBuildType        = B.androidBuildType;
            WebGL_compressionFormat = B.WebGL_compressionFormat;
            WebGL_linkerTarget      = B.WebGL_linkerTarget;
            WebGL_memorySize        = B.WebGL_memorySize;
            WebGL_exceptionSupport  = B.WebGL_exceptionSupport;
#if UNITY_2019_1_OR_NEWER
            WebGL_threadsSupport = B.WebGL_threadsSupport;
            WebGL_wasmStreaming  = B.WebGL_wasmStreaming;
#endif
        }
    private static void RemoveUnsupportedAndroidArchitecture(string location, AndroidArchitecture supportedAndroidArchitecture)
    {
        var values = EnumValue <AndroidArchitecture> .Values;

        foreach (var value in values)
        {
            if (supportedAndroidArchitecture.IsFlagSet(value))
            {
                continue;
            }

            if (!androidArchitectereLocations.TryGetValue(value, out var directoryName))
            {
                continue;
            }

            var path = location.CombinePath(directoryName);
            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
        }
    }
Exemple #14
0
        public static void SetupAchitecture(BuildConfig buildConfig)
        {
            AndroidArchitecture aa = AndroidArchitecture.ARMv7 | AndroidArchitecture.ARM64;

            if (buildConfig.achitecture == BuildConfig.BuildAchietecture.ARMv7)
            {
                aa = AndroidArchitecture.ARMv7;
            }
            else if (buildConfig.achitecture == BuildConfig.BuildAchietecture.ARM64)
            {
                aa = AndroidArchitecture.ARM64;
            }
            else if (buildConfig.achitecture == BuildConfig.BuildAchietecture.X86)
            {
                aa = AndroidArchitecture.X86;
            }
            else if (buildConfig.achitecture == BuildConfig.BuildAchietecture.All)
            {
                aa = AndroidArchitecture.All;
            }

            PlayerSettings.Android.targetArchitectures = aa;
        }
Exemple #15
0
    public static void CopyAndroidIL2CPPSymbols(string pathToBuiltProject, AndroidArchitecture targetArchi)
    {
        string buildName  = Path.GetFileNameWithoutExtension(pathToBuiltProject);
        string symbolsDir = Path.GetDirectoryName(pathToBuiltProject);

        symbolsDir = symbolsDir + "/" + buildName + "_IL2CPPSymbols/";
        Debug.Log("CopyAndroidIL2CPPSymbols : " + symbolsDir + "   " + targetArchi.ToString());

        if (Directory.Exists(symbolsDir))
        {
            Directory.Delete(symbolsDir, true);
        }
        CreateDir(symbolsDir);

        if ((targetArchi & AndroidArchitecture.ARMv7) > 0)
        {
            CopyARMV7Symbols(symbolsDir);
        }
        if ((targetArchi & AndroidArchitecture.ARM64) > 0)
        {
            CopyARMV8Symbols(symbolsDir);
        }
    }
Exemple #16
0
    public static void CopyAndroidIL2CPPSymbols(string pathToBuiltProject, AndroidArchitecture targetDevice)
    {
//		string buildName = Path.GetFileNameWithoutExtension(pathToBuiltProject);
//		FileInfo fileInfo = new FileInfo(pathToBuiltProject);
//		string symbolsDir = fileInfo.Directory.Name;
//		symbolsDir = symbolsDir + "/"+buildName+"_IL2CPPSymbols";
        string symbolsDir = pathToBuiltProject + "/../../IL2CPPSymbols";

        CreateDir(symbolsDir);

        switch (PlayerSettings.Android.targetArchitectures)
        {
        case AndroidArchitecture.All:
        {
            CopyARM64Symbols(symbolsDir);
            CopyARMv7Symbols(symbolsDir);
            CopyX86Symbols(symbolsDir);
            break;
        }

        case AndroidArchitecture.ARM64:
        {
            CopyARM64Symbols(symbolsDir);
            break;
        }

        case AndroidArchitecture.ARMv7:
        {
            CopyARMv7Symbols(symbolsDir);
            break;
        }

        default:
            break;
        }
    }
Exemple #17
0
 public static void SetAndroidArchitecture(AndroidArchitecture androidArchitecture)
 {
     PlayerSettings.Android.targetArchitectures = androidArchitecture;
 }
Exemple #18
0
 public static string AsString(this AndroidArchitecture arch) => arch switch
 {
Exemple #19
0
 /// <summary>
 /// Generate bundle number of build for Android.<br/>
 /// Format: <![CDATA[<revision><branchId><targetId>]]><br/>
 /// Where <i>revision</i> - parsed number from <see cref="GitRequest.Revision"/>;
 /// <i>branchId</i> - 0 if current branch is equal to <see cref="RELEASE_BRANCH"/>, otherwise 1;
 /// <i>targetId</i> - number equivalent of <i>targetDevice</i>.<br/>
 /// Example return: "23403" - revision is 234, release branch, Android target - ARMv7.
 /// </summary>
 /// <param name="targetDevice">Android target device</param>
 /// <returns>Generated bundle number</returns>
 public static int GenBundleNumber(AndroidArchitecture targetDevice)
 {
     return(GenBundleNumber((int)targetDevice));
 }
 private static bool IsArchitectureEnabled(AndroidArchitecture androidArchitecture)
 {
     // Note: Enum.HasFlag() was introduced in .NET 4.x
     return((PlayerSettings.Android.targetArchitectures & androidArchitecture) == androidArchitecture);
 }
 internal static void ApplySettings(AndroidArchitecture targetArchitectures = AndroidArchitecture.All)
 {
     UnityEditor.PlayerSettings.Android.targetArchitectures = targetArchitectures;
 }
 /// <summary>
 /// 実行する時に呼び出されます
 /// </summary>
 protected override BuildCommandResult DoRun()
 {
     m_oldTargetArchitectures = PlayerSettings.Android.targetArchitectures;
     PlayerSettings.Android.targetArchitectures = m_targetArchitectures;
     return(Success(m_targetArchitectures.ToString()));
 }