aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-03-21 06:53:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-03-21 06:53:03 +0200
commita4f2f99f23575a6cdcde5f18b8778ba2827ceb42 (patch)
tree74008e58f0d3fa4cc77be079b9d1d752d4c53d0c
parentdf91839a0f53b1bf266eb6b9ebabf2b587211731 (diff)
Allow multiple values for --archive-lang* pkg-bindist option
-rw-r--r--bpkg/pkg-bindist.cli12
-rw-r--r--bpkg/system-package-manager-archive.cxx40
2 files changed, 31 insertions, 21 deletions
diff --git a/bpkg/pkg-bindist.cli b/bpkg/pkg-bindist.cli
index 7116e7d..0ea51f9 100644
--- a/bpkg/pkg-bindist.cli
+++ b/bpkg/pkg-bindist.cli
@@ -531,7 +531,7 @@ namespace bpkg
defaults may change in the future."
}
- std::map<string, string> --archive-lang
+ std::multimap<string, string> --archive-lang
{
"<ln>=<rt>",
"Map interface language name <ln> to runtime id <rt>. If no mapping is
@@ -540,18 +540,20 @@ namespace bpkg
fail. If the information about an interface language is unimportant and
should be ignored, then empty runtime id can be specified. Note that
the mapping specified with this option is only considered if the
- package type is a library (for other package types all languages
- used are implementation)."
+ package type is a library (for other package types all languages used
+ are implementation). Note also that multiple runtime ids specified for
+ the same language are combined."
}
- std::map<string, string> --archive-lang-impl
+ std::multimap<string, string> --archive-lang-impl
{
"<ln>=<rt>",
"Map implementation language name <ln> to runtime id <rt>. If no mapping
is found for an implementation language in this map, then assume
the information about this implementation language is unimportant
and ignore it (examples of such cases include static linking as well
- as a language runtime that is always present)."
+ as a language runtime that is always present). See \cb{--archive-lang}
+ for background."
}
string --archive-build-meta
diff --git a/bpkg/system-package-manager-archive.cxx b/bpkg/system-package-manager-archive.cxx
index 384a0d5..79d4ca4 100644
--- a/bpkg/system-package-manager-archive.cxx
+++ b/bpkg/system-package-manager-archive.cxx
@@ -522,24 +522,23 @@ namespace bpkg
// @@ Maybe we should just do "soft" version like in <distribution>?
//
// Note that we allow multiple values for the same language to support
- // cases like --archive-lang cc=gcc12 --archive-lang cc=g++12. @@ This
- // is TODO (need cli support for std::multimap).
+ // cases like --archive-lang cc=gcc12 --archive-lang cc=g++12.
//
vector<reference_wrapper<const pair<const string, string>>> langrt;
- auto find = [] (const std::map<string, string>& m, const string& n)
+ auto find = [] (const std::multimap<string, string>& m, const string& n)
{
- auto i (m.find (n));
+ auto p (m.equal_range (n));
- if (i == m.end ())
+ if (p.first == p.second)
{
// If no mapping for c/c++, fallback to cc.
//
if (n == "c" || n == "c++")
- i = m.find ("cc");
+ p = m.equal_range ("cc");
}
- return i != m.end () ? &*i : nullptr;
+ return p;
};
auto add = [&langrt] (const pair<const string, string>& p)
@@ -573,20 +572,23 @@ namespace bpkg
if (l.impl)
continue;
- const pair<const string, string>* p (find (intfm, l.name));
+ auto p (find (intfm, l.name));
- if (p == nullptr)
+ if (p.first == p.second)
p = find (implm, l.name);
- if (p == nullptr)
+ if (p.first == p.second)
fail << "no runtime mapping for language " << l.name <<
info << "consider specifying with --archive-lang[-impl]" <<
info << "or alternatively specify --archive-build-meta";
- if (p->second.empty ())
- continue; // Unimportant.
+ for (auto i (p.first); i != p.second; ++i)
+ {
+ if (i->second.empty ())
+ continue; // Unimportant.
- add (*p);
+ add (*i);
+ }
}
}
@@ -595,12 +597,18 @@ namespace bpkg
if (lib && !l.impl)
continue;
- const pair<const string, string>* p (find (implm, l.name));
+ auto p (find (implm, l.name));
- if (p == nullptr || p->second.empty ())
+ if (p.first == p.second)
continue; // Unimportant.
- add (*p);
+ for (auto i (p.first); i != p.second; ++i)
+ {
+ if (i->second.empty ())
+ continue; // Unimportant.
+
+ add (*i);
+ }
}
for (const pair<const string, string>& p: langrt)