diff --git a/uppsrc/CtrlLib/ChCocoMM.mm b/uppsrc/CtrlLib/ChCocoMM.mm index d595e5ebf..894032a36 100644 --- a/uppsrc/CtrlLib/ChCocoMM.mm +++ b/uppsrc/CtrlLib/ChCocoMM.mm @@ -1,7 +1,10 @@ -#include #include -#include + +#ifdef PLATFORM_COCOA + +#include #include "ChCocoMM.h" +#include void Coco_ThemePaint(void *cgcontext, const Upp::Rect& r, int type, int value, int state, bool focus) { @@ -67,3 +70,4 @@ int Coco_Metric(int k) return m; } +#endif diff --git a/uppsrc/ide/AutoSetup.cpp b/uppsrc/ide/AutoSetup.cpp index 69b5a86ad..5aacd6d1d 100644 --- a/uppsrc/ide/AutoSetup.cpp +++ b/uppsrc/ide/AutoSetup.cpp @@ -871,20 +871,6 @@ void AutoSetup() SaveFile(AppendFileName(dir, "default_method"), m); } } -#endif - -#ifdef PLATFORM_POSIX - -void AutoSetup() { - InstallWizard iw; - iw.Title("TheIDE - Source management settings"); - iw.Block(0); - iw.Block(4); - iw.SetStep(1); - iw.Run(); -} - -#endif void Ide::AutoSetup() { @@ -892,3 +878,6 @@ void Ide::AutoSetup() SyncBuildMode(); SetBar(); } + +#endif + diff --git a/uppsrc/ide/Install.cpp b/uppsrc/ide/Install.cpp index c92e9bfd6..f9b6717c1 100644 --- a/uppsrc/ide/Install.cpp +++ b/uppsrc/ide/Install.cpp @@ -3,59 +3,72 @@ #ifndef PLATFORM_WIN32 -bool CopyFolder(Progress& pi, const char *dst, const char *src) -{ - return CopyFolder(dst, src, &pi); -} - -void ChkSupp(const char *s, String& dir) -{ - if(IsNull(dir) && FileExists(AppendFileName(s, "GCC.bm"))) - dir = s; -} - -String DefaultInstallFolder() -{ - String DefaultFolder; - String ExeTitle = ToUpper(GetExeTitle()); - for(int i = 0; i < ExeTitle.GetCount(); i++) { - if(ExeTitle[i] >= 'a' && ExeTitle[i] <= 'z') - ExeTitle.Set(i, ExeTitle[i] + 'A'-'a'); - } - if(ExeTitle.Find("SVN") >= 0) - DefaultFolder = "upp-svn"; - else if(ExeTitle.Find("DEV") >= 0) - DefaultFolder = "upp-dev"; - else if(ExeTitle.Find("BETA") >= 0) - DefaultFolder = "upp-beta"; - else - DefaultFolder = "upp"; - - return DefaultFolder; -} +const char *gcc_bm = +R"(BUILDER = "GCC"; +COMPILER = ""; +COMMON_OPTIONS = ""; +COMMON_CPP_OPTIONS = "-std=c++14 -Wno-parentheses"; +COMMON_C_OPTIONS = ""; +COMMON_LINK = ""; +COMMON_FLAGS = ""; +DEBUG_INFO = "2"; +DEBUG_BLITZ = "1"; +DEBUG_LINKMODE = "1"; +DEBUG_OPTIONS = "-O0 -Wall -DflagGTK"; +DEBUG_FLAGS = ""; +DEBUG_LINK = ""; +RELEASE_BLITZ = "0"; +RELEASE_LINKMODE = "1"; +RELEASE_OPTIONS = "-O3 -ffunction-sections -fdata-sections -DflagGTK -DflagGTK"; +RELEASE_FLAGS = ""; +RELEASE_LINK = "-Wl,--gc-sections"; +DEBUGGER = "gdb"; +ALLOW_PRECOMPILED_HEADERS = "0"; +DISABLE_BLITZ = "0"; +PATH = ""; +INCLUDE = "/usr/include/freetype2;/usr/include/gtk-2.0;/usr/include/glib-2.0;/usr/lib/glib-2.0/include;/usr/lib/gtk-2.0/include;/usr/include/cairo;/usr/include/pango-1.0;/usr/include/atk-1.0;/usr/X11R6/include;/usr/X11R6/include/freetype2;/usr/X11R6/include/gtk-2.0;/usr/X11R6/include/glib-2.0;/usr/X11R6/lib/glib-2.0/include;/usr/X11R6/lib/gtk-2.0/include;/usr/X11R6/include/cairo;/usr/X11R6/include/pango-1.0;/usr/X11R6/include/atk-1.0;/usr/lib/x86_64-linux-gnu/glib-2.0/include;/usr/lib/x86_64-linux-gnu/gtk-2.0/include;/usr/include/freetype2;/usr/include/gtk-2.0;/usr/include/glib-2.0;/usr/lib/glib-2.0/include;/usr/lib/gtk-2.0/include;/usr/include/cairo;/usr/include/pango-1.0;/usr/include/atk-1.0;/usr/X11R6/include;/usr/X11R6/include/freetype2;/usr/X11R6/include/gtk-2.0;/usr/X11R6/include/glib-2.0;/usr/X11R6/lib/glib-2.0/include;/usr/X11R6/lib/gtk-2.0/include;/usr/X11R6/include/cairo;/usr/X11R6/include/pango-1.0;/usr/X11R6/include/atk-1.0;/usr/include/gdk-pixbuf-2.0;/usr/lib/x86_64-linux-gnu/glib-2.0/include;/usr/lib/x86_64-linux-gnu/gtk-2.0/include"; +LIB = "/usr/X11R6/lib;/usr/lib"; +LINKMODE_LOCK = "0";)"; bool Install() { - int status = InstallWizard().Run(); - if (status == IDCANCEL) { - return false; - } - - String supp = UpdaterCfg().globalsrc; - FindFile ff(ConfigFile("*.bm")); - if(!ff) { - ff.Search(AppendFileName(supp, "*.bm")); - while(ff) { - FileCopy(ff.GetPath(), ConfigFile(ff.GetName())); - ff.Next(); - } - } - // 2008/06/01 -- add valgrind suppression file - String ValgSupp = ConfigFile("valgrind.supp"); - if(IsNull(LoadFile(ValgSupp))) - SaveFile(ValgSupp, LoadFile(AppendFileName(supp, "uppsrc/ide/valgrind.supp"))); - // 2008/06/01 -- END + String out = GetHomeDirFile("out"); + String ass = GetConfigFolder(); + String myapps = GetHomeDirFile("MyApps"); + RealizeDirectory(out); + String uppsrc = GetHomeDirFile("uppsrc"); + + auto MakeAssembly = [&](String b, String name = Null) { + name = Nvl(name, GetFileTitle(b)); + String a = ass + '/' + name + ".var"; + if(name != "uppsrc") + b << ';' << uppsrc; + SaveFile(a, + "UPP = " + AsCString(b) + ";\r\n" + "OUTPUT = " + AsCString(out) + ";\r\n" + ); + LOG("Creating assembly " << a); + }; + + for(FindFile ff(GetHomeDirFile("*")); ff; ff.Next()) + if(ff.IsFolder()) { + String path = ff.GetPath(); + for(FindFile ff2(path + "/*"); ff2; ff2.Next()) { + String p = ff2.GetPath(); + if(FileExists(p + '/' + GetFileTitle(p) + ".upp")) + MakeAssembly(path); + } + } + + MakeAssembly(myapps); + uppsrc = GetHomeDirFile("bazaar") + ';' + uppsrc; + MakeAssembly(myapps, "MyApps-bazaar"); + String bm = ConfigFile("GCC.bm"); + if(IsNull(LoadFile(bm))) { + LOG("Creating GCC.bm"); + SaveFile(bm, gcc_bm); + } return true; } diff --git a/uppsrc/ide/SelectPkg.cpp b/uppsrc/ide/SelectPkg.cpp index 33e8042df..276eec68b 100644 --- a/uppsrc/ide/SelectPkg.cpp +++ b/uppsrc/ide/SelectPkg.cpp @@ -310,7 +310,7 @@ Vector SelectPackageDlg::GetSvnDirs() Vector dirs = SplitDirs(GetVar("UPP")); for(int i = 0; i < dirs.GetCount(); i++) { String d = NormalizePath(dirs[i]); - if(IsSvnDir(d)) + if(GetRepoKind(d)) r.Add(d); } return r; diff --git a/uppsrc/ide/SetupSVN.cpp b/uppsrc/ide/SetupSVN.cpp index b7004adc0..b1986045b 100644 --- a/uppsrc/ide/SetupSVN.cpp +++ b/uppsrc/ide/SetupSVN.cpp @@ -76,9 +76,9 @@ void SetupSVNTrunk() String ass = GetExeFolder(); String myapps = GetExeDirFile("MyApps"); #else - String out = GetHomeDirectoryFile("out"); + String out = GetHomeDirFile("out"); String ass = GetConfigFolder(); - String myapps = GetExeDirFile("MyApps"); + String myapps = GetHomeDirFile("MyApps"); #endif RealizeDirectory(out); diff --git a/uppsrc/ide/SrcUpdater/Install.cpp b/uppsrc/ide/SrcUpdater/Install.cpp deleted file mode 100644 index 99cbd5292..000000000 --- a/uppsrc/ide/SrcUpdater/Install.cpp +++ /dev/null @@ -1,378 +0,0 @@ -#include "SrcUpdater.h" - -#define IMAGECLASS IdeImg -#define IMAGEFILE -#include - -bool LoadVarFile(const char *name, VectorMap& _var); - -InstallWizard::InstallWizard() -{ - Title("TheIDE - Initial setting wizard"); - Sizeable(); - Icon(IdeImg::Package(), IdeImg::PackageLarge()); - - s0.text<<="[ [ [/ Welcome to TheIDE !]&][ &][ [1 This short wizard dialogue will help you to set up everything you need to get a full working Integrated Development Environment. Clicking ][/1 Finish][1 at any time will save the values to your hard disk (using default values for unfilled fields), while ][/1 Cancel][1 leaves this wizard without doing anything.]]"; - s1.text<<="[ [ [/ Source code handling methods]&][ &][ [1 There is several ways how to access the U`+`+ source codes. Choose the method that best suits your needs. You can always change the settings later if necessary.]]"; - s1.src<<=THISBACK(SrcChange); - bool usrshare = !UpdaterCfg().globalsrc.IsEmpty(); - if(usrshare) { - s1.src.EnableCase(0); - s1.src.EnableCase(1); - s1.src.SetLabel(0,"Local copy of sources from " + UpdaterCfg().globalsrc); - s1.src.SetLabel(1,"Read only sources in " + UpdaterCfg().globalsrc + " [recommended]"); - } else { - s1.src.SetLabel(0,"Local copy of sources [recommended]"); - s1.src.DisableCase(1); - } - bool hassvn = HasSvn(); - s1.src.EnableCase(2, hassvn); - - if (usrshare) { - s1.src = 1; - } - else { - s1.src = 0; - } - s1.unit.Add(1, "minute(s)") - .Add(60, "hour(s)") - .Add(1440, "day(s)") - .Add(10080,"week(s)"); - s1.unit.SetIndex(1); - int p=UpdaterCfg().period; - if(!IsNull(p)) { - if(p<=0) - s1.startup = true; - if(p!=0){ - if(p%10080==0) - s1.unit.SetIndex(3); - else if(p%1440==0) - s1.unit.SetIndex(2); - else if(p%60==0) - s1.unit.SetIndex(1); - else - s1.unit.SetIndex(0); - s1.period<<=abs(p)/int(~s1.unit); - } - } - SrcChange(); - - s2.text <<= - R"([ [ [/ SVN options]&][ &][ [1 Since you have chosen to use SVN working copy for assemblies, - you can now specify which server to use and what sychronization scheme you want to use. - Default server is the read only official Upp mirror, - but you can also use any other server (e.g. if you are a developer with commit rights) using the custom setup.]])"; - if(UpdaterCfg().svnserver==""||UpdaterCfg().svnserver=="http://upp-mirror.googlecode.com/svn/trunk/"){ - s2.server<<=0; - } else { - s2.server<<=1; - svndlg.readonly<<=UpdaterCfg().svnreadonly; - } - svndlg.url<<=UpdaterCfg().svnserver; - svndlg.usr<<=UpdaterCfg().svnuser; - svndlg.pwd<<=UpdaterCfg().svnpass; - svndlg.pwd.Password(true); - CtrlLayoutOK(svndlg,"Custom SVN repository"); - s2.server<<=THISBACK(RepoChange); - s2.svnsetup<<=THISBACK(RepoEdit); - s2.syncmethod<<=UpdaterCfg().sync; - RepoChange(); - s3.text <<= "[ [ [/ Set up assemblies]&][ &][ [1 You can choose which assemblies should be set up for you. Assembly is a set of directories (called nests) containing packages. You can find more about assemblies, nests and package managment in U`+`+ in the ][^http`:`/`/ultimatepp`.org`/app`$ide`$PackagesAssembliesAndNests`$en`-us`.html^1 manual][1 . To edit assemblies double-click or right`-click on them.]]"; - s3.srcpath <<= UpdaterCfg().localsrc; - s3.outpath <<= GetHomeDirFile(".upp/_out"); - s3.asmbls.AddColumn("Name"); - s3.asmbls.AddColumn("Paths"); - s3.asmbls.AddColumn("Output"); - s3.asmbls.AddColumn("Description"); - s3.asmbls.ColumnWidths("10 25 10 25"); - s3.asmbls.WhenBar = THISBACK(AsmMenu); - s3.asmbls.WhenLeftDouble = THISBACK(OnAsmEdit); - s3.restore<<=THISBACK(RestoreAsm); - RestoreAsm(); - s4.text<<="[ [/ Thank you ...]&&][ [1 That is all, thank you for your patience. Now just click ][/1 Finish][1 to save all the changes to your hard drive. TheIDE will now proceed to start up normaly.]&][> [/ &Happy coding with TheIDE! ]"; - WhenFinish=THISBACK(Perform); -} - -void InstallWizard::RestoreAsm() -{ - if(s1.src==1) - s3.srcpath <<= UpdaterCfg().globalsrc; - else if(UpdaterCfg().localsrc.StartsWith("/usr")) - s3.srcpath <<= GetHomeDirFile("upp"); - else - s3.srcpath<<=UpdaterCfg().localsrc; - s3.outpath<<=GetHomeDirFile(".upp/_out"); - s3.asmbls.Clear(); - - // we should explain new user what is inside the assemblies - static const char* desc[]={"", - "The \"heart\" of U++", - "Example applications", - "Simple reference examples", - "Sources of tutorial examples", - "Community contributed packages", - "U++ infrastructure (web, packaging)", - "Place for users own packages"}; - VectorMap map; - map.Add(~s3.srcpath,"$(SRC)"); - map.Add(~s3.outpath,"$(OUT)"); - for(FindFile ff(ConfigFile("*.var")); ff; ff.Next()) - if(ff.IsFile()){ - VectorMap var; - String name(ff.GetName()); - LoadVarFile(ConfigFile(name),var); - int upp=var.Find("UPP"); - int out=var.Find("OUTPUT"); - if(upp>=0&&out>=0){ - name=name.Left(name.GetCount()-4); - int d=0; - if(name=="uppsrc") {d=1;} - else if(name=="examples") {d=2;} - else if(name=="reference"){d=3;} - else if(name=="tutorial") {d=4;} - else if(name=="bazaar") {d=5;} - else if(name=="uppbox") {d=6;} - else if(name=="MyApps") {d=7;} - s3.asmbls.Add(name,ReplaceVars(var[upp],map),ReplaceVars(var[out],map),desc[d]); - } - } - if(s3.asmbls.Find("uppsrc",0)<0) - s3.asmbls.Add("uppsrc","$(SRC)/uppsrc","$(OUT)","The heart of U++"); - if(s3.asmbls.Find("examples",0)<0) - s3.asmbls.Add("examples","$(SRC)/examples;$(SRC)/uppsrc","$(OUT)","Example applications"); - if(s3.asmbls.Find("reference",0)<0) - s3.asmbls.Add("reference","$(SRC)/reference;$(SRC)/uppsrc","$(OUT)","Simple reference examples"); - if(s3.asmbls.Find("tutorial",0)<0) - s3.asmbls.Add("tutorial","$(SRC)/tutorial;$(SRC)/uppsrc","$(OUT)","Sources of tutorial examples"); - if(s3.asmbls.Find("bazaar",0)<0) - s3.asmbls.Add("bazaar","$(SRC)/bazaar;$(SRC)/uppsrc","$(OUT)","Community contributed packages"); - if(s3.asmbls.Find("uppbox",0)<0 && s1.src==2) - s3.asmbls.Add("uppbox","$(SRC)/uppbox;$(SRC)/uppsrc","$(OUT)","U++ infrastructure (web, packaging)"); - if(s3.asmbls.Find("MyApps",0)<0) - s3.asmbls.Add("MyApps",GetHomeDirFile("MyApps")+";$(SRC)/uppsrc","$(OUT)","Place for users own packages"); -} - -void InstallWizard::AsmMenu(Bar& bar) -{ - bar.Add("New assembly..", THISBACK(OnAsmAdd)) - .Key(K_INSERT); - bar.Add(s3.asmbls.IsCursor(), "Edit assembly..", THISBACK(OnAsmEdit)) - .Key(K_CTRL_ENTER); - bar.Add(s3.asmbls.IsCursor(), "Remove assembly", THISBACK(OnAsmRemove)) - .Key(K_CTRL_DELETE); -} - -void InstallWizard::OnAsmAdd(){ - WithAsmSetupLayout dlg; - CtrlLayoutOKCancel(dlg,"Assembly setup"); - if(s3.asmbls.IsCursor()){ - dlg.base <<=s3.asmbls.Get(0); - dlg.upp <<=s3.asmbls.Get(1); - dlg.output<<=s3.asmbls.Get(2); - } - if(dlg.Run()==IDOK) { - s3.asmbls.Add(~dlg.base,~dlg.upp,~dlg.output); - } -} - -void InstallWizard::OnAsmEdit(){ - if(!s3.asmbls.IsCursor()) - return; - WithAsmSetupLayout dlg; - CtrlLayoutOKCancel(dlg,"Assembly setup"); - dlg.base <<=s3.asmbls.Get(0); - dlg.upp <<=s3.asmbls.Get(1); - dlg.output<<=s3.asmbls.Get(2); - if(dlg.Run()==IDOK) { - s3.asmbls.Set(0,~dlg.base); - s3.asmbls.Set(1,~dlg.upp); - s3.asmbls.Set(2,~dlg.output); - } -} - -void InstallWizard::OnAsmRemove() -{ - int c = s3.asmbls.GetCursor(); - if(c < 0) return; - s3.asmbls.Remove(c); -} - -void InstallWizard::SrcChange() -{ - int s=s1.src; - - bool check = s == 2; - s1.period.Enable(check); - s1.unit.Enable(check); - s1.startup.Enable(check); - - int i=s3.asmbls.Find("uppbox",0); - if(s==2 && i<0) { - s3.asmbls.Add("uppbox","$(SRC)/uppbox;$(SRC)/uppsrc","$(OUT)","U++ infrastructure (web, packaging)"); - } - if(s!=2 && i>=0 && s3.asmbls.Get(i,1) == "$(SRC)/uppbox;$(SRC)/uppsrc" && !FileExists(ConfigFile("uppbox.var"))) { - s3.asmbls.Remove(i); - } - - Block(2,(s!=2)); //block 2 unless svn - Block(3,(s==3)); //block 3 if no repositories - - if(s==1){ - s3.srcpath.Disable(); - s3.srcpath<<=UpdaterCfg().globalsrc; - } else { - s3.srcpath.Enable(); - if(UpdaterCfg().localsrc == UpdaterCfg().globalsrc) - s3.srcpath <<= GetHomeDirFile("upp"); - else - s3.srcpath <<= UpdaterCfg().localsrc; - } -} - -void InstallWizard::RepoChange() -{ - s2.svnsetup.Enable(s2.server==1); -} - -void InstallWizard::RepoEdit() -{ - svndlg.ExecuteOK(); -} - -String InstallWizard::ReplaceVars(String str,const VectorMap& vars) -{ - String tmp; - int o,p; - for(int i=0;i=0){ - tmp+=str.Mid(o,p-o)+vars[i]; - o=p+strlen(var); - p=str.Find(var,o); - } - str=tmp+str.Mid(o); - tmp=""; - } - return str; -} - -void InstallWizard::Perform() -{ - Progress progress; - progress.AlignText(LEFT); - progress.Title("Installation"); - UpdaterCfg().method=s1.src; - UpdaterCfg().sync=s2.syncmethod; - if(!IsNull(~s1.period)){ - UpdaterCfg().period=s1.period * int(~s1.unit) * (bool(s1.startup)?-1:1); - }else{ - UpdaterCfg().period=bool(s1.startup)?0:int(Null); - } - UpdaterCfg().localsrc = ~s3.srcpath; - if(s2.server==0) { - //defualt SVN server - UpdaterCfg().svnserver="svn://www.ultimatepp.org/upp/trunk/"; - UpdaterCfg().svnuser=""; - UpdaterCfg().svnpass=""; - UpdaterCfg().svnreadonly=true; - } else { - //custom SVN server - UpdaterCfg().svnserver=~svndlg.url; - UpdaterCfg().svnuser=~svndlg.usr; - UpdaterCfg().svnpass=~svndlg.pwd; - UpdaterCfg().svnreadonly=~svndlg.readonly; - } - switch(UpdaterCfg().method) { - case 0:{ - // local copy of files from /usr/share/upp - progress.SetText("Copying files ..."); - if(!CopyFolder(UpdaterCfg().localsrc, UpdaterCfg().globalsrc, &progress)){ - Exclamation(DeQtf("Failed to copy "+UpdaterCfg().globalsrc+" to "+UpdaterCfg().localsrc)); - } - FindFile ff(AppendFileName(UpdaterCfg().globalsrc, "*.bm")); - while (ff) { - DeleteFile(AppendFileName(UpdaterCfg().localsrc, ff.GetName())); - ff.Next(); - } - break; - } - case 1:{ - // read-only repos in /usr/share/upp - UpdaterCfg().localsrc=UpdaterCfg().globalsrc; - break; - } - case 2: { - // SVN assemblies - progress.SetText("Downloading sources from svn (This may take a while) ..."); - String cmd="svn checkout --non-interactive --force "; - if(!UpdaterCfg().svnuser.IsEmpty()){cmd+="--username \""+UpdaterCfg().svnuser+"\" ";} - if(!UpdaterCfg().svnpass.IsEmpty()){cmd+="--password \""+UpdaterCfg().svnpass+"\" ";} - cmd+=String(~svndlg.url); - if(UpdaterCfg().sync==1){cmd+="@"+IntStr(ScanInt(IDE_VERSION));} - cmd+=" "+String(~s3.srcpath); - LocalProcess svn(cmd); - int count=0; - while(svn.IsRunning()){ - progress.Step(); - Sleep(50); - //we better assure user that something is happening, downloading all the files is rather long... - String out=svn.Get(); - int i=out.Find('\n',0); - while(i>0){ - i=out.Find('\n',i+1); - count++; - } - progress.SetText(Format("%i files downloaded",count)); - } - String err; - SaveFile(AppendFileName(~s3.srcpath,"uppsrc/ide/version.h"),"#define IDE_VERSION \""+GetSvnVersion(UpdaterCfg().localsrc,false,err)+"\"\n"); - break; - } - case 3: - //no assemblies - return; - } - for(int i=0;i map; - map.Add("$(SRC)",~s3.srcpath); - map.Add("$(OUT)",~s3.outpath); - String cfg="UPP = " + AsCString(ReplaceVars(s3.asmbls.Get(i,1),map)) + "\n"; - cfg+="OUTPUT = " + AsCString(ReplaceVars(s3.asmbls.Get(i,2),map)); - SaveFile(ConfigFile(AsString(s3.asmbls.Get(i,0))+".var"),cfg); - } - - Vector deleted; - for(FindFile ff(ConfigFile("*.var")); ff; ff.Next()) - if(ff.IsFile()){ - String name=ff.GetName(); - name=name.Left(name.GetCount()-4); - if(s3.asmbls.Find(name)<0) - deleted.Add(ConfigFile(name+".var")); - } - String list; - for(int i = 0; i < deleted.GetCount(); i++){ - list<<'&'<& dest,int c, Progress& p){ - p.Title("Calculating hashes ..."); - p.SetText(dir); - FindFile ff(AppendFileName(dir,"*")); - for(; ff; ff.Next()){ - String path=AppendFileName(dir,ff.GetName()); - if(ff.IsFile()) { - p.Step(); - dest.GetAdd(path.Mid(prefix)).a[c]=CRC32(LoadFile(path)); - } else if(ff.IsFolder()){ - p.SetText(path); - GetFiles(path,prefix,dest,c,p); - } - } -} - -void LoadHashes(const String& fn,VectorMap& dest, int c, Progress& p){ - p.Title("Loading hashes ..."); - FileIn f(fn); - for(int i=0;i& src, int c){ - FileOut f(fn); - for(int i=0;i=list.GetCount() || row<0) return; - row = list.Get(row,4); - if(row<0) return; - String file = files.GetKey(row); - - for(int j=0; j& cs = s.GetCases(); - s<<=cs[action].value; - } - } - list.ScrollInto(row); -} - -void LocalSync::Manage(){ - TopWindow dlg; - dlg.Title("Ignored files"); - LineEdit edit; - edit <<= Join(UpdaterCfg().ignores,"\n"); - dlg.Add(edit.SizePos()); - dlg.Sizeable().Run(true); - UpdaterCfg().ignores = Split(AsString(~edit),"\n"); - Populate(files); -} - -class ShowFileDlg:public TopWindow{ - TextDiffCtrl diff; - LineEdit plain; -public: - ShowFileDlg(const String& local,const String& global){ - diff.Set(LoadFile(local),LoadFile(global)); - Add(diff.SizePos()); - Title(local+" vs. "+global); - } - ShowFileDlg(const String& file){ - plain.SetData(LoadFile(file)); - Add(plain.SizePos()); - Title(file); - } -}; - -void LocalSync::DoShowFile(const String& l, const String& g){ - if(l.IsEmpty()&&g.IsEmpty()) - Remove(); - else if(!(l.IsEmpty()||g.IsEmpty())) - ShowFileDlg(l,g).Execute(); - else - ShowFileDlg(l+g).Execute(); -} - -void LocalSync::ShowFile(){ - int i = list.GetClickRow(); - if(i >= 0) btns[i].WhenAction(); -} - -void LocalSync::Perform(){ - SaveHashes(ConfigFile("hashes.crc"),files,NEW); - if(list.Get(0,0)=="") return; - for(int i = 0; i < list.GetCount(); i++){ - int n = list.Get(i,4); - ASSERT(n>=0); - String file = files.GetKey(n); - switch(switches[i]){ - case FA_INSTALL: //incoming update - case FA_ADD: //added to upstream - case FA_REVERT: //local change or deletion - { - String orig=AppendFileName(globalsrc,file); - file=AppendFileName(localsrc,file); - if(!RealizePath(file)) - Exclamation("Could not create directory "+GetFileDirectory(file)+"."); - if(!FileCopy(orig,file)) - Exclamation("Could not copy file "+orig+" to "+file+"."); - break; - } - case FA_DELETE: //file not present in upstream - { - file=AppendFileName(localsrc,file); - if(!FileDelete(file)) - Exclamation("Could not delete file "+file+"."); - break; - } - case FA_SKIP: - case FA_KEEP:{} //do nothing - } - } -} - -void LocalSync::Populate(const VectorMap& files){ - int r = 0; - for(int i=0; i ignores(UpdaterCfg().ignores, 0); - bool ignore = false; - ignores.Add("uppsrc/ide/version.h"); - ignores.Add("*.bm"); - for(int j=0; j=0) - list.Remove(pos); - continue; - } - if(pos>=0){ - r++; - continue; - } - dword u = files[i].a[USER]; - dword o = files[i].a[ORIG]; - dword n = files[i].a[NEW]; - bool ue = FileExists(AppendFileName(localsrc, files.GetKey(i))); - bool oe = o!=0; - bool ne = FileExists(AppendFileName(globalsrc, files.GetKey(i))); - FileState state; - if(!(oe&&ue&&ne)){ - if(oe&&ne){ - if(o==n) state(FA_SKIP|FA_REVERT,"Local copy deleted", LtRed(),1); - else state(FA_SKIP|FA_INSTALL,"Local copy deleted & incoming update", LtRed(),1); - }else if(oe&&ue){ - if(o==u) state(FA_SKIP|FA_DELETE,"Upstream deleted",Red(),1); - else state(FA_KEEP|FA_DELETE,"Local change & upstream deleted",Magenta(),1); - }else if(ue&&ne){ - if(u==n) state(FA_NOOP,"",Null,0); //Local and upstream added - else state(FA_KEEP|FA_INSTALL,"Local and upstream added (different)",Magenta(),0); - }else if(ue) - state(FA_KEEP|FA_DELETE,"Local added",Green(),1); - else if(ne) - state(FA_SKIP|FA_ADD,"Upstream added",LtGreen(),1); - else if(oe) - state(FA_NOOP,"",Null,0); //Local and upstream deleted - }else{ - if(u==n){ - // u==n==o -> unchanged - // u==n!=o -> user updated manualy - state(FA_NOOP,"",Null,0); - }else{ - if(u==o) - state(FA_SKIP|FA_INSTALL,"Incomming update",LtBlue(),0); - else if(n==o) - state(FA_KEEP|FA_REVERT,"Local change",Blue(),0); - else // if(o!=n) - state(FA_KEEP|FA_INSTALL,"Local change & incoming update",LtBlue(),0); - } - } - if(state.n!=FA_NOOP){ - Switch& s = switches.Add(); - Button& b = btns.Add(); - int sel=0xffff; - #define _ACTION(FA,LBL) if(state.n&FA){ s.Add(FA,LBL); sel=min(sel,int(FA)); } - _ACTION(FA_SKIP,"Skip"); - _ACTION(FA_KEEP,"Keep"); - _ACTION(FA_REVERT,"Revert"); - _ACTION(FA_INSTALL,"Install new"); - _ACTION(FA_ADD,"Add"); - _ACTION(FA_DELETE,"Delete"); - #undef _ACTION - b.SetLabel("Examine"); - b <<= THISBACK2(DoShowFile, - ue?AppendFileName(localsrc,files.GetKey(i)):"", - ne?AppendFileName(globalsrc,files.GetKey(i)):""); - list.Insert(r); - list.Set(r,0,state.desc); - list.Set(r,1,sel); - list.SetCtrl(r, 1, s.NoWantFocus()); - list.Set(r,2,AttrText(files.GetKey(i)).Ink(state.c).SetFont(state.f)); - list.SetCtrl(r, 3, b.NoWantFocus()); - list.Set(r,4,i); - r++; - } - } - if(r==0){ - list.Add("", Null, AttrText("No changes in the installed nests").SetFont(StdFont().Italic()),Null,Null); - } - list.ScrollInto(row); -} diff --git a/uppsrc/ide/SrcUpdater/SrcUpdater.h b/uppsrc/ide/SrcUpdater/SrcUpdater.h deleted file mode 100644 index 7c487376d..000000000 --- a/uppsrc/ide/SrcUpdater/SrcUpdater.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef _SourceUpdater_SourceUpdater_h -#define _SourceUpdater_SourceUpdater_h - -#include "Wizard.h" -#include -#include -#include - -#if !defined(PLATFORM_POSIX) && !defined(flagWIN32) -#error Updater is only implemented for POSIX compliant platforms -#endif - -#define LAYOUTFILE -#include - -struct UpdaterConfig -{ - int method,sync,ignored,period; - String localsrc,globalsrc; - String svnserver,svnuser,svnpass; - Time last; - Vector ignores; - bool svnreadonly,available; - void Xmlize(XmlIO xml){ - xml("Method",method) - ("Synchronization",sync) - ("CheckPeriod",period) - ("LastCheck",last) - ("Ignored",ignored) - ("LocalSource",localsrc) - ("GlobalSource",globalsrc) - ("IgnoredFiles",ignores) - ("SVN",svnserver) - ("SVNUser",svnuser) - ("SVNPassword",svnpass) - ("SVNReadonly",svnreadonly); - } -}; - -UpdaterConfig& UpdaterCfg(); - -void Uninstall(); -String FindGlobalSrc(); -void LoadUpdaterCfg(); -String GetSvnVersion(const String& server,bool verbose,String& error); -String GetSrcVersion(const char* dir,String& error); - -typedef Wizard, - WithSourceLayout, - WithSvnLayout, - WithAssembliesLayout, - WithTextOnlyLayout - > SrcWiz; - -class InstallWizard : public SrcWiz { - typedef InstallWizard CLASSNAME; - -public: - WithCustomSvnLayout svndlg; - InstallWizard(); - -private: - void SrcChange(); - void RepoChange(); - void RepoEdit(); - void Perform(); - void AsmMenu(Bar& bar); - void OnAsmAdd(); - void OnAsmEdit(); - void OnAsmRemove(); - void RestoreAsm(); - - String ReplaceVars(String str,const VectorMap& vars); - -private: - String src; - String out; -}; - -//storage and access to triplets of crc hashes (in moveable struct) -struct synchashes{ - dword a[3]; - synchashes(){a[0]=a[1]=a[2]=0;} -}; -inline void AssertMoveable0(synchashes*){}; - -struct LocalSync : WithSvnSyncLayout { - String localsrc,globalsrc; - Array switches; - Array