diff --git a/uppsrc/ide/Builders/Build.cpp b/uppsrc/ide/Builders/Build.cpp index 4391805be..7a5b24444 100644 --- a/uppsrc/ide/Builders/Build.cpp +++ b/uppsrc/ide/Builders/Build.cpp @@ -308,6 +308,10 @@ 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); + DDUMP(b->pkg_config); const TargetMode& m = targetmode == 0 ? debug : release; b->version = m.version; b->method = method; diff --git a/uppsrc/ide/Builders/GccBuilder.cpp b/uppsrc/ide/Builders/GccBuilder.cpp index 6b92dc17b..9a7e4ce4e 100644 --- a/uppsrc/ide/Builders/GccBuilder.cpp +++ b/uppsrc/ide/Builders/GccBuilder.cpp @@ -14,8 +14,10 @@ String GccBuilder::CompilerName() const String GccBuilder::CmdLine(const String& package, const Package& pkg) { String cc = CompilerName(); - cc << " -c "; - cc << IncludesDefinesTargetTime(package, pkg); + cc << " -c"; + for(String s : pkg_config) + cc << " `pkg-config --cflags " << s << "`"; + cc << ' ' << IncludesDefinesTargetTime(package, pkg); return cc; } @@ -127,6 +129,10 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V } String cc = CmdLine(package, pkg); + + DDUMP(pkg_config); + DDUMP(cc); + if(HasFlag("WIN32")/* && HasFlag("MT")*/) cc << " -mthreads"; if(HasFlag("DEBUG_MINIMAL")) @@ -523,6 +529,8 @@ bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, } if(!HasFlag("SOLARIS") && !HasFlag("OSX") && !HasFlag("OBJC")) lnk << " -Wl,--start-group "; + for(String s : pkg_config) + lnk << " `pkg-config --libs " << s << "`"; for(int pass = 0; pass < 2; pass++) { for(i = 0; i < lib.GetCount(); i++) { String ln = lib[i]; diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index fc4f7be09..c0b6a1edc 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -347,6 +347,7 @@ public: Array link; Array option; Array include; + Array pkg_config; Array file; Array config; Array custom; @@ -442,6 +443,8 @@ struct Builder { bool main_conf; bool allow_pch; FileTime start_time; + + Index pkg_config; // names of packages for pkg-config String CmdX(const char *s); diff --git a/uppsrc/ide/Core/Package.cpp b/uppsrc/ide/Core/Package.cpp index ae9b4bc90..e05db8f9b 100644 --- a/uppsrc/ide/Core/Package.cpp +++ b/uppsrc/ide/Core/Package.cpp @@ -220,6 +220,7 @@ bool Package::Load(const char *path) link.Clear(); uses.Clear(); include.Clear(); + pkg_config.Clear(); accepts.Clear(); file.Clear(); config.Clear(); @@ -240,7 +241,8 @@ bool Package::Load(const char *path) !LoadOpt(p, "flags", flag) && !LoadOpt(p, "target", target) && !LoadOpt(p, "uses", uses) && - !LoadOpt(p, "include", include)) { + !LoadOpt(p, "include", include) && + !LoadOpt(p, "pkg_config", pkg_config)) { if(p.Id("charset")) charset = CharsetByNameX(p.ReadString()); else @@ -473,6 +475,7 @@ bool Package::Save(const char *path) const { putopt(out, "options", option); putopt(out, "link", link); putopt(out, "include", include); + putopt(out, "pkg_config", pkg_config); if(file.GetCount()) { out << "file\n"; int i; diff --git a/uppsrc/ide/UppDlg.cpp b/uppsrc/ide/UppDlg.cpp index ac82d47fb..80f2f1981 100644 --- a/uppsrc/ide/UppDlg.cpp +++ b/uppsrc/ide/UppDlg.cpp @@ -234,7 +234,7 @@ void PackageEditor::PackageCursor() accepts.Enable(); option.Enable(); option.Clear(); - for(int i = FLAG; i <= INCLUDE; i++) + for(int i = FLAG; i <= PKG_LAST; i++) OptionAdd(i, opt_name[i], *opt[i]); } } @@ -316,7 +316,7 @@ void PackageEditor::RemoveOption() if(!option.IsCursor() || IsNull(actualpackage)) return; int type = option.Get(0); - if(type >= FLAG && type <= INCLUDE) { + if(type >= FLAG && type <= PKG_LAST) { Array& m = *opt[type]; int i = option.Get(1); if(i >= 0 && i < m.GetCount()) @@ -342,7 +342,7 @@ void PackageEditor::EditOption() } return; } - if(type >= FLAG && type <= INCLUDE) { + if(type >= FLAG && type <= PKG_LAST) { Array& m = *opt[type]; int i = option.Get(1); if(i >= 0 && i < m.GetCount()) { @@ -363,7 +363,7 @@ void PackageEditor::MoveOption(int d) if(!option.IsCursor() || IsNull(actualpackage)) return; int type = option.Get(0); - if(type >= FLAG && type <= INCLUDE) { + if(type >= FLAG && type <= PKG_LAST) { Array& m = *opt[type]; int i = option.Get(1); if(min(i, i + d) >= 0 && max(i, i + d) < m.GetCount()) { @@ -378,7 +378,7 @@ void PackageEditor::OptionMenu(Bar& bar) { bool b = !IsNull(actualpackage); bar.Add(b, "Add package..", IdeImg::package_add(), THISBACK1(AddOption, USES)); - for(int j = FLAG; j <= INCLUDE; j++) + for(int j = FLAG; j <= PKG_LAST; j++) if(j != USES) bar.Add(b, "New " + opt_name[j] + "..", THISBACK1(AddOption, j)); bar.Separator(); @@ -391,7 +391,7 @@ void PackageEditor::OptionMenu(Bar& bar) int type = option.IsCursor() ? (int)option.Get(0) : -1; int i = -1; Array *m = NULL; - if(type >= FLAG && type <= INCLUDE) { + if(type >= FLAG && type <= PKG_LAST) { m = opt[type]; i = option.Get(1); } @@ -646,6 +646,7 @@ PackageEditor::PackageEditor() Add("Link options", actual.link); Add("Compiler options", actual.option); Add("Internal includes", actual.include); + Add("pkg-config", actual.pkg_config); Init(option); option.WhenCursor = THISBACK(AdjustPackageOptionCursor); diff --git a/uppsrc/ide/UppDlg.h b/uppsrc/ide/UppDlg.h index 183c20dd4..8c68861cd 100644 --- a/uppsrc/ide/UppDlg.h +++ b/uppsrc/ide/UppDlg.h @@ -413,7 +413,8 @@ struct PackageEditor : WorkspaceWork, WithUppLayout { virtual void PackageCursor(); enum OptionType { - FLAG = 0, USES, TARGET, LIBRARY, STATIC_LIBRARY, LINK, COMPILER, INCLUDE, + FLAG = 0, USES, TARGET, LIBRARY, STATIC_LIBRARY, LINK, COMPILER, INCLUDE, PKG_CONFIG, + PKG_LAST = PKG_CONFIG, FILEOPTION, FILEDEPENDS };