本文整理汇总了C++中One::Link方法的典型用法代码示例。如果您正苦于以下问题:C++ One::Link方法的具体用法?C++ One::Link怎么用?C++ One::Link使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类One
的用法示例。
在下文中一共展示了One::Link方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildPackage
bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, int pkcount,
String mainparam, String outfile, Vector<String>& linkfile, String& linkopt, bool link)
{
String package = wspc[pkindex];
String mainpackage = wspc[0];
const Package& pkg = wspc.package[pkindex];
VectorMap<String, String> bm = GetMethodVars(method);
if(bm.GetCount() == 0) {
PutConsole("Invalid build method");
ConsoleShow();
return false;
}
One<Host> host = CreateHost(false);
if(!IsNull(onefile)) {
OneFileHost *h = new OneFileHost;
h->host = host;
h->onefile = onefile;
host = h;
}
One<Builder> b = CreateBuilder(~host);
if(!b)
return false;
b->config = PackageConfig(wspc, pkindex, bm, mainparam, *host, *b);
const TargetMode& m = targetmode == 0 ? debug : release;
b->version = m.version;
b->method = method;
b->outdir = OutDir(b->config, package, bm);
host->RealizeDir(b->outdir);
String mainfn = Null;
Index<String> mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, &mainfn);
HdependClearDependencies();
for(int i = 0; i < pkg.GetCount(); i++) {
const Array<OptItem>& f = pkg[i].depends;
for(int j = 0; j < f.GetCount(); j++)
if(MatchWhen(f[j].when, mcfg.GetKeys()))
HdependAddDependency(SourcePath(package, pkg[i]), SourcePath(package, f[j].text));
}
String tout = OutDir(mcfg, mainpackage, bm, use_target);
host->RealizeDir(tout);
if(IsNull(mainfn))
mainfn = GetFileTitle(mainpackage) + b->GetTargetExt();
if(!IsNull(outfile))
target = NormalizePath(outfile, tout);
else {
if(m.target_override && !IsNull(m.target) && IsFolder(m.target))
target = host->NormalizePath(AppendFileName(m.target, mainfn));
else
if(m.target_override && (IsFullPath(m.target) || *m.target == '/' || *m.target == '\\'))
target = m.target;
else
if(m.target_override && !IsNull(m.target))
target = host->NormalizePath(AppendFileName(tout, m.target));
else
if(IsFullPath(mainfn))
target = mainfn;
else
target = host->NormalizePath(AppendFileName(tout, mainfn));
}
b->target = target;
b->mainpackage = mainpackage;
if(IsNull(onefile)) {
String out;
out << "----- " << package << " ( " << Join(b->config.GetKeys(), " ") << " )";
if(pkcount > 1)
out << " (" << (pknumber + 1) << " / " << pkcount << ')';
PutConsole(out);
}
else
b->config.FindAdd("NOLIB");
bool ok = b->BuildPackage(package, linkfile, linkopt,
GetAllUses(wspc, pkindex),
GetAllLibraries(wspc, pkindex, bm, mainparam, *host, *b),
targetmode - 1);
Vector<String> errors = PickErrors();
host->DeleteFile(errors);
if(!ok || !errors.IsEmpty())
return false;
if(link) {
ok = b->Link(linkfile, linkopt, GetTargetMode().createmap);
errors = PickErrors();
host->DeleteFile(errors);
if(!ok || !errors.IsEmpty())
return false;
}
return true;
}