Skip to content

Commit

Permalink
Update WolffunAzureDevops.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhducdk16 committed Mar 2, 2024
1 parent 5d37e55 commit c5e1670
Showing 1 changed file with 101 additions and 100 deletions.
201 changes: 101 additions & 100 deletions Editor/WolffunAzureDevops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public sealed class WolffunAzureDevops
static string splitApplicationBinary = "false";
static string androidCreateSymbols = "false";
#endif


static string il2cppCodegen = "OptimizeSpeed";
static string buildAddressables = "true";


#if UNITY_IOS
static string xcodeBuildConfig = "Release";
Expand All @@ -56,13 +56,13 @@ public sealed class WolffunAzureDevops
static string buildAppBundle = "true";
#endif
static string customScenesToBuild = "";
#region Addressable
#region Addressable
/// <summary>
/// This is method that using to build manual addressable
/// </summary>
public static void AddRessableBuild()
{

Debug.Log("Start build Addressable");
var settings = AddressableAssetSettingsDefaultObject.Settings;
if (settings == null)
Expand All @@ -72,7 +72,7 @@ public static void AddRessableBuild()
}
var mode = ScriptableObject.CreateInstance<BuildScriptsAzurePipeline>();
var res = mode.BuildData<AddressablesPlayerBuildResult>(new AddressablesDataBuilderInput(settings));

if (!string.IsNullOrEmpty(res.Error))
{
Debug.LogError("Addressable build failed");
Expand All @@ -83,16 +83,16 @@ public static void AddRessableBuild()
Debug.Log("Addressable content successfully built");
}
}
#endregion
#region BuildPlayer
#endregion
#region BuildPlayer
public static void PerformBuild()
{
//get commandline arguments -outputPath $(Build.BinariesDirectory)
//-outputFileName $(XcodeProjectFolderName) -configuration $(Configuration) -buildNumber $(BuildNumber) -appversion $(AppVersion)
string[] args = System.Environment.GetCommandLineArgs();
//log all arguments joined by space
Debug.Log(string.Join(" ", args));


for (int i = 0; i < args.Length; i++)
{
Expand Down Expand Up @@ -132,27 +132,27 @@ public static void PerformBuild()
{
outputExtension = args[i + 1];
}
else if(args[i] == "-typeBundle")
else if (args[i] == "-typeBundle")
{
typeBundle = args[i + 1];
}
else if(args[i] == "-assetBundle")
else if (args[i] == "-assetBundle")
{
assetBundle = args[i + 1];
}
else if(args[i] == "-addressableRule")
else if (args[i] == "-addressableRule")
{
addressableRule = args[i + 1];
}
else if(args[i] == "-enableAddressableRule")
else if (args[i] == "-enableAddressableRule")
{
enableAddressableRule = args[i + 1];
}
else if(args[i] == "-buildServer")
else if (args[i] == "-buildServer")
{
buildServer = args[i + 1];
}
else if(args[i] == "-buildManualAddressable")
else if (args[i] == "-buildManualAddressable")
{
buildManualAddressable = args[i + 1];
}
Expand Down Expand Up @@ -289,7 +289,7 @@ public static void PerformBuild()
{
var settings = UnityEditor.AddressableAssets.AddressableAssetSettingsDefaultObject.Settings;
settings.BuildAddressablesWithPlayerBuild =
AddressableAssetSettings.PlayerBuildOption.DoNotBuildWithPlayer;
AddressableAssetSettings.PlayerBuildOption.DoNotBuildWithPlayer;
}
else
{
Expand All @@ -308,20 +308,20 @@ public static void PerformBuild()
var settings = UnityEditor.AddressableAssets.AddressableAssetSettingsDefaultObject.Settings;
settings.BuildAddressablesWithPlayerBuild =
AddressableAssetSettings.PlayerBuildOption.DoNotBuildWithPlayer;
}
}
}
}
else if(typeBundle == "AssetBundle")
else if (typeBundle == "AssetBundle")
{
if (assetBundle == "true")
{
BuildBundle();
BuildBundle();
}
}

}
catch (Exception)
{
catch (Exception)
{
// ignored
}

Expand Down Expand Up @@ -362,8 +362,9 @@ public static void PerformBuild()
Debug.Log("Skip append build");
}
#endif

Debug.Log("buildAppBundle: " + buildAppBundle);
#if UNITY_ANDROID
Debug.Log("UNITY_ANDROID: android");
PlayerSettings.stripEngineCode = true;
PlayerSettings.Android.useCustomKeystore = false;

Expand All @@ -376,7 +377,7 @@ public static void PerformBuild()
{
EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Disabled;
}

Debug.Log("buildAppBundle: " + buildAppBundle);
switch (buildAppBundle)
{
case "true":
Expand All @@ -385,7 +386,7 @@ public static void PerformBuild()
AndroidArchitecture aac = AndroidArchitecture.ARM64 | AndroidArchitecture.ARMv7;
PlayerSettings.Android.targetArchitectures = aac;
EditorUserBuildSettings.buildAppBundle = true;
Debug.Log("build_arm_x64" +aac);
Debug.Log("build_arm_v7" + true);
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);

