About Monkey 2 › Forums › Monkey 2 Projects › MojoX Build Cleaner Utility
This topic contains 3 replies, has 3 voices, and was last updated by
cocon 1 year, 6 months ago.
-
AuthorPosts
-
September 27, 2017 at 7:04 am #10828
This is a simple utility I made a few months ago, to allow you to cleanup the build directories. From console I made a refreshing update into GUI, that way it will be much more useful.
buildcleaner.monkey2
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246Namespace buildcleaner#import "<std>"#import "<mojo>"#import "<mojox>"Using std..Using mojo..Using mojox..Class BuildCleanerWindow Extends WindowPrivateField context:ContextField textView:TextViewPublicMethod New()Super.New("Monkey2 Build Cleaner", 640, 480, WindowFlags.Resizable)' contextcontext = New Context' root pathLocal pathLabel := New Label("Search Path: ")Local pathField := New TextFieldLocal pathDock := New DockingViewpathDock.AddView(pathLabel, "left", "20%")pathDock.AddView(pathField, "right", "80%")' version pathLocal verLabel := New Label("Search Version: ")Local verField := New TextFieldLocal verDock := New DockingViewverDock.AddView(verLabel, "left", "20%")verDock.AddView(verField, "right", "80%")' buttonLocal butSearch := New Button("Search")Local butDelete := New Button("Delete")Local butDock := New DockingViewbutDock.AddView(butSearch, "left", "50%")butDock.AddView(butDelete, "right", "50%")butSearch.Clicked = Lambda()context.State = "Search"context.BaseDirectory = pathField.Textcontext.VersionPattern = verField.TextOperations.UpdateProcess(context)EndbutDelete.Clicked = Lambda()If context.State = "Delete"Operations.UpdateProcess(context)EndEnd' reporttextView = New TextViewtextView.Text = "Welcome To Monkey2 Build CleanerThis utility will help you clean Monkey2 ~qbuildv~q and~qproduct~q directories.Set the ~qSearch Path~q as the initial directoryfrom where the searching will be initiated, thiswill include any subdirectories below that matchthe criteria.Optionally you can set an identifier to ~qSearch Version~qfield so you can limit the search results even further intospecific versions. Leaving the version field blank willlead you to include just everything.Then press the ~qSearch~q button to start searchingfor the subdirectories, once the search is completedpress the ~qDelete~q button to initiate the deletionprocess."' main dockLocal mainDock := New DockingViewmainDock.AddView(pathDock, "top")mainDock.AddView(verDock , "top")mainDock.AddView(butDock , "top")mainDock.AddView(textView, "top", "100%", True)ContentView = mainDock' testpathField.Text = "D:\Programming\monkey2"EndMethod ReportClear()textView.Text = ""EndMethod Report(s:String)textView.Text += s + "~n"EndEndFunction Main()New AppInstanceNew BuildCleanerWindowApp.Run()EndClass ContextField BaseDirectory:StringField VersionPattern:StringField SearchResults:List<String>Field State:StringField ErrorMessage:StringProperty HasVersion:Bool()Return VersionPattern <> Null And VersionPattern.Length > 0EndProperty HasResults:Bool()Return SearchResults <> Null And SearchResults.Count() > 0EndEndClass Operations AbstractFunction UpdateProcess(context:Context)Utils.Window().ReportClear()Select context.StateCase "Search"Utils.ValidateContextInputFields(context)DirectorySearch.StartSearch(context)If Not context.HasResultsUtils.Window().Report("No Results Found")context.State = "Search"ElseUtils.Window().Report("Results Found:~n")DirectoryOperations.Report(context)context.State = "Delete"EndCase "Delete"Utils.Window().Report("Deleting Directories~n")DirectoryOperations.DeleteDirectories(context)Utils.Window().Report("~nCompleted")context.State = "Search"EndEndEndClass DirectorySearch AbstractPrivateGlobal directoryStack:Stack<String>Function IsDirectory:Bool(path:String)Return GetFileType(path) = FileType.DirectoryEndFunction TestDirectoryToIgnore:Bool(path:String)Return path.Contains(".git") = FalseEndFunction TestDirectoryToInclude:Bool(context:Context, path:String)Local containsBuild := path.Contains(".buildv")Local containsProduct := path.Contains(".products")Local containsPattern := path.Contains(context.VersionPattern)If containsProduct Then Return TrueIf context.HasVersionIf containsBuild And containsPattern Then Return TrueElseIf containsBuild Then Return TrueEndReturn FalseEndFunction PushSubdirectoriesToStack(path:String)For Local p := Eachin LoadDir(path)Local fullPath := path+"/"+pIf IsDirectory(fullPath)If TestDirectoryToIgnore(fullPath)directoryStack.Push(fullPath)EndEndNextEndPublicFunction StartSearch(context:Context)context.SearchResults = New List<String>directoryStack = New Stack<String>directoryStack.Push(context.BaseDirectory)While directoryStack.Length > 0Local dir := directoryStack.Pop()If TestDirectoryToInclude(context, dir)context.SearchResults.Add(dir)ContinueEndPushSubdirectoriesToStack(dir)EndEndEndClass DirectoryOperations AbstractFunction Report(context:Context)If context.HasResultsFor Local i := Eachin context.SearchResultsUtils.Window().Report(i)NextEndEndFunction DeleteDirectories(context:Context)For Local r := Eachin context.SearchResultsDeleteDir(r, True)Utils.Window().Report("Deleted: " + r)NextEndEndClass Utils AbstractFunction ValidateContextInputFields(context:Context)context.BaseDirectory = CleanPath(context.BaseDirectory)EndFunction CleanPath:String(path:String)Return path.Replace( "\","/" ).Replace("~q", "")EndFunction Window:BuildCleanerWindow()Return Cast<BuildCleanerWindow>(App.ActiveWindow)EndEndAttachments:
September 27, 2017 at 8:20 am #10836Very useful. Thanks for sharing.
September 27, 2017 at 11:03 am #10839Similar feature is right inside of Ted2Go IDE – right click on project name and select menu item “Clean (delete .buildv)”.
It works if you have a .buildv right inside project folder. So you can’t clean modules inside of ‘monkey2’ project.
I can add recursive search if needed.
September 27, 2017 at 6:44 pm #10847Thanks for the feedback.
If you have any suggestions let me know.
nerobot: I will respond to the Ted2Go thread for more information.
-
AuthorPosts
You must be logged in to reply to this topic.


