mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-31 22:02:58 -06:00
*ide: brc fixed to work in 64bit windows exe
git-svn-id: svn://ultimatepp.org/upp/trunk@3817 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9de12f3502
commit
f14c2c9d11
4 changed files with 95 additions and 81 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#define BUILDERS_H
|
||||
|
||||
#include <ide/Core/Core.h>
|
||||
#include <coff/binobj/binobj.h>
|
||||
#include <plugin/bz2/bz2.h>
|
||||
|
||||
#include "Build.h"
|
||||
|
||||
|
|
@ -54,6 +56,8 @@ struct CppBuilder : Builder {
|
|||
|
||||
void ShowTime(int count, int start_time);
|
||||
|
||||
String BrcToC(String objfile, CParser& binscript, String basedir, const String& package, const Package& pkg);
|
||||
|
||||
Blitz BlitzStep(Vector<String>& sfile, Vector<String>& soptions,
|
||||
Vector<String>& obj, const char *objext, Vector<bool>& optimize);
|
||||
|
||||
|
|
@ -112,6 +116,8 @@ struct MscBuilder : CppBuilder {
|
|||
bool IsMsc86() const;
|
||||
bool IsMscArm() const;
|
||||
bool IsMsc64() const;
|
||||
|
||||
void BinaryToObject(String objfile, CParser& binscript, String basedir, const String& package, const Package& pkg);
|
||||
};
|
||||
|
||||
struct JavaBuilder : CppBuilder {
|
||||
|
|
|
|||
|
|
@ -361,3 +361,80 @@ String CppBuilder::IncludesDefinesTargetTime(const String& package, const Packag
|
|||
targettime = GetFileTime(target);
|
||||
return cc;
|
||||
}
|
||||
|
||||
String CppBuilder::BrcToC(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, "\t", ASCSTRING_OCTALHI | ASCSTRING_SMART) << ";\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";
|
||||
}
|
||||
}
|
||||
return fo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
#include "Builders.h"
|
||||
|
||||
#include <coff/binobj/binobj.h>
|
||||
#include <plugin/bz2/bz2.h>
|
||||
|
||||
void GccBuilder::AddFlags(Index<String>& cfg)
|
||||
{
|
||||
}
|
||||
|
|
@ -26,78 +23,7 @@ String GccBuilder::CmdLine(const String& package, const Package& pkg)
|
|||
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 fo = BrcToC(objfile, binscript, basedir, package, pkg);
|
||||
String tmpfile = ForceExt(objfile, ".c");
|
||||
SaveFile(tmpfile, fo);
|
||||
String cc = CmdLine(package, pkg);
|
||||
|
|
|
|||
|
|
@ -284,14 +284,19 @@ bool MscBuilder::BuildPackage(const String& package, Vector<String>& linkfile, S
|
|||
}
|
||||
else
|
||||
if(brc) {
|
||||
PutConsole(GetFileNamePos(fn));
|
||||
try {
|
||||
String hfn = GetHostPath(fn);
|
||||
String brcdata = LoadFile(hfn);
|
||||
// String hfn = GetHostPath(fn);
|
||||
String brcdata = LoadFile(fn);
|
||||
if(brcdata.IsVoid())
|
||||
throw Exc(NFormat("error reading file '%s'", hfn));
|
||||
CParser parser(brcdata, hfn);
|
||||
BinaryToObject(GetHostPath(objfile), parser, GetFileDirectory(hfn), THISBACK(BinObjConsole));
|
||||
throw Exc(NFormat("error reading file '%s'", fn));
|
||||
CParser parser(brcdata, fn);
|
||||
String fo = BrcToC(GetHostPath(objfile), parser, GetFileDirectory(fn), package, pkg);
|
||||
String tmpfile = ForceExt(objfile, ".c");
|
||||
SaveFile(tmpfile, fo);
|
||||
int slot = AllocSlot();
|
||||
if(slot < 0 || !Run(cc + " -Tc " + GetHostPathQ(tmpfile) + " -Fo" + GetHostPath(objfile),
|
||||
slot, GetHostPath(objfile), 1))
|
||||
throw Exc(NFormat("Error compiling binary object '%s'.", objfile));
|
||||
}
|
||||
catch(Exc e) {
|
||||
PutConsole(e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue