Skip to content

Commit

Permalink
Fix for #31 Make it easier to do clean builds.
Browse files Browse the repository at this point in the history
Now offers command line arguments "-clean" and "-noclean" to force selected buildprocesses to run with either setting. Added an option to the UBSAssetInspector to select if the buildprocess in it should be run with CleanBuildCache option on. This can be set individually in the build options of each process.
  • Loading branch information
kwnetzwelt committed Feb 23, 2023
1 parent 7729d06 commit 486daa4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions Editor/UBS/BuildCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void SaveVersion(bool writeToPlayerSettings)

public BuildVersion version = null;
public string versionCode = "1";
public bool cleanBuild = false;

public void SaveVersionCode()
{
Expand Down
13 changes: 12 additions & 1 deletion Editor/UBS/UBSAssetInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public override void OnInspectorGUI()
var logtypes= serializedObject.FindPropertyByAutoPropertyName("LogTypes");
EditorGUILayout.PropertyField(logtypes, new GUIContent("Logging Configuration"), true);
serializedObject.ApplyModifiedProperties();

data.cleanBuild = EditorGUILayout.Toggle("Run clean builds", data.cleanBuild);
Tooltip("If set to true adds CleanBuildCache to the BuildOptions when calling the buildpipeline. ");


GUILayout.BeginHorizontal();
{
Expand Down Expand Up @@ -97,7 +101,14 @@ public override void OnInspectorGUI()

}


private void Tooltip(string text, MouseCursor cursor = MouseCursor.Arrow)
{
Rect rect = GUILayoutUtility.GetLastRect();
EditorGUIUtility.AddCursorRect(rect, cursor);
GUI.Label(rect, new GUIContent("", text));
}


[MenuItem("Assets/Create/UBS Build Collection")]
public static void CreateBuildCollectionMenuCommand()
{
Expand Down
37 changes: 31 additions & 6 deletions Editor/UBS/UBSProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,23 @@ public static void BuildFromCommandLine()
"-buildTag=",
"-buildAll",
"-commitID=",
"-clean", // force clean builds on
"-noclean", // force clean builds off
"-tagName=",
"-buildProcessByNames="

};

bool batchMode = parser.Collection.HasArgument("batchmode");
CleanBuildArgument clean = CleanBuildArgument.NotAssigned;
if(parser.Collection.HasArgument("clean"))
{
clean = CleanBuildArgument.Clean;
}else if (parser.Collection.HasArgument("noclean"))
{
clean = CleanBuildArgument.NoClean;
}

string collectionPath = parser.Collection.GetValue<string>("collection");
string androidSdkPath = parser.Collection.GetValue<string>("android-sdk");
string buildTag = parser.Collection.GetValue<string>("buildTag");
Expand Down Expand Up @@ -245,11 +256,11 @@ public static void BuildFromCommandLine()
{
string[] buildProcessNameList = startBuildProcessByNames.Split(',');
var lowerCaseTrimmedBuildProcessNameList = buildProcessNameList.Select(x => x.ToLower()).Select(x => x.Trim()).ToArray();
Create(collection, false, lowerCaseTrimmedBuildProcessNameList, batchMode, buildTag);
Create(collection, false, lowerCaseTrimmedBuildProcessNameList, batchMode, buildTag, clean);
}
else
{
Create(collection, false, buildAll, batchMode, buildTag);
Create(collection, false, buildAll, batchMode, buildTag, clean);
}


Expand Down Expand Up @@ -296,12 +307,14 @@ public static string AddBuildTag(string pOutputPath, string pTag)

#endregion

public static void Create(BuildCollection collection, bool buildAndRun, bool pBatchMode = false, bool pBuildAll = false, string buildTag = "")
public static void Create(BuildCollection collection, bool buildAndRun, bool pBatchMode = false, bool pBuildAll = false, string buildTag = "", CleanBuildArgument clean = CleanBuildArgument.NotAssigned)
{
UBSProcess p = ScriptableObject.CreateInstance<UBSProcess>();
p._buildAndRun = buildAndRun;
p._batchMode = pBatchMode;
p._collection = collection;
if(clean != CleanBuildArgument.NotAssigned)
collection.cleanBuild = clean == CleanBuildArgument.Clean;
if(!pBuildAll)
{
p._selectedProcesses = p._collection.Processes.FindAll( obj => obj.Selected );
Expand Down Expand Up @@ -329,12 +342,14 @@ public static void Create(BuildCollection collection, bool buildAndRun, bool pBa
/// Builds a buildcollection by using an array of build process names (',' seperated!)
/// By using a list of build process names, we reconfigure and retarget the actual build collection.
/// </summary>
public static void Create(BuildCollection collection, bool buildAndRun, string[] namesToBuild, bool batchMode = false, string buildTag = "")
public static void Create(BuildCollection collection, bool buildAndRun, string[] namesToBuild, bool batchMode = false, string buildTag = "", CleanBuildArgument clean = CleanBuildArgument.NotAssigned)
{
UBSProcess p = ScriptableObject.CreateInstance<UBSProcess>();
p._buildAndRun = buildAndRun;
p._batchMode = batchMode;
p._collection = collection;
if(clean != CleanBuildArgument.NotAssigned)
collection.cleanBuild = clean == CleanBuildArgument.Clean;
if (namesToBuild != null && namesToBuild.Length > 0)
{
var selectedProcesses = p._collection.Processes
Expand Down Expand Up @@ -479,6 +494,9 @@ void DoBuilding()
{

BuildOptions bo = CurrentProcess.Options;
if(CurrentBuildConfiguration.GetCurrentBuildCollection().cleanBuild)
bo &= BuildOptions.CleanBuildCache;

if (_buildAndRun)
bo |= BuildOptions.AutoRunPlayer;

Expand Down Expand Up @@ -612,8 +630,15 @@ bool CheckOutputPath(BuildProcess pProcess)

}
}

public enum UBSState

public enum CleanBuildArgument
{
NotAssigned,
Clean,
NoClean
}

public enum UBSState
{
invalid,
setup,
Expand Down

0 comments on commit 486daa4

Please sign in to comment.