mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.devloping umake
git-svn-id: svn://ultimatepp.org/upp/trunk@3717 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
624c5a8f84
commit
f75271f669
15 changed files with 1761 additions and 1727 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ private:
|
|||
void InsertPaste();
|
||||
void InsertFile();
|
||||
void MoveSlot(int d);
|
||||
void ChangeSlot(int d);
|
||||
|
||||
static FileSel& ImgFile();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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_
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,489 +1,489 @@
|
|||
#include "Builders.h"
|
||||
|
||||
#include <coff/binobj/binobj.h>
|
||||
#include <plugin/bz2/bz2.h>
|
||||
|
||||
void GccBuilder::AddFlags(Index<String>& 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<int, BinObjInfo::Block>& belem = info.blocks[i];
|
||||
if(belem[0].flags & (BinObjInfo::Block::FLG_ARRAY | BinObjInfo::Block::FLG_MASK)) {
|
||||
int count = Max(belem.GetKeys()) + 1;
|
||||
Vector<BinObjInfo::Block *> 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<String>& linkfile,
|
||||
String& linkoptions, const Vector<String>& all_uses, const Vector<String>& 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<String> 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<String> sfile, isfile;
|
||||
Vector<String> soptions, isoptions;
|
||||
Vector<bool> 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<String> 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<String> 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<String>& 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<String> 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 <coff/binobj/binobj.h>
|
||||
#include <plugin/bz2/bz2.h>
|
||||
|
||||
void GccBuilder::AddFlags(Index<String>& 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<int, BinObjInfo::Block>& belem = info.blocks[i];
|
||||
if(belem[0].flags & (BinObjInfo::Block::FLG_ARRAY | BinObjInfo::Block::FLG_MASK)) {
|
||||
int count = Max(belem.GetKeys()) + 1;
|
||||
Vector<BinObjInfo::Block *> 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<String>& linkfile,
|
||||
String& linkoptions, const Vector<String>& all_uses, const Vector<String>& 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<String> 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<String> sfile, isfile;
|
||||
Vector<String> soptions, isoptions;
|
||||
Vector<bool> 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<String> 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<String> 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<String>& 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<String> 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);
|
||||
}
|
||||
|
|
@ -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<String>& linkfile, String& linkoptions,
|
||||
const Vector<String>& all_uses, const Vector<String>& 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<String> pkgsfile;
|
||||
Vector<String> sfile;
|
||||
Vector<String> sobjfile;
|
||||
Vector<String> 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<String> 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<Host::FileInfo> 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<String> 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<String>& 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<String>& linkfile, String& linkoptions,
|
||||
const Vector<String>& all_uses, const Vector<String>& 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<String> pkgsfile;
|
||||
Vector<String> sfile;
|
||||
Vector<String> sobjfile;
|
||||
Vector<String> 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<String> 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<Host::FileInfo> 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<String> 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<String>& 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);
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -433,7 +433,7 @@ Builder *CreateOwcBuilder()
|
|||
return new OwcBuilder;
|
||||
}
|
||||
|
||||
void RegisterOwcBuilder()
|
||||
INITBLOCK
|
||||
{
|
||||
RegisterBuilder("OWC", CreateOwcBuilder);
|
||||
}
|
||||
|
|
@ -1,343 +1,343 @@
|
|||
#include "Builders.h"
|
||||
|
||||
#include <Esc/Esc.h>
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, Vector<EscValue>& 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<EscValue> args;
|
||||
return ExecuteIf(fn, args);
|
||||
}
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg)
|
||||
{
|
||||
Vector<EscValue> args;
|
||||
args.Add(arg);
|
||||
return ExecuteIf(fn, args);
|
||||
}
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2)
|
||||
{
|
||||
Vector<EscValue> args;
|
||||
args.Add(arg1);
|
||||
args.Add(arg2);
|
||||
return ExecuteIf(fn, args);
|
||||
}
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2, EscValue arg3)
|
||||
{
|
||||
Vector<EscValue> 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<String>& linkfile, String& linkoptions,
|
||||
const Vector<String>& all_uses, const Vector<String>& all_libraries, int)
|
||||
{
|
||||
int i;
|
||||
String packagepath = PackagePath(package);
|
||||
Package pkg;
|
||||
pkg.Load(packagepath);
|
||||
String packagedir = GetFileFolder(packagepath);
|
||||
ChDir(packagedir);
|
||||
PutVerbose("cd " + packagedir);
|
||||
Vector<String> obj;
|
||||
script_error = false;
|
||||
|
||||
String gfl = Gather(pkg.option, config.GetKeys());
|
||||
|
||||
Vector<String> sfile;
|
||||
Vector<String> 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<String> 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<String> 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<String>& 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<EscValue> 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<Font>(v))
|
||||
w = EscFont(v);
|
||||
if(IsString(v))
|
||||
w = (WString)v;
|
||||
if(IsNumber(v))
|
||||
w = (double)v;
|
||||
if(IsType<Color>(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<EscValue>& 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<EscValue> arg;
|
||||
return ExecuteMethod(method, arg);
|
||||
}
|
||||
|
||||
Size LayoutItem::GetMinSize()
|
||||
{
|
||||
return SizeEsc(ExecuteMethod("GetMinSize"));
|
||||
}
|
||||
*/
|
||||
#include "Builders.h"
|
||||
|
||||
#include <Esc/Esc.h>
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, Vector<EscValue>& 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<EscValue> args;
|
||||
return ExecuteIf(fn, args);
|
||||
}
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg)
|
||||
{
|
||||
Vector<EscValue> args;
|
||||
args.Add(arg);
|
||||
return ExecuteIf(fn, args);
|
||||
}
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2)
|
||||
{
|
||||
Vector<EscValue> args;
|
||||
args.Add(arg1);
|
||||
args.Add(arg2);
|
||||
return ExecuteIf(fn, args);
|
||||
}
|
||||
|
||||
EscValue ScriptBuilder::ExecuteIf(const char *fn, EscValue arg1, EscValue arg2, EscValue arg3)
|
||||
{
|
||||
Vector<EscValue> 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<String>& linkfile, String& linkoptions,
|
||||
const Vector<String>& all_uses, const Vector<String>& all_libraries, int)
|
||||
{
|
||||
int i;
|
||||
String packagepath = PackagePath(package);
|
||||
Package pkg;
|
||||
pkg.Load(packagepath);
|
||||
String packagedir = GetFileFolder(packagepath);
|
||||
ChDir(packagedir);
|
||||
PutVerbose("cd " + packagedir);
|
||||
Vector<String> obj;
|
||||
script_error = false;
|
||||
|
||||
String gfl = Gather(pkg.option, config.GetKeys());
|
||||
|
||||
Vector<String> sfile;
|
||||
Vector<String> 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<String> 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<String> 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<String>& 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<EscValue> 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<Font>(v))
|
||||
w = EscFont(v);
|
||||
if(IsString(v))
|
||||
w = (WString)v;
|
||||
if(IsNumber(v))
|
||||
w = (double)v;
|
||||
if(IsType<Color>(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<EscValue>& 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<EscValue> arg;
|
||||
return ExecuteMethod(method, arg);
|
||||
}
|
||||
|
||||
Size LayoutItem::GetMinSize()
|
||||
{
|
||||
return SizeEsc(ExecuteMethod("GetMinSize"));
|
||||
}
|
||||
*/
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ description "TheIDE - common library\377B";
|
|||
|
||||
uses
|
||||
CtrlLib,
|
||||
Esc;
|
||||
Esc,
|
||||
Web;
|
||||
|
||||
file
|
||||
Core.h,
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
#define _ide_Core_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#include "Esc/init"
|
||||
#include "Web/init"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ void Ide::InsertMenu(Bar& bar)
|
|||
if(ext == ".tpp") {
|
||||
String s;
|
||||
s << "#define TOPICFILE <" << pp << "/all.i>\n"
|
||||
<< "#include <Core/topic_group.h>\n";
|
||||
<< "#include <Core/topic_group.h>\n";
|
||||
bar.Add(fn + " include", THISBACK1(InsertText, s));
|
||||
n++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue