diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2019-04-01 13:07:09 -0400 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2019-04-08 10:22:17 -0400 |
commit | 2def9c02b31425551cf904d4b6e9920b64dd1c06 (patch) | |
tree | e1ad4ee413fe37e73e95375602f82c98cea9f8ce | |
parent | c8a133c3714d80d02cb8524d5278e6c1321e26f1 (diff) | |
download | mongo-2def9c02b31425551cf904d4b6e9920b64dd1c06.tar.gz |
SERVER-40389 small tweaks to third_party/fmt & related.
Add an option to scons: --use-system-fmt
import.sh: use the upstream libfmt github repo.
StringData fmt interop
noexcept for to_string_view(StringData) hook
noexcept for StringData's rawData() and size()
add fmt to THIRD-PARTY-NOTICES + markdown tweaks
import the fmt LICENSE.rst
update fmt lib revision
-rw-r--r-- | README.third_party.md | 131 | ||||
-rw-r--r-- | SConstruct | 8 | ||||
-rw-r--r-- | distsrc/THIRD-PARTY-NOTICES | 25 | ||||
-rw-r--r-- | src/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/base/string_data.h | 10 | ||||
-rw-r--r-- | src/mongo/base/string_data_test.cpp | 6 | ||||
-rw-r--r-- | src/third_party/SConscript | 29 | ||||
-rw-r--r-- | src/third_party/fmt/SConscript | 7 | ||||
-rw-r--r-- | src/third_party/fmt/dist/LICENSE.rst | 23 | ||||
-rw-r--r-- | src/third_party/fmt/dist/include/fmt/printf.h | 47 | ||||
-rwxr-xr-x | src/third_party/fmt/scripts/import.sh | 54 | ||||
-rw-r--r-- | src/third_party/shim_fmt.cpp | 3 |
13 files changed, 207 insertions, 138 deletions
diff --git a/README.third_party.md b/README.third_party.md index 12f7fb0cbfa..1088987d5dd 100644 --- a/README.third_party.md +++ b/README.third_party.md @@ -19,36 +19,66 @@ not authored by MongoDB, and has a license which requires reproduction, a notice will be included in `THIRD-PARTY-NOTICES`. -| Name | License | Upstream Version | Vendored Version | Emits persisted data | Distributed in Release Binaries | -| --------------------------------------------------------------------------------------------------------------- | ----------------- | ---------------- | ---------------------------------------- | :------------------: | :-----------------------------: | -| [abseil-cpp](https://github.com/abseil/abseil-cpp) | Apache-2.0 | HEAD | 070f6e47b33a2909d039e620c873204f78809492 | | ✗ | -| Aladdin MD5 | Zlib | Unknown | Unknown | ✗ | ✗ | -| [ASIO](https://github.com/chriskohlhoff/asio) | BSL-1.0 | HEAD | b0926b61b057ce563241d609cae5768ed3a4e1b1 | | ✗ | -| [benchmark](https://github.com/google/benchmark) | Apache-2.0 | 1.4.1 | 1.4.1 | | | -| [Boost](http://www.boost.org/) | BSL-1.0 | 1.69.0 | 1.69.0 | | ✗ | -| [GPerfTools](https://github.com/gperftools/gperftools) | BSD-3-Clause | 2.7 | 2.5, 2.7 | | ✗ | -| [ICU4](http://site.icu-project.org/download/) | ICU | 63.1 | 57.1 | ✗ | ✗ | -| [Intel Decimal FP Library](https://software.intel.com/en-us/articles/intel-decimal-floating-point-math-library) | BSD-3-Clause | 2.0 Update 2 | 2.0 Update 1 | | ✗ | -| [JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite) | MIT | HEAD | 728066f9c5c258ba3 | | | -| [kms-message](https://github.com/mongodb-labs/kms-message) | | HEAD | 8d91fa28cf179be591f595ca6611f74443357fdb | | ✗ | -| [libstemmer](https://github.com/snowballstem/snowball) | BSD-3-Clause | HEAD | Unknown | ✗ | ✗ | -| [linenoise](https://github.com/antirez/linenoise) | BSD-3-Clause | HEAD | Unknown + changes | | ✗ | -| [MozJS](https://www.mozilla.org/en-US/security/known-vulnerabilities/firefox-esr) | MPL-2.0 | ESR 60.5.1 | ESR 60.3.0 | | ✗ | -| [MurmurHash3](https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp) | Public Domain | HEAD | Unknown + changes | ✗ | ✗ | -| [Pcre](http://www.pcre.org/) | BSD-3-Clause | 8.43 | 8.42 | | ✗ | -| [S2](https://github.com/google/s2geometry) | Apache-2.0 | HEAD | Unknown | ✗ | ✗ | -| [scons](https://github.com/SCons/scons) | MIT | 3.0.4 | 3.0.4 | | | -| [Snappy](https://github.com/google/snappy/releases) | BSD-3-Clause | 1.1.7 | 1.1.7 | ✗ | ✗ | -| [sqlite](https://sqlite.org/) | Public Domain | 3270200 | 3260000 | ✗ | ✗ | -| [timelib](https://github.com/derickr/timelib) | MIT | 2018.01 | 2018.01 | | ✗ | -| [TomCrypt](https://github.com/libtom/libtomcrypt/releases) | Public Domain | 1.18.2 | 1.18.2 | ✗ | ✗ | -| [Unicode](http://www.unicode.org/versions/enumeratedversions.html) | Unicode-DFS-2015 | 12.0.0 | 8.0.0 | ✗ | ✗ | -| [Valgrind](http://valgrind.org/downloads/current.html) | BSD-3-Clause\[1\] | 3.14.0 | 3.11.0 | | ✗ | -| [variant](https://github.com/mpark/variant) | BSL-1.0 | 1.4.0 | 1.3.0 | | ✗ | -| [wiredtiger](https://github.com/wiredtiger/wiredtiger) | | HEAD | \[2\] | ✗ | ✗ | -| [yaml-cpp](https://github.com/jbeder/yaml-cpp/releases) | MIT | 0.6.2 | 0.6.2 | | ✗ | -| [Zlib](https://zlib.net/) | Zlib | 1.2.11 | 1.2.11 | ✗ | ✗ | -| [Zstandard](https://github.com/facebook/zstd) | BSD-3-Clause | 1.3.8 | 1.3.7 | ✗ | ✗ | +| Name | License | Upstream Version | Vendored Version | Emits persisted data | Distributed in Release Binaries | +| ---------------------------| ----------------- | ---------------- | ------------------| :------------------: | :-----------------------------: | +| [abseil-cpp] | Apache-2.0 | | 070f6e47b3 | | ✗ | +| Aladdin MD5 | Zlib | | Unknown | ✗ | ✗ | +| [ASIO] | BSL-1.0 | | b0926b61b0 | | ✗ | +| [benchmark] | Apache-2.0 | 1.4.1 | 1.4.1 | | | +| [Boost] | BSL-1.0 | 1.69.0 | 1.69.0 | | ✗ | +| [fmt] | BSD-2-Clause | | 018d8b57f6 | | ✗ | +| [GPerfTools] | BSD-3-Clause | 2.7 | 2.5, 2.7 | | ✗ | +| [ICU4] | ICU | 63.1 | 57.1 | ✗ | ✗ | +| [Intel Decimal FP Library] | BSD-3-Clause | 2.0 Update 2 | 2.0 Update 1 | | ✗ | +| [JSON-Schema-Test-Suite] | MIT | | 728066f9c5 | | | +| [kms-message] | | | 8d91fa28cf | | ✗ | +| [libstemmer] | BSD-3-Clause | | Unknown | ✗ | ✗ | +| [linenoise] | BSD-3-Clause | | Unknown + changes | | ✗ | +| [MozJS] | MPL-2.0 | ESR 60.5.1 | ESR 60.3.0 | | ✗ | +| [MurmurHash3] | Public Domain | | Unknown + changes | ✗ | ✗ | +| [Pcre] | BSD-3-Clause | 8.43 | 8.42 | | ✗ | +| [S2] | Apache-2.0 | | Unknown | ✗ | ✗ | +| [scons] | MIT | 3.0.4 | 3.0.4 | | | +| [Snappy] | BSD-3-Clause | 1.1.7 | 1.1.7 | ✗ | ✗ | +| [sqlite] | Public Domain | 3270200 | 3260000 | ✗ | ✗ | +| [timelib] | MIT | 2018.01 | 2018.01 | | ✗ | +| [TomCrypt] | Public Domain | 1.18.2 | 1.18.2 | ✗ | ✗ | +| [Unicode] | Unicode-DFS-2015 | 12.0.0 | 8.0.0 | ✗ | ✗ | +| [Valgrind] | BSD-3-Clause<sup>\[<a href="#note_vg" id="ref_vg">1</a>]</sup> | 3.14.0 | 3.11.0 | | ✗ | +| [variant] | BSL-1.0 | 1.4.0 | 1.3.0 | | ✗ | +| [wiredtiger] | | | <sup>\[<a href="#note_wt" id="ref_wt">2</a>]</sup> | ✗ | ✗ | +| [yaml-cpp] | MIT | 0.6.2 | 0.6.2 | | ✗ | +| [Zlib] | Zlib | 1.2.11 | 1.2.11 | ✗ | ✗ | +| [Zstandard] | BSD-3-Clause | 1.3.8 | 1.3.7 | ✗ | ✗ | + +[abseil-cpp]: https://github.com/abseil/abseil-cpp +[ASIO]: https://github.com/chriskohlhoff/asio +[benchmark]: https://github.com/google/benchmark +[Boost]: http://www.boost.org/ +[fmt]: http://www.fmtlib.net/ +[GPerfTools]: https://github.com/gperftools/gperftools +[ICU4]: http://site.icu-project.org/download/ +[Intel Decimal FP Library]: https://software.intel.com/en-us/articles/intel-decimal-floating-point-math-library +[JSON-Schema-Test-Suite]: https://github.com/json-schema-org/JSON-Schema-Test-Suite +[kms-message]: https://github.com/mongodb-labs/kms-message +[libstemmer]: https://github.com/snowballstem/snowball +[linenoise]: https://github.com/antirez/linenoise +[MozJS]: https://www.mozilla.org/en-US/security/known-vulnerabilities/firefox-esr +[MurmurHash3]: https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp +[Pcre]: http://www.pcre.org/ +[S2]: https://github.com/google/s2geometry +[scons]: https://github.com/SCons/scons +[Snappy]: https://github.com/google/snappy/releases +[sqlite]: https://sqlite.org/ +[timelib]: https://github.com/derickr/timelib +[TomCrypt]: https://github.com/libtom/libtomcrypt/releases +[Unicode]: http://www.unicode.org/versions/enumeratedversions.html +[Valgrind]: http://valgrind.org/downloads/current.html +[variant]: https://github.com/mpark/variant +[wiredtiger]: https://github.com/wiredtiger/wiredtiger +[yaml-cpp]: https://github.com/jbeder/yaml-cpp/releases +[Zlib]: https://zlib.net/ +[Zstandard]: https://github.com/facebook/zstd ## WiredTiger Vendored Test Libraries @@ -117,23 +147,26 @@ these libraries. Releases prepared in this fashion will include a copy of these libraries’ license in a file named `THIRD-PARTY-NOTICES.windows`. -| Name | Enterprise Only | Has Windows DLLS | +| Name | Enterprise Only | Has Windows DLLs | | :--------- | :-------------: | :--------------: | -| Cyrus SASL | Yes | Yes | -| libldap | Yes | No | -| net-snmp | Yes | Yes | -| OpenSSL | No | Yes\[2\] | -| libcurl | No | No | - -1. The majority of Valgrind is licensed under the GPL, with the - exception of a single header file which is licensed under a BSD - license. This BSD licensed header is the only file from Valgrind - which is vendored and consumed by MongoDB. - -2. WiredTiger is maintained by MongoDB in a separate repository. As a - part of our development process, we periodically ingest the latest - snapshot of that repository. - -3. OpenSSL is only shipped as a dependency of the MongoDB tools written - in Go. The MongoDB shell and server binaries use Windows’ - cryptography APIs. +| Cyrus SASL | Yes | Yes | +| libldap | Yes | No | +| net-snmp | Yes | Yes | +| OpenSSL | No | Yes<sup>\[<a href="#note_ssl" id="ref_ssl">3</a>]</sup> | +| libcurl | No | No | + + +## Notes: + +1. <a id="note_vg" href="#ref_vg">^</a> + The majority of Valgrind is licensed under the GPL, with the exception of a single + header file which is licensed under a BSD license. This BSD licensed header is the only + file from Valgrind which is vendored and consumed by MongoDB. + +2. <a id="note_wt" href="#ref_wt">^</a> + WiredTiger is maintained by MongoDB in a separate repository. As a part of our + development process, we periodically ingest the latest snapshot of that repository. + +3. <a id="note_ssl" href="#ref_ssl">^</a> + OpenSSL is only shipped as a dependency of the MongoDB tools written in Go. The MongoDB + shell and server binaries use Windows’ cryptography APIs. diff --git a/SConstruct b/SConstruct index adbdf29d1fd..26a5678664e 100644 --- a/SConstruct +++ b/SConstruct @@ -313,6 +313,11 @@ add_option('use-system-tcmalloc', nargs=0, ) +add_option('use-system-fmt', + help='use system version of fmt library', + nargs=0, +) + add_option('use-system-pcre', help='use system version of pcre library', nargs=0, @@ -3218,6 +3223,9 @@ def doConfigure(myenv): if use_system_version_of_library("yaml"): conf.FindSysLibDep("yaml", ["yaml-cpp"]) + if use_system_version_of_library("fmt"): + conf.FindSysLibDep("fmt", ["fmt"]) + if use_system_version_of_library("intel_decimal128"): conf.FindSysLibDep("intel_decimal128", ["bid"]) diff --git a/distsrc/THIRD-PARTY-NOTICES b/distsrc/THIRD-PARTY-NOTICES index 783b3604c88..b1c7cc71254 100644 --- a/distsrc/THIRD-PARTY-NOTICES +++ b/distsrc/THIRD-PARTY-NOTICES @@ -1504,4 +1504,29 @@ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + 25) License notice for fmt +--------------------------- + +Copyright (c) 2012 - present, Victor Zverovich +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or other + materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + End diff --git a/src/SConscript b/src/SConscript index 89ef06baa9c..178013b39dd 100644 --- a/src/SConscript +++ b/src/SConscript @@ -18,6 +18,7 @@ env = env.Clone() env.InjectThirdParty(libraries=[ 'abseil-cpp', 'boost', + 'fmt', 'pcre', ]) diff --git a/src/mongo/SConscript b/src/mongo/SConscript index fc881a3ab8e..6067fd412f8 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -146,6 +146,7 @@ env.Library( '$BUILD_DIR/third_party/shim_abseil', '$BUILD_DIR/third_party/shim_allocator', '$BUILD_DIR/third_party/shim_boost', + '$BUILD_DIR/third_party/shim_fmt', '$BUILD_DIR/third_party/shim_intel_decimal128', '$BUILD_DIR/third_party/shim_pcrecpp', 'util/quick_exit', diff --git a/src/mongo/base/string_data.h b/src/mongo/base/string_data.h index ffb7941e7ac..4192ccd60f6 100644 --- a/src/mongo/base/string_data.h +++ b/src/mongo/base/string_data.h @@ -36,6 +36,8 @@ #include <stdexcept> #include <string> +#include <fmt/format.h> + #include "mongo/stdx/type_traits.h" #define MONGO_INCLUDE_INVARIANT_H_WHITELISTED #include "mongo/util/invariant.h" @@ -166,11 +168,11 @@ public: * null-terminated, so if using this without checking size(), you are likely doing * something wrong. */ - constexpr const char* rawData() const { + constexpr const char* rawData() const noexcept { return _data; } - constexpr size_t size() const { + constexpr size_t size() const noexcept { return _size; } constexpr bool empty() const { @@ -352,4 +354,8 @@ inline std::string operator+(StringData lhs, std::string rhs) { return rhs; } +constexpr fmt::string_view to_string_view(StringData s) noexcept { + return fmt::string_view(s.rawData(), s.size()); +} + } // namespace mongo diff --git a/src/mongo/base/string_data_test.cpp b/src/mongo/base/string_data_test.cpp index 3e19a557d8e..a1d9d7d7773 100644 --- a/src/mongo/base/string_data_test.cpp +++ b/src/mongo/base/string_data_test.cpp @@ -319,4 +319,10 @@ TEST(ConstIterator, StdReplaceCopy) { } } +TEST(StringDataFmt, Fmt) { + using namespace fmt::literals; + ASSERT_EQUALS(fmt::format("-{}-", "abc"_sd), "-abc-"); + ASSERT_EQUALS("-{}-"_format("abc"_sd), "-abc-"); +} + } // namespace mongo diff --git a/src/third_party/SConscript b/src/third_party/SConscript index 9683b7e7480..67477e1fb57 100644 --- a/src/third_party/SConscript +++ b/src/third_party/SConscript @@ -163,18 +163,37 @@ env.AddMethod(injectThirdParty, 'InjectThirdParty') env = env.Clone() murmurEnv = env.Clone() +murmurEnv.InjectThirdParty(libraries=['fmt']) murmurEnv.SConscript('murmurhash3/SConscript', exports={ 'env' : murmurEnv }) s2Env = env.Clone() -s2Env.InjectThirdParty(libraries=['s2', 'boost', 'abseil-cpp']) +s2Env.InjectThirdParty(libraries=['s2', 'boost', 'abseil-cpp', 'fmt']) s2Env.InjectMongoIncludePaths() s2Env.SConscript('s2/SConscript', exports={'env' : s2Env}) -fmtEnv = env.Clone() -fmtEnv.InjectThirdParty(libraries=['fmt']) -fmtEnv.InjectMongoIncludePaths() -fmtEnv.SConscript('fmt/SConscript', exports={'env' : fmtEnv}) + +if use_system_version_of_library("fmt"): + fmtEnv = env.Clone( + SYSLIBDEPS=[ + env['LIBDEPS_FMT_SYSLIBDEP'], + ]) +else: + fmtEnv = env.Clone() + fmtEnv.InjectThirdParty(libraries=['fmt']) + fmtEnv.InjectMongoIncludePaths() + fmtEnv.SConscript('fmt/SConscript', exports={'env' : fmtEnv}) + fmtEnv = fmtEnv.Clone( + LIBDEPS_INTERFACE=[ + 'fmt/fmt', + ]) + +fmtEnv.Library( + target="shim_fmt", + source=[ + 'shim_fmt.cpp', + ]) + if use_system_version_of_library("pcre"): pcreEnv = env.Clone( diff --git a/src/third_party/fmt/SConscript b/src/third_party/fmt/SConscript index cbf8c940e4a..9b73f97e282 100644 --- a/src/third_party/fmt/SConscript +++ b/src/third_party/fmt/SConscript @@ -3,8 +3,9 @@ Import("env") Import("has_option") Import("debugBuild") env = env.Clone() -files = ['format.cc', 'posix.cc'] env.Library( target='fmt', - source=['dist/src/' + f for f in files], -) + source=env.File([ + 'format.cc', + 'posix.cc', + ], 'dist/src')) diff --git a/src/third_party/fmt/dist/LICENSE.rst b/src/third_party/fmt/dist/LICENSE.rst new file mode 100644 index 00000000000..6061de720b5 --- /dev/null +++ b/src/third_party/fmt/dist/LICENSE.rst @@ -0,0 +1,23 @@ +Copyright (c) 2012 - present, Victor Zverovich + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/third_party/fmt/dist/include/fmt/printf.h b/src/third_party/fmt/dist/include/fmt/printf.h index e540a55b601..50a3de48679 100644 --- a/src/third_party/fmt/dist/include/fmt/printf.h +++ b/src/third_party/fmt/dist/include/fmt/printf.h @@ -584,14 +584,6 @@ typedef basic_printf_context_t<internal::wbuffer>::type wprintf_context; typedef basic_format_args<printf_context> printf_args; typedef basic_format_args<wprintf_context> wprintf_args; -template <typename OutputIt, typename Char = typename OutputIt::value_type> -struct basic_printf_n_context_t { - typedef fmt::internal::truncating_iterator<OutputIt> OutputIter; - typedef output_range<OutputIter, Char> Range; - typedef basic_printf_context<OutputIter, Char, printf_arg_formatter<Range>> - type; -}; - /** \rst Constructs an `~fmt::format_arg_store` object that contains references to @@ -627,17 +619,6 @@ inline std::basic_string<Char> vsprintf( return to_string(buffer); } -template <typename OutputIt, typename S, typename Char = FMT_CHAR(S), - FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value)> -inline format_to_n_result<OutputIt> vsnprintf( - OutputIt out, std::size_t n, const S& format, - basic_format_args<typename basic_printf_n_context_t<OutputIt, Char>::type> - args) { - typedef internal::truncating_iterator<OutputIt> It; - auto it = printf(It(out, n), to_string_view(format), args); - return {it.base(), it.count()}; -} - /** \rst Formats arguments and returns the result as a string. @@ -658,34 +639,6 @@ inline std::basic_string<FMT_CHAR(S)> sprintf(const S& format, return vsprintf(to_string_view(format), basic_format_args<context>(as)); } -/** - \rst - Formats arguments for up to ``n`` characters stored through output iterator - ``out``. The function returns the updated iterator and the untruncated amount - of characters. - - **Example**:: - std::vector<char> out; - - typedef fmt::format_to_n_result< - std::back_insert_iterator<std::vector<char>>> res; - res Res = fmt::snprintf(std::back_inserter(out), 5, "The answer is %d", 42); - \endrst -*/ -template <typename OutputIt, typename S, typename... Args, - FMT_ENABLE_IF(internal::is_string<S>::value&& - internal::is_output_iterator<OutputIt>::value)> -inline format_to_n_result<OutputIt> snprintf(OutputIt out, std::size_t n, - const S& format, - const Args&... args) { - internal::check_format_string<Args...>(format); - typedef FMT_CHAR(S) Char; - typedef typename basic_printf_n_context_t<OutputIt, Char>::type context; - format_arg_store<context, Args...> as{args...}; - return vsnprintf(out, n, to_string_view(format), - basic_format_args<context>(as)); -} - template <typename S, typename Char = FMT_CHAR(S)> inline int vfprintf( std::FILE* f, const S& format, diff --git a/src/third_party/fmt/scripts/import.sh b/src/third_party/fmt/scripts/import.sh index 37606ab6736..5d7116a910b 100755 --- a/src/third_party/fmt/scripts/import.sh +++ b/src/third_party/fmt/scripts/import.sh @@ -1,35 +1,25 @@ #!/bin/bash # This script downloads and imports libfmt. -set -euo pipefail -IFS=$'\n\t' - -set -vx - -if [[ "$#" -ne 0 ]]; then - echo "This script does not take any arguments" >&2 - exit 1 -fi - -NAME=fmt -REVISION=mongodb - -# If WSL, get Windows temp directory -if $(grep -q Microsoft /proc/version); then - TEMP_ROOT=$(wslpath -u $(powershell.exe -Command "Get-ChildItem Env:TEMP | Get-Content | Write-Host")) -else - TEMP_ROOT="/tmp" -fi -GITDIR=$(mktemp -d $TEMP_ROOT/$NAME.XXXXXX) -trap "rm -rf $GITDIR" EXIT - -DIST=$(git rev-parse --show-toplevel)/src/third_party/$NAME/dist - -git clone "git@github.com:BillyDonahue/fmt.git" -c core.autocrlf=false $GITDIR -git -C $GITDIR checkout $REVISION - -mkdir -p $DIST -cp -Trp $GITDIR/src $DIST/src - -mkdir -p $DIST/include/fmt -cp -Trp $GITDIR/include/fmt $DIST/include/fmt +set -vxeuo pipefail + +FMT_GIT_URL="https://github.com/mongodb-forks/fmt.git" +FMT_GIT_REV=018d8b57f6ff76fc5bb5abaa243ff3f805bf297f # 2019-03-30 +FMT_GIT_DIR=$(mktemp -d /tmp/import-fmt.XXXXXX) +trap "rm -rf $FMT_GIT_DIR" EXIT + +DIST=$(git rev-parse --show-toplevel)/src/third_party/fmt/dist +git clone "$FMT_GIT_URL" $FMT_GIT_DIR +git -C $FMT_GIT_DIR checkout $FMT_GIT_REV + +# Exclude the file 'include/format', which provides experimental +# 'std::' definitions. +SUBDIR_WHITELIST=( + src + include/fmt + LICENSE.rst +) +for subdir in ${SUBDIR_WHITELIST[@]}; do + [[ -d $FMT_GIT_DIR/$subdir ]] && mkdir -p $DIST/$subdir + cp -Trp $FMT_GIT_DIR/$subdir $DIST/$subdir +done diff --git a/src/third_party/shim_fmt.cpp b/src/third_party/shim_fmt.cpp new file mode 100644 index 00000000000..0f3a704961f --- /dev/null +++ b/src/third_party/shim_fmt.cpp @@ -0,0 +1,3 @@ +// This file intentionally blank. shim_fmt.cpp is part of the +// third_party/fmt library, which is just a placeholder for forwarding +// library dependencies. |