mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: Export now properly manages brc files
git-svn-id: svn://ultimatepp.org/upp/trunk@4621 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
77414d5b02
commit
1a1836d3c4
10 changed files with 1480 additions and 1448 deletions
|
|
@ -17,6 +17,8 @@ struct Blitz {
|
|||
String info;
|
||||
};
|
||||
|
||||
String BrcToC(CParser& binscript, String basedir);
|
||||
|
||||
struct CppBuilder : Builder {
|
||||
virtual String GetTargetExt() const;
|
||||
|
||||
|
|
@ -58,8 +60,6 @@ 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -396,101 +396,3 @@ String CppBuilder::IncludesDefinesTargetTime(const String& package, const Packag
|
|||
targettime = GetFileTime(target);
|
||||
return cc;
|
||||
}
|
||||
|
||||
static void WriteByteArray(StringBuffer& fo, const String& data)
|
||||
{
|
||||
int pos = 0;
|
||||
for(int p = 0; p < data.GetLength(); p++) {
|
||||
if(pos >= 70) {
|
||||
fo << '\n';
|
||||
pos = 0;
|
||||
}
|
||||
if(pos == 0)
|
||||
fo << '\t';
|
||||
String part = FormatInt((byte)data[p]);
|
||||
fo << part << ", ";
|
||||
pos += part.GetLength() + 2;
|
||||
}
|
||||
}
|
||||
|
||||
String CppBuilder::BrcToC(String objfile, CParser& binscript, String basedir,
|
||||
const String& package, const Package& pkg)
|
||||
{
|
||||
BinObjInfo info;
|
||||
info.Parse(binscript, basedir);
|
||||
StringBuffer 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');
|
||||
WriteByteArray(fo, data);
|
||||
fo << "\n};\n\n";
|
||||
// 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\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
BinObjInfo::Block& b = belem[0];
|
||||
fo << "static 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');
|
||||
WriteByteArray(fo, data);
|
||||
fo << "\n};\n\n"
|
||||
"char *" << ident << " = " << ident << "_;\n\n"
|
||||
// fo << AsCString(data, 70) << ";\n\n"
|
||||
"int " << ident << "_length = " << b_length << ";\n\n";
|
||||
}
|
||||
}
|
||||
return fo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +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)
|
||||
{
|
||||
String fo = BrcToC(objfile, binscript, basedir, package, pkg);
|
||||
String fo = BrcToC(binscript, basedir);
|
||||
String tmpfile = ForceExt(objfile, ".c");
|
||||
SaveFile(tmpfile, fo);
|
||||
String cc = CmdLine(package, pkg);
|
||||
|
|
|
|||
|
|
@ -1,248 +1,252 @@
|
|||
#include "Builders.h"
|
||||
|
||||
static String MakeIdent(const char *name)
|
||||
{
|
||||
String out;
|
||||
for(; *name; name++)
|
||||
out << (iscid(*name) ? *name : '_');
|
||||
return out;
|
||||
}
|
||||
|
||||
static String MakeSourcePath(const Vector<String>& dirs, String fn, bool raw, bool exporting)
|
||||
{
|
||||
fn = UnixPath(fn);
|
||||
for(int i = 0; i < dirs.GetCount(); i++)
|
||||
{
|
||||
int dl = dirs[i].GetLength();
|
||||
if(fn.GetLength() >= dl + 2 && !memcmp(fn, dirs[i], dl) && fn[dl] == '/') {
|
||||
String s;
|
||||
if(!exporting)
|
||||
s << "$(UPPDIR" << (i + 1) << ")";
|
||||
s << AdjustMakePath(fn.GetIter(dl + 1));
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return raw ? String() : AdjustMakePath(fn);
|
||||
}
|
||||
|
||||
String CppBuilder::GetMakePath(String fn) const
|
||||
{
|
||||
return ::GetMakePath(fn, HasFlag("WIN32"));
|
||||
}
|
||||
|
||||
void CppBuilder::AddMakeFile(MakeFile& makefile, String package,
|
||||
const Vector<String>& all_uses, const Vector<String>& all_libraries,
|
||||
const Index<String>& common_config, bool exporting)
|
||||
{
|
||||
String packagepath = PackagePath(package);
|
||||
Package pkg;
|
||||
pkg.Load(packagepath);
|
||||
String packagedir = GetFileFolder(packagepath);
|
||||
Vector<String> src = GetUppDirs();
|
||||
for(int i = 0; i < src.GetCount(); i++)
|
||||
src[i] = UnixPath(src[i]);
|
||||
|
||||
bool main = HasFlag("MAIN");
|
||||
bool is_shared = HasFlag("SO");
|
||||
bool libout = !main && !HasFlag("NOLIB");
|
||||
bool win32 = HasFlag("WIN32");
|
||||
|
||||
String pack_ident = MakeIdent(package);
|
||||
String outdir = "OutDir_" + pack_ident;
|
||||
String macros = "Macro_" + pack_ident;
|
||||
String macdef = "$(Macro)";
|
||||
String objext = (HasFlag("MSC") || HasFlag("EVC") ? ".obj" : ".o");
|
||||
|
||||
Vector<String> x(config.GetKeys(), 1);
|
||||
Sort(x);
|
||||
for(int i = 0; i < x.GetCount(); i++) {
|
||||
if(common_config.Find(x[i]) < 0)
|
||||
macdef << " -Dflag" << x[i];
|
||||
x[i] = InitCaps(x[i]);
|
||||
}
|
||||
|
||||
makefile.outdir << "$(" << outdir << ")";
|
||||
makefile.outfile << AdjustMakePath(GetFileTitle(NativePath(package)));
|
||||
if(main)
|
||||
makefile.outfile << GetTargetExt();
|
||||
else if(is_shared)
|
||||
makefile.outfile << (win32 ? ".dll" : ".so");
|
||||
else
|
||||
makefile.outfile << (win32 && HasFlag("MSC") ? ".lib" : ".a");
|
||||
makefile.output << (main ? String("$(OutDir)") : makefile.outdir) << makefile.outfile;
|
||||
|
||||
if(main) {
|
||||
makefile.config << "CXX = c++\n"
|
||||
"LINKER = $(CXX)\n";
|
||||
String flags;
|
||||
if(HasFlag("DEBUG"))
|
||||
flags << " -D_DEBUG " << debug_options;
|
||||
else
|
||||
flags << ' ' << release_options;
|
||||
if(HasFlag("DEBUG_MINIMAL"))
|
||||
flags << " -ggdb -g1";
|
||||
if(HasFlag("DEBUG_FULL"))
|
||||
flags << " -ggdb -g2";
|
||||
if(is_shared && !win32)
|
||||
flags << " -fPIC ";
|
||||
flags << ' ' << Gather(pkg.option, config.GetKeys());
|
||||
makefile.config << "CFLAGS =" << flags << "\n"
|
||||
"CXXFLAGS =" << flags << "\n"
|
||||
"LDFLAGS = " << (HasFlag("DEBUG") ? debug_link : release_link) << " $(LINKOPTIONS)\n"
|
||||
"LIBPATH =";
|
||||
for(int i = 0; i < libpath.GetCount(); i++)
|
||||
makefile.config << " -L" << GetMakePath(AdjustMakePath(GetHostPathQ(libpath[i])));
|
||||
makefile.config << "\n"
|
||||
"AR = ar -sr\n\n";
|
||||
makefile.install << "\t-mkdir -p $(OutDir)\n";
|
||||
Vector<String> lib;
|
||||
String lnk;
|
||||
lnk << "$(LINKER)";
|
||||
if(!HasFlag("SHARED"))
|
||||
lnk << " -static";
|
||||
if(HasFlag("WIN32")) {
|
||||
lnk << " -mwindows";
|
||||
if(!HasFlag("GUI"))
|
||||
makefile.linkfiles << " -mconsole";
|
||||
}
|
||||
lnk << " -o $(OutFile)";
|
||||
if(HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL"))
|
||||
lnk << " -ggdb";
|
||||
else
|
||||
lnk << (!HasFlag("OSX11") ? " -Wl,-s" : "");
|
||||
|
||||
lnk << " $(LIBPATH)";
|
||||
if (!HasFlag("OSX11"))
|
||||
lnk << " -Wl,-O,2";
|
||||
lnk << " $(LDFLAGS) -Wl,--start-group ";
|
||||
|
||||
makefile.linkfiles = lnk;
|
||||
}
|
||||
|
||||
makefile.config << outdir << " = $(UPPOUT)"
|
||||
<< GetMakePath(AdjustMakePath(String().Cat() << package << '/' << method << '-' << Join(x, "-") << '/')) << "\n"
|
||||
<< macros << " = " << macdef << "\n";
|
||||
|
||||
makefile.install << "\t-mkdir -p $(" << outdir << ")\n";
|
||||
|
||||
String libdep, libfiles;
|
||||
|
||||
libdep << makefile.output << ":";
|
||||
if(is_shared)
|
||||
{
|
||||
libfiles = "c++ -shared -fPIC"; // -v";
|
||||
Point p = ExtractVersion();
|
||||
if(!IsNull(p.x)) {
|
||||
libfiles << " -Xlinker --major-image-version -Xlinker " << p.x;
|
||||
if(!IsNull(p.y))
|
||||
libfiles << " -Xlinker --minor-image-version -Xlinker " << p.y;
|
||||
}
|
||||
libfiles << " -o ";
|
||||
}
|
||||
else
|
||||
libfiles = "$(AR) ";
|
||||
libfiles << makefile.output;
|
||||
|
||||
Vector<String> libs = Split(Gather(pkg.library, config.GetKeys()), ' ');
|
||||
for(int i = 0; i < libs.GetCount(); i++) {
|
||||
String ln = libs[i];
|
||||
String ext = ToLower(GetFileExt(ln));
|
||||
if(ext == ".a" || ext == ".so" || ext == ".dll")
|
||||
makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
|
||||
else
|
||||
makefile.linkfileend << " \\\n\t\t\t-l" << ln;
|
||||
}
|
||||
|
||||
for(int i = 0; i < pkg.GetCount(); i++)
|
||||
if(!pkg[i].separator) {
|
||||
String gop = Gather(pkg[i].option, config.GetKeys());
|
||||
String fn = SourcePath(package, pkg[i]);
|
||||
String ext = ToLower(GetFileExt(fn));
|
||||
bool isc = ext == ".c";
|
||||
bool isrc = (ext == ".rc" && HasFlag("WIN32"));
|
||||
bool iscpp = (ext == ".cpp" || ext == ".cc" || ext == ".cxx");
|
||||
bool isicpp = (ext == ".icpp");
|
||||
if(isc || isrc || iscpp || isicpp) {
|
||||
String outfile;
|
||||
outfile << makefile.outdir << AdjustMakePath(GetFileTitle(fn)) << (isrc ? "_rc" : "") << objext;
|
||||
String srcfile = GetMakePath(MakeSourcePath(src, fn, false, exporting));
|
||||
makefile.rules << outfile << ": " << srcfile;
|
||||
Vector<String> dep = HdependGetDependencies(fn);
|
||||
Sort(dep, GetLanguageInfo());
|
||||
for(int d = 0; d < dep.GetCount(); d++) {
|
||||
String dfn = MakeSourcePath(src, dep[d], true, exporting);
|
||||
if(!IsNull(dfn))
|
||||
makefile.rules << " \\\n\t" << GetMakePath(dfn);
|
||||
}
|
||||
makefile.rules << "\n"
|
||||
"\t$(CXX) -c " << (isc ? "-x c $(CFLAGS)" : "-x c++ $(CXXFLAGS)") << " $(CINC) $(" << macros << ") "
|
||||
<< gop << " " << srcfile << " -o " << outfile << "\n\n";
|
||||
if(!libout || isicpp) {
|
||||
makefile.linkdep << " \\\n\t" << outfile;
|
||||
makefile.linkfiles << " \\\n\t\t" << outfile;
|
||||
}
|
||||
else {
|
||||
libdep << " \\\n\t" << outfile;
|
||||
libfiles << " \\\n\t\t" << outfile;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(ext == ".o" || ext == ".obj" || ext == ".a" || ext == ".so" || ext == ".lib" || ext == ".dll") {
|
||||
makefile.linkdep << " \\\n\t" << fn;
|
||||
makefile.linkfiles << ' ' << fn;
|
||||
}
|
||||
}
|
||||
|
||||
if(libout) {
|
||||
makefile.rules << libdep << "\n\t" << libfiles << "\n\n";
|
||||
makefile.linkdep << " \\\n\t" << makefile.output;
|
||||
makefile.linkfiles << " \\\n\t\t\t" << makefile.output;
|
||||
}
|
||||
/*
|
||||
if(main) {
|
||||
if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
|
||||
makefile.linkfiles << " \\\n\t\t-Wl,--start-group ";
|
||||
DDUMPC(all_libraries);
|
||||
for(int i = 0; i < all_libraries.GetCount(); i++) {
|
||||
String ln = all_libraries[i];
|
||||
String ext = ToLower(GetFileExt(ln));
|
||||
if(ext == ".a" || ext == ".so" || ext == ".dll")
|
||||
makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
|
||||
else
|
||||
makefile.linkfileend << " \\\n\t\t\t-l" << ln;
|
||||
}
|
||||
if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
|
||||
makefile.linkfileend << " \\\n\t\t-Wl,--end-group\n\n";
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Point CppBuilder::ExtractVersion()
|
||||
{
|
||||
Point v = Point(Null, Null);
|
||||
CParser p(version);
|
||||
while(!p.IsEof()) {
|
||||
if(p.IsNumber()) {
|
||||
v.x = p.ReadNumber();
|
||||
break;
|
||||
}
|
||||
p.GetChar();
|
||||
p.Spaces();
|
||||
}
|
||||
while(!p.IsEof()) {
|
||||
if(p.IsNumber()) {
|
||||
v.y = p.ReadNumber();
|
||||
break;
|
||||
}
|
||||
p.GetChar();
|
||||
p.Spaces();
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
void CppBuilder::ShowTime(int count, int start_time)
|
||||
{
|
||||
if(count)
|
||||
PutConsole(NFormat("%d file(s) compiled in %s %d msec/file",
|
||||
count, GetPrintTime(start_time), msecs(start_time) / count));
|
||||
}
|
||||
#include "Builders.h"
|
||||
|
||||
static String MakeIdent(const char *name)
|
||||
{
|
||||
String out;
|
||||
for(; *name; name++)
|
||||
out << (iscid(*name) ? *name : '_');
|
||||
return out;
|
||||
}
|
||||
|
||||
static String MakeSourcePath(const Vector<String>& dirs, String fn, bool raw, bool exporting)
|
||||
{
|
||||
fn = UnixPath(fn);
|
||||
for(int i = 0; i < dirs.GetCount(); i++)
|
||||
{
|
||||
int dl = dirs[i].GetLength();
|
||||
if(fn.GetLength() >= dl + 2 && !memcmp(fn, dirs[i], dl) && fn[dl] == '/') {
|
||||
String s;
|
||||
if(!exporting)
|
||||
s << "$(UPPDIR" << (i + 1) << ")";
|
||||
s << AdjustMakePath(fn.GetIter(dl + 1));
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return raw ? String() : AdjustMakePath(fn);
|
||||
}
|
||||
|
||||
String CppBuilder::GetMakePath(String fn) const
|
||||
{
|
||||
return ::GetMakePath(fn, HasFlag("WIN32"));
|
||||
}
|
||||
|
||||
void CppBuilder::AddMakeFile(MakeFile& makefile, String package,
|
||||
const Vector<String>& all_uses, const Vector<String>& all_libraries,
|
||||
const Index<String>& common_config, bool exporting)
|
||||
{
|
||||
String packagepath = PackagePath(package);
|
||||
Package pkg;
|
||||
pkg.Load(packagepath);
|
||||
String packagedir = GetFileFolder(packagepath);
|
||||
Vector<String> src = GetUppDirs();
|
||||
for(int i = 0; i < src.GetCount(); i++)
|
||||
src[i] = UnixPath(src[i]);
|
||||
|
||||
bool main = HasFlag("MAIN");
|
||||
bool is_shared = HasFlag("SO");
|
||||
bool libout = !main && !HasFlag("NOLIB");
|
||||
bool win32 = HasFlag("WIN32");
|
||||
|
||||
String pack_ident = MakeIdent(package);
|
||||
String outdir = "OutDir_" + pack_ident;
|
||||
String macros = "Macro_" + pack_ident;
|
||||
String macdef = "$(Macro)";
|
||||
String objext = (HasFlag("MSC") || HasFlag("EVC") ? ".obj" : ".o");
|
||||
|
||||
Vector<String> x(config.GetKeys(), 1);
|
||||
Sort(x);
|
||||
for(int i = 0; i < x.GetCount(); i++) {
|
||||
if(common_config.Find(x[i]) < 0)
|
||||
macdef << " -Dflag" << x[i];
|
||||
x[i] = InitCaps(x[i]);
|
||||
}
|
||||
|
||||
makefile.outdir << "$(" << outdir << ")";
|
||||
makefile.outfile << AdjustMakePath(GetFileTitle(NativePath(package)));
|
||||
if(main)
|
||||
makefile.outfile << GetTargetExt();
|
||||
else if(is_shared)
|
||||
makefile.outfile << (win32 ? ".dll" : ".so");
|
||||
else
|
||||
makefile.outfile << (win32 && HasFlag("MSC") ? ".lib" : ".a");
|
||||
makefile.output << (main ? String("$(OutDir)") : makefile.outdir) << makefile.outfile;
|
||||
|
||||
if(main) {
|
||||
makefile.config << "CXX = c++\n"
|
||||
"LINKER = $(CXX)\n";
|
||||
String flags;
|
||||
if(HasFlag("DEBUG"))
|
||||
flags << " -D_DEBUG " << debug_options;
|
||||
else
|
||||
flags << ' ' << release_options;
|
||||
if(HasFlag("DEBUG_MINIMAL"))
|
||||
flags << " -ggdb -g1";
|
||||
if(HasFlag("DEBUG_FULL"))
|
||||
flags << " -ggdb -g2";
|
||||
if(is_shared && !win32)
|
||||
flags << " -fPIC ";
|
||||
flags << ' ' << Gather(pkg.option, config.GetKeys());
|
||||
makefile.config << "CFLAGS =" << flags << "\n"
|
||||
"CXXFLAGS =" << flags << "\n"
|
||||
"LDFLAGS = " << (HasFlag("DEBUG") ? debug_link : release_link) << " $(LINKOPTIONS)\n"
|
||||
"LIBPATH =";
|
||||
for(int i = 0; i < libpath.GetCount(); i++)
|
||||
makefile.config << " -L" << GetMakePath(AdjustMakePath(GetHostPathQ(libpath[i])));
|
||||
makefile.config << "\n"
|
||||
"AR = ar -sr\n\n";
|
||||
makefile.install << "\t-mkdir -p $(OutDir)\n";
|
||||
Vector<String> lib;
|
||||
String lnk;
|
||||
lnk << "$(LINKER)";
|
||||
if(!HasFlag("SHARED"))
|
||||
lnk << " -static";
|
||||
if(HasFlag("WIN32")) {
|
||||
lnk << " -mwindows";
|
||||
if(!HasFlag("GUI"))
|
||||
makefile.linkfiles << " -mconsole";
|
||||
}
|
||||
lnk << " -o $(OutFile)";
|
||||
if(HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL"))
|
||||
lnk << " -ggdb";
|
||||
else
|
||||
lnk << (!HasFlag("OSX11") ? " -Wl,-s" : "");
|
||||
|
||||
lnk << " $(LIBPATH)";
|
||||
if (!HasFlag("OSX11"))
|
||||
lnk << " -Wl,-O,2";
|
||||
lnk << " $(LDFLAGS) -Wl,--start-group ";
|
||||
|
||||
makefile.linkfiles = lnk;
|
||||
}
|
||||
|
||||
makefile.config << outdir << " = $(UPPOUT)"
|
||||
<< GetMakePath(AdjustMakePath(String().Cat() << package << '/' << method << '-' << Join(x, "-") << '/')) << "\n"
|
||||
<< macros << " = " << macdef << "\n";
|
||||
|
||||
makefile.install << "\t-mkdir -p $(" << outdir << ")\n";
|
||||
|
||||
String libdep, libfiles;
|
||||
|
||||
libdep << makefile.output << ":";
|
||||
if(is_shared)
|
||||
{
|
||||
libfiles = "c++ -shared -fPIC"; // -v";
|
||||
Point p = ExtractVersion();
|
||||
if(!IsNull(p.x)) {
|
||||
libfiles << " -Xlinker --major-image-version -Xlinker " << p.x;
|
||||
if(!IsNull(p.y))
|
||||
libfiles << " -Xlinker --minor-image-version -Xlinker " << p.y;
|
||||
}
|
||||
libfiles << " -o ";
|
||||
}
|
||||
else
|
||||
libfiles = "$(AR) ";
|
||||
libfiles << makefile.output;
|
||||
|
||||
Vector<String> libs = Split(Gather(pkg.library, config.GetKeys()), ' ');
|
||||
for(int i = 0; i < libs.GetCount(); i++) {
|
||||
String ln = libs[i];
|
||||
String ext = ToLower(GetFileExt(ln));
|
||||
if(ext == ".a" || ext == ".so" || ext == ".dll")
|
||||
makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
|
||||
else
|
||||
makefile.linkfileend << " \\\n\t\t\t-l" << ln;
|
||||
}
|
||||
|
||||
for(int i = 0; i < pkg.GetCount(); i++)
|
||||
if(!pkg[i].separator) {
|
||||
String gop = Gather(pkg[i].option, config.GetKeys());
|
||||
String fn = SourcePath(package, pkg[i]);
|
||||
String ext = ToLower(GetFileExt(fn));
|
||||
bool isc = ext == ".c";
|
||||
bool isrc = (ext == ".rc" && HasFlag("WIN32"));
|
||||
bool iscpp = (ext == ".cpp" || ext == ".cc" || ext == ".cxx");
|
||||
bool isicpp = (ext == ".icpp");
|
||||
if(ext == ".brc") {
|
||||
isc = true;
|
||||
fn << "c";
|
||||
}
|
||||
if(isc || isrc || iscpp || isicpp) {
|
||||
String outfile;
|
||||
outfile << makefile.outdir << AdjustMakePath(GetFileTitle(fn)) << (isrc ? "_rc" : "") << objext;
|
||||
String srcfile = GetMakePath(MakeSourcePath(src, fn, false, exporting));
|
||||
makefile.rules << outfile << ": " << srcfile;
|
||||
Vector<String> dep = HdependGetDependencies(fn);
|
||||
Sort(dep, GetLanguageInfo());
|
||||
for(int d = 0; d < dep.GetCount(); d++) {
|
||||
String dfn = MakeSourcePath(src, dep[d], true, exporting);
|
||||
if(!IsNull(dfn))
|
||||
makefile.rules << " \\\n\t" << GetMakePath(dfn);
|
||||
}
|
||||
makefile.rules << "\n"
|
||||
"\t$(CXX) -c " << (isc ? "-x c $(CFLAGS)" : "-x c++ $(CXXFLAGS)") << " $(CINC) $(" << macros << ") "
|
||||
<< gop << " " << srcfile << " -o " << outfile << "\n\n";
|
||||
if(!libout || isicpp) {
|
||||
makefile.linkdep << " \\\n\t" << outfile;
|
||||
makefile.linkfiles << " \\\n\t\t" << outfile;
|
||||
}
|
||||
else {
|
||||
libdep << " \\\n\t" << outfile;
|
||||
libfiles << " \\\n\t\t" << outfile;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(ext == ".o" || ext == ".obj" || ext == ".a" || ext == ".so" || ext == ".lib" || ext == ".dll") {
|
||||
makefile.linkdep << " \\\n\t" << fn;
|
||||
makefile.linkfiles << ' ' << fn;
|
||||
}
|
||||
}
|
||||
|
||||
if(libout) {
|
||||
makefile.rules << libdep << "\n\t" << libfiles << "\n\n";
|
||||
makefile.linkdep << " \\\n\t" << makefile.output;
|
||||
makefile.linkfiles << " \\\n\t\t\t" << makefile.output;
|
||||
}
|
||||
/*
|
||||
if(main) {
|
||||
if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
|
||||
makefile.linkfiles << " \\\n\t\t-Wl,--start-group ";
|
||||
DDUMPC(all_libraries);
|
||||
for(int i = 0; i < all_libraries.GetCount(); i++) {
|
||||
String ln = all_libraries[i];
|
||||
String ext = ToLower(GetFileExt(ln));
|
||||
if(ext == ".a" || ext == ".so" || ext == ".dll")
|
||||
makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
|
||||
else
|
||||
makefile.linkfileend << " \\\n\t\t\t-l" << ln;
|
||||
}
|
||||
if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
|
||||
makefile.linkfileend << " \\\n\t\t-Wl,--end-group\n\n";
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Point CppBuilder::ExtractVersion()
|
||||
{
|
||||
Point v = Point(Null, Null);
|
||||
CParser p(version);
|
||||
while(!p.IsEof()) {
|
||||
if(p.IsNumber()) {
|
||||
v.x = p.ReadNumber();
|
||||
break;
|
||||
}
|
||||
p.GetChar();
|
||||
p.Spaces();
|
||||
}
|
||||
while(!p.IsEof()) {
|
||||
if(p.IsNumber()) {
|
||||
v.y = p.ReadNumber();
|
||||
break;
|
||||
}
|
||||
p.GetChar();
|
||||
p.Spaces();
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
void CppBuilder::ShowTime(int count, int start_time)
|
||||
{
|
||||
if(count)
|
||||
PutConsole(NFormat("%d file(s) compiled in %s %d msec/file",
|
||||
count, GetPrintTime(start_time), msecs(start_time) / count));
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,417 +1,535 @@
|
|||
#include "Core.h"
|
||||
|
||||
typedef VectorMap<String, Builder *(*)()> BuilderMapType;
|
||||
GLOBAL_VAR(BuilderMapType, BuilderMap)
|
||||
|
||||
void RegisterBuilder(const char *name, Builder *(*create)())
|
||||
{
|
||||
ASSERT(BuilderMap().Find(name) < 0);
|
||||
BuilderMap().Add(name, create);
|
||||
}
|
||||
|
||||
String FindInDirs(const Vector<String>& dir, const String& file)
|
||||
{
|
||||
if(!IsFullPath(file))
|
||||
for(int i = 0; i < dir.GetCount(); i++) {
|
||||
String ef = CatAnyPath(dir[i], file);
|
||||
if(FileExists(ef))
|
||||
return ef;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
String FindCommand(const Vector<String>& exedir, const String& cmdline)
|
||||
{
|
||||
String app;
|
||||
const char *s = cmdline;
|
||||
while(*s && (byte)*s <= ' ')
|
||||
s++;
|
||||
if(*s == '\"')
|
||||
{
|
||||
const char *b = ++s;
|
||||
while(*s && *s != '\"')
|
||||
s++;
|
||||
app = String(b, s);
|
||||
if(*s)
|
||||
s++;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *b = s;
|
||||
while(*s && (byte)*s > ' ')
|
||||
s++;
|
||||
app = String(b, s);
|
||||
}
|
||||
String tail = s;
|
||||
String fn = FindInDirs(exedir, app);
|
||||
if(!FileExists(fn))
|
||||
#ifdef PLATFORM_WIN32
|
||||
fn = FindInDirs(exedir, ForceExt(app, ".exe"));
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
fn = FindInDirs(exedir, app);
|
||||
#endif
|
||||
if(fn.Find(' ') >= 0)
|
||||
fn = '\"' + fn + '\"';
|
||||
return fn + tail;
|
||||
}
|
||||
|
||||
String GetMakePath(String fn, bool win32)
|
||||
{
|
||||
fn = UnixPath(fn);
|
||||
if(!win32)
|
||||
return fn;
|
||||
String out;
|
||||
for(const char *p = fn; *p; p++)
|
||||
if(*p == '/')
|
||||
out << "\\\\";
|
||||
else
|
||||
out.Cat(*p);
|
||||
return out;
|
||||
}
|
||||
|
||||
String AdjustMakePath(const char *fn)
|
||||
{
|
||||
String out;
|
||||
for(; *fn; fn++)
|
||||
if(*fn == '$')
|
||||
out << '$' << '$';
|
||||
else
|
||||
out << *fn;
|
||||
return out;
|
||||
}
|
||||
|
||||
static IdeContext *the_ide;
|
||||
|
||||
IdeContext *TheIde() { return the_ide; }
|
||||
void TheIde(IdeContext *context) { the_ide = context; }
|
||||
|
||||
void PutConsole(const char *s) { if(the_ide) the_ide->PutConsole(s); }
|
||||
void PutVerbose(const char *s) { if(the_ide) the_ide->PutVerbose(s); }
|
||||
|
||||
const Workspace& GetIdeWorkspace()
|
||||
{
|
||||
if(the_ide)
|
||||
return the_ide->IdeWorkspace();
|
||||
static Workspace x;
|
||||
return x;
|
||||
}
|
||||
|
||||
String IdeContext::GetDefaultMethod()
|
||||
{
|
||||
return LoadFile(ConfigFile("default_method"));
|
||||
}
|
||||
|
||||
VectorMap<String, String> IdeContext::GetMethodVars(const String& method)
|
||||
{
|
||||
VectorMap<String, String> map;
|
||||
LoadVarFile(ConfigFile((String)~method + ".bm"), map);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
String GetDefaultMethod()
|
||||
{
|
||||
return the_ide ? the_ide->GetDefaultMethod() : String();
|
||||
}
|
||||
|
||||
VectorMap<String, String> GetMethodVars(const String& method)
|
||||
{
|
||||
return the_ide ? the_ide->GetMethodVars(method) : VectorMap<String, String>();
|
||||
}
|
||||
|
||||
bool IdeIsBuilding()
|
||||
{
|
||||
return the_ide && the_ide->IdeIsBuilding();
|
||||
}
|
||||
|
||||
void IdeSetBar()
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeSetBar();
|
||||
}
|
||||
|
||||
String IdeGetOneFile()
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetOneFile() : String(Null);
|
||||
}
|
||||
|
||||
int IdeConsoleExecute(const char *cmdline, Stream *out, const char *envptr, bool quiet)
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleExecute(cmdline, out, envptr, quiet) : -1;
|
||||
}
|
||||
|
||||
int IdeConsoleExecuteWithInput(const char *cmdline, Stream *out, const char *envptr, bool quiet)
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleExecuteWithInput(cmdline, out, envptr, quiet) : -1;
|
||||
}
|
||||
|
||||
int IdeConsoleExecute(One<SlaveProcess> process, const char *cmdline, Stream *out, bool quiet)
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleExecute(process, cmdline, out, quiet) : -1;
|
||||
}
|
||||
|
||||
int IdeConsoleAllocSlot()
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleAllocSlot() : 0;
|
||||
}
|
||||
|
||||
bool IdeConsoleRun(const char *cmdline, Stream *out, const char *envptr, bool quiet, int slot, String key, int blitz_count)
|
||||
{
|
||||
return the_ide && the_ide->IdeConsoleRun(cmdline, out, envptr, quiet, slot, key, blitz_count);
|
||||
}
|
||||
|
||||
bool IdeConsoleRun(One<SlaveProcess> process, const char *cmdline, Stream *out, bool quiet, int slot, String key, int blitz_count)
|
||||
{
|
||||
return the_ide && the_ide->IdeConsoleRun(process, cmdline, out, quiet, slot, key, blitz_count);
|
||||
}
|
||||
|
||||
void IdeConsoleFlush()
|
||||
{
|
||||
if(the_ide) the_ide->IdeConsoleFlush();
|
||||
}
|
||||
|
||||
void IdeConsoleBeginGroup(String group)
|
||||
{
|
||||
if(the_ide) the_ide->IdeConsoleBeginGroup(group);
|
||||
}
|
||||
|
||||
void IdeConsoleEndGroup()
|
||||
{
|
||||
if(the_ide) the_ide->IdeConsoleEndGroup();
|
||||
}
|
||||
|
||||
bool IdeConsoleWait()
|
||||
{
|
||||
return the_ide && the_ide->IdeConsoleWait();
|
||||
}
|
||||
|
||||
void IdeGotoCodeRef(String s)
|
||||
{
|
||||
if(the_ide) the_ide->IdeGotoCodeRef(s);
|
||||
}
|
||||
|
||||
void IdeSetBottom(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeSetBottom(ctrl);
|
||||
}
|
||||
|
||||
void IdeActivateBottom() {
|
||||
if(the_ide) the_ide->IdeActivateBottom();
|
||||
}
|
||||
|
||||
|
||||
void IdeRemoveBottom(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeRemoveBottom(ctrl);
|
||||
}
|
||||
|
||||
void IdeSetRight(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeSetRight(ctrl);
|
||||
}
|
||||
|
||||
void IdeRemoveRight(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeRemoveRight(ctrl);
|
||||
}
|
||||
|
||||
bool IdeIsDebug()
|
||||
{
|
||||
return the_ide && the_ide->IdeIsDebug();
|
||||
}
|
||||
|
||||
void IdeEndDebug()
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeEndDebug();
|
||||
}
|
||||
|
||||
void IdeSetDebugPos(const String& file, int line, const Image& img, int i)
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeSetDebugPos(file, line, img, i);
|
||||
}
|
||||
|
||||
void IdeHidePtr()
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeHidePtr();
|
||||
}
|
||||
|
||||
bool IdeDebugLock()
|
||||
{
|
||||
return the_ide && the_ide->IdeDebugLock();
|
||||
}
|
||||
|
||||
bool IdeDebugUnLock()
|
||||
{
|
||||
return the_ide && the_ide->IdeDebugUnLock();
|
||||
}
|
||||
|
||||
bool IdeIsDebugLock()
|
||||
{
|
||||
return the_ide && the_ide->IdeIsDebugLock();
|
||||
}
|
||||
|
||||
String IdeGetFileName()
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetFileName() : String(Null);
|
||||
}
|
||||
|
||||
int IdeGetFileLine()
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetFileLine() : 0;
|
||||
}
|
||||
|
||||
String IdeGetLine(int i)
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetLine(i) : String(Null);
|
||||
}
|
||||
|
||||
bool SaveChangedFile(const char *path, String data, bool delete_empty)
|
||||
{
|
||||
if(LoadFile(path) == data)
|
||||
return true;
|
||||
if(delete_empty && IsNull(data))
|
||||
return FileDelete(path);
|
||||
else
|
||||
return SaveFile(path, data);
|
||||
}
|
||||
|
||||
static int sReadCharc(CParser& p)
|
||||
{
|
||||
p.PassChar('\'');
|
||||
if(!IsAlpha(p.PeekChar()))
|
||||
p.ThrowError("language code alphabetic character expected");
|
||||
char c = p.GetChar();
|
||||
p.PassChar('\'');
|
||||
return c;
|
||||
}
|
||||
|
||||
static void sReadLNG(CParser& p, char *c)
|
||||
{
|
||||
p.PassChar('(');
|
||||
c[0] = sReadCharc(p);
|
||||
p.PassChar(',');
|
||||
c[1] = sReadCharc(p);
|
||||
p.PassChar(',');
|
||||
c[2] = sReadCharc(p);
|
||||
p.PassChar(',');
|
||||
c[3] = sReadCharc(p);
|
||||
}
|
||||
|
||||
int ReadLNG(CParser& p) {
|
||||
char c[4];
|
||||
if(p.Id("LNG_CZECH"))
|
||||
return LNG_CZECH;
|
||||
else
|
||||
if(p.Id("LNG_ENGLISH"))
|
||||
return LNG_ENGLISH;
|
||||
else
|
||||
if(p.Id("LNG_")) {
|
||||
sReadLNG(p, c);
|
||||
p.PassChar(')');
|
||||
return LNG_(c[0], c[1], c[2], c[3]);
|
||||
}
|
||||
else
|
||||
if(p.Id("LNGC_")) {
|
||||
sReadLNG(p, c);
|
||||
p.PassChar(',');
|
||||
dword l = LNGC_(c[0], c[1], c[2], c[3], p.ReadInt());
|
||||
p.PassChar(')');
|
||||
return l;
|
||||
}
|
||||
else
|
||||
p.ThrowError("invalid language code");
|
||||
return 0;
|
||||
}
|
||||
|
||||
String MakeLNG(int lang)
|
||||
{
|
||||
int cs = GetLNGCharset(lang);
|
||||
String str;
|
||||
if(cs)
|
||||
return str << "LNGC_('"
|
||||
<< char(((lang >> 15) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 10) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 5) & 31) + 'A' - 1) << "', '"
|
||||
<< char((lang & 31) + 'A' - 1) << "', " << cs << ")";
|
||||
else
|
||||
return str << "LNG_('"
|
||||
<< char(((lang >> 15) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 10) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 5) & 31)+ 'A' - 1) << "', '"
|
||||
<< char((lang & 31) + 'A' - 1) << "')";
|
||||
}
|
||||
|
||||
String PrintTime(int time) {
|
||||
int q = time % 1000 / 10;
|
||||
time /= 1000;
|
||||
return Format("(%d:%02d.%02d)", time / 60, time % 60, q);
|
||||
}
|
||||
|
||||
Point ReadNums(CParser& p) {
|
||||
Point pt;
|
||||
pt.x = p.ReadInt();
|
||||
p.PassChar(',');
|
||||
pt.y = p.ReadInt();
|
||||
return pt;
|
||||
}
|
||||
|
||||
Point ReadPoint(CParser& p)
|
||||
{
|
||||
Point pt;
|
||||
p.PassChar('(');
|
||||
pt = ReadNums(p);
|
||||
p.PassChar(')');
|
||||
return pt;
|
||||
}
|
||||
|
||||
bool OldLang() {
|
||||
static int q = -1;
|
||||
if(q < 0)
|
||||
q = FileExists(ConfigFile("oldlang"));
|
||||
return q;
|
||||
}
|
||||
|
||||
int CharFilterCid(int c)
|
||||
{
|
||||
return IsAlNum(c) || c == '_' ? c : 0;
|
||||
}
|
||||
|
||||
|
||||
bool IsDoc(String s)
|
||||
{
|
||||
s = ToLower(s);
|
||||
if(s.Find("svn") >= 0)
|
||||
return false;
|
||||
return s.Find("readme") >= 0 || s.Find("copying") >= 0 || s.Find("license") >= 0 ||
|
||||
s.Find("authors") >= 0;
|
||||
}
|
||||
|
||||
void CopyFolder(const char *_dst, const char *_src, Index<String>& used, bool all)
|
||||
{
|
||||
String dst = NativePath(_dst);
|
||||
String src = NativePath(_src);
|
||||
if(dst == src)
|
||||
return;
|
||||
FindFile ff(AppendFileName(src, "*"));
|
||||
bool realize = true;
|
||||
while(ff) {
|
||||
String s = AppendFileName(src, ff.GetName());
|
||||
String d = AppendFileName(dst, ff.GetName());
|
||||
if(ff.IsFolder())
|
||||
CopyFolder(d, s, used, all);
|
||||
else
|
||||
if(ff.IsFile() && (all || IsDoc(s) || used.Find(s) >= 0)) {
|
||||
if(realize) {
|
||||
RealizeDirectory(dst);
|
||||
realize = false;
|
||||
}
|
||||
SaveFile(d, LoadFile(s));
|
||||
SetFileTime(d, ff.GetLastWriteTime());
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
}
|
||||
#include "Core.h"
|
||||
|
||||
typedef VectorMap<String, Builder *(*)()> BuilderMapType;
|
||||
GLOBAL_VAR(BuilderMapType, BuilderMap)
|
||||
|
||||
void RegisterBuilder(const char *name, Builder *(*create)())
|
||||
{
|
||||
ASSERT(BuilderMap().Find(name) < 0);
|
||||
BuilderMap().Add(name, create);
|
||||
}
|
||||
|
||||
String FindInDirs(const Vector<String>& dir, const String& file)
|
||||
{
|
||||
if(!IsFullPath(file))
|
||||
for(int i = 0; i < dir.GetCount(); i++) {
|
||||
String ef = CatAnyPath(dir[i], file);
|
||||
if(FileExists(ef))
|
||||
return ef;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
String FindCommand(const Vector<String>& exedir, const String& cmdline)
|
||||
{
|
||||
String app;
|
||||
const char *s = cmdline;
|
||||
while(*s && (byte)*s <= ' ')
|
||||
s++;
|
||||
if(*s == '\"')
|
||||
{
|
||||
const char *b = ++s;
|
||||
while(*s && *s != '\"')
|
||||
s++;
|
||||
app = String(b, s);
|
||||
if(*s)
|
||||
s++;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *b = s;
|
||||
while(*s && (byte)*s > ' ')
|
||||
s++;
|
||||
app = String(b, s);
|
||||
}
|
||||
String tail = s;
|
||||
String fn = FindInDirs(exedir, app);
|
||||
if(!FileExists(fn))
|
||||
#ifdef PLATFORM_WIN32
|
||||
fn = FindInDirs(exedir, ForceExt(app, ".exe"));
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
fn = FindInDirs(exedir, app);
|
||||
#endif
|
||||
if(fn.Find(' ') >= 0)
|
||||
fn = '\"' + fn + '\"';
|
||||
return fn + tail;
|
||||
}
|
||||
|
||||
String GetMakePath(String fn, bool win32)
|
||||
{
|
||||
fn = UnixPath(fn);
|
||||
if(!win32)
|
||||
return fn;
|
||||
String out;
|
||||
for(const char *p = fn; *p; p++)
|
||||
if(*p == '/')
|
||||
out << "\\\\";
|
||||
else
|
||||
out.Cat(*p);
|
||||
return out;
|
||||
}
|
||||
|
||||
String AdjustMakePath(const char *fn)
|
||||
{
|
||||
String out;
|
||||
for(; *fn; fn++)
|
||||
if(*fn == '$')
|
||||
out << '$' << '$';
|
||||
else
|
||||
out << *fn;
|
||||
return out;
|
||||
}
|
||||
|
||||
static IdeContext *the_ide;
|
||||
|
||||
IdeContext *TheIde() { return the_ide; }
|
||||
void TheIde(IdeContext *context) { the_ide = context; }
|
||||
|
||||
void PutConsole(const char *s) { if(the_ide) the_ide->PutConsole(s); }
|
||||
void PutVerbose(const char *s) { if(the_ide) the_ide->PutVerbose(s); }
|
||||
|
||||
const Workspace& GetIdeWorkspace()
|
||||
{
|
||||
if(the_ide)
|
||||
return the_ide->IdeWorkspace();
|
||||
static Workspace x;
|
||||
return x;
|
||||
}
|
||||
|
||||
String IdeContext::GetDefaultMethod()
|
||||
{
|
||||
return LoadFile(ConfigFile("default_method"));
|
||||
}
|
||||
|
||||
VectorMap<String, String> IdeContext::GetMethodVars(const String& method)
|
||||
{
|
||||
VectorMap<String, String> map;
|
||||
LoadVarFile(ConfigFile((String)~method + ".bm"), map);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
String GetDefaultMethod()
|
||||
{
|
||||
return the_ide ? the_ide->GetDefaultMethod() : String();
|
||||
}
|
||||
|
||||
VectorMap<String, String> GetMethodVars(const String& method)
|
||||
{
|
||||
return the_ide ? the_ide->GetMethodVars(method) : VectorMap<String, String>();
|
||||
}
|
||||
|
||||
bool IdeIsBuilding()
|
||||
{
|
||||
return the_ide && the_ide->IdeIsBuilding();
|
||||
}
|
||||
|
||||
void IdeSetBar()
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeSetBar();
|
||||
}
|
||||
|
||||
String IdeGetOneFile()
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetOneFile() : String(Null);
|
||||
}
|
||||
|
||||
int IdeConsoleExecute(const char *cmdline, Stream *out, const char *envptr, bool quiet)
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleExecute(cmdline, out, envptr, quiet) : -1;
|
||||
}
|
||||
|
||||
int IdeConsoleExecuteWithInput(const char *cmdline, Stream *out, const char *envptr, bool quiet)
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleExecuteWithInput(cmdline, out, envptr, quiet) : -1;
|
||||
}
|
||||
|
||||
int IdeConsoleExecute(One<SlaveProcess> process, const char *cmdline, Stream *out, bool quiet)
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleExecute(process, cmdline, out, quiet) : -1;
|
||||
}
|
||||
|
||||
int IdeConsoleAllocSlot()
|
||||
{
|
||||
return the_ide ? the_ide->IdeConsoleAllocSlot() : 0;
|
||||
}
|
||||
|
||||
bool IdeConsoleRun(const char *cmdline, Stream *out, const char *envptr, bool quiet, int slot, String key, int blitz_count)
|
||||
{
|
||||
return the_ide && the_ide->IdeConsoleRun(cmdline, out, envptr, quiet, slot, key, blitz_count);
|
||||
}
|
||||
|
||||
bool IdeConsoleRun(One<SlaveProcess> process, const char *cmdline, Stream *out, bool quiet, int slot, String key, int blitz_count)
|
||||
{
|
||||
return the_ide && the_ide->IdeConsoleRun(process, cmdline, out, quiet, slot, key, blitz_count);
|
||||
}
|
||||
|
||||
void IdeConsoleFlush()
|
||||
{
|
||||
if(the_ide) the_ide->IdeConsoleFlush();
|
||||
}
|
||||
|
||||
void IdeConsoleBeginGroup(String group)
|
||||
{
|
||||
if(the_ide) the_ide->IdeConsoleBeginGroup(group);
|
||||
}
|
||||
|
||||
void IdeConsoleEndGroup()
|
||||
{
|
||||
if(the_ide) the_ide->IdeConsoleEndGroup();
|
||||
}
|
||||
|
||||
bool IdeConsoleWait()
|
||||
{
|
||||
return the_ide && the_ide->IdeConsoleWait();
|
||||
}
|
||||
|
||||
void IdeGotoCodeRef(String s)
|
||||
{
|
||||
if(the_ide) the_ide->IdeGotoCodeRef(s);
|
||||
}
|
||||
|
||||
void IdeSetBottom(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeSetBottom(ctrl);
|
||||
}
|
||||
|
||||
void IdeActivateBottom() {
|
||||
if(the_ide) the_ide->IdeActivateBottom();
|
||||
}
|
||||
|
||||
|
||||
void IdeRemoveBottom(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeRemoveBottom(ctrl);
|
||||
}
|
||||
|
||||
void IdeSetRight(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeSetRight(ctrl);
|
||||
}
|
||||
|
||||
void IdeRemoveRight(Ctrl& ctrl)
|
||||
{
|
||||
if(the_ide) the_ide->IdeRemoveRight(ctrl);
|
||||
}
|
||||
|
||||
bool IdeIsDebug()
|
||||
{
|
||||
return the_ide && the_ide->IdeIsDebug();
|
||||
}
|
||||
|
||||
void IdeEndDebug()
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeEndDebug();
|
||||
}
|
||||
|
||||
void IdeSetDebugPos(const String& file, int line, const Image& img, int i)
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeSetDebugPos(file, line, img, i);
|
||||
}
|
||||
|
||||
void IdeHidePtr()
|
||||
{
|
||||
if(the_ide)
|
||||
the_ide->IdeHidePtr();
|
||||
}
|
||||
|
||||
bool IdeDebugLock()
|
||||
{
|
||||
return the_ide && the_ide->IdeDebugLock();
|
||||
}
|
||||
|
||||
bool IdeDebugUnLock()
|
||||
{
|
||||
return the_ide && the_ide->IdeDebugUnLock();
|
||||
}
|
||||
|
||||
bool IdeIsDebugLock()
|
||||
{
|
||||
return the_ide && the_ide->IdeIsDebugLock();
|
||||
}
|
||||
|
||||
String IdeGetFileName()
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetFileName() : String(Null);
|
||||
}
|
||||
|
||||
int IdeGetFileLine()
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetFileLine() : 0;
|
||||
}
|
||||
|
||||
String IdeGetLine(int i)
|
||||
{
|
||||
return the_ide ? the_ide->IdeGetLine(i) : String(Null);
|
||||
}
|
||||
|
||||
bool SaveChangedFile(const char *path, String data, bool delete_empty)
|
||||
{
|
||||
if(LoadFile(path) == data)
|
||||
return true;
|
||||
if(delete_empty && IsNull(data))
|
||||
return FileDelete(path);
|
||||
else
|
||||
return SaveFile(path, data);
|
||||
}
|
||||
|
||||
static int sReadCharc(CParser& p)
|
||||
{
|
||||
p.PassChar('\'');
|
||||
if(!IsAlpha(p.PeekChar()))
|
||||
p.ThrowError("language code alphabetic character expected");
|
||||
char c = p.GetChar();
|
||||
p.PassChar('\'');
|
||||
return c;
|
||||
}
|
||||
|
||||
static void sReadLNG(CParser& p, char *c)
|
||||
{
|
||||
p.PassChar('(');
|
||||
c[0] = sReadCharc(p);
|
||||
p.PassChar(',');
|
||||
c[1] = sReadCharc(p);
|
||||
p.PassChar(',');
|
||||
c[2] = sReadCharc(p);
|
||||
p.PassChar(',');
|
||||
c[3] = sReadCharc(p);
|
||||
}
|
||||
|
||||
int ReadLNG(CParser& p) {
|
||||
char c[4];
|
||||
if(p.Id("LNG_CZECH"))
|
||||
return LNG_CZECH;
|
||||
else
|
||||
if(p.Id("LNG_ENGLISH"))
|
||||
return LNG_ENGLISH;
|
||||
else
|
||||
if(p.Id("LNG_")) {
|
||||
sReadLNG(p, c);
|
||||
p.PassChar(')');
|
||||
return LNG_(c[0], c[1], c[2], c[3]);
|
||||
}
|
||||
else
|
||||
if(p.Id("LNGC_")) {
|
||||
sReadLNG(p, c);
|
||||
p.PassChar(',');
|
||||
dword l = LNGC_(c[0], c[1], c[2], c[3], p.ReadInt());
|
||||
p.PassChar(')');
|
||||
return l;
|
||||
}
|
||||
else
|
||||
p.ThrowError("invalid language code");
|
||||
return 0;
|
||||
}
|
||||
|
||||
String MakeLNG(int lang)
|
||||
{
|
||||
int cs = GetLNGCharset(lang);
|
||||
String str;
|
||||
if(cs)
|
||||
return str << "LNGC_('"
|
||||
<< char(((lang >> 15) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 10) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 5) & 31) + 'A' - 1) << "', '"
|
||||
<< char((lang & 31) + 'A' - 1) << "', " << cs << ")";
|
||||
else
|
||||
return str << "LNG_('"
|
||||
<< char(((lang >> 15) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 10) & 31) + 'A' - 1) << "', '"
|
||||
<< char(((lang >> 5) & 31)+ 'A' - 1) << "', '"
|
||||
<< char((lang & 31) + 'A' - 1) << "')";
|
||||
}
|
||||
|
||||
String PrintTime(int time) {
|
||||
int q = time % 1000 / 10;
|
||||
time /= 1000;
|
||||
return Format("(%d:%02d.%02d)", time / 60, time % 60, q);
|
||||
}
|
||||
|
||||
Point ReadNums(CParser& p) {
|
||||
Point pt;
|
||||
pt.x = p.ReadInt();
|
||||
p.PassChar(',');
|
||||
pt.y = p.ReadInt();
|
||||
return pt;
|
||||
}
|
||||
|
||||
Point ReadPoint(CParser& p)
|
||||
{
|
||||
Point pt;
|
||||
p.PassChar('(');
|
||||
pt = ReadNums(p);
|
||||
p.PassChar(')');
|
||||
return pt;
|
||||
}
|
||||
|
||||
bool OldLang() {
|
||||
static int q = -1;
|
||||
if(q < 0)
|
||||
q = FileExists(ConfigFile("oldlang"));
|
||||
return q;
|
||||
}
|
||||
|
||||
int CharFilterCid(int c)
|
||||
{
|
||||
return IsAlNum(c) || c == '_' ? c : 0;
|
||||
}
|
||||
|
||||
|
||||
bool IsDoc(String s)
|
||||
{
|
||||
s = ToLower(s);
|
||||
if(s.Find("svn") >= 0)
|
||||
return false;
|
||||
return s.Find("readme") >= 0 || s.Find("copying") >= 0 || s.Find("license") >= 0 ||
|
||||
s.Find("authors") >= 0;
|
||||
}
|
||||
|
||||
static void WriteByteArray(StringBuffer& fo, const String& data)
|
||||
{
|
||||
int pos = 0;
|
||||
for(int p = 0; p < data.GetLength(); p++) {
|
||||
if(pos >= 70) {
|
||||
fo << '\n';
|
||||
pos = 0;
|
||||
}
|
||||
if(pos == 0)
|
||||
fo << '\t';
|
||||
String part = FormatInt((byte)data[p]);
|
||||
fo << part << ", ";
|
||||
pos += part.GetLength() + 2;
|
||||
}
|
||||
}
|
||||
|
||||
String BrcToC(CParser& binscript, String basedir)
|
||||
{
|
||||
BinObjInfo info;
|
||||
info.Parse(binscript, basedir);
|
||||
StringBuffer 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');
|
||||
WriteByteArray(fo, data);
|
||||
fo << "\n};\n\n";
|
||||
// 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\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
BinObjInfo::Block& b = belem[0];
|
||||
fo << "static 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');
|
||||
WriteByteArray(fo, data);
|
||||
fo << "\n};\n\n"
|
||||
"char *" << ident << " = " << ident << "_;\n\n"
|
||||
// fo << AsCString(data, 70) << ";\n\n"
|
||||
"int " << ident << "_length = " << b_length << ";\n\n";
|
||||
}
|
||||
}
|
||||
return fo;
|
||||
}
|
||||
|
||||
void CopyFile(const String& d, const String& s, bool brc)
|
||||
{
|
||||
FindFile ff(s);
|
||||
if(ff) {
|
||||
String ext = ToLower(GetFileExt(s));
|
||||
if(brc && ext == ".brc") {
|
||||
try {
|
||||
String brcdata = LoadFile(s);
|
||||
if(brcdata.IsVoid())
|
||||
throw Exc(Format("error reading file '%s'", s));
|
||||
CParser parser(brcdata, s);
|
||||
Upp::SaveFile(d + "c", BrcToC(parser, GetFileDirectory(s)));
|
||||
}
|
||||
catch(Exc e) {
|
||||
PutConsole(e);
|
||||
}
|
||||
}
|
||||
SaveFile(d, LoadFile(s));
|
||||
SetFileTime(d, ff.GetLastWriteTime());
|
||||
}
|
||||
}
|
||||
|
||||
void CopyFolder(const char *_dst, const char *_src, Index<String>& used, bool all, bool brc)
|
||||
{
|
||||
String dst = NativePath(_dst);
|
||||
String src = NativePath(_src);
|
||||
if(dst == src)
|
||||
return;
|
||||
FindFile ff(AppendFileName(src, "*"));
|
||||
bool realize = true;
|
||||
while(ff) {
|
||||
String s = AppendFileName(src, ff.GetName());
|
||||
String d = AppendFileName(dst, ff.GetName());
|
||||
if(ff.IsFolder())
|
||||
CopyFolder(d, s, used, all, brc);
|
||||
else
|
||||
if(ff.IsFile() && (all || IsDoc(s) || used.Find(s) >= 0)) {
|
||||
if(realize) {
|
||||
RealizeDirectory(dst);
|
||||
realize = false;
|
||||
}
|
||||
CopyFile(d, s, brc);
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <Esc/Esc.h>
|
||||
#include <Web/Web.h>
|
||||
#include <coff/binobj/binobj.h>
|
||||
#include <plugin/bz2/bz2.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
|
|
@ -19,7 +21,9 @@ inline String GetPrintTime(dword time0) { return PrintTime(msecs(time0)); }
|
|||
bool SaveChangedFile(const char *path, String data, bool delete_empty = false);
|
||||
|
||||
bool IsDoc(String s);
|
||||
void CopyFolder(const char *_dst, const char *_src, Index<String>& used, bool all);
|
||||
|
||||
void CopyFile(const String& dst, const String& src, bool brc = false);
|
||||
void CopyFolder(const char *_dst, const char *_src, Index<String>& used, bool all, bool brc = false);
|
||||
|
||||
class Workspace;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ description "TheIDE - common library\377B";
|
|||
|
||||
uses
|
||||
Esc,
|
||||
Web;
|
||||
Web,
|
||||
coff/binobj,
|
||||
plugin/bz2;
|
||||
|
||||
file
|
||||
Core.h,
|
||||
|
|
|
|||
|
|
@ -2,4 +2,6 @@
|
|||
#define _ide_Core_icpp_init_stub
|
||||
#include "Esc/init"
|
||||
#include "Web/init"
|
||||
#include "coff/binobj/init"
|
||||
#include "plugin/bz2/init"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,68 +1,68 @@
|
|||
#include "ide.h"
|
||||
|
||||
void Ide::ExportMakefile(const String& ep)
|
||||
{
|
||||
SaveMakeFile(AppendFileName(ep, "Makefile"), true);
|
||||
}
|
||||
|
||||
void Ide::ExportProject(const String& ep, bool all, bool gui)
|
||||
{
|
||||
SaveFile(false);
|
||||
::Workspace wspc;
|
||||
wspc.Scan(main);
|
||||
Index<String> used;
|
||||
HdependClearDependencies();
|
||||
for(int i = 0; i < wspc.GetCount(); i++) {
|
||||
const Package& p = wspc.GetPackage(i);
|
||||
String pn = wspc[i];
|
||||
for(int j = 0; j < p.GetCount(); j++) {
|
||||
const Package::File& f = p[j];
|
||||
if(!f.separator) {
|
||||
String p = SourcePath(pn, f);
|
||||
used.FindAdd(p);
|
||||
Vector<String> d = HdependGetDependencies(p);
|
||||
for(int q = 0; q < d.GetCount(); q++)
|
||||
used.FindAdd(d[q]);
|
||||
for(int q = 0; q < f.depends.GetCount(); q++)
|
||||
used.FindAdd(SourcePath(pn, f.depends[q].text));
|
||||
}
|
||||
}
|
||||
used.FindAdd(SourcePath(pn, "init"));
|
||||
}
|
||||
if(FileExists(ep)) {
|
||||
if(gui && !PromptYesNo(DeQtf(ep) + " is existing file.&"
|
||||
"Do you want to delete it?")) return;
|
||||
FileDelete(ep);
|
||||
}
|
||||
if(DirectoryExists(ep)) {
|
||||
if(gui && !PromptYesNo(DeQtf(ep) + " is existing directory.&"
|
||||
"Do you want to replace it?")) return;
|
||||
DeleteFolderDeep(ep);
|
||||
}
|
||||
|
||||
Progress pi("Exporting project");
|
||||
pi.SetTotal(wspc.GetCount());
|
||||
for(int i = 0; i < wspc.GetCount(); i++) {
|
||||
if(gui && pi.StepCanceled())
|
||||
return;
|
||||
CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all);
|
||||
}
|
||||
Vector<String> upp = GetUppDirs();
|
||||
for(int i = 0; i < upp.GetCount(); i++) {
|
||||
if(gui && pi.StepCanceled())
|
||||
return;
|
||||
String d = upp[i];
|
||||
FindFile ff(AppendFileName(d, "*"));
|
||||
while(ff) {
|
||||
if(ff.IsFile()) {
|
||||
String fn = ff.GetName();
|
||||
String path = AppendFileName(d, fn);
|
||||
if(all || used.Find(path) >= 0)
|
||||
Upp::SaveFile(AppendFileName(ep, fn), LoadFile(path));
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all);
|
||||
}
|
||||
ExportMakefile(ep);
|
||||
}
|
||||
#include "ide.h"
|
||||
|
||||
void Ide::ExportMakefile(const String& ep)
|
||||
{
|
||||
SaveMakeFile(AppendFileName(ep, "Makefile"), true);
|
||||
}
|
||||
|
||||
void Ide::ExportProject(const String& ep, bool all, bool gui)
|
||||
{
|
||||
SaveFile(false);
|
||||
::Workspace wspc;
|
||||
wspc.Scan(main);
|
||||
Index<String> used;
|
||||
HdependClearDependencies();
|
||||
for(int i = 0; i < wspc.GetCount(); i++) {
|
||||
const Package& p = wspc.GetPackage(i);
|
||||
String pn = wspc[i];
|
||||
for(int j = 0; j < p.GetCount(); j++) {
|
||||
const Package::File& f = p[j];
|
||||
if(!f.separator) {
|
||||
String p = SourcePath(pn, f);
|
||||
used.FindAdd(p);
|
||||
Vector<String> d = HdependGetDependencies(p);
|
||||
for(int q = 0; q < d.GetCount(); q++)
|
||||
used.FindAdd(d[q]);
|
||||
for(int q = 0; q < f.depends.GetCount(); q++)
|
||||
used.FindAdd(SourcePath(pn, f.depends[q].text));
|
||||
}
|
||||
}
|
||||
used.FindAdd(SourcePath(pn, "init"));
|
||||
}
|
||||
if(FileExists(ep)) {
|
||||
if(gui && !PromptYesNo(DeQtf(ep) + " is existing file.&"
|
||||
"Do you want to delete it?")) return;
|
||||
FileDelete(ep);
|
||||
}
|
||||
if(DirectoryExists(ep)) {
|
||||
if(gui && !PromptYesNo(DeQtf(ep) + " is existing directory.&"
|
||||
"Do you want to replace it?")) return;
|
||||
DeleteFolderDeep(ep);
|
||||
}
|
||||
|
||||
Progress pi("Exporting project");
|
||||
pi.SetTotal(wspc.GetCount());
|
||||
for(int i = 0; i < wspc.GetCount(); i++) {
|
||||
if(gui && pi.StepCanceled())
|
||||
return;
|
||||
CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true);
|
||||
}
|
||||
Vector<String> upp = GetUppDirs();
|
||||
for(int i = 0; i < upp.GetCount(); i++) {
|
||||
if(gui && pi.StepCanceled())
|
||||
return;
|
||||
String d = upp[i];
|
||||
FindFile ff(AppendFileName(d, "*"));
|
||||
while(ff) {
|
||||
if(ff.IsFile()) {
|
||||
String fn = ff.GetName();
|
||||
String path = AppendFileName(d, fn);
|
||||
if(all || used.Find(path) >= 0)
|
||||
CopyFile(AppendFileName(ep, fn), path, true);
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true);
|
||||
}
|
||||
ExportMakefile(ep);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue