aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp196
-rw-r--r--METADATA20
-rw-r--r--MODULE_LICENSE_BSD0
-rw-r--r--NOTICE23
-rw-r--r--OWNERS1
-rw-r--r--TEST_MAPPING24
-rw-r--r--include/fmt/format.h2
-rw-r--r--support/Android.mk19
8 files changed, 269 insertions, 16 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 00000000..e1fb5cb5
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,196 @@
+package {
+ default_applicable_licenses: ["external_fmtlib_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+//
+// large-scale-change included anything that looked like it might be a license
+// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
+//
+// Please consider removing redundant or irrelevant files from 'license_text:'.
+// See: http://go/android-license-faq
+license {
+ name: "external_fmtlib_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-BSD",
+ "SPDX-license-identifier-CC0-1.0",
+ "SPDX-license-identifier-MIT",
+ "SPDX-license-identifier-PSF-2.0",
+ "legacy_unencumbered",
+ ],
+ license_text: [
+ "LICENSE",
+ "NOTICE",
+ ],
+}
+
+cc_defaults {
+ name: "fmtlib-non-test-defaults",
+ cflags: [
+ "-fno-exceptions",
+ // If built without exceptions, libfmt uses assert.
+ // The tests *require* exceptions, so we can't win here.
+ // (This is also why we have two cc_defaults in this file.)
+ // Unless proven to be a bad idea, let's at least have some run-time
+ // checking.
+ "-UNDEBUG",
+ ],
+ srcs: ["src/format.cc"],
+ local_include_dirs: ["include"],
+ export_include_dirs: ["include"],
+ visibility: ["//system/libbase"],
+ min_sdk_version: "29",
+}
+
+cc_library_headers {
+ name: "fmtlib_headers",
+ export_include_dirs: ["include"],
+
+ vendor_available: true,
+ product_available: true,
+ ramdisk_available: true,
+ vendor_ramdisk_available: true,
+ recovery_available: true,
+ host_supported: true,
+ native_bridge_supported: true,
+ target: {
+ linux_bionic: {
+ enabled: true,
+ },
+ windows: {
+ enabled: true,
+ },
+ },
+ visibility: ["//system/libbase"],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
+}
+
+// This is built into libbase. If you want to use this library, link to libbase instead.
+cc_library_static {
+ name: "fmtlib",
+ defaults: ["fmtlib-non-test-defaults"],
+
+ vendor_available: true,
+ product_available: true,
+ ramdisk_available: true,
+ vendor_ramdisk_available: true,
+ recovery_available: true,
+ host_supported: true,
+ native_bridge_supported: true,
+ target: {
+ linux_bionic: {
+ enabled: true,
+ },
+ windows: {
+ enabled: true,
+ },
+ },
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
+ min_sdk_version: "29",
+}
+
+cc_library_static {
+ name: "fmtlib_ndk",
+ defaults: ["fmtlib-non-test-defaults"],
+ sdk_version: "current",
+ stl: "c++_static",
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.mediaprovider",
+ ],
+}
+
+cc_defaults {
+ name: "fmtlib-test-defaults",
+ srcs: [
+ "src/format.cc",
+ "src/os.cc",
+ "test/gtest-extra.cc",
+ "test/util.cc",
+ ],
+ local_include_dirs: ["include"],
+ host_supported: true,
+ test_suites: ["general-tests"],
+ // The tests require exceptions and RTTI.
+ cflags: [
+ "-fexceptions",
+ // https://github.com/fmtlib/fmt/issues/3884
+ "-Wno-non-virtual-dtor",
+ ],
+ rtti: true,
+ // The usual "gtest *and* gmock, please" dance...
+ gtest: false,
+ include_dirs: [
+ "external/googletest/googlemock/include/gmock",
+ "external/googletest/googletest/include/gtest",
+ ],
+ static_libs: [
+ "libgmock",
+ "libgtest",
+ "libgtest_main",
+ ],
+}
+
+// Most of the fmtlib tests.
+cc_test {
+ name: "fmtlib_test_1",
+ defaults: ["fmtlib-test-defaults"],
+ srcs: [
+ "test/args-test.cc",
+ "test/chrono-test.cc",
+ "test/color-test.cc",
+ "test/core-test.cc",
+ "test/enforce-checks-test.cc",
+ "test/format-test.cc",
+ "test/noexception-test.cc",
+ // Some of the os-test tests deliberately try to do bad things with
+ // file descriptors, but Android's fdsan won't let them.
+ // "test/os-test.cc",
+ "test/ranges-odr-test.cc",
+ "test/scan-test.cc",
+ // Depends on filesystem_error declarations which are not linked.
+ // "test/std-test.cc",
+ "test/unicode-test.cc",
+ "test/xchar-test.cc",
+ ],
+}
+
+// This one needs to be separate because some of the test names overlap with
+// other tests.
+cc_test {
+ name: "fmtlib_test_2",
+ defaults: ["fmtlib-test-defaults"],
+ srcs: [
+ "test/ostream-test.cc",
+ "test/printf-test.cc",
+ ],
+}
+
+cc_test {
+ name: "fmtlib_test_3",
+ defaults: ["fmtlib-test-defaults"],
+ srcs: [
+ "test/ranges-test.cc",
+ ],
+}
diff --git a/METADATA b/METADATA
new file mode 100644
index 00000000..b4da998f
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,20 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update external/fmtlib
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
+
+name: "fmtlib"
+description: "{fmt} is an open-source formatting library providing a fast and safe alternative to C stdio and C++ iostreams."
+third_party {
+ license_type: NOTICE
+ last_upgrade_date {
+ year: 2024
+ month: 3
+ day: 5
+ }
+ homepage: "https://github.com/fmtlib/fmt"
+ identifier {
+ type: "Git"
+ value: "https://github.com/fmtlib/fmt.git"
+ version: "10.2.0"
+ }
+}
diff --git a/MODULE_LICENSE_BSD b/MODULE_LICENSE_BSD
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/MODULE_LICENSE_BSD
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 00000000..eb6be650
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,23 @@
+Copyright (c) 2012 - 2016, 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/OWNERS b/OWNERS
new file mode 100644
index 00000000..7529cb92
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/system/core:/janitors/OWNERS
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 00000000..fa4f8a2a
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,24 @@
+{
+ "postsubmit": [
+ {
+ "name": "fmtlib_test_1"
+ },
+ {
+ "name": "fmtlib_test_2"
+ },
+ {
+ "name": "fmtlib_test_3"
+ }
+ ],
+ "hwasan-postsubmit": [
+ {
+ "name": "fmtlib_test_1"
+ },
+ {
+ "name": "fmtlib_test_2"
+ },
+ {
+ "name": "fmtlib_test_3"
+ }
+ ]
+}
diff --git a/include/fmt/format.h b/include/fmt/format.h
index 97f0e1fb..f0ca55cf 100644
--- a/include/fmt/format.h
+++ b/include/fmt/format.h
@@ -2745,7 +2745,7 @@ template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value&&
has_isfinite<T>::value)>
FMT_CONSTEXPR20 auto isfinite(T value) -> bool {
constexpr T inf = T(std::numeric_limits<double>::infinity());
- if (is_constant_evaluated())
+ if (is_constant_evaluated(true))
return !detail::isnan(value) && value < inf && value > -inf;
return std::isfinite(value);
}
diff --git a/support/Android.mk b/support/Android.mk
index 84a3e32f..0660b8a2 100644
--- a/support/Android.mk
+++ b/support/Android.mk
@@ -1,15 +1,4 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := fmt_static
-LOCAL_MODULE_FILENAME := libfmt
-
-LOCAL_SRC_FILES := ../src/format.cc
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
-
-LOCAL_CFLAGS += -std=c++11 -fexceptions
-
-include $(BUILD_STATIC_LIBRARY)
-
+# The Android.mk provided by the upstream fmtlib repository is for use with the
+# NDK and is not appropriate for the platform build. When integrating changes
+# from upstream, omit their Android.mk and leave the existing Android.bp
+# instead.