ide: pkg_config support in makefile export

git-svn-id: svn://ultimatepp.org/upp/trunk@13843 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-01-09 11:55:29 +00:00
parent 01df106dfc
commit 18f414c15c
5 changed files with 37 additions and 17 deletions

View file

@ -284,6 +284,13 @@ struct OneFileHost : Host {
}
};
void MakeBuild::PkgConfig(const Workspace& wspc, const Index<String>& config, Index<String>& pkg_config)
{
for(int i = 0; i < wspc.GetCount(); i++)
for(String h : Split(Gather(wspc.GetPackage(i).pkg_config, config.GetKeys()), ' '))
pkg_config.FindAdd(h);
}
bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, int pkcount,
String mainparam, String outfile, Vector<String>& linkfile, Vector<String>& immfile,
String& linkopt, bool link)
@ -308,9 +315,7 @@ bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, i
if(!b)
return false;
b->config = PackageConfig(wspc, pkindex, bm, mainparam, *host, *b);
for(int i = 0; i < wspc.GetCount(); i++)
for(String h : Split(Gather(wspc.GetPackage(i).pkg_config, b->config.GetKeys()), ' '))
b->pkg_config.FindAdd(h);
PkgConfig(wspc, b->config, b->pkg_config);
const TargetMode& m = targetmode == 0 ? debug : release;
b->version = m.version;
b->method = method;
@ -634,11 +639,14 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting)
Workspace wspc;
wspc.Scan(GetMain(), allconfig.GetKeys());
for(int i = 1; i < wspc.GetCount(); i++) {
Index<String> pkg_config;
for(int i = 0; i < wspc.GetCount(); i++) {
Index<String> modconfig = PackageConfig(wspc, i, bm, mainconfigparam, *host, *b);
for(int a = allconfig.GetCount(); --a >= 0;)
if(modconfig.Find(allconfig[a]) < 0)
allconfig.Remove(a);
PkgConfig(wspc, modconfig, pkg_config);
if(i)
for(int a = allconfig.GetCount(); --a >= 0;)
if(modconfig.Find(allconfig[a]) < 0)
allconfig.Remove(a);
}
if(!exporting)
@ -649,10 +657,14 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting)
}
else
inclist << "-I./";
for(String s : pkg_config)
inclist << " `pkg-config --cflags " << s << "`";
Vector<String> includes = SplitDirs(bm.Get("INCLUDE",""));
for(int i = 0; i < includes.GetCount(); i++)
inclist << " -I" << includes[i];
makefile << "\n"
"UPPOUT = " << (exporting ? "_out/" : GetMakePath(AdjustMakePath(host->GetHostPath(AppendFileName(uppout, ""))), win32)) << "\n"
"CINC = " << inclist << "\n"
@ -664,6 +676,9 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting)
String output, config, install, rules, linkdep, linkfiles, linkfileend;
for(String s : pkg_config)
linkfileend << " \\\n\t\t\t`pkg-config --libs " << s << "`";
for(int i = 0; i < wspc.GetCount(); i++) {
b->config = PackageConfig(wspc, i, bm, mainconfigparam, *host, *b);
b->version = tm.version;
@ -720,7 +735,7 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting)
linkfiles << mf.linkfiles;
linkfileend << mf.linkfileend;
}
makefile
<< config
<< install

View file

@ -73,6 +73,7 @@ public:
One<Builder> CreateBuilder(Host *host);
String OutDir(const Index<String>& cfg, const String& package,
const VectorMap<String, String>& bm, bool use_target = false);
void PkgConfig(const Workspace& wspc, const Index<String>& config, Index<String>& pkg_config);
bool BuildPackage(const Workspace& wspc, int pkindex, int pknumber, int pkcount,
String mainparam, String outfile, Vector<String>& linkfile, Vector<String>& immfile,
String& linkopt, bool link = false);

View file

@ -172,7 +172,7 @@ void CppBuilder::AddMakeFile(MakeFile& makefile, String package,
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);
Vector<String> dep = HdependGetDependencies(fn, false);
Sort(dep, GetLanguageInfo());
for(int d = 0; d < dep.GetCount(); d++) {
String dfn = MakeSourcePath(src, dep[d], true, exporting);

View file

@ -496,7 +496,7 @@ void HdependTimeDirty();
void HdependClearDependencies();
void HdependAddDependency(const String& file, const String& depends);
Time HdependFileTime(const String& path);
Vector<String> HdependGetDependencies(const String& path);
Vector<String> HdependGetDependencies(const String& file, bool bydefine_too = true);
String FindIncludeFile(const char *s, const String& filedir);
bool HdependBlitzApproved(const String& path);
const Vector<String>& HdependGetDefines(const String& path);

View file

@ -75,7 +75,7 @@ public:
bool BlitzApproved(const String& path);
String FindIncludeFile(const char *s, const String& filedir) { return ::FindIncludeFile(s, filedir, incdir); }
const Vector<String>& GetDefines(const String& path);
Vector<String> GetDependencies(const String& path);
Vector<String> GetDependencies(const String& path, bool bydefine_too = true);
const Vector<String>& GetAllFiles() { return map.GetKeys(); }
};
@ -358,14 +358,18 @@ Time Hdepend::FileTime(int ii)
return time;
}
Vector<String> Hdepend::GetDependencies(const String& path)
Vector<String> Hdepend::GetDependencies(const String& path, bool bydefine_too)
{
ClearFlag();
Index<int> out;
out.Add(File(path));
for(int i = 0; i < out.GetCount(); i++)
if(out[i] >= 0)
FindAppend(out, map[out[i]].depend);
if(out[i] >= 0) {
Info& f = map[out[i]];
for(int i = 0; i < f.depend.GetCount(); i++)
if(bydefine_too || !f.bydefine[i])
out.FindAdd(f.depend[i]);
}
Vector<String> outnames;
for(int i = 1; i < out.GetCount(); i++)
if(out[i] >= 0)
@ -477,9 +481,9 @@ const Vector<String>& HdependGetDefines(const String& path)
return Single<Hdepend>().GetDefines(path);
}
Vector<String> HdependGetDependencies(const String& file)
Vector<String> HdependGetDependencies(const String& file, bool bydefine_too)
{
return Single<Hdepend>().GetDependencies(file);
return Single<Hdepend>().GetDependencies(file, bydefine_too);
}
void HdependClearDependencies()