From f75271f6693463ecafffbde8a329d349a66f9873 Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 30 Jul 2011 14:39:57 +0000 Subject: [PATCH] .devloping umake git-svn-id: svn://ultimatepp.org/upp/trunk@3717 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/IconDes/Bar.cpp | 2 + uppsrc/IconDes/IconDes.h | 1 + uppsrc/IconDes/List.cpp | 10 + uppsrc/PostgreSQL/PostgreSQLSchema.h | 10 + uppsrc/ide/Builders/Builders.upp | 10 +- .../{GccBuilder.cpp => GccBuilder.icpp} | 978 +++++++------- .../{JavaBuilder.cpp => JavaBuilder.icpp} | 630 ++++----- .../{MscBuilder.cpp => MscBuilder.icpp} | 1132 ++++++++--------- .../{OwcBuilder.cpp => OwcBuilder.icpp} | 2 +- .../{ScriptBuilder.cpp => ScriptBuilder.icpp} | 686 +++++----- uppsrc/ide/Builders/init | 15 + uppsrc/ide/Core/Core.upp | 3 +- uppsrc/ide/Core/init | 1 + uppsrc/ide/Insert.cpp | 2 +- uppsrc/ide/idewin.cpp | 6 - 15 files changed, 1761 insertions(+), 1727 deletions(-) rename uppsrc/ide/Builders/{GccBuilder.cpp => GccBuilder.icpp} (96%) rename uppsrc/ide/Builders/{JavaBuilder.cpp => JavaBuilder.icpp} (96%) rename uppsrc/ide/Builders/{MscBuilder.cpp => MscBuilder.icpp} (96%) rename uppsrc/ide/Builders/{OwcBuilder.cpp => OwcBuilder.icpp} (95%) rename uppsrc/ide/Builders/{ScriptBuilder.cpp => ScriptBuilder.icpp} (96%) diff --git a/uppsrc/IconDes/Bar.cpp b/uppsrc/IconDes/Bar.cpp index f4de4fb45..bd1232631 100644 --- a/uppsrc/IconDes/Bar.cpp +++ b/uppsrc/IconDes/Bar.cpp @@ -20,6 +20,8 @@ bool IconDes::Key(dword key, int count) case K_SHIFT_RIGHT: KeyMove(1, 0); return true; case K_SHIFT_UP: KeyMove(0, -1); return true; case K_SHIFT_DOWN: KeyMove(0, 1); return true; + case K_PAGEUP: ChangeSlot(-1); return true; + case K_PAGEDOWN: ChangeSlot(1); return true; } return false; } diff --git a/uppsrc/IconDes/IconDes.h b/uppsrc/IconDes/IconDes.h index e6d4b507b..93af86f6f 100644 --- a/uppsrc/IconDes/IconDes.h +++ b/uppsrc/IconDes/IconDes.h @@ -274,6 +274,7 @@ private: void InsertPaste(); void InsertFile(); void MoveSlot(int d); + void ChangeSlot(int d); static FileSel& ImgFile(); diff --git a/uppsrc/IconDes/List.cpp b/uppsrc/IconDes/List.cpp index 077cda695..22b892549 100644 --- a/uppsrc/IconDes/List.cpp +++ b/uppsrc/IconDes/List.cpp @@ -255,6 +255,16 @@ void IconDes::MoveSlot(int d) } } +void IconDes::ChangeSlot(int d) +{ + if(!IsCurrent()) + return; + int c = list.GetCursor(); + d = c + d; + if(d >= 0 && d < slot.GetCount()) + list.SetCursor(d); +} + void IconDes::ListMenu(Bar& bar) { using namespace IconDesKeys; diff --git a/uppsrc/PostgreSQL/PostgreSQLSchema.h b/uppsrc/PostgreSQL/PostgreSQLSchema.h index 899c0cad4..161ff44c2 100644 --- a/uppsrc/PostgreSQL/PostgreSQLSchema.h +++ b/uppsrc/PostgreSQL/PostgreSQLSchema.h @@ -43,6 +43,11 @@ #define TIME_(x) COLUMN_("timestamp", Time, x, 0, 0) #define TIME_ARRAY_(x, items) COLUMN_ARRAY_("timestamp", Time, x, 0, 0, items) +#define TIME_SEC(x) COLUMN("timestamp(0)", Time, x, 0, 0) +#define TIME_SEC_ARRAY(x, items) COLUMN_ARRAY("timestamp(0)", Time, x, 0, 0, items) +#define TIME_SEC_(x) COLUMN_("timestamp(0)", Time, x, 0, 0) +#define TIME_SEC_ARRAY_(x, items) COLUMN_ARRAY_("timestamp(0)", Time, x, 0, 0, items) + #define BOOL(x) COLUMN("char(1)", bool, x, 0, 0) #define BOOL_ARRAY(x, items) COLUMN_ARRAY("char(1)", bool, x, 0, 0, items) #define BOOL_(x) COLUMN_("char(1)", bool, x, 0, 0) @@ -164,6 +169,11 @@ ATTRIBUTE("alter table @t add constraint UQ_@t$" #name " unique (" list ");", \ #undef TIME_ #undef TIME_ARRAY_ +#undef TIME_SEC +#undef TIME_SEC_ARRAY +#undef TIME_SEC_ +#undef TIME_SEC_ARRAY_ + #undef BOOL #undef BOOL_ARRAY #undef BOOL_ diff --git a/uppsrc/ide/Builders/Builders.upp b/uppsrc/ide/Builders/Builders.upp index dafd650de..0d96c9f20 100644 --- a/uppsrc/ide/Builders/Builders.upp +++ b/uppsrc/ide/Builders/Builders.upp @@ -10,11 +10,11 @@ file Builders.h, CppBuilder.cpp, MakeFile.cpp, - GccBuilder.cpp, - MscBuilder.cpp, - OwcBuilder.cpp, - JavaBuilder.cpp, - ScriptBuilder.cpp, + GccBuilder.icpp, + MscBuilder.icpp, + OwcBuilder.icpp, + JavaBuilder.icpp, + ScriptBuilder.icpp, Info readonly separator, Build.h, Build.cpp, diff --git a/uppsrc/ide/Builders/GccBuilder.cpp b/uppsrc/ide/Builders/GccBuilder.icpp similarity index 96% rename from uppsrc/ide/Builders/GccBuilder.cpp rename to uppsrc/ide/Builders/GccBuilder.icpp index 020df94b2..c53548691 100644 --- a/uppsrc/ide/Builders/GccBuilder.cpp +++ b/uppsrc/ide/Builders/GccBuilder.icpp @@ -1,489 +1,489 @@ -#include "Builders.h" - -#include -#include - -void GccBuilder::AddFlags(Index& cfg) -{ -} - -String GccBuilder::CompilerName() const -{ - if(!IsNull(compiler)) return compiler; - return HasFlag("GCC_ARM") ? "arm-wince-pe-c++" : "c++"; -} - -String GccBuilder::CmdLine(const String& package, const Package& pkg) -{ - String cc = CompilerName(); - cc << " -c "; - cc << IncludesDefinesTargetTime(package, pkg); - if(HasFlag("GCC32")) - cc << " -m32"; - return cc; -} - -void GccBuilder::BinaryToObject(String objfile, CParser& binscript, String basedir, - const String& package, const Package& pkg) -{ - BinObjInfo info; - info.Parse(binscript, basedir); - String fo; - for(int i = 0; i < info.blocks.GetCount(); i++) { - String ident = info.blocks.GetKey(i); - ArrayMap& belem = info.blocks[i]; - if(belem[0].flags & (BinObjInfo::Block::FLG_ARRAY | BinObjInfo::Block::FLG_MASK)) { - int count = Max(belem.GetKeys()) + 1; - Vector blockref; - blockref.SetCount(count, 0); - for(int a = 0; a < belem.GetCount(); a++) { - BinObjInfo::Block& b = belem[a]; - blockref[b.index] = &b; - } - for(int i = 0; i < blockref.GetCount(); i++) - if(blockref[i]) { - BinObjInfo::Block& b = *blockref[i]; - fo << "static char " << ident << "_" << i << "[] =\n"; - String data = ::LoadFile(b.file); - if(data.IsVoid()) - throw Exc(NFormat("Error reading file '%s'", b.file)); - if(data.GetLength() != b.length) - throw Exc(NFormat("length of file '%s' changed (%d -> %d) during object creation", - b.file, b.length, data.GetLength())); - switch(b.encoding) { - case BinObjInfo::Block::ENC_BZ2: data = BZ2Compress(data); break; - case BinObjInfo::Block::ENC_ZIP: data = ZCompress(data); break; - } - b.length = data.GetLength(); - data.Cat('\0'); - fo << AsCString(data, 70) << ";\n\n"; - } - - fo << "int " << ident << "_count = " << blockref.GetCount() << ";\n\n" - "int " << ident << "_length[] = {\n"; - for(int i = 0; i < blockref.GetCount(); i++) - fo << '\t' << (blockref[i] ? blockref[i]->length : -1) << ",\n"; - fo << "};\n\n" - "char *" << ident << "[] = {\n"; - for(int i = 0; i < blockref.GetCount(); i++) - if(blockref[i]) - fo << '\t' << ident << '_' << i << ",\n"; - else - fo << "\t0,\n"; - fo << "};\n\n"; - if(belem[0].flags & BinObjInfo::Block::FLG_MASK) { - fo << "char *" << ident << "_files[] = {\n"; - for(int i = 0; i < blockref.GetCount(); i++) - fo << '\t' << AsCString(blockref[i] ? GetFileName(blockref[i]->file) : String(Null)) << ",\n"; - fo << "};\n\n"; - } - } - else { - BinObjInfo::Block& b = belem[0]; - fo << "char *" << ident << " =\n"; - String data = ::LoadFile(b.file); - if(data.IsVoid()) - throw Exc(NFormat("Error reading file '%s'", b.file)); - if(data.GetLength() != b.length) - throw Exc(NFormat("length of file '%s' changed (%d -> %d) during object creation", - b.file, b.length, data.GetLength())); - switch(b.encoding) { - case BinObjInfo::Block::ENC_BZ2: data = BZ2Compress(data); break; - case BinObjInfo::Block::ENC_ZIP: data = ZCompress(data); break; - } - int b_length = data.GetLength(); - data.Cat('\0'); - fo << AsCString(data, 70) << ";\n\n" - "int " << ident << "_length = " << b_length << ";\n\n"; - } - } - - String tmpfile = ForceExt(objfile, ".c"); - SaveFile(tmpfile, fo); - String cc = CmdLine(package, pkg); - cc << " -c -o " << GetHostPathQ(objfile) << " -x c " << GetHostPathQ(tmpfile); - int slot = AllocSlot(); - if(slot < 0 || !Run(cc, slot, objfile, 1)) - throw Exc(NFormat("Error compiling binary object '%s'.", objfile)); -} - -bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, - String& linkoptions, const Vector& all_uses, const Vector& all_libraries, - int opt) -{ - int i; - String packagepath = PackagePath(package); - Package pkg; - pkg.Load(packagepath); - String packagedir = GetFileFolder(packagepath); - ChDir(packagedir); - PutVerbose("cd " + packagedir); - IdeConsoleBeginGroup(package); - Vector obj; - - bool is_shared = HasFlag("SO"); - String shared_ext = (HasFlag("WIN32") ? ".dll" : ".so"); - - String cc = CmdLine(package, pkg); - if(HasFlag("WIN32") && HasFlag("MT")) - cc << " -mthreads"; - if(HasFlag("DEBUG_MINIMAL")) - cc << (HasFlag("WIN32") ? " -g1" : " -ggdb -g1"); - if(HasFlag("DEBUG_FULL")) - cc << (HasFlag("WIN32") ? " -g2" : " -ggdb -g2"); - String fuse_cxa_atexit; - if(is_shared /*&& !HasFlag("MAIN")*/) { - cc << " -shared -fPIC"; - fuse_cxa_atexit = " -fuse-cxa-atexit"; - } - if(!HasFlag("SHARED") && !is_shared) - cc << " -static "; -// else if(!HasFlag("WIN32")) // TRC 05/03/08: dynamic fPIC doesn't seem to work in MinGW -// cc << " -dynamic -fPIC "; // TRC 05/03/30: dynamic fPIC doesn't seem to work in GCC either :-) - cc << ' ' << Gather(pkg.option, config.GetKeys()); - cc << " -fexceptions "; - - if (HasFlag("OSX11")) { - if (HasFlag("POWERPC")) - cc << " -arch ppc"; - if (HasFlag("X86")) - cc << " -arch i386"; - } - - if(HasFlag("SSE2")) - cc << " -msse2 -mfpmath=sse"; - - String cc_speed = cc; - bool release = false; - - if(HasFlag("DEBUG")) - cc << " -D_DEBUG " << debug_options; - else { - release = true; - cc << ' ' << release_size_options; - cc_speed << ' ' << release_options; - if(opt == R_SPEED || pkg.optimize_speed) - cc = cc_speed; - } - - Vector sfile, isfile; - Vector soptions, isoptions; - Vector optimize, ioptimize; - bool error = false; - - for(i = 0; i < pkg.GetCount(); i++) { - if(!IdeIsBuilding()) - return false; - if(!pkg[i].separator) { - String gop = Gather(pkg[i].option, config.GetKeys()); - Vector srcfile = CustomStep(SourcePath(package, pkg[i])); - if(srcfile.GetCount() == 0) - error = true; - for(int j = 0; j < srcfile.GetCount(); j++) { - String fn = srcfile[j]; - String ext = ToLower(GetFileExt(fn)); - if(ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" - || ext == ".s" || ext == ".S" - || ext == ".brc" || (ext == ".rc" && HasFlag("WIN32"))) { - sfile.Add(fn); - soptions.Add(gop); - optimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); - } - else - if(ext == ".icpp") { - isfile.Add(fn); - isoptions.Add(gop); - ioptimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); - } - else - if(ext == ".o") - obj.Add(fn); - else - if(ext == ".a" || ext == ".so") - linkfile.Add(fn); - } - } - } - - if(HasFlag("BLITZ")) { - Blitz b = BlitzStep(sfile, soptions, obj, ".o", optimize); - if(b.build) { - PutConsole("BLITZ:" + b.info); - int slot = AllocSlot(); - if(slot < 0 || !Run(String().Cat() << cc << ' ' - << GetHostPathQ(b.path) << " -o " << GetHostPathQ(b.object), slot, GetHostPath(b.object), b.count)) - error = true; - } - } - - int first_ifile = sfile.GetCount(); - sfile.AppendPick(isfile); - soptions.AppendPick(isoptions); - optimize.AppendPick(ioptimize); - - int ccount = 0; - for(i = 0; i < sfile.GetCount(); i++) { - if(!IdeIsBuilding()) - return false; - String fn = sfile[i]; - String ext = ToLower(GetFileExt(fn)); - bool rc = (ext == ".rc"); - bool brc = (ext == ".brc"); - bool init = (i >= first_ifile); - String objfile = CatAnyPath(outdir, GetFileTitle(fn) + (rc ? "$rc.o" : brc ? "$brc.o" : ".o")); - if(HdependFileTime(fn) > GetFileTime(GetHostPath(objfile))) { - PutConsole(GetFileName(fn)); - int time = GetTickCount(); - bool execerr = false; - if(rc) { - String exec; - exec << "windres -i " << GetHostPathQ(fn) - << " -o " << GetHostPathQ(objfile) << IncludesShort(" --include-dir=", package, pkg); - PutVerbose(exec); - int slot = AllocSlot(); - execerr = (slot < 0 || !Run(exec, slot, GetHostPath(objfile), 1)); - } - else if(brc) { - try { -// String hfn = GetHostPath(fn); - String brcdata = LoadFile(fn); - if(brcdata.IsVoid()) - throw Exc(NFormat("error reading file '%s'", fn)); - CParser parser(brcdata, fn); - BinaryToObject(GetHostPath(objfile), parser, GetFileDirectory(fn), package, pkg); - } - catch(Exc e) { - PutConsole(e); - execerr = true; - } - } - else { - String exec = optimize[i] ? cc_speed : cc; - if(ext == ".c") - exec << " -x c "; - else if(ext == ".s" || ext == ".S") - exec << " -x assembler-with-cpp "; - else - exec << fuse_cxa_atexit << " -x c++ "; - exec << GetHostPathQ(fn) << " -o " << GetHostPathQ(objfile); - PutVerbose(exec); - int slot = AllocSlot(); - execerr = (slot < 0 || !Run(exec, slot, GetHostPath(objfile), 1)); - } - if(execerr) - DeleteFile(objfile); - error |= execerr; - PutVerbose("compiled in " + GetPrintTime(time)); - ccount++; - } - if(init) - linkfile.Add(objfile); - else - obj.Add(objfile); - } - - if(error) { -// if(ccount) -// PutCompileTime(time, ccount); - IdeConsoleEndGroup(); - return false; - } - - linkoptions << Gather(pkg.link, config.GetKeys()); - if(linkoptions.GetCount()) - linkoptions << ' '; - - Vector libs = Split(Gather(pkg.library, config.GetKeys()), ' '); - linkfile.Append(libs); - - int libtime = GetTickCount(); - if(!HasFlag("MAIN")) { - if(HasFlag("BLITZ") || HasFlag("NOLIB")) { - linkfile.Append(obj); - IdeConsoleEndGroup(); -// if(ccount) -// PutCompileTime(time, ccount); - return true; - } - IdeConsoleEndGroup(); - if(!Wait()) - return false; - String product; - if(is_shared) - product = GetSharedLibPath(package); - else - product = CatAnyPath(outdir, GetAnyFileName(package) + ".a"); - String hproduct = GetHostPath(product); - Time producttime = GetFileTime(hproduct); -// LOG("hproduct = " << hproduct << ", time = " << producttime); - linkfile.Add(GetHostPath(product)); - for(int i = 0; i < obj.GetCount(); i++) - if(GetFileTime(obj[i]) > producttime) { - String lib; - if(is_shared) { - lib = CompilerName(); - lib << " -shared -fPIC -fuse-cxa-atexit"; - if(!HasFlag("SHARED") && !is_shared) - lib << " -static"; -// else if(!HasFlag("WIN32")) // TRC 05/03/08: dynamic fPIC causes trouble in MinGW -// lib << " -dynamic -fPIC"; // TRC 05/03/30: dynamic fPIC doesn't seem to work in GCC either :-) - if(HasFlag("GCC32")) - lib << " -m32"; - Point p = ExtractVersion(); - if(!IsNull(p.x)) { - lib << " -Xlinker --major-image-version -Xlinker " << p.x; - if(!IsNull(p.y)) - lib << " -Xlinker --minor-image-version -Xlinker " << p.y; - } - lib << ' ' << Gather(pkg.link, config.GetKeys()); - lib << " -o "; - } - else - lib = "ar -sr "; - lib << GetHostPathQ(product); - for(int i = 0; i < obj.GetCount(); i++) - lib << ' ' << GetHostPathQ(obj[i]); - PutConsole("Creating library..."); - DeleteFile(hproduct); - if(is_shared) { - for(int i = 0; i < libpath.GetCount(); i++) - lib << " -L" << GetHostPathQ(libpath[i]); - for(int i = 0; i < all_uses.GetCount(); i++) - lib << ' ' << GetHostPathQ(GetSharedLibPath(all_uses[i])); - for(int i = 0; i < all_libraries.GetCount(); i++) - lib << " -l" << GetHostPathQ(all_libraries[i]); - } - if(!Execute(lib) == 0) { - DeleteFile(hproduct); - return false; - } - PutConsole(String().Cat() << hproduct << " (" << GetFileInfo(hproduct).length - << " B) created in " << GetPrintTime(libtime)); - break; - } - return true; - } - - IdeConsoleEndGroup(); - obj.Append(linkfile); - linkfile = obj; - return true; -} - - -bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, bool createmap) -{ - if(!Wait()) - return false; - int time = GetTickCount(); - for(int i = 0; i < linkfile.GetCount(); i++) - if(GetFileTime(linkfile[i]) >= targettime) { - Vector lib; - String lnk = CompilerName(); - if(HasFlag("GCC32")) - lnk << " -m32"; - if(HasFlag("DLL")) - lnk << " -shared"; - if(!HasFlag("SHARED") && !HasFlag("SO")) - lnk << " -static"; -// else if(!HasFlag("WIN32")) // TRC 05/03/08: see above -// lnk << " -dynamic -fPIC"; // TRC 05/03/30: dynamic fPIC doesn't seem to work in GCC either :-) - if(HasFlag("WINCE")) - lnk << " -mwindowsce"; - else if(HasFlag("WIN32")) { - lnk << " -mwindows"; - if(HasFlag("MT")) - lnk << " -mthreads"; - if(!HasFlag("GUI")) - lnk << " -mconsole"; - } - lnk << " -o " << GetHostPathQ(target); - if(createmap) - lnk << " -Wl,-Map," << GetHostPathQ(GetFileDirectory(target) + GetFileTitle(target) + ".map"); - if(HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL")) - lnk << " -ggdb"; - else - lnk << (!HasFlag("OSX11") ? " -Wl,-s" : ""); - for(i = 0; i < libpath.GetCount(); i++) - lnk << " -L" << GetHostPathQ(libpath[i]); -// lnk << " -Wl,--gc-sections,-O,2 "; - if (!HasFlag("OSX11")) - lnk << " -Wl,-O,2 "; // CXL 05/11/14 --gc-sections causing trouble on ubuntu - lnk << linkoptions; - - if (HasFlag("OSX11")) { - if (HasFlag("POWERPC")) - lnk << " -arch ppc"; - if (HasFlag("X86")) - lnk << " -arch i386"; - } - - for(i = 0; i < linkfile.GetCount(); i++) - if(ToLower(GetFileExt(linkfile[i])) == ".o") - lnk << ' ' << GetHostPathQ(linkfile[i]); - else - lib.Add(linkfile[i]); - if(!HasFlag("SOLARIS")&&!HasFlag("OSX11")) - lnk << " -Wl,--start-group "; - for(int pass = 0; pass < 2; pass++) - for(i = 0; i < lib.GetCount(); i++) { - String ln = lib[i]; - String ext = ToLower(GetFileExt(ln)); - if(pass == 0) { - if(ext == ".a") - lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i])); - } - else - if(ext != ".a") - if(ext == ".so" || ext == ".dll" || ext == ".lib") - lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i])); - else - lnk << " -l" << ln; - } - if(!HasFlag("SOLARIS")&&!HasFlag("OSX11")) - lnk << " -Wl,--end-group"; - PutConsole("Linking..."); - CustomStep(".pre-link"); - if(Execute(lnk) == 0) { - CustomStep(".post-link"); - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length - << " B) linked in " << GetPrintTime(time)); - return true; - } - else { - DeleteFile(target); - return false; - } - } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length - << " B) is up to date."); - return true; -} - -bool GccBuilder::Preprocess(const String& package, const String& file, const String& target, bool asmout) -{ - Package pkg; - String packagepath = PackagePath(package); - pkg.Load(packagepath); - String packagedir = GetFileFolder(packagepath); - ChDir(packagedir); - PutVerbose("cd " + packagedir); - - String cmd = CmdLine(package, pkg); - cmd << " " << Gather(pkg.option, config.GetKeys()); - cmd << " -o " << target; - cmd << (asmout ? " -S " : " -E ") << GetHostPathQ(file); - return Execute(cmd); -} - -Builder *CreateGccBuilder() -{ - return new GccBuilder; -} - -void RegisterGccBuilder() -{ - RegisterBuilder("GCC", CreateGccBuilder); - RegisterBuilder("GCC32", CreateGccBuilder); - RegisterBuilder("GCC_ARM", CreateGccBuilder); -} +#include "Builders.h" + +#include +#include + +void GccBuilder::AddFlags(Index& cfg) +{ +} + +String GccBuilder::CompilerName() const +{ + if(!IsNull(compiler)) return compiler; + return HasFlag("GCC_ARM") ? "arm-wince-pe-c++" : "c++"; +} + +String GccBuilder::CmdLine(const String& package, const Package& pkg) +{ + String cc = CompilerName(); + cc << " -c "; + cc << IncludesDefinesTargetTime(package, pkg); + if(HasFlag("GCC32")) + cc << " -m32"; + return cc; +} + +void GccBuilder::BinaryToObject(String objfile, CParser& binscript, String basedir, + const String& package, const Package& pkg) +{ + BinObjInfo info; + info.Parse(binscript, basedir); + String fo; + for(int i = 0; i < info.blocks.GetCount(); i++) { + String ident = info.blocks.GetKey(i); + ArrayMap& belem = info.blocks[i]; + if(belem[0].flags & (BinObjInfo::Block::FLG_ARRAY | BinObjInfo::Block::FLG_MASK)) { + int count = Max(belem.GetKeys()) + 1; + Vector blockref; + blockref.SetCount(count, 0); + for(int a = 0; a < belem.GetCount(); a++) { + BinObjInfo::Block& b = belem[a]; + blockref[b.index] = &b; + } + for(int i = 0; i < blockref.GetCount(); i++) + if(blockref[i]) { + BinObjInfo::Block& b = *blockref[i]; + fo << "static char " << ident << "_" << i << "[] =\n"; + String data = ::LoadFile(b.file); + if(data.IsVoid()) + throw Exc(NFormat("Error reading file '%s'", b.file)); + if(data.GetLength() != b.length) + throw Exc(NFormat("length of file '%s' changed (%d -> %d) during object creation", + b.file, b.length, data.GetLength())); + switch(b.encoding) { + case BinObjInfo::Block::ENC_BZ2: data = BZ2Compress(data); break; + case BinObjInfo::Block::ENC_ZIP: data = ZCompress(data); break; + } + b.length = data.GetLength(); + data.Cat('\0'); + fo << AsCString(data, 70) << ";\n\n"; + } + + fo << "int " << ident << "_count = " << blockref.GetCount() << ";\n\n" + "int " << ident << "_length[] = {\n"; + for(int i = 0; i < blockref.GetCount(); i++) + fo << '\t' << (blockref[i] ? blockref[i]->length : -1) << ",\n"; + fo << "};\n\n" + "char *" << ident << "[] = {\n"; + for(int i = 0; i < blockref.GetCount(); i++) + if(blockref[i]) + fo << '\t' << ident << '_' << i << ",\n"; + else + fo << "\t0,\n"; + fo << "};\n\n"; + if(belem[0].flags & BinObjInfo::Block::FLG_MASK) { + fo << "char *" << ident << "_files[] = {\n"; + for(int i = 0; i < blockref.GetCount(); i++) + fo << '\t' << AsCString(blockref[i] ? GetFileName(blockref[i]->file) : String(Null)) << ",\n"; + fo << "};\n\n"; + } + } + else { + BinObjInfo::Block& b = belem[0]; + fo << "char *" << ident << " =\n"; + String data = ::LoadFile(b.file); + if(data.IsVoid()) + throw Exc(NFormat("Error reading file '%s'", b.file)); + if(data.GetLength() != b.length) + throw Exc(NFormat("length of file '%s' changed (%d -> %d) during object creation", + b.file, b.length, data.GetLength())); + switch(b.encoding) { + case BinObjInfo::Block::ENC_BZ2: data = BZ2Compress(data); break; + case BinObjInfo::Block::ENC_ZIP: data = ZCompress(data); break; + } + int b_length = data.GetLength(); + data.Cat('\0'); + fo << AsCString(data, 70) << ";\n\n" + "int " << ident << "_length = " << b_length << ";\n\n"; + } + } + + String tmpfile = ForceExt(objfile, ".c"); + SaveFile(tmpfile, fo); + String cc = CmdLine(package, pkg); + cc << " -c -o " << GetHostPathQ(objfile) << " -x c " << GetHostPathQ(tmpfile); + int slot = AllocSlot(); + if(slot < 0 || !Run(cc, slot, objfile, 1)) + throw Exc(NFormat("Error compiling binary object '%s'.", objfile)); +} + +bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, + String& linkoptions, const Vector& all_uses, const Vector& all_libraries, + int opt) +{ + int i; + String packagepath = PackagePath(package); + Package pkg; + pkg.Load(packagepath); + String packagedir = GetFileFolder(packagepath); + ChDir(packagedir); + PutVerbose("cd " + packagedir); + IdeConsoleBeginGroup(package); + Vector obj; + + bool is_shared = HasFlag("SO"); + String shared_ext = (HasFlag("WIN32") ? ".dll" : ".so"); + + String cc = CmdLine(package, pkg); + if(HasFlag("WIN32") && HasFlag("MT")) + cc << " -mthreads"; + if(HasFlag("DEBUG_MINIMAL")) + cc << (HasFlag("WIN32") ? " -g1" : " -ggdb -g1"); + if(HasFlag("DEBUG_FULL")) + cc << (HasFlag("WIN32") ? " -g2" : " -ggdb -g2"); + String fuse_cxa_atexit; + if(is_shared /*&& !HasFlag("MAIN")*/) { + cc << " -shared -fPIC"; + fuse_cxa_atexit = " -fuse-cxa-atexit"; + } + if(!HasFlag("SHARED") && !is_shared) + cc << " -static "; +// else if(!HasFlag("WIN32")) // TRC 05/03/08: dynamic fPIC doesn't seem to work in MinGW +// cc << " -dynamic -fPIC "; // TRC 05/03/30: dynamic fPIC doesn't seem to work in GCC either :-) + cc << ' ' << Gather(pkg.option, config.GetKeys()); + cc << " -fexceptions "; + + if (HasFlag("OSX11")) { + if (HasFlag("POWERPC")) + cc << " -arch ppc"; + if (HasFlag("X86")) + cc << " -arch i386"; + } + + if(HasFlag("SSE2")) + cc << " -msse2 -mfpmath=sse"; + + String cc_speed = cc; + bool release = false; + + if(HasFlag("DEBUG")) + cc << " -D_DEBUG " << debug_options; + else { + release = true; + cc << ' ' << release_size_options; + cc_speed << ' ' << release_options; + if(opt == R_SPEED || pkg.optimize_speed) + cc = cc_speed; + } + + Vector sfile, isfile; + Vector soptions, isoptions; + Vector optimize, ioptimize; + bool error = false; + + for(i = 0; i < pkg.GetCount(); i++) { + if(!IdeIsBuilding()) + return false; + if(!pkg[i].separator) { + String gop = Gather(pkg[i].option, config.GetKeys()); + Vector srcfile = CustomStep(SourcePath(package, pkg[i])); + if(srcfile.GetCount() == 0) + error = true; + for(int j = 0; j < srcfile.GetCount(); j++) { + String fn = srcfile[j]; + String ext = ToLower(GetFileExt(fn)); + if(ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" + || ext == ".s" || ext == ".S" + || ext == ".brc" || (ext == ".rc" && HasFlag("WIN32"))) { + sfile.Add(fn); + soptions.Add(gop); + optimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); + } + else + if(ext == ".icpp") { + isfile.Add(fn); + isoptions.Add(gop); + ioptimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); + } + else + if(ext == ".o") + obj.Add(fn); + else + if(ext == ".a" || ext == ".so") + linkfile.Add(fn); + } + } + } + + if(HasFlag("BLITZ")) { + Blitz b = BlitzStep(sfile, soptions, obj, ".o", optimize); + if(b.build) { + PutConsole("BLITZ:" + b.info); + int slot = AllocSlot(); + if(slot < 0 || !Run(String().Cat() << cc << ' ' + << GetHostPathQ(b.path) << " -o " << GetHostPathQ(b.object), slot, GetHostPath(b.object), b.count)) + error = true; + } + } + + int first_ifile = sfile.GetCount(); + sfile.AppendPick(isfile); + soptions.AppendPick(isoptions); + optimize.AppendPick(ioptimize); + + int ccount = 0; + for(i = 0; i < sfile.GetCount(); i++) { + if(!IdeIsBuilding()) + return false; + String fn = sfile[i]; + String ext = ToLower(GetFileExt(fn)); + bool rc = (ext == ".rc"); + bool brc = (ext == ".brc"); + bool init = (i >= first_ifile); + String objfile = CatAnyPath(outdir, GetFileTitle(fn) + (rc ? "$rc.o" : brc ? "$brc.o" : ".o")); + if(HdependFileTime(fn) > GetFileTime(GetHostPath(objfile))) { + PutConsole(GetFileName(fn)); + int time = GetTickCount(); + bool execerr = false; + if(rc) { + String exec; + exec << "windres -i " << GetHostPathQ(fn) + << " -o " << GetHostPathQ(objfile) << IncludesShort(" --include-dir=", package, pkg); + PutVerbose(exec); + int slot = AllocSlot(); + execerr = (slot < 0 || !Run(exec, slot, GetHostPath(objfile), 1)); + } + else if(brc) { + try { +// String hfn = GetHostPath(fn); + String brcdata = LoadFile(fn); + if(brcdata.IsVoid()) + throw Exc(NFormat("error reading file '%s'", fn)); + CParser parser(brcdata, fn); + BinaryToObject(GetHostPath(objfile), parser, GetFileDirectory(fn), package, pkg); + } + catch(Exc e) { + PutConsole(e); + execerr = true; + } + } + else { + String exec = optimize[i] ? cc_speed : cc; + if(ext == ".c") + exec << " -x c "; + else if(ext == ".s" || ext == ".S") + exec << " -x assembler-with-cpp "; + else + exec << fuse_cxa_atexit << " -x c++ "; + exec << GetHostPathQ(fn) << " -o " << GetHostPathQ(objfile); + PutVerbose(exec); + int slot = AllocSlot(); + execerr = (slot < 0 || !Run(exec, slot, GetHostPath(objfile), 1)); + } + if(execerr) + DeleteFile(objfile); + error |= execerr; + PutVerbose("compiled in " + GetPrintTime(time)); + ccount++; + } + if(init) + linkfile.Add(objfile); + else + obj.Add(objfile); + } + + if(error) { +// if(ccount) +// PutCompileTime(time, ccount); + IdeConsoleEndGroup(); + return false; + } + + linkoptions << Gather(pkg.link, config.GetKeys()); + if(linkoptions.GetCount()) + linkoptions << ' '; + + Vector libs = Split(Gather(pkg.library, config.GetKeys()), ' '); + linkfile.Append(libs); + + int libtime = GetTickCount(); + if(!HasFlag("MAIN")) { + if(HasFlag("BLITZ") || HasFlag("NOLIB")) { + linkfile.Append(obj); + IdeConsoleEndGroup(); +// if(ccount) +// PutCompileTime(time, ccount); + return true; + } + IdeConsoleEndGroup(); + if(!Wait()) + return false; + String product; + if(is_shared) + product = GetSharedLibPath(package); + else + product = CatAnyPath(outdir, GetAnyFileName(package) + ".a"); + String hproduct = GetHostPath(product); + Time producttime = GetFileTime(hproduct); +// LOG("hproduct = " << hproduct << ", time = " << producttime); + linkfile.Add(GetHostPath(product)); + for(int i = 0; i < obj.GetCount(); i++) + if(GetFileTime(obj[i]) > producttime) { + String lib; + if(is_shared) { + lib = CompilerName(); + lib << " -shared -fPIC -fuse-cxa-atexit"; + if(!HasFlag("SHARED") && !is_shared) + lib << " -static"; +// else if(!HasFlag("WIN32")) // TRC 05/03/08: dynamic fPIC causes trouble in MinGW +// lib << " -dynamic -fPIC"; // TRC 05/03/30: dynamic fPIC doesn't seem to work in GCC either :-) + if(HasFlag("GCC32")) + lib << " -m32"; + Point p = ExtractVersion(); + if(!IsNull(p.x)) { + lib << " -Xlinker --major-image-version -Xlinker " << p.x; + if(!IsNull(p.y)) + lib << " -Xlinker --minor-image-version -Xlinker " << p.y; + } + lib << ' ' << Gather(pkg.link, config.GetKeys()); + lib << " -o "; + } + else + lib = "ar -sr "; + lib << GetHostPathQ(product); + for(int i = 0; i < obj.GetCount(); i++) + lib << ' ' << GetHostPathQ(obj[i]); + PutConsole("Creating library..."); + DeleteFile(hproduct); + if(is_shared) { + for(int i = 0; i < libpath.GetCount(); i++) + lib << " -L" << GetHostPathQ(libpath[i]); + for(int i = 0; i < all_uses.GetCount(); i++) + lib << ' ' << GetHostPathQ(GetSharedLibPath(all_uses[i])); + for(int i = 0; i < all_libraries.GetCount(); i++) + lib << " -l" << GetHostPathQ(all_libraries[i]); + } + if(!Execute(lib) == 0) { + DeleteFile(hproduct); + return false; + } + PutConsole(String().Cat() << hproduct << " (" << GetFileInfo(hproduct).length + << " B) created in " << GetPrintTime(libtime)); + break; + } + return true; + } + + IdeConsoleEndGroup(); + obj.Append(linkfile); + linkfile = obj; + return true; +} + + +bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, bool createmap) +{ + if(!Wait()) + return false; + int time = GetTickCount(); + for(int i = 0; i < linkfile.GetCount(); i++) + if(GetFileTime(linkfile[i]) >= targettime) { + Vector lib; + String lnk = CompilerName(); + if(HasFlag("GCC32")) + lnk << " -m32"; + if(HasFlag("DLL")) + lnk << " -shared"; + if(!HasFlag("SHARED") && !HasFlag("SO")) + lnk << " -static"; +// else if(!HasFlag("WIN32")) // TRC 05/03/08: see above +// lnk << " -dynamic -fPIC"; // TRC 05/03/30: dynamic fPIC doesn't seem to work in GCC either :-) + if(HasFlag("WINCE")) + lnk << " -mwindowsce"; + else if(HasFlag("WIN32")) { + lnk << " -mwindows"; + if(HasFlag("MT")) + lnk << " -mthreads"; + if(!HasFlag("GUI")) + lnk << " -mconsole"; + } + lnk << " -o " << GetHostPathQ(target); + if(createmap) + lnk << " -Wl,-Map," << GetHostPathQ(GetFileDirectory(target) + GetFileTitle(target) + ".map"); + if(HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL")) + lnk << " -ggdb"; + else + lnk << (!HasFlag("OSX11") ? " -Wl,-s" : ""); + for(i = 0; i < libpath.GetCount(); i++) + lnk << " -L" << GetHostPathQ(libpath[i]); +// lnk << " -Wl,--gc-sections,-O,2 "; + if (!HasFlag("OSX11")) + lnk << " -Wl,-O,2 "; // CXL 05/11/14 --gc-sections causing trouble on ubuntu + lnk << linkoptions; + + if (HasFlag("OSX11")) { + if (HasFlag("POWERPC")) + lnk << " -arch ppc"; + if (HasFlag("X86")) + lnk << " -arch i386"; + } + + for(i = 0; i < linkfile.GetCount(); i++) + if(ToLower(GetFileExt(linkfile[i])) == ".o") + lnk << ' ' << GetHostPathQ(linkfile[i]); + else + lib.Add(linkfile[i]); + if(!HasFlag("SOLARIS")&&!HasFlag("OSX11")) + lnk << " -Wl,--start-group "; + for(int pass = 0; pass < 2; pass++) + for(i = 0; i < lib.GetCount(); i++) { + String ln = lib[i]; + String ext = ToLower(GetFileExt(ln)); + if(pass == 0) { + if(ext == ".a") + lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i])); + } + else + if(ext != ".a") + if(ext == ".so" || ext == ".dll" || ext == ".lib") + lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i])); + else + lnk << " -l" << ln; + } + if(!HasFlag("SOLARIS")&&!HasFlag("OSX11")) + lnk << " -Wl,--end-group"; + PutConsole("Linking..."); + CustomStep(".pre-link"); + if(Execute(lnk) == 0) { + CustomStep(".post-link"); + PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + << " B) linked in " << GetPrintTime(time)); + return true; + } + else { + DeleteFile(target); + return false; + } + } + PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + << " B) is up to date."); + return true; +} + +bool GccBuilder::Preprocess(const String& package, const String& file, const String& target, bool asmout) +{ + Package pkg; + String packagepath = PackagePath(package); + pkg.Load(packagepath); + String packagedir = GetFileFolder(packagepath); + ChDir(packagedir); + PutVerbose("cd " + packagedir); + + String cmd = CmdLine(package, pkg); + cmd << " " << Gather(pkg.option, config.GetKeys()); + cmd << " -o " << target; + cmd << (asmout ? " -S " : " -E ") << GetHostPathQ(file); + return Execute(cmd); +} + +Builder *CreateGccBuilder() +{ + return new GccBuilder; +} + +INITBLOCK +{ + RegisterBuilder("GCC", CreateGccBuilder); + RegisterBuilder("GCC32", CreateGccBuilder); + RegisterBuilder("GCC_ARM", CreateGccBuilder); +} diff --git a/uppsrc/ide/Builders/JavaBuilder.cpp b/uppsrc/ide/Builders/JavaBuilder.icpp similarity index 96% rename from uppsrc/ide/Builders/JavaBuilder.cpp rename to uppsrc/ide/Builders/JavaBuilder.icpp index 63825daab..64998545c 100644 --- a/uppsrc/ide/Builders/JavaBuilder.cpp +++ b/uppsrc/ide/Builders/JavaBuilder.icpp @@ -1,315 +1,315 @@ -#include "Builders.h" - -String AdjustLines(const String& file) -{ - String out; - const char *p = file; - while(*p) - { - const char *b = p; - while(*p && (byte)*p <= ' ' && *p != '\r' && *p != '\n') - p++; - if(*p == '#') - { - out.Cat("//"); - b = p; - while(*p && *p != '\n' && *p != '\"') - p++; - out.Cat(b, (int)(p - b)); - b = p; - if(*p == '\"') - { - out.Cat('\"'); - b = ++p; - while(*p && *p++ != '\n') - ; - const char *e = p; - while(e > b && (byte)e[-1] <= ' ') - e--; - if(e[-1] == '\"') - e--; - out.Cat(UnixPath(String(b, e))); - out.Cat("\"\r\n"); - b = p; - continue; - } - } - out.Cat(b, (int)(p - b)); - while(*p && *p != '\n') - { - b = p; - while(*p && *p != '\n' && *p != '\r') - p++; - out.Cat(b, (int)(p - b)); - while(*p == '\r') - p++; - } - if(*p == '\n') - { - p++; - out.Cat("\r\n"); - } - } - return out; -} - -String JavaBuilder::JavaLine() -{ - return "javac"; -} - -String JavaBuilder::JarLine() -{ - return "jar"; -} - -enum { MAINCLASS, MAINDIR, MANIFEST, ITEMCOUNT }; - -bool JavaBuilder::BuildPackage(const String& package, Vector& linkfile, String& linkoptions, - const Vector& all_uses, const Vector& all_libraries, int) -{ - int time = msecs(); - int i; - int manifest = -1; - String packagepath = PackagePath(package); - Package pkg; - pkg.Load(packagepath); - String packagedir = GetFileFolder(packagepath); - ChDir(packagedir); - PutVerbose("cd " + packagedir); - Vector pkgsfile; - Vector sfile; - Vector sobjfile; - Vector soptions; - bool error = false; - bool main = HasFlag("MAIN"); - - for(i = 0; i < pkg.GetCount(); i++) { - if(!IdeIsBuilding()) - return false; - if(!pkg[i].separator) { - String gop = Gather(pkg[i].option, config.GetKeys()); - Vector srcfile = CustomStep(SourcePath(package, pkg[i])); - if(srcfile.GetCount() == 0) - error = true; - for(int j = 0; j < srcfile.GetCount(); j++) - { - String fn = srcfile[j]; - String ext = ToLower(GetFileExt(fn)); - bool ismf = false; - if(ext == ".java" || main && ext == ".mf") - { - if(ext == ".mf") - { - ismf = true; - if(manifest >= 0) - { - PutConsole(NFormat("%s(1): duplicate manifest file", GetHostPath(fn))); - PutConsole(NFormat("%s(1): (previous manifest file)", GetHostPath(sfile[manifest]))); - } - manifest = sfile.GetCount(); - } - String pkgfile = AppendFileName(package, pkg[i]); - pkgsfile.Add(pkgfile); - sfile.Add(fn); - soptions.Add(gop); - String objfile = NativePath(CatAnyPath(outdir, ismf ? String("manifest.mf") : pkgfile)); - sobjfile.Add(objfile); - } - } - } - } - - Vector sobjinfo = host->GetFileInfo(sobjfile); - int ccount = 0; - for(i = 0; i < sfile.GetCount(); i++) { - if(!IdeIsBuilding()) - return false; - if(HdependFileTime(sfile[i]) > sobjinfo[i]) { - ccount++; - if(!PreprocessJava(sfile[i], sobjfile[i], soptions[i], package, pkg)) - error = true; - } - } - linkfile.Add(outdir); - if(ccount > 0) - PutConsole(String().Cat() << ccount << " file(s) preprocessed in " << GetPrintTime(time) << - " " << int(GetTickCount() - time) / ccount << " msec/file"); - linkoptions << ' ' << Gather(pkg.link, config.GetKeys()); - - if(!error && HasFlag("MAIN") && !sfile.IsEmpty()) - { - String mainfile = sfile.Top(); - String mainobj = sobjfile.Top(); - String maincls = ForceExt(mainobj, ".class"); - String libs; - int i; - for(i = 0; i < libpath.GetCount(); i++) - libs << (i ? ";" : " -classpath ") << '\"' << libpath[i] << '\"'; - String linkcmd; - linkcmd << "javac"; - linkcmd << (HasFlag("DEBUG") ? " -g" : " -g:none"); - if(!HasFlag("DEBUG")) - if(!IsNull(release_options)) - linkcmd << ' ' << release_options; - else - linkcmd << " -O"; - linkcmd << " -deprecation" << linkoptions << " -sourcepath "; - bool win32 = HasFlag("WIN32"); - for(i = 0; i < linkfile.GetCount(); i++) { - linkcmd << (i ? (win32 ? ";" : ":") : ""); - if(linkfile[i].Find(' ') >= 0) - linkcmd << '\"' << linkfile[i] << '\"'; - else - linkcmd << linkfile[i]; - } - linkfile.InsertN(0, ITEMCOUNT); - linkfile[MAINCLASS] = maincls; - linkfile[MAINDIR] = outdir; - linkfile[MANIFEST] = (manifest >= 0 ? sobjfile[manifest] : String()); - linkcmd << ' ' << mainobj; - linkoptions = linkcmd; - } - return !error; -} - -bool JavaBuilder::Preprocess(const String& package, const String& file, const String& target, bool) -{ - return Preprocess(file, target, Null, false); -} - -bool JavaBuilder::PreprocessJava(String file, String target, String options, - String package, const Package& pkg) -{ - String mscpp = GetVar("MSCPP_JDK"); - String cc; - if(!IsNull(mscpp)) - cc = mscpp + " /C /TP /P /nologo "; - else - cc = "cpp -C "; - cc << IncludesDefinesTargetTime(package, pkg); - int time = GetTickCount(); - RealizePath(target); - String execpath; - execpath << cc << ' ' << options << ' '; - String prepfile; - bool error = false; - if(!IsNull(mscpp)) - { - prepfile = ForceExt(file, ".i"); - host->ChDir(GetFileFolder(prepfile)); - execpath << GetHostPath(file); - } - else - { - PutConsole(file); - execpath << GetHostPath(file) << " " << GetHostPath(target); - prepfile = target; - } - if(Execute(execpath) != 0) - { - DeleteFile(target); - error = true; - } - String prep = LoadFile(prepfile); - if(prep.IsEmpty()) - { - PutConsole(NFormat("Error loading preprocessed file %s", prepfile)); - error = true; - } - DeleteFile(prepfile); - if(!prep.IsEmpty() && !::SaveFile(target, AdjustLines(prep))) - { - DeleteFile(target); - error = true; - PutConsole(NFormat("%s: error saving file.", target)); - } - PutVerbose("preprocessed in " + GetPrintTime(time)); - return !error; -} - -Time JavaBuilder::AddClassDeep(String& link, String dir, String reldir) -{ - Time time = Time::Low(); - Vector folders; - for(FindFile ff(AppendFileName(dir, AppendFileName(reldir, "*"))); ff; ff.Next()) { - if(ff.IsFolder()) - folders.Add(ff.GetName()); - else if(!stricmp(GetFileExtPos(ff.GetName()), ".class")) - { - link << " -C \"" << dir << "\" \"" << UnixPath(CatAnyPath(reldir, ff.GetName())) << '\"'; - time = max(time, Time(ff.GetLastWriteTime())); - } - } - for(int f = 0; f < folders.GetCount(); f++) - time = max(time, AddClassDeep(link, dir, AppendFileName(reldir, folders[f]))); - return time; -} - -bool JavaBuilder::Link(const Vector& linkfile, const String& linkoptions, bool) -{ - if(linkfile.GetCount() < ITEMCOUNT) - return false; - int time = GetTickCount(); - String mainclass = linkfile[MAINCLASS]; - String maindir = linkfile[MAINDIR]; - String manifest = linkfile[MANIFEST]; - PutConsole("Compiling..."); - if(Execute(linkoptions) != 0) { - DeleteFile(mainclass); - return false; - } - PutVerbose("compiled in " + GetPrintTime(time)); - host->ChDir(maindir); - - PutConsole("Archiving..."); - String cmdline; - cmdline << "cf"; - if(!manifest.IsEmpty()) - cmdline << 'm'; - cmdline << ' ' << GetHostPath(target); - if(!manifest.IsEmpty()) - cmdline << ' ' << GetHostPath(manifest); - Time tm = Time::Low(); - for(int i = ITEMCOUNT; i < linkfile.GetCount(); i++) - tm = max(tm, AddClassDeep(cmdline, linkfile[i], Null)); - if(tm > targettime) { - CustomStep(".pre-link"); - String link, response; - link << "jar "; - if(cmdline.GetLength() < 32000) - link << cmdline; - else { - response = GetTempFileName("jar"); - link << '@' << response; - if(!UPP::SaveFile(response, cmdline)) { - PutConsole(String().Cat() << "Error writing JAR response file '" << response << "'"); - return false; - } - } - bool ok = (Execute(link) == 0); - if(!IsNull(response)) - FileDelete(response); - if(!ok) { - DeleteFile(target); - return false; - } - CustomStep(".post-link"); - PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length - << " B) archived in " << GetPrintTime(time)); - } - else - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length - << " B) is up to date."); - return true; -} - -static Builder *CreateJavaBuilder() -{ - return new JavaBuilder; -} - -void RegisterJavaBuilder() -{ - RegisterBuilder("JDK", &CreateJavaBuilder); -} +#include "Builders.h" + +String AdjustLines(const String& file) +{ + String out; + const char *p = file; + while(*p) + { + const char *b = p; + while(*p && (byte)*p <= ' ' && *p != '\r' && *p != '\n') + p++; + if(*p == '#') + { + out.Cat("//"); + b = p; + while(*p && *p != '\n' && *p != '\"') + p++; + out.Cat(b, (int)(p - b)); + b = p; + if(*p == '\"') + { + out.Cat('\"'); + b = ++p; + while(*p && *p++ != '\n') + ; + const char *e = p; + while(e > b && (byte)e[-1] <= ' ') + e--; + if(e[-1] == '\"') + e--; + out.Cat(UnixPath(String(b, e))); + out.Cat("\"\r\n"); + b = p; + continue; + } + } + out.Cat(b, (int)(p - b)); + while(*p && *p != '\n') + { + b = p; + while(*p && *p != '\n' && *p != '\r') + p++; + out.Cat(b, (int)(p - b)); + while(*p == '\r') + p++; + } + if(*p == '\n') + { + p++; + out.Cat("\r\n"); + } + } + return out; +} + +String JavaBuilder::JavaLine() +{ + return "javac"; +} + +String JavaBuilder::JarLine() +{ + return "jar"; +} + +enum { MAINCLASS, MAINDIR, MANIFEST, ITEMCOUNT }; + +bool JavaBuilder::BuildPackage(const String& package, Vector& linkfile, String& linkoptions, + const Vector& all_uses, const Vector& all_libraries, int) +{ + int time = msecs(); + int i; + int manifest = -1; + String packagepath = PackagePath(package); + Package pkg; + pkg.Load(packagepath); + String packagedir = GetFileFolder(packagepath); + ChDir(packagedir); + PutVerbose("cd " + packagedir); + Vector pkgsfile; + Vector sfile; + Vector sobjfile; + Vector soptions; + bool error = false; + bool main = HasFlag("MAIN"); + + for(i = 0; i < pkg.GetCount(); i++) { + if(!IdeIsBuilding()) + return false; + if(!pkg[i].separator) { + String gop = Gather(pkg[i].option, config.GetKeys()); + Vector srcfile = CustomStep(SourcePath(package, pkg[i])); + if(srcfile.GetCount() == 0) + error = true; + for(int j = 0; j < srcfile.GetCount(); j++) + { + String fn = srcfile[j]; + String ext = ToLower(GetFileExt(fn)); + bool ismf = false; + if(ext == ".java" || main && ext == ".mf") + { + if(ext == ".mf") + { + ismf = true; + if(manifest >= 0) + { + PutConsole(NFormat("%s(1): duplicate manifest file", GetHostPath(fn))); + PutConsole(NFormat("%s(1): (previous manifest file)", GetHostPath(sfile[manifest]))); + } + manifest = sfile.GetCount(); + } + String pkgfile = AppendFileName(package, pkg[i]); + pkgsfile.Add(pkgfile); + sfile.Add(fn); + soptions.Add(gop); + String objfile = NativePath(CatAnyPath(outdir, ismf ? String("manifest.mf") : pkgfile)); + sobjfile.Add(objfile); + } + } + } + } + + Vector sobjinfo = host->GetFileInfo(sobjfile); + int ccount = 0; + for(i = 0; i < sfile.GetCount(); i++) { + if(!IdeIsBuilding()) + return false; + if(HdependFileTime(sfile[i]) > sobjinfo[i]) { + ccount++; + if(!PreprocessJava(sfile[i], sobjfile[i], soptions[i], package, pkg)) + error = true; + } + } + linkfile.Add(outdir); + if(ccount > 0) + PutConsole(String().Cat() << ccount << " file(s) preprocessed in " << GetPrintTime(time) << + " " << int(GetTickCount() - time) / ccount << " msec/file"); + linkoptions << ' ' << Gather(pkg.link, config.GetKeys()); + + if(!error && HasFlag("MAIN") && !sfile.IsEmpty()) + { + String mainfile = sfile.Top(); + String mainobj = sobjfile.Top(); + String maincls = ForceExt(mainobj, ".class"); + String libs; + int i; + for(i = 0; i < libpath.GetCount(); i++) + libs << (i ? ";" : " -classpath ") << '\"' << libpath[i] << '\"'; + String linkcmd; + linkcmd << "javac"; + linkcmd << (HasFlag("DEBUG") ? " -g" : " -g:none"); + if(!HasFlag("DEBUG")) + if(!IsNull(release_options)) + linkcmd << ' ' << release_options; + else + linkcmd << " -O"; + linkcmd << " -deprecation" << linkoptions << " -sourcepath "; + bool win32 = HasFlag("WIN32"); + for(i = 0; i < linkfile.GetCount(); i++) { + linkcmd << (i ? (win32 ? ";" : ":") : ""); + if(linkfile[i].Find(' ') >= 0) + linkcmd << '\"' << linkfile[i] << '\"'; + else + linkcmd << linkfile[i]; + } + linkfile.InsertN(0, ITEMCOUNT); + linkfile[MAINCLASS] = maincls; + linkfile[MAINDIR] = outdir; + linkfile[MANIFEST] = (manifest >= 0 ? sobjfile[manifest] : String()); + linkcmd << ' ' << mainobj; + linkoptions = linkcmd; + } + return !error; +} + +bool JavaBuilder::Preprocess(const String& package, const String& file, const String& target, bool) +{ + return Preprocess(file, target, Null, false); +} + +bool JavaBuilder::PreprocessJava(String file, String target, String options, + String package, const Package& pkg) +{ + String mscpp = GetVar("MSCPP_JDK"); + String cc; + if(!IsNull(mscpp)) + cc = mscpp + " /C /TP /P /nologo "; + else + cc = "cpp -C "; + cc << IncludesDefinesTargetTime(package, pkg); + int time = GetTickCount(); + RealizePath(target); + String execpath; + execpath << cc << ' ' << options << ' '; + String prepfile; + bool error = false; + if(!IsNull(mscpp)) + { + prepfile = ForceExt(file, ".i"); + host->ChDir(GetFileFolder(prepfile)); + execpath << GetHostPath(file); + } + else + { + PutConsole(file); + execpath << GetHostPath(file) << " " << GetHostPath(target); + prepfile = target; + } + if(Execute(execpath) != 0) + { + DeleteFile(target); + error = true; + } + String prep = LoadFile(prepfile); + if(prep.IsEmpty()) + { + PutConsole(NFormat("Error loading preprocessed file %s", prepfile)); + error = true; + } + DeleteFile(prepfile); + if(!prep.IsEmpty() && !::SaveFile(target, AdjustLines(prep))) + { + DeleteFile(target); + error = true; + PutConsole(NFormat("%s: error saving file.", target)); + } + PutVerbose("preprocessed in " + GetPrintTime(time)); + return !error; +} + +Time JavaBuilder::AddClassDeep(String& link, String dir, String reldir) +{ + Time time = Time::Low(); + Vector folders; + for(FindFile ff(AppendFileName(dir, AppendFileName(reldir, "*"))); ff; ff.Next()) { + if(ff.IsFolder()) + folders.Add(ff.GetName()); + else if(!stricmp(GetFileExtPos(ff.GetName()), ".class")) + { + link << " -C \"" << dir << "\" \"" << UnixPath(CatAnyPath(reldir, ff.GetName())) << '\"'; + time = max(time, Time(ff.GetLastWriteTime())); + } + } + for(int f = 0; f < folders.GetCount(); f++) + time = max(time, AddClassDeep(link, dir, AppendFileName(reldir, folders[f]))); + return time; +} + +bool JavaBuilder::Link(const Vector& linkfile, const String& linkoptions, bool) +{ + if(linkfile.GetCount() < ITEMCOUNT) + return false; + int time = GetTickCount(); + String mainclass = linkfile[MAINCLASS]; + String maindir = linkfile[MAINDIR]; + String manifest = linkfile[MANIFEST]; + PutConsole("Compiling..."); + if(Execute(linkoptions) != 0) { + DeleteFile(mainclass); + return false; + } + PutVerbose("compiled in " + GetPrintTime(time)); + host->ChDir(maindir); + + PutConsole("Archiving..."); + String cmdline; + cmdline << "cf"; + if(!manifest.IsEmpty()) + cmdline << 'm'; + cmdline << ' ' << GetHostPath(target); + if(!manifest.IsEmpty()) + cmdline << ' ' << GetHostPath(manifest); + Time tm = Time::Low(); + for(int i = ITEMCOUNT; i < linkfile.GetCount(); i++) + tm = max(tm, AddClassDeep(cmdline, linkfile[i], Null)); + if(tm > targettime) { + CustomStep(".pre-link"); + String link, response; + link << "jar "; + if(cmdline.GetLength() < 32000) + link << cmdline; + else { + response = GetTempFileName("jar"); + link << '@' << response; + if(!UPP::SaveFile(response, cmdline)) { + PutConsole(String().Cat() << "Error writing JAR response file '" << response << "'"); + return false; + } + } + bool ok = (Execute(link) == 0); + if(!IsNull(response)) + FileDelete(response); + if(!ok) { + DeleteFile(target); + return false; + } + CustomStep(".post-link"); + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length + << " B) archived in " << GetPrintTime(time)); + } + else + PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + << " B) is up to date."); + return true; +} + +static Builder *CreateJavaBuilder() +{ + return new JavaBuilder; +} + +INITBLOCK +{ + RegisterBuilder("JDK", &CreateJavaBuilder); +} diff --git a/uppsrc/ide/Builders/MscBuilder.cpp b/uppsrc/ide/Builders/MscBuilder.icpp similarity index 96% rename from uppsrc/ide/Builders/MscBuilder.cpp rename to uppsrc/ide/Builders/MscBuilder.icpp index b57a6bf93..70978c26e 100644 --- a/uppsrc/ide/Builders/MscBuilder.cpp +++ b/uppsrc/ide/Builders/MscBuilder.icpp @@ -1,566 +1,566 @@ -#include "Builders.h" - -#include - -#ifdef PLATFORM_WIN32 -static bool HasTail(String s, const char *tail) -{ - int tl = (int)strlen(tail); - int sl = s.GetLength(); - if(sl < tl) - return false; - for(const char *p = s.GetIter(sl - tl); *p; p++, tail++) - if(*tail != '*' && *tail != *p) - return false; - return *tail == 0; -} -#endif - -static void AddObjectExports(const char *path, Index& out) -{ -#ifdef PLATFORM_WIN32 - FileMapping mapping; - if(!mapping.Open(path)) - return; - const byte *begin = mapping.Begin(); - const COFF_IMAGE_FILE_HEADER *hdr = (const COFF_IMAGE_FILE_HEADER *)begin; - if(hdr->Machine != COFF_IMAGE_FILE_MACHINE_I386) - return; - const COFF_IMAGE_SECTION_HEADER *sechdr = (const COFF_IMAGE_SECTION_HEADER *)(begin - + sizeof(COFF_IMAGE_FILE_HEADER) + hdr->SizeOfOptionalHeader); - Index code_sections; - for(int i = 0; i < hdr->NumberOfSections; i++) - if(sechdr[i].Characteristics & COFF_IMAGE_SCN_CNT_CODE) - code_sections.Add(i + 1); - const COFF_IMAGE_SYMBOL *symtbl = (const COFF_IMAGE_SYMBOL *)(begin + hdr->PointerToSymbolTable); - const char *strtbl = (const char *)(symtbl + hdr->NumberOfSymbols); - for(int i = 0; i < (int)hdr->NumberOfSymbols; i++) - { - const COFF_IMAGE_SYMBOL& sym = symtbl[i]; - if(sym.StorageClass == COFF_IMAGE_SYM_CLASS_EXTERNAL && code_sections.Find(sym.SectionNumber) >= 0) - { - String name = COFFSymbolName(sym, strtbl); - if(!HasTail(name, "AEPAXI@Z")) - { - if(*name == '_' && name.Find('@') < 0) - name.Remove(0, 1); - out.FindAdd(name); - } - } - i += sym.NumberOfAuxSymbols; - } -#endif -} - -void MscBuilder::AddFlags(Index& cfg) -{ - cfg.FindAdd("MSC"); -} - -String MscBuilder::CmdLine(const String& package, const Package& pkg) -{ - String cc; - if(HasFlag("ARM")) - cc = "clarm"; - else - if(HasFlag("MIPS")) - cc = "clmips"; - else - if(HasFlag("SH3")) - cc = "shcl /Qsh3"; - else - if(HasFlag("SH4")) - cc = "shcl /Qsh4"; - else - if(HasFlag("MSC8ARM")) - cc = "cl -GS- "; - else - cc = HasFlag("INTEL") ? "icl" : "cl"; -// TRC 080605-documentation says Wp64 works in 32-bit compilation only -// cc << (IsMsc64() ? " -nologo -Wp64 -W3 -GR -c" : " -nologo -W3 -GR -c"); - cc << " -nologo -W3 -GR -c"; - cc << IncludesDefinesTargetTime(package, pkg); - return cc; -} - -String MscBuilder::MachineName() const -{ - if(HasFlag("ARM")) return "ARM"; - if(HasFlag("MIPS")) return "MIPS"; - if(HasFlag("SH3")) return "SH3"; - if(HasFlag("SH4")) return "SH4"; - if(IsMscArm()) return "ARM"; - if(IsMsc64()) return "x64"; - if(HasFlag("WIN32")) return "I386"; - return "IX86"; -} - -bool MscBuilder::IsMsc89() const -{ - return IsMsc86() || IsMsc64() || IsMscArm(); -} - -bool MscBuilder::IsMsc86() const -{ - return HasFlag("MSC8") || HasFlag("MSC9") || HasFlag("MSC10"); -} - -bool MscBuilder::IsMscArm() const -{ - return HasFlag("MSC8ARM") || HasFlag("MSC9ARM"); -} - -bool MscBuilder::IsMsc64() const -{ - return HasFlag("MSC8X64") || HasFlag("MSC9X64") || HasFlag("MSC10X64"); -} - -String MscBuilder::LinkerName() const -{ - if(HasFlag("ULD")) return "uld"; - if(HasFlag("INTEL")) return "xilink"; - return "link"; -} - -static bool sContainsPchOptions(const String& x) -{ - Index a = Split(x, ' '); - return a.Find("-GL") >= 0 || a.Find("/GL") >= 0 || a.Find("-Y-") >= 0 || a.Find("/Y-") >= 0 - || a.Find("-Yc") >= 0 || a.Find("/Yc") >= 0 || a.Find("-Yd") >= 0 || a.Find("/Yd") >= 0 - || a.Find("-Yl") >= 0 || a.Find("/Yl") >= 0 || a.Find("-Yu") >= 0 || a.Find("/Yu") >= 0 - || a.Find("-YX") >= 0 || a.Find("/YX") >= 0; -} - -bool MscBuilder::HasAnyDebug() const -{ - return HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL"); -} - -String MscBuilder::PdbPch(String package, int slot, bool do_pch) const -{ - String pkg_slot = NFormat("%s-%d", GetAnyFileName(package), slot + 1); - String pdb = GetHostPathQ(CatAnyPath(outdir, pkg_slot + ".pdb")); - String cc; - cc << " -Gy -Fd" << pdb; - if(do_pch && !IsMsc89()) // MSC8/9 does not support automatic precompiled headers... - cc << " -YX -Fp" << GetHostPathQ(CatAnyPath(outdir, pkg_slot + ".pch")) << ' '; - return cc; -} - -bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, String& linkoptions, - const Vector& all_uses, const Vector& all_libraries, int opt) -{ - int i; - String packagepath = PackagePath(package); - Package pkg; - pkg.Load(packagepath); - String packagedir = GetFileFolder(packagepath); - ChDir(packagedir); - PutVerbose("cd " + packagedir); - IdeConsoleBeginGroup(package); - Vector obj; - - bool is_shared = HasFlag("SO"); - - String cc = CmdLine(package, pkg); - if(HasFlag("EVC")) { - if(!HasFlag("SH3") && !HasFlag("SH4")) - cc << " -Gs8192"; // disable stack checking - cc << " -GF" // read-only string pooling - " -GX-"; // turn off exception handling - } - else - if(IsMsc89()) - cc << " -EHsc"; - else - cc << " -GX"; -// String pdb = GetHostPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pdb")); -// String pch; -// if(!HasFlag("MSC8")) // MSC8 does not support automatic precompiled headers... -// pch << " -YX -Fp" << GetHostPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pch")) << ' '; -// cc << " -Gy -Fd" << pdb; - if(HasFlag("SSE2")) - cc << " /arch:SSE2"; - if(HasFlag("DEBUG_MINIMAL")) - cc << " -Zd"; - if(HasFlag("DEBUG_FULL")) - cc << " -Zi"; - cc << ' ' << Gather(pkg.option, config.GetKeys()); - cc << (HasFlag("SHARED") || is_shared ? " -MD" - : (HasFlag("MT") || IsMsc89()) ? " -MT" : " -ML"); - - String cc_size = cc; - String cc_speed = cc; - bool release = false; - - if(HasFlag("DEBUG")) - cc << "d " << debug_options; - else { - release = true; - cc << ' ' << release_size_options; - cc_speed << ' ' << release_options; - if(opt == R_SPEED || pkg.optimize_speed) - cc = cc_speed; - } - - - Vector sfile, isfile; - Vector soptions, isoptions; - Vector optimize, ioptimize; - Vector sobjfile; - bool error = false; - - for(i = 0; i < pkg.GetCount(); i++) { - if(!IdeIsBuilding()) - return false; - if(!pkg[i].separator) { - String gop = Gather(pkg[i].option, config.GetKeys()); - Vector srcfile = CustomStep(SourcePath(package, pkg[i])); - if(srcfile.GetCount() == 0) - error = true; - for(int j = 0; j < srcfile.GetCount(); j++) { - String fn = srcfile[j]; - String ext = ToLower(GetFileExt(fn)); - if(ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" || ext == ".rc" || ext == ".brc") { - sfile.Add(fn); - soptions.Add(gop); - optimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); - } - else - if(ext == ".icpp") { - isfile.Add(fn); - isoptions.Add(gop); - ioptimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); - } - else - if(ext == ".obj") - obj.Add(fn); - else - if(ext == ".lib") - linkfile.Add(fn); - } - } - } - - if(HasFlag("BLITZ")) { - Blitz b = BlitzStep(sfile, soptions, obj, ".obj", optimize); - if(b.build) { - PutConsole("BLITZ:" + b.info); - int slot = AllocSlot(); - if(slot < 0 || ! Run(cc + PdbPch(package, slot, false) - + " -Tp " + GetHostPathQ(b.path) + " -Fo" + GetHostPathQ(b.object), slot, GetHostPath(b.object), b.count)) - error = true; - } - } - - int first_ifile = sfile.GetCount(); - sfile.AppendPick(isfile); - soptions.AppendPick(isoptions); - optimize.AppendPick(ioptimize); - - int ccount = 0; - -// if(sContainsPchOptions(cc)) -// pch = Null; - - for(i = 0; i < sfile.GetCount(); i++) { - if(!IdeIsBuilding()) - return false; - String fn = sfile[i]; - String ext = ToLower(GetFileExt(fn)); - bool rc = (ext == ".rc"); - bool brc = (ext == ".brc"); - bool init = (i >= first_ifile); - String objfile = CatAnyPath(outdir, GetFileTitle(fn) + (rc ? "$rc.obj" : brc ? "$brc.obj" : ".obj")); - if(HdependFileTime(fn) > GetFileTime(objfile)) { - int time = GetTickCount(); - bool execerr = false; - if(rc) { - PutConsole(GetFileNamePos(fn)); - int slot = AllocSlot(); - if(slot < 0 || !Run("rc /fo" + GetHostPathQ(objfile) + Includes(" /i", package, pkg) - + ' ' + GetHostPathQ(fn), slot, GetHostPath(objfile), 1)) - execerr = true; - } - else - if(brc) { - PutConsole(GetFileNamePos(fn)); - try { - String hfn = GetHostPath(fn); - String brcdata = LoadFile(hfn); - if(brcdata.IsVoid()) - throw Exc(NFormat("error reading file '%s'", hfn)); - CParser parser(brcdata, hfn); - BinaryToObject(GetHostPath(objfile), parser, GetFileDirectory(hfn), THISBACK(BinObjConsole)); - } - catch(Exc e) { - PutConsole(e); - execerr = true; - } - } - else { - String c = cc; - if(optimize[i]) - c = cc_speed; - int slot = AllocSlot(); - if(slot < 0 || !Run(c + PdbPch(package, slot, !sContainsPchOptions(cc) && !sContainsPchOptions(soptions[i])) - + soptions[i] + (ext == ".c" ? " -Tc " : " -Tp ") - + GetHostPathQ(fn) + " -Fo" + GetHostPathQ(objfile), slot, GetHostPath(objfile), 1)) - execerr = true; - } - if(execerr) - DeleteFile(objfile); - error |= execerr; - PutVerbose("compiled in " + GetPrintTime(time)); - ccount++; - } - if(init) - linkfile.Add(objfile); - else - obj.Add(objfile); - } - if(error) { -// ShowTime(ccount, time); - IdeConsoleEndGroup(); - return false; - } - - Vector pkglibs = Split(Gather(pkg.library, config.GetKeys()), ' '); - for(int i = 0; i < pkglibs.GetCount(); i++) { - String libfile = AppendExt(pkglibs[i], ".lib"); - if(!IsFullPath(libfile)) { - for(int p = 0; p < libpath.GetCount(); p++) { - String nf = NormalizePath(libfile, libpath[p]); - if(FileExists(nf)) { - libfile = nf; - break; - } - } - } - linkfile.Add(libfile); - } - linkoptions << ' ' << Gather(pkg.link, config.GetKeys()); - - int linktime = GetTickCount(); - if(!HasFlag("MAIN")) { - if(HasFlag("BLITZ") || HasFlag("NOLIB")) { - linkfile.Append(obj); -// ShowTime(ccount, time); - IdeConsoleEndGroup(); - return true; - } - String product; - if(is_shared) - product = GetSharedLibPath(package); - else - product = CatAnyPath(outdir, GetAnyFileName(package) + ".lib"); - Time producttime = GetFileTime(product); - linkfile.Add(ForceExt(product, ".lib")); - if(!Wait()) { - IdeConsoleEndGroup(); - return false; - } - Vector objinfo = host->GetFileInfo(obj); - for(int i = 0; i < obj.GetCount(); i++) - if(objinfo[i] > producttime) { - String lib; - if(is_shared) { - lib << LinkerName() << " -dll -nologo -machine:" << MachineName() - << " -pdb:" << GetHostPathQ(ForceExt(product, ".pdb")) - << " -out:" << GetHostPathQ(product); - if(!HasFlag("MSC10") && !HasFlag("MSC10X64")) - lib << " -incremental:no"; - if(HasFlag("FORCE_SIZE")){ - if(sContainsPchOptions(release_size_options)) - lib << " -ltcg"; - } - else - if(HasFlag("FORCE_SPEED")) - if(sContainsPchOptions(release_options)) - lib << " -ltcg"; - if(HasAnyDebug()) - lib << " -debug -OPT:NOREF"; - else - lib << " -release -OPT:REF,ICF"; - if(IsMscArm()) - lib << " -subsystem:windowsce,4.20 /ARMPADCODE"; - else - if(HasFlag("GUI")) - lib << (HasFlag("WIN32") ? " -subsystem:windows" - : " -subsystem:windowsce"); - else - lib << " -subsystem:console"; - Index exports; - for(int o = 0; o < obj.GetCount(); o++) - AddObjectExports(obj[o], exports); - String def; - def << "LIBRARY " << AsCString(GetFileName(product)) << "\n\n" - "EXPORTS\n"; - for(int o = 0; o < exports.GetCount(); o++) - def << '\t' << exports[o] << "\n"; //" @" << (o + 1) << "\n"; - String deffile = ForceExt(product, ".def"); - if(!SaveChangedFile(deffile, def)) - { - PutConsole(NFormat("%s: error saving file", deffile)); - return false; - } - lib << " -def:" << GetHostPathQ(deffile); - for(int i = 0; i < libpath.GetCount(); i++) - lib << " -LIBPATH:" << GetHostPathQ(libpath[i]); - lib << ' ' << Gather(pkg.link, config.GetKeys()); - for(int i = 0; i < all_uses.GetCount(); i++) - lib << ' ' << GetHostPathQ(ForceExt(GetSharedLibPath(all_uses[i]), ".lib")); - for(int i = 0; i < all_libraries.GetCount(); i++) { - String libfile = AppendExt(all_libraries[i], ".lib"); - if(!IsFullPath(libfile)) { - for(int p = 0; p < libpath.GetCount(); p++) { - String nf = NormalizePath(libfile, libpath[p]); - if(FileExists(nf)) { - libfile = nf; - break; - } - } - } - lib << ' ' << GetHostPathQ(libfile); - } - } - else{ - lib << (HasFlag("INTEL") ? "xilib" : "link /lib") << " -nologo"; - if(HasFlag("FORCE_SIZE")){ - if(sContainsPchOptions(release_size_options)) - lib << " -ltcg"; - } - else - if(HasFlag("FORCE_SPEED")) - if(sContainsPchOptions(release_options)) - lib << " -ltcg"; - lib << " -out:" << GetHostPathQ(product) << ' ' << Gather(pkg.link, config.GetKeys()); - } - for(int i = 0; i < obj.GetCount(); i++) - lib << ' ' << GetHostPathQ(obj[i]); - PutConsole("Creating library..."); - IdeConsoleEndGroup(); - DeleteFile(product); - if(Execute(lib)) { - DeleteFile(product); - return false; - } - else - if((IsMsc86() || IsMsc64()) && is_shared) { - String mt("mt -nologo -manifest "); - mt << GetHostPathQ(product) << ".manifest -outputresource:" << GetHostPathQ(product) << ";2"; - Execute(mt); - } - PutConsole(String().Cat() << product << " (" << GetFileInfo(product).length - << " B) created in " << GetPrintTime(linktime)); - break; - } - return true; - } - - IdeConsoleEndGroup(); - obj.Append(linkfile); - linkfile = obj; - return true; -} - -bool MscBuilder::Link(const Vector& linkfile, const String& linkoptions, bool createmap) -{ - int time = GetTickCount(); - if(!Wait()) - return false; - for(int i = 0; i < linkfile.GetCount(); i++) - if(GetFileTime(linkfile[i]) >= targettime) { - String link; - link << LinkerName() << " -nologo -machine:" << MachineName() - << " -pdb:" << GetHostPathQ(ForceExt(target, ".pdb")) - << " -out:" << GetHostPathQ(target); - if(HasFlag("FORCE_SIZE")){ - if(sContainsPchOptions(release_size_options)) - link << " -ltcg"; - } - else - if(HasFlag("FORCE_SPEED")) - if(sContainsPchOptions(release_options)) - link << " -ltcg"; - if(!HasFlag("MSC10") && !HasFlag("MSC10X64")) - if(HasAnyDebug()) - link << " -incremental:yes -debug -OPT:NOREF"; - else - link << " -incremental:no -release -OPT:REF,ICF"; - else - if(HasAnyDebug()) - link << " -debug -OPT:NOREF"; - else - link << " -release -OPT:REF,ICF"; - if(IsMscArm()) - link << " -subsystem:windowsce,4.20 /ARMPADCODE -NODEFAULTLIB:\"oldnames.lib\" "; - else - if(HasFlag("GUI") || IsMscArm()) - link << (HasFlag("WIN32") ? " -subsystem:windows" : " -subsystem:windowsce"); - else - link << " -subsystem:console"; - if(createmap) - link << " -MAP"; - if(HasFlag("DLL")) - link << " -DLL"; - for(i = 0; i < libpath.GetCount(); i++) - link << " -LIBPATH:\"" << libpath[i] << '\"'; - link << ' ' << linkoptions << ' '; - for(i = 0; i < linkfile.GetCount(); i++) - link << ' ' << GetHostPathQ(AppendExt(linkfile[i], ".lib")); - PutConsole("Linking..."); - CustomStep(".pre-link"); - if(Execute(link) == 0) { - CustomStep(".post-link"); - if((IsMsc86() || IsMsc64()) && HasFlag("SHARED")) { - String mt("mt -nologo -manifest "); - mt << GetHostPathQ(target) << ".manifest -outputresource:" << GetHostPathQ(target) - << (HasFlag("DLL") ? ";2" : ";1"); - Execute(mt); - } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length - << " B) linked in " << GetPrintTime(time)); - return true; - } - else { - DeleteFile(target); - return false; - } - } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length - << " B) is up to date."); - return true; -} - -bool MscBuilder::Preprocess(const String& package, const String& file, const String& target, bool) -{ - FileOut out(target); - String packagepath = PackagePath(package); - Package pkg; - pkg.Load(packagepath); - return Execute(CmdLine(package, pkg) + " -E " + file, out); -} - -Builder *CreateMscBuilder() -{ - return new MscBuilder; -} - -void RegisterMscBuilder() -{ - RegisterBuilder("MSC71", CreateMscBuilder); - RegisterBuilder("MSC8", CreateMscBuilder); - RegisterBuilder("MSC8X64", CreateMscBuilder); - RegisterBuilder("MSC8ARM", CreateMscBuilder); - RegisterBuilder("MSC9", CreateMscBuilder); - RegisterBuilder("MSC9X64", CreateMscBuilder); - RegisterBuilder("MSC10", CreateMscBuilder); - RegisterBuilder("MSC10X64", CreateMscBuilder); - RegisterBuilder("MSC9ARM", CreateMscBuilder); - RegisterBuilder("EVC_ARM", CreateMscBuilder); - RegisterBuilder("EVC_MIPS", CreateMscBuilder); - RegisterBuilder("EVC_SH3", CreateMscBuilder); - RegisterBuilder("EVC_SH4", CreateMscBuilder); - RegisterBuilder("INTEL", CreateMscBuilder); -} +#include "Builders.h" + +#include + +#ifdef PLATFORM_WIN32 +static bool HasTail(String s, const char *tail) +{ + int tl = (int)strlen(tail); + int sl = s.GetLength(); + if(sl < tl) + return false; + for(const char *p = s.GetIter(sl - tl); *p; p++, tail++) + if(*tail != '*' && *tail != *p) + return false; + return *tail == 0; +} +#endif + +static void AddObjectExports(const char *path, Index& out) +{ +#ifdef PLATFORM_WIN32 + FileMapping mapping; + if(!mapping.Open(path)) + return; + const byte *begin = mapping.Begin(); + const COFF_IMAGE_FILE_HEADER *hdr = (const COFF_IMAGE_FILE_HEADER *)begin; + if(hdr->Machine != COFF_IMAGE_FILE_MACHINE_I386) + return; + const COFF_IMAGE_SECTION_HEADER *sechdr = (const COFF_IMAGE_SECTION_HEADER *)(begin + + sizeof(COFF_IMAGE_FILE_HEADER) + hdr->SizeOfOptionalHeader); + Index code_sections; + for(int i = 0; i < hdr->NumberOfSections; i++) + if(sechdr[i].Characteristics & COFF_IMAGE_SCN_CNT_CODE) + code_sections.Add(i + 1); + const COFF_IMAGE_SYMBOL *symtbl = (const COFF_IMAGE_SYMBOL *)(begin + hdr->PointerToSymbolTable); + const char *strtbl = (const char *)(symtbl + hdr->NumberOfSymbols); + for(int i = 0; i < (int)hdr->NumberOfSymbols; i++) + { + const COFF_IMAGE_SYMBOL& sym = symtbl[i]; + if(sym.StorageClass == COFF_IMAGE_SYM_CLASS_EXTERNAL && code_sections.Find(sym.SectionNumber) >= 0) + { + String name = COFFSymbolName(sym, strtbl); + if(!HasTail(name, "AEPAXI@Z")) + { + if(*name == '_' && name.Find('@') < 0) + name.Remove(0, 1); + out.FindAdd(name); + } + } + i += sym.NumberOfAuxSymbols; + } +#endif +} + +void MscBuilder::AddFlags(Index& cfg) +{ + cfg.FindAdd("MSC"); +} + +String MscBuilder::CmdLine(const String& package, const Package& pkg) +{ + String cc; + if(HasFlag("ARM")) + cc = "clarm"; + else + if(HasFlag("MIPS")) + cc = "clmips"; + else + if(HasFlag("SH3")) + cc = "shcl /Qsh3"; + else + if(HasFlag("SH4")) + cc = "shcl /Qsh4"; + else + if(HasFlag("MSC8ARM")) + cc = "cl -GS- "; + else + cc = HasFlag("INTEL") ? "icl" : "cl"; +// TRC 080605-documentation says Wp64 works in 32-bit compilation only +// cc << (IsMsc64() ? " -nologo -Wp64 -W3 -GR -c" : " -nologo -W3 -GR -c"); + cc << " -nologo -W3 -GR -c"; + cc << IncludesDefinesTargetTime(package, pkg); + return cc; +} + +String MscBuilder::MachineName() const +{ + if(HasFlag("ARM")) return "ARM"; + if(HasFlag("MIPS")) return "MIPS"; + if(HasFlag("SH3")) return "SH3"; + if(HasFlag("SH4")) return "SH4"; + if(IsMscArm()) return "ARM"; + if(IsMsc64()) return "x64"; + if(HasFlag("WIN32")) return "I386"; + return "IX86"; +} + +bool MscBuilder::IsMsc89() const +{ + return IsMsc86() || IsMsc64() || IsMscArm(); +} + +bool MscBuilder::IsMsc86() const +{ + return HasFlag("MSC8") || HasFlag("MSC9") || HasFlag("MSC10"); +} + +bool MscBuilder::IsMscArm() const +{ + return HasFlag("MSC8ARM") || HasFlag("MSC9ARM"); +} + +bool MscBuilder::IsMsc64() const +{ + return HasFlag("MSC8X64") || HasFlag("MSC9X64") || HasFlag("MSC10X64"); +} + +String MscBuilder::LinkerName() const +{ + if(HasFlag("ULD")) return "uld"; + if(HasFlag("INTEL")) return "xilink"; + return "link"; +} + +static bool sContainsPchOptions(const String& x) +{ + Index a = Split(x, ' '); + return a.Find("-GL") >= 0 || a.Find("/GL") >= 0 || a.Find("-Y-") >= 0 || a.Find("/Y-") >= 0 + || a.Find("-Yc") >= 0 || a.Find("/Yc") >= 0 || a.Find("-Yd") >= 0 || a.Find("/Yd") >= 0 + || a.Find("-Yl") >= 0 || a.Find("/Yl") >= 0 || a.Find("-Yu") >= 0 || a.Find("/Yu") >= 0 + || a.Find("-YX") >= 0 || a.Find("/YX") >= 0; +} + +bool MscBuilder::HasAnyDebug() const +{ + return HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL"); +} + +String MscBuilder::PdbPch(String package, int slot, bool do_pch) const +{ + String pkg_slot = NFormat("%s-%d", GetAnyFileName(package), slot + 1); + String pdb = GetHostPathQ(CatAnyPath(outdir, pkg_slot + ".pdb")); + String cc; + cc << " -Gy -Fd" << pdb; + if(do_pch && !IsMsc89()) // MSC8/9 does not support automatic precompiled headers... + cc << " -YX -Fp" << GetHostPathQ(CatAnyPath(outdir, pkg_slot + ".pch")) << ' '; + return cc; +} + +bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, String& linkoptions, + const Vector& all_uses, const Vector& all_libraries, int opt) +{ + int i; + String packagepath = PackagePath(package); + Package pkg; + pkg.Load(packagepath); + String packagedir = GetFileFolder(packagepath); + ChDir(packagedir); + PutVerbose("cd " + packagedir); + IdeConsoleBeginGroup(package); + Vector obj; + + bool is_shared = HasFlag("SO"); + + String cc = CmdLine(package, pkg); + if(HasFlag("EVC")) { + if(!HasFlag("SH3") && !HasFlag("SH4")) + cc << " -Gs8192"; // disable stack checking + cc << " -GF" // read-only string pooling + " -GX-"; // turn off exception handling + } + else + if(IsMsc89()) + cc << " -EHsc"; + else + cc << " -GX"; +// String pdb = GetHostPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pdb")); +// String pch; +// if(!HasFlag("MSC8")) // MSC8 does not support automatic precompiled headers... +// pch << " -YX -Fp" << GetHostPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pch")) << ' '; +// cc << " -Gy -Fd" << pdb; + if(HasFlag("SSE2")) + cc << " /arch:SSE2"; + if(HasFlag("DEBUG_MINIMAL")) + cc << " -Zd"; + if(HasFlag("DEBUG_FULL")) + cc << " -Zi"; + cc << ' ' << Gather(pkg.option, config.GetKeys()); + cc << (HasFlag("SHARED") || is_shared ? " -MD" + : (HasFlag("MT") || IsMsc89()) ? " -MT" : " -ML"); + + String cc_size = cc; + String cc_speed = cc; + bool release = false; + + if(HasFlag("DEBUG")) + cc << "d " << debug_options; + else { + release = true; + cc << ' ' << release_size_options; + cc_speed << ' ' << release_options; + if(opt == R_SPEED || pkg.optimize_speed) + cc = cc_speed; + } + + + Vector sfile, isfile; + Vector soptions, isoptions; + Vector optimize, ioptimize; + Vector sobjfile; + bool error = false; + + for(i = 0; i < pkg.GetCount(); i++) { + if(!IdeIsBuilding()) + return false; + if(!pkg[i].separator) { + String gop = Gather(pkg[i].option, config.GetKeys()); + Vector srcfile = CustomStep(SourcePath(package, pkg[i])); + if(srcfile.GetCount() == 0) + error = true; + for(int j = 0; j < srcfile.GetCount(); j++) { + String fn = srcfile[j]; + String ext = ToLower(GetFileExt(fn)); + if(ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" || ext == ".rc" || ext == ".brc") { + sfile.Add(fn); + soptions.Add(gop); + optimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); + } + else + if(ext == ".icpp") { + isfile.Add(fn); + isoptions.Add(gop); + ioptimize.Add(release && pkg[i].optimize_speed && opt == R_OPTIMAL); + } + else + if(ext == ".obj") + obj.Add(fn); + else + if(ext == ".lib") + linkfile.Add(fn); + } + } + } + + if(HasFlag("BLITZ")) { + Blitz b = BlitzStep(sfile, soptions, obj, ".obj", optimize); + if(b.build) { + PutConsole("BLITZ:" + b.info); + int slot = AllocSlot(); + if(slot < 0 || ! Run(cc + PdbPch(package, slot, false) + + " -Tp " + GetHostPathQ(b.path) + " -Fo" + GetHostPathQ(b.object), slot, GetHostPath(b.object), b.count)) + error = true; + } + } + + int first_ifile = sfile.GetCount(); + sfile.AppendPick(isfile); + soptions.AppendPick(isoptions); + optimize.AppendPick(ioptimize); + + int ccount = 0; + +// if(sContainsPchOptions(cc)) +// pch = Null; + + for(i = 0; i < sfile.GetCount(); i++) { + if(!IdeIsBuilding()) + return false; + String fn = sfile[i]; + String ext = ToLower(GetFileExt(fn)); + bool rc = (ext == ".rc"); + bool brc = (ext == ".brc"); + bool init = (i >= first_ifile); + String objfile = CatAnyPath(outdir, GetFileTitle(fn) + (rc ? "$rc.obj" : brc ? "$brc.obj" : ".obj")); + if(HdependFileTime(fn) > GetFileTime(objfile)) { + int time = GetTickCount(); + bool execerr = false; + if(rc) { + PutConsole(GetFileNamePos(fn)); + int slot = AllocSlot(); + if(slot < 0 || !Run("rc /fo" + GetHostPathQ(objfile) + Includes(" /i", package, pkg) + + ' ' + GetHostPathQ(fn), slot, GetHostPath(objfile), 1)) + execerr = true; + } + else + if(brc) { + PutConsole(GetFileNamePos(fn)); + try { + String hfn = GetHostPath(fn); + String brcdata = LoadFile(hfn); + if(brcdata.IsVoid()) + throw Exc(NFormat("error reading file '%s'", hfn)); + CParser parser(brcdata, hfn); + BinaryToObject(GetHostPath(objfile), parser, GetFileDirectory(hfn), THISBACK(BinObjConsole)); + } + catch(Exc e) { + PutConsole(e); + execerr = true; + } + } + else { + String c = cc; + if(optimize[i]) + c = cc_speed; + int slot = AllocSlot(); + if(slot < 0 || !Run(c + PdbPch(package, slot, !sContainsPchOptions(cc) && !sContainsPchOptions(soptions[i])) + + soptions[i] + (ext == ".c" ? " -Tc " : " -Tp ") + + GetHostPathQ(fn) + " -Fo" + GetHostPathQ(objfile), slot, GetHostPath(objfile), 1)) + execerr = true; + } + if(execerr) + DeleteFile(objfile); + error |= execerr; + PutVerbose("compiled in " + GetPrintTime(time)); + ccount++; + } + if(init) + linkfile.Add(objfile); + else + obj.Add(objfile); + } + if(error) { +// ShowTime(ccount, time); + IdeConsoleEndGroup(); + return false; + } + + Vector pkglibs = Split(Gather(pkg.library, config.GetKeys()), ' '); + for(int i = 0; i < pkglibs.GetCount(); i++) { + String libfile = AppendExt(pkglibs[i], ".lib"); + if(!IsFullPath(libfile)) { + for(int p = 0; p < libpath.GetCount(); p++) { + String nf = NormalizePath(libfile, libpath[p]); + if(FileExists(nf)) { + libfile = nf; + break; + } + } + } + linkfile.Add(libfile); + } + linkoptions << ' ' << Gather(pkg.link, config.GetKeys()); + + int linktime = GetTickCount(); + if(!HasFlag("MAIN")) { + if(HasFlag("BLITZ") || HasFlag("NOLIB")) { + linkfile.Append(obj); +// ShowTime(ccount, time); + IdeConsoleEndGroup(); + return true; + } + String product; + if(is_shared) + product = GetSharedLibPath(package); + else + product = CatAnyPath(outdir, GetAnyFileName(package) + ".lib"); + Time producttime = GetFileTime(product); + linkfile.Add(ForceExt(product, ".lib")); + if(!Wait()) { + IdeConsoleEndGroup(); + return false; + } + Vector objinfo = host->GetFileInfo(obj); + for(int i = 0; i < obj.GetCount(); i++) + if(objinfo[i] > producttime) { + String lib; + if(is_shared) { + lib << LinkerName() << " -dll -nologo -machine:" << MachineName() + << " -pdb:" << GetHostPathQ(ForceExt(product, ".pdb")) + << " -out:" << GetHostPathQ(product); + if(!HasFlag("MSC10") && !HasFlag("MSC10X64")) + lib << " -incremental:no"; + if(HasFlag("FORCE_SIZE")){ + if(sContainsPchOptions(release_size_options)) + lib << " -ltcg"; + } + else + if(HasFlag("FORCE_SPEED")) + if(sContainsPchOptions(release_options)) + lib << " -ltcg"; + if(HasAnyDebug()) + lib << " -debug -OPT:NOREF"; + else + lib << " -release -OPT:REF,ICF"; + if(IsMscArm()) + lib << " -subsystem:windowsce,4.20 /ARMPADCODE"; + else + if(HasFlag("GUI")) + lib << (HasFlag("WIN32") ? " -subsystem:windows" + : " -subsystem:windowsce"); + else + lib << " -subsystem:console"; + Index exports; + for(int o = 0; o < obj.GetCount(); o++) + AddObjectExports(obj[o], exports); + String def; + def << "LIBRARY " << AsCString(GetFileName(product)) << "\n\n" + "EXPORTS\n"; + for(int o = 0; o < exports.GetCount(); o++) + def << '\t' << exports[o] << "\n"; //" @" << (o + 1) << "\n"; + String deffile = ForceExt(product, ".def"); + if(!SaveChangedFile(deffile, def)) + { + PutConsole(NFormat("%s: error saving file", deffile)); + return false; + } + lib << " -def:" << GetHostPathQ(deffile); + for(int i = 0; i < libpath.GetCount(); i++) + lib << " -LIBPATH:" << GetHostPathQ(libpath[i]); + lib << ' ' << Gather(pkg.link, config.GetKeys()); + for(int i = 0; i < all_uses.GetCount(); i++) + lib << ' ' << GetHostPathQ(ForceExt(GetSharedLibPath(all_uses[i]), ".lib")); + for(int i = 0; i < all_libraries.GetCount(); i++) { + String libfile = AppendExt(all_libraries[i], ".lib"); + if(!IsFullPath(libfile)) { + for(int p = 0; p < libpath.GetCount(); p++) { + String nf = NormalizePath(libfile, libpath[p]); + if(FileExists(nf)) { + libfile = nf; + break; + } + } + } + lib << ' ' << GetHostPathQ(libfile); + } + } + else{ + lib << (HasFlag("INTEL") ? "xilib" : "link /lib") << " -nologo"; + if(HasFlag("FORCE_SIZE")){ + if(sContainsPchOptions(release_size_options)) + lib << " -ltcg"; + } + else + if(HasFlag("FORCE_SPEED")) + if(sContainsPchOptions(release_options)) + lib << " -ltcg"; + lib << " -out:" << GetHostPathQ(product) << ' ' << Gather(pkg.link, config.GetKeys()); + } + for(int i = 0; i < obj.GetCount(); i++) + lib << ' ' << GetHostPathQ(obj[i]); + PutConsole("Creating library..."); + IdeConsoleEndGroup(); + DeleteFile(product); + if(Execute(lib)) { + DeleteFile(product); + return false; + } + else + if((IsMsc86() || IsMsc64()) && is_shared) { + String mt("mt -nologo -manifest "); + mt << GetHostPathQ(product) << ".manifest -outputresource:" << GetHostPathQ(product) << ";2"; + Execute(mt); + } + PutConsole(String().Cat() << product << " (" << GetFileInfo(product).length + << " B) created in " << GetPrintTime(linktime)); + break; + } + return true; + } + + IdeConsoleEndGroup(); + obj.Append(linkfile); + linkfile = obj; + return true; +} + +bool MscBuilder::Link(const Vector& linkfile, const String& linkoptions, bool createmap) +{ + int time = GetTickCount(); + if(!Wait()) + return false; + for(int i = 0; i < linkfile.GetCount(); i++) + if(GetFileTime(linkfile[i]) >= targettime) { + String link; + link << LinkerName() << " -nologo -machine:" << MachineName() + << " -pdb:" << GetHostPathQ(ForceExt(target, ".pdb")) + << " -out:" << GetHostPathQ(target); + if(HasFlag("FORCE_SIZE")){ + if(sContainsPchOptions(release_size_options)) + link << " -ltcg"; + } + else + if(HasFlag("FORCE_SPEED")) + if(sContainsPchOptions(release_options)) + link << " -ltcg"; + if(!HasFlag("MSC10") && !HasFlag("MSC10X64")) + if(HasAnyDebug()) + link << " -incremental:yes -debug -OPT:NOREF"; + else + link << " -incremental:no -release -OPT:REF,ICF"; + else + if(HasAnyDebug()) + link << " -debug -OPT:NOREF"; + else + link << " -release -OPT:REF,ICF"; + if(IsMscArm()) + link << " -subsystem:windowsce,4.20 /ARMPADCODE -NODEFAULTLIB:\"oldnames.lib\" "; + else + if(HasFlag("GUI") || IsMscArm()) + link << (HasFlag("WIN32") ? " -subsystem:windows" : " -subsystem:windowsce"); + else + link << " -subsystem:console"; + if(createmap) + link << " -MAP"; + if(HasFlag("DLL")) + link << " -DLL"; + for(i = 0; i < libpath.GetCount(); i++) + link << " -LIBPATH:\"" << libpath[i] << '\"'; + link << ' ' << linkoptions << ' '; + for(i = 0; i < linkfile.GetCount(); i++) + link << ' ' << GetHostPathQ(AppendExt(linkfile[i], ".lib")); + PutConsole("Linking..."); + CustomStep(".pre-link"); + if(Execute(link) == 0) { + CustomStep(".post-link"); + if((IsMsc86() || IsMsc64()) && HasFlag("SHARED")) { + String mt("mt -nologo -manifest "); + mt << GetHostPathQ(target) << ".manifest -outputresource:" << GetHostPathQ(target) + << (HasFlag("DLL") ? ";2" : ";1"); + Execute(mt); + } + PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + << " B) linked in " << GetPrintTime(time)); + return true; + } + else { + DeleteFile(target); + return false; + } + } + PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + << " B) is up to date."); + return true; +} + +bool MscBuilder::Preprocess(const String& package, const String& file, const String& target, bool) +{ + FileOut out(target); + String packagepath = PackagePath(package); + Package pkg; + pkg.Load(packagepath); + return Execute(CmdLine(package, pkg) + " -E " + file, out); +} + +Builder *CreateMscBuilder() +{ + return new MscBuilder; +} + +INITBLOCK +{ + RegisterBuilder("MSC71", CreateMscBuilder); + RegisterBuilder("MSC8", CreateMscBuilder); + RegisterBuilder("MSC8X64", CreateMscBuilder); + RegisterBuilder("MSC8ARM", CreateMscBuilder); + RegisterBuilder("MSC9", CreateMscBuilder); + RegisterBuilder("MSC9X64", CreateMscBuilder); + RegisterBuilder("MSC10", CreateMscBuilder); + RegisterBuilder("MSC10X64", CreateMscBuilder); + RegisterBuilder("MSC9ARM", CreateMscBuilder); + RegisterBuilder("EVC_ARM", CreateMscBuilder); + RegisterBuilder("EVC_MIPS", CreateMscBuilder); + RegisterBuilder("EVC_SH3", CreateMscBuilder); + RegisterBuilder("EVC_SH4", CreateMscBuilder); + RegisterBuilder("INTEL", CreateMscBuilder); +} diff --git a/uppsrc/ide/Builders/OwcBuilder.cpp b/uppsrc/ide/Builders/OwcBuilder.icpp similarity index 95% rename from uppsrc/ide/Builders/OwcBuilder.cpp rename to uppsrc/ide/Builders/OwcBuilder.icpp index 6feab9841..53c58b707 100644 --- a/uppsrc/ide/Builders/OwcBuilder.cpp +++ b/uppsrc/ide/Builders/OwcBuilder.icpp @@ -433,7 +433,7 @@ Builder *CreateOwcBuilder() return new OwcBuilder; } -void RegisterOwcBuilder() +INITBLOCK { RegisterBuilder("OWC", CreateOwcBuilder); } diff --git a/uppsrc/ide/Builders/ScriptBuilder.cpp b/uppsrc/ide/Builders/ScriptBuilder.icpp similarity index 96% rename from uppsrc/ide/Builders/ScriptBuilder.cpp rename to uppsrc/ide/Builders/ScriptBuilder.icpp index 4ca937942..5b198e6d2 100644 --- a/uppsrc/ide/Builders/ScriptBuilder.cpp +++ b/uppsrc/ide/Builders/ScriptBuilder.icpp @@ -1,343 +1,343 @@ -#include "Builders.h" - -#include - -EscValue ScriptBuilder::ExecuteIf(const char *fn, Vector& args) -{ - CheckParse(); - EscValue out; - int f = globals.Find(fn); - if(f < 0) - return out; - try - { - out = ::Execute(globals, NULL, globals[f], args, 50000); - } - catch(Exc e) - { - script_error = true; - PutConsole(e); - } - return out; -} - -EscValue ScriptBuilder::ExecuteIf(const char *fn) -{ - Vector args; - return ExecuteIf(fn, args); -} - -EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg) -{ - Vector args; - args.Add(arg); - return ExecuteIf(fn, args); -} - -EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2) -{ - Vector args; - args.Add(arg1); - args.Add(arg2); - return ExecuteIf(fn, args); -} - -EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2, EscValue arg3) -{ - Vector args; - args.Add(arg1); - args.Add(arg2); - args.Add(arg3); - return ExecuteIf(fn, args); -} - -void ScriptBuilder::ESC_Execute(EscEscape& e) -{ - e = Execute(String(e[0])) ? 0 : 1; -} - -void ScriptBuilder::ESC_PutConsole(EscEscape& e) -{ - PutConsole(String(e[0])); -} - -void ScriptBuilder::ESC_PutVerbose(EscEscape& e) -{ - PutVerbose(String(e[0])); -} - -void ScriptBuilder::CheckParse() -{ - if(is_parsed) - return; - script_error = false; - is_parsed = true; - StdLib(globals); - Escape(globals, "Execute(cmdline)", THISBACK(ESC_Execute)); - Escape(globals, "PutConsole(text)", THISBACK(ESC_PutConsole)); - Escape(globals, "PutVerbose(text)", THISBACK(ESC_PutVerbose)); - EscValue inclist; - inclist.SetEmptyArray(); - for(int i = 0; i < include.GetCount(); i++) - inclist.ArrayAdd(GetHostPathQ(include[i])); - globals.GetAdd("INCLUDE") = inclist; - EscValue liblist; - liblist.SetEmptyArray(); - for(int i = 0; i < libpath.GetCount(); i++) - liblist.ArrayAdd(GetHostPathQ(libpath[i])); - globals.GetAdd("LIBPATH") = liblist; - - try - { - String sdata = LoadFile(script); - if(IsNull(sdata)) - throw Exc(NFormat("%s: not found or empty", script)); - CParser parser(sdata, script, 1); - while(!parser.IsEof()) { - String id = parser.ReadId(); - globals.GetAdd(id) = ReadLambda(parser); - } - } - catch(Exc e) - { - script_error = true; - PutConsole(e); - } -} - -bool ScriptBuilder::BuildPackage(const String& package, Vector& linkfile, String& linkoptions, - const Vector& all_uses, const Vector& all_libraries, int) -{ - int i; - String packagepath = PackagePath(package); - Package pkg; - pkg.Load(packagepath); - String packagedir = GetFileFolder(packagepath); - ChDir(packagedir); - PutVerbose("cd " + packagedir); - Vector obj; - script_error = false; - - String gfl = Gather(pkg.option, config.GetKeys()); - - Vector sfile; - Vector soptions; - bool error = false; - - for(i = 0; i < pkg.GetCount(); i++) { - if(!IdeIsBuilding()) - return false; - if(!pkg[i].separator) { - String gop = Gather(pkg[i].option, config.GetKeys()); - Vector srcfile = CustomStep(SourcePath(package, pkg[i])); - if(srcfile.GetCount() == 0) - error = true; - for(int j = 0; j < srcfile.GetCount(); j++) { - String fn = srcfile[j]; - String ext = ToLower(GetFileExt(fn)); - if(ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" || - (ext == ".rc" && HasFlag("WIN32"))) { - sfile.Add(fn); - soptions.Add(gfl + " " + gop); - } - else - if(ext == ".o") - obj.Add(fn); - else - if(ext == ".a" || ext == ".so") - linkfile.Add(fn); - } - } - } - -/* - if(HasFlag("BLITZ")) { - Blitz b = BlitzStep(sfile, soptions, obj, ".o"); - if(b.build) { - PutConsole("BLITZ:" + b.info); - int time = GetTickCount(); - if(Execute(cc + " " + GetHostPathQ(b.path) + " -o " + GetHostPathQ(b.object)) == 0) - PutCompileTime(time, b.count); - else - error = true; - } - } -*/ - int time = GetTickCount(); - int ccount = 0; - for(i = 0; i < sfile.GetCount() && !script_error; i++) { - if(!IdeIsBuilding()) - return false; - String fn = sfile[i]; - String ext = ToLower(GetFileExt(fn)); -// bool rc = ext == ".rc"; - String objfile = ExecuteIf("objectfile", fn); - if(script_error) - return false; - if(IsNull(objfile)) - objfile = CatAnyPath(outdir, GetFileTitle(fn) + ".o"); - if(HdependFileTime(fn) > GetFileTime(GetHostPath(objfile))) { - PutConsole(GetFileName(fn)); - int time = GetTickCount(); - if(!ExecuteIf("compile", GetHostPathQ(fn), GetHostPathQ(objfile), soptions[i]).GetNumber()) { - DeleteFile(objfile); - error = true; - } - PutVerbose("compiled in " + GetPrintTime(time)); - ccount++; - } - obj.Add(objfile); - } - if(ccount) - PutCompileTime(time, ccount); - - if(error || script_error) - return false; - - linkoptions << Gather(pkg.link, config.GetKeys()); - - Vector libs = Split(Gather(pkg.library, config.GetKeys()), ' '); - linkfile.Append(libs); - - time = GetTickCount(); - if(!HasFlag("MAIN")) { - if(HasFlag("NOLIB")) { - linkfile.Append(obj); - return true; - } - String product = ExecuteIf("libraryfile", package); - if(IsNull(product)) - product = CatAnyPath(outdir, GetAnyFileName(package) + ".a"); - Time producttime = GetFileTime(product); - linkfile.Add("*" + product); //!! ugly - for(int i = 0; i < obj.GetCount(); i++) - if(GetFileTime(obj[i]) > producttime) { - PutConsole("Creating library..."); - DeleteFile(product); - EscValue objlist; - objlist.SetEmptyArray(); - for(int i = 0; i < obj.GetCount(); i++) - objlist.ArrayAdd(GetHostPathQ(obj[i])); - if(!ExecuteIf("library", objlist, product).GetNumber()) { - DeleteFile(product); - error = true; - return false; - } - PutConsole(String().Cat() << product << " (" << GetFileInfo(product).length - << " B) created in " << GetPrintTime(time)); - break; - } - return true; - } - - obj.Append(linkfile); - linkfile = obj; - return true; -} - -bool ScriptBuilder::Link(const Vector& linkfile, const String& linkoptions, bool) -{ - int time = GetTickCount(); - for(int i = 0; i < linkfile.GetCount(); i++) - if(GetFileTime(linkfile[i]) >= targettime) { - EscValue objlist; - objlist.SetEmptyArray(); - EscValue liblist; - liblist.SetEmptyArray(); - for(i = 0; i < linkfile.GetCount(); i++) - if(*linkfile[i] == '*') - liblist.ArrayAdd(GetHostPathQ(linkfile[i].Mid(1))); - else - objlist.ArrayAdd(GetHostPathQ(linkfile[i])); - Vector linkargs; - linkargs.Add(objlist); - linkargs.Add(liblist); - linkargs.Add(GetHostPathQ(target)); - linkargs.Add(linkoptions); - PutConsole("Linking..."); - CustomStep(".pre-link"); - if(!ExecuteIf("link", linkargs).GetNumber()) { - DeleteFile(target); - return false; - } - CustomStep(".post-link"); - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length - << " B) linked in " << GetPrintTime(time)); - return true; - } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length - << " B) is up to date."); - return true; -} - -bool ScriptBuilder::Preprocess(const String& package, const String& file, const String& target, bool) -{ - return ExecuteIf("preprocess", file, target).GetNumber(); -} - -Builder *CreateScriptBuilder() -{ - return new ScriptBuilder; -} - -void RegisterScriptBuilder() -{ - RegisterBuilder("SCRIPT", CreateScriptBuilder); -} - -/* -EscValue LayoutItem::CreateEsc() const -{ - EscValue ctrl; - String tp = type; - String tm; - if(ParseTemplate(tp, tm)) { - CreateMethods(ctrl, tp, true); - ctrl("CtrlPaint") = ctrl("Paint"); - CreateMethods(ctrl, tm, false); - } - else - CreateMethods(ctrl, tp, false); - for(int q = 0; q < property.GetCount(); q++) { - EscValue& w = ctrl(property[q].name); - const Value& v = ~property[q]; - if(IsType(v)) - w = EscFont(v); - if(IsString(v)) - w = (WString)v; - if(IsNumber(v)) - w = (double)v; - if(IsType(v)) - w = EscColor(v); - } - ctrl("type") = (WString)type; - ctrl("GetSize") = ReadLambda(Format("() { return Size(%d, %d); }", - csize.cx, csize.cy)); - ctrl("GetRect") = ReadLambda(Format("() { return Rect(0, 0, %d, %d); }", - csize.cx, csize.cy)); - return ctrl; -} - -EscValue LayoutItem::ExecuteMethod(const char *method, Vector& arg) const -{ - try { - EscValue self = CreateEsc(); - return ::Execute(UscGlobal(), &self, method, arg, 50000); - } - catch(CParser::Error& e) { - PutConsole(e + "\n"); - } - return EscValue(); -} - -EscValue LayoutItem::ExecuteMethod(const char *method) const -{ - Vector arg; - return ExecuteMethod(method, arg); -} - -Size LayoutItem::GetMinSize() -{ - return SizeEsc(ExecuteMethod("GetMinSize")); -} -*/ +#include "Builders.h" + +#include + +EscValue ScriptBuilder::ExecuteIf(const char *fn, Vector& args) +{ + CheckParse(); + EscValue out; + int f = globals.Find(fn); + if(f < 0) + return out; + try + { + out = ::Execute(globals, NULL, globals[f], args, 50000); + } + catch(Exc e) + { + script_error = true; + PutConsole(e); + } + return out; +} + +EscValue ScriptBuilder::ExecuteIf(const char *fn) +{ + Vector args; + return ExecuteIf(fn, args); +} + +EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg) +{ + Vector args; + args.Add(arg); + return ExecuteIf(fn, args); +} + +EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2) +{ + Vector args; + args.Add(arg1); + args.Add(arg2); + return ExecuteIf(fn, args); +} + +EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2, EscValue arg3) +{ + Vector args; + args.Add(arg1); + args.Add(arg2); + args.Add(arg3); + return ExecuteIf(fn, args); +} + +void ScriptBuilder::ESC_Execute(EscEscape& e) +{ + e = Execute(String(e[0])) ? 0 : 1; +} + +void ScriptBuilder::ESC_PutConsole(EscEscape& e) +{ + PutConsole(String(e[0])); +} + +void ScriptBuilder::ESC_PutVerbose(EscEscape& e) +{ + PutVerbose(String(e[0])); +} + +void ScriptBuilder::CheckParse() +{ + if(is_parsed) + return; + script_error = false; + is_parsed = true; + StdLib(globals); + Escape(globals, "Execute(cmdline)", THISBACK(ESC_Execute)); + Escape(globals, "PutConsole(text)", THISBACK(ESC_PutConsole)); + Escape(globals, "PutVerbose(text)", THISBACK(ESC_PutVerbose)); + EscValue inclist; + inclist.SetEmptyArray(); + for(int i = 0; i < include.GetCount(); i++) + inclist.ArrayAdd(GetHostPathQ(include[i])); + globals.GetAdd("INCLUDE") = inclist; + EscValue liblist; + liblist.SetEmptyArray(); + for(int i = 0; i < libpath.GetCount(); i++) + liblist.ArrayAdd(GetHostPathQ(libpath[i])); + globals.GetAdd("LIBPATH") = liblist; + + try + { + String sdata = LoadFile(script); + if(IsNull(sdata)) + throw Exc(NFormat("%s: not found or empty", script)); + CParser parser(sdata, script, 1); + while(!parser.IsEof()) { + String id = parser.ReadId(); + globals.GetAdd(id) = ReadLambda(parser); + } + } + catch(Exc e) + { + script_error = true; + PutConsole(e); + } +} + +bool ScriptBuilder::BuildPackage(const String& package, Vector& linkfile, String& linkoptions, + const Vector& all_uses, const Vector& all_libraries, int) +{ + int i; + String packagepath = PackagePath(package); + Package pkg; + pkg.Load(packagepath); + String packagedir = GetFileFolder(packagepath); + ChDir(packagedir); + PutVerbose("cd " + packagedir); + Vector obj; + script_error = false; + + String gfl = Gather(pkg.option, config.GetKeys()); + + Vector sfile; + Vector soptions; + bool error = false; + + for(i = 0; i < pkg.GetCount(); i++) { + if(!IdeIsBuilding()) + return false; + if(!pkg[i].separator) { + String gop = Gather(pkg[i].option, config.GetKeys()); + Vector srcfile = CustomStep(SourcePath(package, pkg[i])); + if(srcfile.GetCount() == 0) + error = true; + for(int j = 0; j < srcfile.GetCount(); j++) { + String fn = srcfile[j]; + String ext = ToLower(GetFileExt(fn)); + if(ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" || + (ext == ".rc" && HasFlag("WIN32"))) { + sfile.Add(fn); + soptions.Add(gfl + " " + gop); + } + else + if(ext == ".o") + obj.Add(fn); + else + if(ext == ".a" || ext == ".so") + linkfile.Add(fn); + } + } + } + +/* + if(HasFlag("BLITZ")) { + Blitz b = BlitzStep(sfile, soptions, obj, ".o"); + if(b.build) { + PutConsole("BLITZ:" + b.info); + int time = GetTickCount(); + if(Execute(cc + " " + GetHostPathQ(b.path) + " -o " + GetHostPathQ(b.object)) == 0) + PutCompileTime(time, b.count); + else + error = true; + } + } +*/ + int time = GetTickCount(); + int ccount = 0; + for(i = 0; i < sfile.GetCount() && !script_error; i++) { + if(!IdeIsBuilding()) + return false; + String fn = sfile[i]; + String ext = ToLower(GetFileExt(fn)); +// bool rc = ext == ".rc"; + String objfile = ExecuteIf("objectfile", fn); + if(script_error) + return false; + if(IsNull(objfile)) + objfile = CatAnyPath(outdir, GetFileTitle(fn) + ".o"); + if(HdependFileTime(fn) > GetFileTime(GetHostPath(objfile))) { + PutConsole(GetFileName(fn)); + int time = GetTickCount(); + if(!ExecuteIf("compile", GetHostPathQ(fn), GetHostPathQ(objfile), soptions[i]).GetNumber()) { + DeleteFile(objfile); + error = true; + } + PutVerbose("compiled in " + GetPrintTime(time)); + ccount++; + } + obj.Add(objfile); + } + if(ccount) + PutCompileTime(time, ccount); + + if(error || script_error) + return false; + + linkoptions << Gather(pkg.link, config.GetKeys()); + + Vector libs = Split(Gather(pkg.library, config.GetKeys()), ' '); + linkfile.Append(libs); + + time = GetTickCount(); + if(!HasFlag("MAIN")) { + if(HasFlag("NOLIB")) { + linkfile.Append(obj); + return true; + } + String product = ExecuteIf("libraryfile", package); + if(IsNull(product)) + product = CatAnyPath(outdir, GetAnyFileName(package) + ".a"); + Time producttime = GetFileTime(product); + linkfile.Add("*" + product); //!! ugly + for(int i = 0; i < obj.GetCount(); i++) + if(GetFileTime(obj[i]) > producttime) { + PutConsole("Creating library..."); + DeleteFile(product); + EscValue objlist; + objlist.SetEmptyArray(); + for(int i = 0; i < obj.GetCount(); i++) + objlist.ArrayAdd(GetHostPathQ(obj[i])); + if(!ExecuteIf("library", objlist, product).GetNumber()) { + DeleteFile(product); + error = true; + return false; + } + PutConsole(String().Cat() << product << " (" << GetFileInfo(product).length + << " B) created in " << GetPrintTime(time)); + break; + } + return true; + } + + obj.Append(linkfile); + linkfile = obj; + return true; +} + +bool ScriptBuilder::Link(const Vector& linkfile, const String& linkoptions, bool) +{ + int time = GetTickCount(); + for(int i = 0; i < linkfile.GetCount(); i++) + if(GetFileTime(linkfile[i]) >= targettime) { + EscValue objlist; + objlist.SetEmptyArray(); + EscValue liblist; + liblist.SetEmptyArray(); + for(i = 0; i < linkfile.GetCount(); i++) + if(*linkfile[i] == '*') + liblist.ArrayAdd(GetHostPathQ(linkfile[i].Mid(1))); + else + objlist.ArrayAdd(GetHostPathQ(linkfile[i])); + Vector linkargs; + linkargs.Add(objlist); + linkargs.Add(liblist); + linkargs.Add(GetHostPathQ(target)); + linkargs.Add(linkoptions); + PutConsole("Linking..."); + CustomStep(".pre-link"); + if(!ExecuteIf("link", linkargs).GetNumber()) { + DeleteFile(target); + return false; + } + CustomStep(".post-link"); + PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + << " B) linked in " << GetPrintTime(time)); + return true; + } + PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + << " B) is up to date."); + return true; +} + +bool ScriptBuilder::Preprocess(const String& package, const String& file, const String& target, bool) +{ + return ExecuteIf("preprocess", file, target).GetNumber(); +} + +Builder *CreateScriptBuilder() +{ + return new ScriptBuilder; +} + +INITBLOCK +{ + RegisterBuilder("SCRIPT", CreateScriptBuilder); +} + +/* +EscValue LayoutItem::CreateEsc() const +{ + EscValue ctrl; + String tp = type; + String tm; + if(ParseTemplate(tp, tm)) { + CreateMethods(ctrl, tp, true); + ctrl("CtrlPaint") = ctrl("Paint"); + CreateMethods(ctrl, tm, false); + } + else + CreateMethods(ctrl, tp, false); + for(int q = 0; q < property.GetCount(); q++) { + EscValue& w = ctrl(property[q].name); + const Value& v = ~property[q]; + if(IsType(v)) + w = EscFont(v); + if(IsString(v)) + w = (WString)v; + if(IsNumber(v)) + w = (double)v; + if(IsType(v)) + w = EscColor(v); + } + ctrl("type") = (WString)type; + ctrl("GetSize") = ReadLambda(Format("() { return Size(%d, %d); }", + csize.cx, csize.cy)); + ctrl("GetRect") = ReadLambda(Format("() { return Rect(0, 0, %d, %d); }", + csize.cx, csize.cy)); + return ctrl; +} + +EscValue LayoutItem::ExecuteMethod(const char *method, Vector& arg) const +{ + try { + EscValue self = CreateEsc(); + return ::Execute(UscGlobal(), &self, method, arg, 50000); + } + catch(CParser::Error& e) { + PutConsole(e + "\n"); + } + return EscValue(); +} + +EscValue LayoutItem::ExecuteMethod(const char *method) const +{ + Vector arg; + return ExecuteMethod(method, arg); +} + +Size LayoutItem::GetMinSize() +{ + return SizeEsc(ExecuteMethod("GetMinSize")); +} +*/ diff --git a/uppsrc/ide/Builders/init b/uppsrc/ide/Builders/init index 2b23937fb..7a86a37ab 100644 --- a/uppsrc/ide/Builders/init +++ b/uppsrc/ide/Builders/init @@ -2,4 +2,19 @@ #define _ide_Builders_icpp_init_stub #include "coff\binobj/init" #include "ide\Core/init" +#define BLITZ_INDEX__ FA3F768F4F68584D236C40C6DF6A68E40 +#include "GccBuilder.icpp" +#undef BLITZ_INDEX__ +#define BLITZ_INDEX__ FCF60224B4DFC8C1432DE6B142D025463 +#include "MscBuilder.icpp" +#undef BLITZ_INDEX__ +#define BLITZ_INDEX__ FE071E95732F1075BAFD700EC3DE99B84 +#include "OwcBuilder.icpp" +#undef BLITZ_INDEX__ +#define BLITZ_INDEX__ FCBB5F9B767211D93A3ED1B649CC25373 +#include "JavaBuilder.icpp" +#undef BLITZ_INDEX__ +#define BLITZ_INDEX__ F9DC5DB2609C325CEC56405DCC5DAD17F +#include "ScriptBuilder.icpp" +#undef BLITZ_INDEX__ #endif diff --git a/uppsrc/ide/Core/Core.upp b/uppsrc/ide/Core/Core.upp index 659340c32..714fcc6a6 100644 --- a/uppsrc/ide/Core/Core.upp +++ b/uppsrc/ide/Core/Core.upp @@ -2,7 +2,8 @@ description "TheIDE - common library\377B"; uses CtrlLib, - Esc; + Esc, + Web; file Core.h, diff --git a/uppsrc/ide/Core/init b/uppsrc/ide/Core/init index d60feb1cc..4afdbe062 100644 --- a/uppsrc/ide/Core/init +++ b/uppsrc/ide/Core/init @@ -2,4 +2,5 @@ #define _ide_Core_icpp_init_stub #include "CtrlLib/init" #include "Esc/init" +#include "Web/init" #endif diff --git a/uppsrc/ide/Insert.cpp b/uppsrc/ide/Insert.cpp index 1016eabcd..1318144ac 100644 --- a/uppsrc/ide/Insert.cpp +++ b/uppsrc/ide/Insert.cpp @@ -109,7 +109,7 @@ void Ide::InsertMenu(Bar& bar) if(ext == ".tpp") { String s; s << "#define TOPICFILE <" << pp << "/all.i>\n" - << "#include \n"; + << "#include \n"; bar.Add(fn + " include", THISBACK1(InsertText, s)); n++; } diff --git a/uppsrc/ide/idewin.cpp b/uppsrc/ide/idewin.cpp index 29baa5968..3ed4890bf 100644 --- a/uppsrc/ide/idewin.cpp +++ b/uppsrc/ide/idewin.cpp @@ -828,12 +828,6 @@ void AppMain___() try { void RegisterLayDes(); RegisterLayDes(); void RegisterIconDes(); RegisterIconDes(); - // void RegisterIdeVectorDes(); RegisterIdeVectorDes(); - void RegisterGccBuilder(); RegisterGccBuilder(); - void RegisterMscBuilder(); RegisterMscBuilder(); - void RegisterOwcBuilder(); RegisterOwcBuilder(); - void RegisterJavaBuilder(); RegisterJavaBuilder(); - void RegisterScriptBuilder(); RegisterScriptBuilder(); splash_screen = true;