Expand All @@ -403,7 +404,7 @@ public static void PerformBuild()
case "false":
PlayerSettings.SetManagedStrippingLevel(BuildTargetGroup.Android, ManagedStrippingLevel.Low);
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;

Debug.Log("build_arm_v7" + false);
EditorUserBuildSettings.buildAppBundle = false;
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
Expand All @@ -430,9 +431,9 @@ public static void PerformBuild()
switch (configuration)
{
case "Debug":
{
buildPlayerOptions.options |= BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler;
}
{
buildPlayerOptions.options |= BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler;
}
break;
case "Release":
case "Development":
Expand Down Expand Up @@ -462,90 +463,90 @@ public static void PerformBuild()
if (buildServer == "true")
{
buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;
PlayerSettings.bundleVersion = appversion;
//linux output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
}
else
{
switch (buildTarget)
{
switch (buildTarget)
{
case "Android":
buildPlayerOptions.target = BuildTarget.Android;
PlayerSettings.Android.bundleVersionCode = int.Parse(buildNumber);
PlayerSettings.bundleVersion = appversion;
break;
case "iOS":
buildPlayerOptions.target = BuildTarget.iOS;
PlayerSettings.iOS.buildNumber = buildNumber;
PlayerSettings.bundleVersion = appversion;
break;
case "StandaloneWindows":
buildPlayerOptions.target = BuildTarget.StandaloneWindows;
PlayerSettings.bundleVersion = appversion;
//windows 32 bit output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
break;
case "StandaloneWindows64":
buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
PlayerSettings.bundleVersion = appversion;
//windows 64 bit output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
case "Android":
buildPlayerOptions.target = BuildTarget.Android;
PlayerSettings.Android.bundleVersionCode = int.Parse(buildNumber);
PlayerSettings.bundleVersion = appversion;
break;
case "iOS":
buildPlayerOptions.target = BuildTarget.iOS;
PlayerSettings.iOS.buildNumber = buildNumber;
PlayerSettings.bundleVersion = appversion;
break;
case "StandaloneWindows":
buildPlayerOptions.target = BuildTarget.StandaloneWindows;
PlayerSettings.bundleVersion = appversion;
//windows 32 bit output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
break;
case "StandaloneWindows64":
buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
PlayerSettings.bundleVersion = appversion;
//windows 64 bit output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);

break;
case "StandaloneOSX":
buildPlayerOptions.target = BuildTarget.StandaloneOSX;
PlayerSettings.macOS.buildNumber = buildNumber;
PlayerSettings.bundleVersion = appversion;
//mac output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
break;
case "WebGL":
buildPlayerOptions.target = BuildTarget.WebGL;
PlayerSettings.bundleVersion = appversion;
PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat.Brotli;
PlayerSettings.WebGL.memorySize = 512;
PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.None;
//webgl output file
buildPlayerOptions.locationPathName = Path.Combine(outputPath, outputFileName);
break;
case "StandaloneOSX":
buildPlayerOptions.target = BuildTarget.StandaloneOSX;
PlayerSettings.macOS.buildNumber = buildNumber;
PlayerSettings.bundleVersion = appversion;
//mac output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
break;
case "WebGL":
buildPlayerOptions.target = BuildTarget.WebGL;
PlayerSettings.bundleVersion = appversion;
PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat.Brotli;
PlayerSettings.WebGL.memorySize = 512;
PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.None;
//webgl output file
buildPlayerOptions.locationPathName = Path.Combine(outputPath, outputFileName);

break;
case "LinuxServer64":
buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;
PlayerSettings.bundleVersion = appversion;
//linux output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
break;
case "LinuxServer64":
buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;
PlayerSettings.bundleVersion = appversion;
//linux output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);

break;
//Windows Server
case "WindowsServer":
buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;
PlayerSettings.bundleVersion = appversion;
//windows 64 bit output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);
break;
//Windows Server
case "WindowsServer":
buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
buildPlayerOptions.subtarget = (int)StandaloneBuildSubtarget.Server;
EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;
PlayerSettings.bundleVersion = appversion;
//windows 64 bit output file
buildPlayerOptions.locationPathName =
Path.Combine(outputPath, outputFileName + "." + outputExtension);

break;
break;

default:
buildPlayerOptions.target = BuildTarget.StandaloneWindows;
break;
}
default:
buildPlayerOptions.target = BuildTarget.StandaloneWindows;
break;
}
}
//target


//disable logo unity
try
Expand Down Expand Up @@ -725,8 +726,8 @@ private static void ClearFolder(string folderPath)
Directory.CreateDirectory(folderPath);
}
}
#endregion
#endregion


}
}
}

0 comments on commit c5e1670

Please sign in to comment.