mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
ide: Fixed release build of packages with only .icpp files, Skylark: Removed DDUMPs
git-svn-id: svn://ultimatepp.org/upp/trunk@5416 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3a80e8c6be
commit
439abb0af8
7 changed files with 1403 additions and 1401 deletions
|
|
@ -420,7 +420,6 @@ Value Compiler::ExeBlock::Eval(ExeContext& x) const
|
|||
String Render(const One<Exe>& exe, Renderer *r, Vector<Value>& var)
|
||||
{
|
||||
LTIMING("Render0");
|
||||
DDUMPC(var);
|
||||
ExeContext x(var, r);
|
||||
Value v = exe->Eval(x);
|
||||
x.out.Cat(AsString(v));
|
||||
|
|
|
|||
|
|
@ -30,4 +30,4 @@ INITBLOCK {
|
|||
Compiler::Register("ImlImg", ImlImg);
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
#define _Skylark_Iml_icpp_init_stub
|
||||
#include "Draw/init"
|
||||
#include "plugin\png/init"
|
||||
#include "plugin\jpg/init"
|
||||
#define BLITZ_INDEX__ F2cfe659668367946f7f2baa1fbeb2b5e
|
||||
#define BLITZ_INDEX__ Fe08bb47a4f2334977b7d8bba44463f3f
|
||||
#include "Lib.icpp"
|
||||
#undef BLITZ_INDEX__
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,439 +1,440 @@
|
|||
#include "Builders.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)
|
||||
{
|
||||
String fo = BrcToC(binscript, basedir);
|
||||
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(pkg[i], package, error);
|
||||
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 == ".m" || ext == ".mm"
|
||||
|| 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 if (ext == ".m" || ext == ".mm")
|
||||
exec << fuse_cxa_atexit << " -x objective-c++ ";
|
||||
else
|
||||
exec << fuse_cxa_atexit << " -x c++ ";
|
||||
exec << GetHostPathQ(fn) << " " << soptions[i] << " -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 ";
|
||||
lnk << linkoptions;
|
||||
|
||||
if (HasFlag("OSX11")) {
|
||||
if (HasFlag("POWERPC"))
|
||||
lnk << " -arch ppc";
|
||||
if (HasFlag("X86"))
|
||||
lnk << " -arch i386";
|
||||
}
|
||||
|
||||
String lfilename;
|
||||
if(HasFlag("OBJC")) {
|
||||
String lfilename;
|
||||
String linklist;
|
||||
for(i = 0; i < linkfile.GetCount(); i++)
|
||||
if(ToLower(GetFileExt(linkfile[i])) == ".o" || ToLower(GetFileExt(linkfile[i])) == ".a")
|
||||
linklist << GetHostPath(linkfile[i]) << '\n';
|
||||
|
||||
String linklistM = "Producing link file list ...\n";
|
||||
String odir = GetFileDirectory(linkfile[0]);
|
||||
lfilename << GetHostPath(GetFileFolder(linkfile[0])) << ".LinkFileList";
|
||||
|
||||
linklistM << lfilename;
|
||||
UPP::SaveFile(lfilename, linklist);
|
||||
lnk << " -L" << GetHostPathQ(odir)
|
||||
<< " -F" << GetHostPathQ(odir)
|
||||
<< " -filelist " << lfilename << " ";
|
||||
PutConsole( linklistM );
|
||||
}
|
||||
else
|
||||
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") && !HasFlag("OBJC"))
|
||||
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...");
|
||||
bool error = false;
|
||||
CustomStep(".pre-link", Null, error);
|
||||
if(!error && Execute(lnk) == 0) {
|
||||
CustomStep(".post-link", Null, error);
|
||||
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
||||
<< " B) linked in " << GetPrintTime(time));
|
||||
return !error;
|
||||
}
|
||||
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);
|
||||
}
|
||||
#include "Builders.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)
|
||||
{
|
||||
String fo = BrcToC(binscript, basedir);
|
||||
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(pkg[i], package, error);
|
||||
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 == ".m" || ext == ".mm"
|
||||
|| 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 if (ext == ".m" || ext == ".mm")
|
||||
exec << fuse_cxa_atexit << " -x objective-c++ ";
|
||||
else
|
||||
exec << fuse_cxa_atexit << " -x c++ ";
|
||||
exec << GetHostPathQ(fn) << " " << soptions[i] << " -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);
|
||||
if(obj.GetCount())
|
||||
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 ";
|
||||
lnk << linkoptions;
|
||||
|
||||
if (HasFlag("OSX11")) {
|
||||
if (HasFlag("POWERPC"))
|
||||
lnk << " -arch ppc";
|
||||
if (HasFlag("X86"))
|
||||
lnk << " -arch i386";
|
||||
}
|
||||
|
||||
String lfilename;
|
||||
if(HasFlag("OBJC")) {
|
||||
String lfilename;
|
||||
String linklist;
|
||||
for(i = 0; i < linkfile.GetCount(); i++)
|
||||
if(ToLower(GetFileExt(linkfile[i])) == ".o" || ToLower(GetFileExt(linkfile[i])) == ".a")
|
||||
linklist << GetHostPath(linkfile[i]) << '\n';
|
||||
|
||||
String linklistM = "Producing link file list ...\n";
|
||||
String odir = GetFileDirectory(linkfile[0]);
|
||||
lfilename << GetHostPath(GetFileFolder(linkfile[0])) << ".LinkFileList";
|
||||
|
||||
linklistM << lfilename;
|
||||
UPP::SaveFile(lfilename, linklist);
|
||||
lnk << " -L" << GetHostPathQ(odir)
|
||||
<< " -F" << GetHostPathQ(odir)
|
||||
<< " -filelist " << lfilename << " ";
|
||||
PutConsole( linklistM );
|
||||
}
|
||||
else
|
||||
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") && !HasFlag("OBJC"))
|
||||
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...");
|
||||
bool error = false;
|
||||
CustomStep(".pre-link", Null, error);
|
||||
if(!error && Execute(lnk) == 0) {
|
||||
CustomStep(".post-link", Null, error);
|
||||
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
||||
<< " B) linked in " << GetPrintTime(time));
|
||||
return !error;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -186,7 +186,8 @@ bool OwcBuilder::BuildPackage(const String& package, Vector<String>& linkfile, S
|
|||
product = CatAnyPath(outdir, GetAnyFileName(package) + ".lib");
|
||||
|
||||
Time producttime = GetFileTime(product);
|
||||
linkfile.Add(ForceExt(product, ".lib"));
|
||||
if(obj.GetCount())
|
||||
linkfile.Add(ForceExt(product, ".lib"));
|
||||
|
||||
Vector<String> files, res;
|
||||
for (int i = 0, n = obj.GetCount(); i < n; ++i)
|
||||
|
|
|
|||
|
|
@ -1,344 +1,345 @@
|
|||
#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(pkg[i], package, error);
|
||||
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...");
|
||||
bool error = false;
|
||||
CustomStep(".pre-link", Null, error);
|
||||
if(!error && !ExecuteIf("link", linkargs).GetNumber()) {
|
||||
DeleteFile(target);
|
||||
return false;
|
||||
}
|
||||
CustomStep(".post-link", Null, error);
|
||||
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
||||
<< " B) linked in " << GetPrintTime(time));
|
||||
return !error;
|
||||
}
|
||||
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"));
|
||||
}
|
||||
*/
|
||||
#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(pkg[i], package, error);
|
||||
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);
|
||||
if(obj.GetCount())
|
||||
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...");
|
||||
bool error = false;
|
||||
CustomStep(".pre-link", Null, error);
|
||||
if(!error && !ExecuteIf("link", linkargs).GetNumber()) {
|
||||
DeleteFile(target);
|
||||
return false;
|
||||
}
|
||||
CustomStep(".post-link", Null, error);
|
||||
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
||||
<< " B) linked in " << GetPrintTime(time));
|
||||
return !error;
|
||||
}
|
||||
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"));
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue