diff options
| author | 2023-04-30 01:22:28 +0000 | |
|---|---|---|
| committer | 2023-05-04 09:05:59 +0000 | |
| commit | 997d3cf6f91cb66f446583b0eeaf76ccab229b7d (patch) | |
| tree | ba4b4ca83da72671dc20095b32906d56671a48ed | |
| parent | b3b9269b5f1cafbfa17df539eda694d5ca876a68 (diff) | |
Replace uses of _format with a macro.
_format is a user-defined literal which is removed from newer
releases of libfmt.
Ignore-AOSP-First: internal UDC branch has additional uses
of _format that are not present in AOSP master
Bug: 271622675
Test: presubmit
Change-Id: I2f5cc706ca8f734b1cad89e7d957fb7a52f78a10
| -rw-r--r-- | artd/artd.cc | 85 | ||||
| -rw-r--r-- | artd/artd_test.cc | 12 | ||||
| -rw-r--r-- | artd/file_utils.cc | 14 | ||||
| -rw-r--r-- | artd/path_utils.cc | 32 | ||||
| -rw-r--r-- | libartbase/base/macros.h | 4 | ||||
| -rw-r--r-- | libarttools/Android.bp | 1 | ||||
| -rw-r--r-- | libarttools/tools/art_exec.cc | 5 | ||||
| -rw-r--r-- | libarttools/tools/art_exec_test.cc | 29 | ||||
| -rw-r--r-- | libarttools/tools/tools.cc | 8 | ||||
| -rw-r--r-- | odrefresh/odr_common.cc | 7 | ||||
| -rw-r--r-- | odrefresh/odrefresh.cc | 72 | ||||
| -rw-r--r-- | odrefresh/odrefresh_test.cc | 26 | ||||
| -rw-r--r-- | runtime/gc/space/image_space.cc | 8 | ||||
| -rw-r--r-- | runtime/oat_file_assistant.cc | 46 |
14 files changed, 175 insertions, 174 deletions
diff --git a/artd/artd.cc b/artd/artd.cc index c44c0bd5cb..5d65b4fc9c 100644 --- a/artd/artd.cc +++ b/artd/artd.cc @@ -59,11 +59,11 @@ #include "base/file_utils.h" #include "base/globals.h" #include "base/logging.h" +#include "base/macros.h" #include "base/os.h" #include "cmdline_types.h" #include "exec_utils.h" #include "file_utils.h" -#include "fmt/format.h" #include "oat_file_assistant.h" #include "oat_file_assistant_context.h" #include "path_utils.h" @@ -109,8 +109,6 @@ using ::android::base::WriteStringToFd; using ::art::tools::CmdlineBuilder; using ::ndk::ScopedAStatus; -using ::fmt::literals::operator""_format; // NOLINT - using ArtifactsLocation = GetDexoptNeededResult::ArtifactsLocation; using TmpProfilePath = ProfilePath::TmpProfilePath; @@ -132,7 +130,7 @@ std::optional<int64_t> GetSize(std::string_view path) { if (ec) { // It is okay if the file does not exist. We don't have to log it. if (ec.value() != ENOENT) { - LOG(ERROR) << "Failed to get the file size of '{}': {}"_format(path, ec.message()); + LOG(ERROR) << ART_FORMAT("Failed to get the file size of '{}': {}", path, ec.message()); } return std::nullopt; } @@ -149,7 +147,7 @@ int64_t GetSizeAndDeleteFile(const std::string& path) { std::error_code ec; if (!std::filesystem::remove(path, ec)) { - LOG(ERROR) << "Failed to remove '{}': {}"_format(path, ec.message()); + LOG(ERROR) << ART_FORMAT("Failed to remove '{}': {}", path, ec.message()); return 0; } @@ -466,7 +464,7 @@ ndk::ScopedAStatus Artd::isProfileUsable(const ProfilePath& in_profile, return ScopedAStatus::ok(); } return NonFatal( - "Failed to open profile '{}': {}"_format(profile_path, profile.error().message())); + ART_FORMAT("Failed to open profile '{}': {}", profile_path, profile.error().message())); } args.Add("--reference-profile-file-fd=%d", profile.value()->Fd()); fd_logger.Add(*profile.value()); @@ -485,11 +483,11 @@ ndk::ScopedAStatus Artd::isProfileUsable(const ProfilePath& in_profile, return NonFatal("Failed to run profman: " + result.error().message()); } - LOG(INFO) << "profman returned code {}"_format(result.value()); + LOG(INFO) << ART_FORMAT("profman returned code {}", result.value()); if (result.value() != ProfmanResult::kSkipCompilationSmallDelta && result.value() != ProfmanResult::kSkipCompilationEmptyProfiles) { - return NonFatal("profman returned an unexpected code: {}"_format(result.value())); + return NonFatal(ART_FORMAT("profman returned an unexpected code: {}", result.value())); } *_aidl_return = result.value() == ProfmanResult::kSkipCompilationSmallDelta; @@ -518,7 +516,8 @@ ndk::ScopedAStatus Artd::copyAndRewriteProfile(const ProfilePath& in_src, *_aidl_return = false; return ScopedAStatus::ok(); } - return NonFatal("Failed to open src profile '{}': {}"_format(src_path, src.error().message())); + return NonFatal( + ART_FORMAT("Failed to open src profile '{}': {}", src_path, src.error().message())); } args.Add("--profile-file-fd=%d", src.value()->Fd()); fd_logger.Add(*src.value()); @@ -542,7 +541,7 @@ ndk::ScopedAStatus Artd::copyAndRewriteProfile(const ProfilePath& in_src, return NonFatal("Failed to run profman: " + result.error().message()); } - LOG(INFO) << "profman returned code {}"_format(result.value()); + LOG(INFO) << ART_FORMAT("profman returned code {}", result.value()); if (result.value() == ProfmanResult::kCopyAndUpdateNoMatch) { *_aidl_return = false; @@ -550,7 +549,7 @@ ndk::ScopedAStatus Artd::copyAndRewriteProfile(const ProfilePath& in_src, } if (result.value() != ProfmanResult::kCopyAndUpdateSuccess) { - return NonFatal("profman returned an unexpected code: {}"_format(result.value())); + return NonFatal(ART_FORMAT("profman returned an unexpected code: {}", result.value())); } OR_RETURN_NON_FATAL(dst->Keep()); @@ -567,8 +566,8 @@ ndk::ScopedAStatus Artd::commitTmpProfile(const TmpProfilePath& in_profile) { std::error_code ec; std::filesystem::rename(tmp_profile_path, ref_profile_path, ec); if (ec) { - return NonFatal( - "Failed to move '{}' to '{}': {}"_format(tmp_profile_path, ref_profile_path, ec.message())); + return NonFatal(ART_FORMAT( + "Failed to move '{}' to '{}': {}", tmp_profile_path, ref_profile_path, ec.message())); } return ScopedAStatus::ok(); @@ -580,7 +579,7 @@ ndk::ScopedAStatus Artd::deleteProfile(const ProfilePath& in_profile) { std::error_code ec; std::filesystem::remove(profile_path, ec); if (ec) { - LOG(ERROR) << "Failed to remove '{}': {}"_format(profile_path, ec.message()); + LOG(ERROR) << ART_FORMAT("Failed to remove '{}': {}", profile_path, ec.message()); } return ScopedAStatus::ok(); @@ -624,7 +623,7 @@ ndk::ScopedAStatus Artd::mergeProfiles(const std::vector<ProfilePath>& in_profil for (const ProfilePath& profile : in_profiles) { std::string profile_path = OR_RETURN_FATAL(BuildProfileOrDmPath(profile)); if (profile.getTag() == ProfilePath::dexMetadataPath) { - return Fatal("Does not support DM file, got '{}'"_format(profile_path)); + return Fatal(ART_FORMAT("Does not support DM file, got '{}'", profile_path)); } profile_paths.push_back(std::move(profile_path)); } @@ -653,8 +652,8 @@ ndk::ScopedAStatus Artd::mergeProfiles(const std::vector<ProfilePath>& in_profil // Skip non-existing file. continue; } - return NonFatal( - "Failed to open profile '{}': {}"_format(profile_path, profile_file.error().message())); + return NonFatal(ART_FORMAT( + "Failed to open profile '{}': {}", profile_path, profile_file.error().message())); } args.Add("--profile-file-fd=%d", profile_file.value()->Fd()); fd_logger.Add(*profile_file.value()); @@ -679,7 +678,7 @@ ndk::ScopedAStatus Artd::mergeProfiles(const std::vector<ProfilePath>& in_profil std::string reference_profile_path = OR_RETURN_FATAL(BuildProfileOrDmPath(*in_referenceProfile)); if (in_referenceProfile->getTag() == ProfilePath::dexMetadataPath) { - return Fatal("Does not support DM file, got '{}'"_format(reference_profile_path)); + return Fatal(ART_FORMAT("Does not support DM file, got '{}'", reference_profile_path)); } OR_RETURN_NON_FATAL(CopyFile(reference_profile_path, *output_profile_file)); } @@ -721,7 +720,7 @@ ndk::ScopedAStatus Artd::mergeProfiles(const std::vector<ProfilePath>& in_profil return NonFatal("Failed to run profman: " + result.error().message()); } - LOG(INFO) << "profman returned code {}"_format(result.value()); + LOG(INFO) << ART_FORMAT("profman returned code {}", result.value()); if (result.value() == ProfmanResult::kSkipCompilationSmallDelta || result.value() == ProfmanResult::kSkipCompilationEmptyProfiles) { @@ -734,7 +733,7 @@ ndk::ScopedAStatus Artd::mergeProfiles(const std::vector<ProfilePath>& in_profil ProfmanResult::kSuccess : ProfmanResult::kCompile; if (result.value() != expected_result) { - return NonFatal("profman returned an unexpected code: {}"_format(result.value())); + return NonFatal(ART_FORMAT("profman returned an unexpected code: {}", result.value())); } OR_RETURN_NON_FATAL(output_profile_file->Keep()); @@ -810,7 +809,8 @@ ndk::ScopedAStatus Artd::dexopt( if (in_classLoaderContext.has_value()) { context = ClassLoaderContext::Create(in_classLoaderContext->c_str()); if (context == nullptr) { - return Fatal("Class loader context '{}' is invalid"_format(in_classLoaderContext.value())); + return Fatal( + ART_FORMAT("Class loader context '{}' is invalid", in_classLoaderContext.value())); } } @@ -840,9 +840,9 @@ ndk::ScopedAStatus Artd::dexopt( struct stat dex_st = OR_RETURN_NON_FATAL(Fstat(*dex_file)); if ((dex_st.st_mode & S_IROTH) == 0) { if (fs_permission.isOtherReadable) { - return NonFatal( - "Outputs cannot be other-readable because the dex file '{}' is not other-readable"_format( - dex_file->GetPath())); + return NonFatal(ART_FORMAT( + "Outputs cannot be other-readable because the dex file '{}' is not other-readable", + dex_file->GetPath())); } // Negative numbers mean no `chown`. 0 means root. // Note: this check is more strict than it needs to be. For example, it doesn't allow the @@ -851,13 +851,13 @@ ndk::ScopedAStatus Artd::dexopt( if ((fs_permission.uid > 0 && static_cast<uid_t>(fs_permission.uid) != dex_st.st_uid) || (fs_permission.gid > 0 && static_cast<gid_t>(fs_permission.gid) != dex_st.st_uid && static_cast<gid_t>(fs_permission.gid) != dex_st.st_gid)) { - return NonFatal( - "Outputs' owner doesn't match the dex file '{}' (outputs: {}:{}, dex file: {}:{})"_format( - dex_file->GetPath(), - fs_permission.uid, - fs_permission.gid, - dex_st.st_uid, - dex_st.st_gid)); + return NonFatal(ART_FORMAT( + "Outputs' owner doesn't match the dex file '{}' (outputs: {}:{}, dex file: {}:{})", + dex_file->GetPath(), + fs_permission.uid, + fs_permission.gid, + dex_st.st_uid, + dex_st.st_gid)); } } @@ -886,8 +886,9 @@ ndk::ScopedAStatus Artd::dexopt( std::unique_ptr<NewFile> swap_file = nullptr; if (ShouldCreateSwapFileForDexopt()) { - swap_file = OR_RETURN_NON_FATAL( - NewFile::Create("{}.swap"_format(oat_path), FsPermission{.uid = -1, .gid = -1})); + std::string swap_file_path = ART_FORMAT("{}.swap", oat_path); + swap_file = + OR_RETURN_NON_FATAL(NewFile::Create(swap_file_path, FsPermission{.uid = -1, .gid = -1})); args.Add("--swap-fd=%d", swap_file->Fd()); fd_logger.Add(*swap_file); } @@ -933,9 +934,9 @@ ndk::ScopedAStatus Artd::dexopt( fd_logger.Add(*profile_file); struct stat profile_st = OR_RETURN_NON_FATAL(Fstat(*profile_file)); if (fs_permission.isOtherReadable && (profile_st.st_mode & S_IROTH) == 0) { - return NonFatal( - "Outputs cannot be other-readable because the profile '{}' is not other-readable"_format( - profile_file->GetPath())); + return NonFatal(ART_FORMAT( + "Outputs cannot be other-readable because the profile '{}' is not other-readable", + profile_file->GetPath())); } // TODO(b/260228411): Check uid and gid. } @@ -997,10 +998,10 @@ ndk::ScopedAStatus Artd::dexopt( return NonFatal("Failed to run dex2oat: " + result.error().message()); } - LOG(INFO) << "dex2oat returned code {}"_format(result.value()); + LOG(INFO) << ART_FORMAT("dex2oat returned code {}", result.value()); if (result.value() != 0) { - return NonFatal("dex2oat returned an unexpected code: {}"_format(result.value())); + return NonFatal(ART_FORMAT("dex2oat returned an unexpected code: {}", result.value())); } int64_t size_bytes = 0; @@ -1060,7 +1061,7 @@ ScopedAStatus Artd::cleanup(const std::vector<ProfilePath>& in_profilesToKeep, *_aidl_return = 0; for (const std::string& file : OR_RETURN_NON_FATAL(ListManagedFiles())) { if (files_to_keep.find(file) == files_to_keep.end()) { - LOG(INFO) << "Cleaning up obsolete file '{}'"_format(file); + LOG(INFO) << ART_FORMAT("Cleaning up obsolete file '{}'", file); *_aidl_return += GetSizeAndDeleteFile(file); } } @@ -1073,7 +1074,7 @@ ScopedAStatus Artd::isIncrementalFsPath(const std::string& in_dexFile [[maybe_un OR_RETURN_FATAL(ValidateDexPath(in_dexFile)); struct statfs st; if (statfs(in_dexFile.c_str(), &st) != 0) { - PLOG(ERROR) << "Failed to statfs '{}'"_format(in_dexFile); + PLOG(ERROR) << ART_FORMAT("Failed to statfs '{}'", in_dexFile); *_aidl_return = false; return ScopedAStatus::ok(); } @@ -1236,9 +1237,9 @@ void Artd::AddCompilerConfigFlags(const std::string& instruction_set, const DexoptOptions& dexopt_options, /*out*/ CmdlineBuilder& args) { args.Add("--instruction-set=%s", instruction_set); - std::string features_prop = "dalvik.vm.isa.{}.features"_format(instruction_set); + std::string features_prop = ART_FORMAT("dalvik.vm.isa.{}.features", instruction_set); args.AddIfNonEmpty("--instruction-set-features=%s", props_->GetOrEmpty(features_prop)); - std::string variant_prop = "dalvik.vm.isa.{}.variant"_format(instruction_set); + std::string variant_prop = ART_FORMAT("dalvik.vm.isa.{}.variant", instruction_set); args.AddIfNonEmpty("--instruction-set-variant=%s", props_->GetOrEmpty(variant_prop)); args.Add("--compiler-filter=%s", compiler_filter) diff --git a/artd/artd_test.cc b/artd/artd_test.cc index 1fca5a7bbf..b61b11a394 100644 --- a/artd/artd_test.cc +++ b/artd/artd_test.cc @@ -51,8 +51,8 @@ #include "android/binder_status.h" #include "base/array_ref.h" #include "base/common_art_test.h" +#include "base/macros.h" #include "exec_utils.h" -#include "fmt/format.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "oat_file.h" @@ -115,8 +115,6 @@ using PrimaryCurProfilePath = ProfilePath::PrimaryCurProfilePath; using PrimaryRefProfilePath = ProfilePath::PrimaryRefProfilePath; using TmpProfilePath = ProfilePath::TmpProfilePath; -using ::fmt::literals::operator""_format; // NOLINT - ScopeGuard<std::function<void()>> ScopedSetLogger(android::base::LogFunction&& logger) { android::base::LogFunction old_logger = android::base::SetLogger(std::move(logger)); return make_scope_guard([old_logger = std::move(old_logger)]() mutable { @@ -206,7 +204,7 @@ MATCHER_P2(ListFlag, flag, matcher, "") { // Matches an FD of a file whose path matches `matcher`. MATCHER_P(FdOf, matcher, "") { - std::string proc_path = "/proc/self/fd/{}"_format(arg); + std::string proc_path = ART_FORMAT("/proc/self/fd/{}", arg); char path[PATH_MAX]; ssize_t len = readlink(proc_path.c_str(), path, sizeof(path)); if (len < 0) { @@ -370,7 +368,7 @@ class ArtdTest : public CommonArtTest { }; clc_1_ = GetTestDexFileName("Main"); clc_2_ = GetTestDexFileName("Nested"); - class_loader_context_ = "PCL[{}:{}]"_format(clc_1_, clc_2_); + class_loader_context_ = ART_FORMAT("PCL[{}:{}]", clc_1_, clc_2_); compiler_filter_ = "speed"; TmpProfilePath tmp_profile_path{ .finalPath = @@ -1948,11 +1946,11 @@ TEST_F(ArtdTest, cleanup) { .isOk()); for (const std::string& path : gc_removed_files) { - EXPECT_FALSE(std::filesystem::exists(path)) << "'{}' should be removed"_format(path); + EXPECT_FALSE(std::filesystem::exists(path)) << ART_FORMAT("'{}' should be removed", path); } for (const std::string& path : gc_kept_files) { - EXPECT_TRUE(std::filesystem::exists(path)) << "'{}' should be kept"_format(path); + EXPECT_TRUE(std::filesystem::exists(path)) << ART_FORMAT("'{}' should be kept", path); } } diff --git a/artd/file_utils.cc b/artd/file_utils.cc index fb55dec5d5..f3558534ba 100644 --- a/artd/file_utils.cc +++ b/artd/file_utils.cc @@ -33,9 +33,9 @@ #include "android-base/logging.h" #include "android-base/result.h" #include "android-base/scopeguard.h" +#include "base/macros.h" #include "base/os.h" #include "base/unix_file/fd_file.h" -#include "fmt/format.h" namespace art { namespace artd { @@ -46,13 +46,11 @@ using ::aidl::com::android::server::art::FsPermission; using ::android::base::make_scope_guard; using ::android::base::Result; -using ::fmt::literals::operator""_format; // NOLINT - void UnlinkIfExists(const std::string& path) { std::error_code ec; std::filesystem::remove(path, ec); if (ec) { - LOG(WARNING) << "Failed to remove file '{}': {}"_format(path, ec.message()); + LOG(WARNING) << ART_FORMAT("Failed to remove file '{}': {}", path, ec.message()); } } @@ -143,8 +141,10 @@ Result<void> NewFile::CommitAllOrAbandon(const std::vector<NewFile*>& files_to_c if (ec) { // This should never happen. We were able to move the file from `original_path` to // `temp_path`. We should be able to move it back. - LOG(WARNING) << "Failed to move old file '{}' back from temporary path '{}': {}"_format( - original_path, temp_path, ec.message()); + LOG(WARNING) << ART_FORMAT("Failed to move old file '{}' back from temporary path '{}': {}", + original_path, + temp_path, + ec.message()); } } }); @@ -206,7 +206,7 @@ Result<void> NewFile::CommitAllOrAbandon(const std::vector<NewFile*>& files_to_c } std::string NewFile::BuildTempPath(std::string_view final_path, const std::string& id) { - return "{}.{}.tmp"_format(final_path, id); + return ART_FORMAT("{}.{}.tmp", final_path, id); } Result<std::unique_ptr<File>> OpenFileForReading(const std::string& path) { diff --git a/artd/path_utils.cc b/artd/path_utils.cc index 6ef0eafb53..d504bb2ad0 100644 --- a/artd/path_utils.cc +++ b/artd/path_utils.cc @@ -26,8 +26,8 @@ #include "android-base/strings.h" #include "arch/instruction_set.h" #include "base/file_utils.h" +#include "base/macros.h" #include "file_utils.h" -#include "fmt/format.h" #include "oat_file_assistant.h" #include "tools/tools.h" @@ -43,8 +43,6 @@ using ::aidl::com::android::server::art::VdexPath; using ::android::base::Error; using ::android::base::Result; -using ::fmt::literals::operator""_format; // NOLINT - using PrebuiltProfilePath = ProfilePath::PrebuiltProfilePath; using PrimaryCurProfilePath = ProfilePath::PrimaryCurProfilePath; using PrimaryRefProfilePath = ProfilePath::PrimaryRefProfilePath; @@ -158,7 +156,7 @@ Result<void> ValidateDexPath(const std::string& dex_path) { } Result<std::string> BuildArtBinPath(const std::string& binary_name) { - return "{}/bin/{}"_format(OR_RETURN(GetArtRootOrError()), binary_name); + return ART_FORMAT("{}/bin/{}", OR_RETURN(GetArtRootOrError()), binary_name); } Result<std::string> BuildOatPath(const ArtifactsPath& artifacts_path) { @@ -191,9 +189,10 @@ Result<std::string> BuildPrimaryRefProfilePath( const PrimaryRefProfilePath& primary_ref_profile_path) { OR_RETURN(ValidatePathElement(primary_ref_profile_path.packageName, "packageName")); OR_RETURN(ValidatePathElementSubstring(primary_ref_profile_path.profileName, "profileName")); - return "{}/misc/profiles/ref/{}/{}.prof"_format(OR_RETURN(GetAndroidDataOrError()), - primary_ref_profile_path.packageName, - primary_ref_profile_path.profileName); + return ART_FORMAT("{}/misc/profiles/ref/{}/{}.prof", + OR_RETURN(GetAndroidDataOrError()), + primary_ref_profile_path.packageName, + primary_ref_profile_path.profileName); } Result<std::string> BuildPrebuiltProfilePath(const PrebuiltProfilePath& prebuilt_profile_path) { @@ -205,24 +204,27 @@ Result<std::string> BuildPrimaryCurProfilePath( const PrimaryCurProfilePath& primary_cur_profile_path) { OR_RETURN(ValidatePathElement(primary_cur_profile_path.packageName, "packageName")); OR_RETURN(ValidatePathElementSubstring(primary_cur_profile_path.profileName, "profileName")); - return "{}/misc/profiles/cur/{}/{}/{}.prof"_format(OR_RETURN(GetAndroidDataOrError()), - primary_cur_profile_path.userId, - primary_cur_profile_path.packageName, - primary_cur_profile_path.profileName); + return ART_FORMAT("{}/misc/profiles/cur/{}/{}/{}.prof", + OR_RETURN(GetAndroidDataOrError()), + primary_cur_profile_path.userId, + primary_cur_profile_path.packageName, + primary_cur_profile_path.profileName); } Result<std::string> BuildSecondaryRefProfilePath( const SecondaryRefProfilePath& secondary_ref_profile_path) { OR_RETURN(ValidateDexPath(secondary_ref_profile_path.dexPath)); std::filesystem::path dex_path(secondary_ref_profile_path.dexPath); - return "{}/oat/{}.prof"_format(dex_path.parent_path().string(), dex_path.filename().string()); + return ART_FORMAT( + "{}/oat/{}.prof", dex_path.parent_path().string(), dex_path.filename().string()); } Result<std::string> BuildSecondaryCurProfilePath( const SecondaryCurProfilePath& secondary_cur_profile_path) { OR_RETURN(ValidateDexPath(secondary_cur_profile_path.dexPath)); std::filesystem::path dex_path(secondary_cur_profile_path.dexPath); - return "{}/oat/{}.cur.prof"_format(dex_path.parent_path().string(), dex_path.filename().string()); + return ART_FORMAT( + "{}/oat/{}.cur.prof", dex_path.parent_path().string(), dex_path.filename().string()); } Result<std::string> BuildFinalProfilePath(const TmpProfilePath& tmp_profile_path) { @@ -235,7 +237,7 @@ Result<std::string> BuildFinalProfilePath(const TmpProfilePath& tmp_profile_path // No default. All cases should be explicitly handled, or the compilation will fail. } // This should never happen. Just in case we get a non-enumerator value. - LOG(FATAL) << "Unexpected writable profile path type {}"_format(final_path.getTag()); + LOG(FATAL) << ART_FORMAT("Unexpected writable profile path type {}", final_path.getTag()); } Result<std::string> BuildTmpProfilePath(const TmpProfilePath& tmp_profile_path) { @@ -268,7 +270,7 @@ Result<std::string> BuildProfileOrDmPath(const ProfilePath& profile_path) { // No default. All cases should be explicitly handled, or the compilation will fail. } // This should never happen. Just in case we get a non-enumerator value. - LOG(FATAL) << "Unexpected profile path type {}"_format(profile_path.getTag()); + LOG(FATAL) << ART_FORMAT("Unexpected profile path type {}", profile_path.getTag()); } Result<std::string> BuildVdexPath(const VdexPath& vdex_path) { diff --git a/libartbase/base/macros.h b/libartbase/base/macros.h index 13e87d770d..5f2100f9e8 100644 --- a/libartbase/base/macros.h +++ b/libartbase/base/macros.h @@ -20,6 +20,7 @@ #include <stddef.h> // for size_t #include <unistd.h> // for TEMP_FAILURE_RETRY +#include "android-base/format.h" #include "android-base/macros.h" #include "android-base/thread_annotations.h" @@ -32,6 +33,9 @@ friend class test_set_name##_##individual_test##_Test #define ART_FRIEND_TYPED_TEST(test_set_name, individual_test)\ template<typename T> ART_FRIEND_TEST(test_set_name, individual_test) +// Shorthand for formatting with compile time checking of the format string +#define ART_FORMAT(str, ...) ::fmt::format(FMT_STRING(str), __VA_ARGS__) + // A macro to disallow new and delete operators for a class. It goes in the private: declarations. // NOTE: Providing placement new (and matching delete) for constructing container elements. #define DISALLOW_ALLOCATION() \ diff --git a/libarttools/Android.bp b/libarttools/Android.bp index d38ef45d6d..5c0f1f21c4 100644 --- a/libarttools/Android.bp +++ b/libarttools/Android.bp @@ -34,6 +34,7 @@ cc_defaults { "tools/tools.cc", ], export_include_dirs: ["."], + header_libs: ["art_libartbase_headers"], shared_libs: [ "libbase", ], diff --git a/libarttools/tools/art_exec.cc b/libarttools/tools/art_exec.cc index 1806ed4514..8f3365885b 100644 --- a/libarttools/tools/art_exec.cc +++ b/libarttools/tools/art_exec.cc @@ -36,7 +36,6 @@ #include "android-base/strings.h" #include "base/macros.h" #include "base/scoped_cap.h" -#include "fmt/format.h" #include "palette/palette.h" #include "system/thread_defs.h" @@ -48,8 +47,6 @@ using ::android::base::ParseInt; using ::android::base::Result; using ::android::base::Split; -using ::fmt::literals::operator""_format; // NOLINT - constexpr const char* kUsage = R"(A wrapper binary that configures the process and executes a command. @@ -170,7 +167,7 @@ Result<void> CloseFds(const std::unordered_set<int>& keep_fds) { if (keep_fds.find(fd) == keep_fds.end()) { if (close(fd) != 0) { Result<void> error = ErrnoErrorf("Failed to close FD {}", fd); - if (std::filesystem::exists("/proc/self/fd/{}"_format(fd))) { + if (std::filesystem::exists(ART_FORMAT("/proc/self/fd/{}", fd))) { return error; } } diff --git a/libarttools/tools/art_exec_test.cc b/libarttools/tools/art_exec_test.cc index 9e8b0de3ad..a5a0b01ead 100644 --- a/libarttools/tools/art_exec_test.cc +++ b/libarttools/tools/art_exec_test.cc @@ -37,7 +37,6 @@ #include "base/os.h" #include "base/scoped_cap.h" #include "exec_utils.h" -#include "fmt/format.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "system/thread_defs.h" @@ -57,10 +56,6 @@ using ::testing::ElementsAre; using ::testing::HasSubstr; using ::testing::Not; -// clang-tidy incorrectly complaints about the using declaration while the user-defined literal is -// actually being used. -using ::fmt::literals::operator""_format; // NOLINT - constexpr uid_t kRoot = 0; constexpr uid_t kNobody = 9999; @@ -73,9 +68,13 @@ constexpr uid_t kNobody = 9999; // TODO(b/247108425): Remove this when ART gtests no longer use LD_LIBRARY_PATH. constexpr const char* kEmptyLdLibraryPath = "--env=LD_LIBRARY_PATH="; -std::string GetArtBin(const std::string& name) { return "{}/bin/{}"_format(GetArtRoot(), name); } +std::string GetArtBin(const std::string& name) { + return ART_FORMAT("{}/bin/{}", GetArtRoot(), name); +} -std::string GetBin(const std::string& name) { return "{}/bin/{}"_format(GetAndroidRoot(), name); } +std::string GetBin(const std::string& name) { + return ART_FORMAT("{}/bin/{}", GetAndroidRoot(), name); +} // Executes the command, waits for it to finish, and keeps it in a waitable state until the current // scope exits. @@ -217,16 +216,20 @@ TEST_F(ArtExecTest, CloseFds) { ASSERT_GE(scratch_file.GetFd(), 0); std::vector<std::string> args{art_exec_bin_, - "--keep-fds={}:{}"_format(file3->Fd(), file2->Fd()), + ART_FORMAT("--keep-fds={}:{}", file3->Fd(), file2->Fd()), kEmptyLdLibraryPath, "--", GetBin("sh"), "-c", - "(" - "readlink /proc/self/fd/{} || echo;" - "readlink /proc/self/fd/{} || echo;" - "readlink /proc/self/fd/{} || echo;" - ") > {}"_format(file1->Fd(), file2->Fd(), file3->Fd(), filename)}; + ART_FORMAT("(" + "readlink /proc/self/fd/{} || echo;" + "readlink /proc/self/fd/{} || echo;" + "readlink /proc/self/fd/{} || echo;" + ") > {}", + file1->Fd(), + file2->Fd(), + file3->Fd(), + filename)}; ScopedExecAndWait(args); diff --git a/libarttools/tools/tools.cc b/libarttools/tools/tools.cc index 3d5301ad7f..4ec9d9a750 100644 --- a/libarttools/tools/tools.cc +++ b/libarttools/tools/tools.cc @@ -28,7 +28,7 @@ #include <vector> #include "android-base/logging.h" -#include "fmt/format.h" +#include "base/macros.h" namespace art { namespace tools { @@ -37,8 +37,6 @@ namespace { using ::std::placeholders::_1; -using ::fmt::literals::operator""_format; // NOLINT - // Returns true if `path_prefix` matches `pattern` or can be a prefix of a path that matches // `pattern` (i.e., `path_prefix` represents a directory that may contain a file whose path matches // `pattern`). @@ -117,13 +115,13 @@ void MatchGlobRecursive(const std::vector<std::filesystem::path>& patterns, // It's expected that we don't have permission to stat some dirs/files, and we don't care // about them. if (ec2.value() != EACCES) { - LOG(ERROR) << "Unable to lstat '{}': {}"_format(entry.path().string(), ec2.message()); + LOG(ERROR) << ART_FORMAT("Unable to lstat '{}': {}", entry.path().string(), ec2.message()); } continue; } } if (ec) { - LOG(ERROR) << "Unable to walk through '{}': {}"_format(root_dir.string(), ec.message()); + LOG(ERROR) << ART_FORMAT("Unable to walk through '{}': {}", root_dir.string(), ec.message()); } } diff --git a/odrefresh/odr_common.cc b/odrefresh/odr_common.cc index ec18884a05..d76aff2d1d 100644 --- a/odrefresh/odr_common.cc +++ b/odrefresh/odr_common.cc @@ -28,19 +28,16 @@ #include "android-base/logging.h" #include "android-base/parseint.h" #include "android-base/result.h" -#include "fmt/format.h" +#include "base/macros.h" namespace art { namespace odrefresh { namespace { - using ::android::base::Result; - -using ::fmt::literals::operator""_format; // NOLINT } -std::string QuotePath(std::string_view path) { return "'{}'"_format(path); } +std::string QuotePath(std::string_view path) { return ART_FORMAT("'{}'", path); } Result<int> ParseSecurityPatchStr(const std::string& security_patch_str) { std::regex security_patch_regex(R"re((\d{4})-(\d{2})-(\d{2}))re"); diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc index 85766ccaf9..a0b1a1c343 100644 --- a/odrefresh/odrefresh.cc +++ b/odrefresh/odrefresh.cc @@ -81,7 +81,6 @@ #include "dex/art_dex_file_loader.h" #include "dexoptanalyzer.h" #include "exec_utils.h" -#include "fmt/format.h" #include "gc/collector/mark_compact.h" #include "log/log.h" #include "odr_artifacts.h" @@ -118,8 +117,6 @@ using ::android::base::StringPrintf; using ::android::base::Timer; using ::android::modules::sdklevel::IsAtLeastU; -using ::fmt::literals::operator""_format; // NOLINT - // Name of cache info file in the ART Apex artifact cache. constexpr const char* kCacheInfoFile = "cache-info.xml"; @@ -158,7 +155,7 @@ bool MoveOrEraseFiles(const std::vector<std::unique_ptr<File>>& files, std::vector<std::unique_ptr<File>> output_files; for (auto& file : files) { std::string file_basename(Basename(file->GetPath())); - std::string output_file_path = "{}/{}"_format(output_directory_path, file_basename); + std::string output_file_path = ART_FORMAT("{}/{}", output_directory_path, file_basename); std::string input_file_path = file->GetPath(); output_files.emplace_back(OS::CreateEmptyFileWriteOnly(output_file_path.c_str())); @@ -887,7 +884,7 @@ std::string OnDeviceRefresh::GetSystemBootImageFrameworkExtension() const { std::string basename = GetBootImageComponentBasename(framework_bcp_jars[0], /*is_first_jar=*/false); // Typically "/system/framework/boot-framework.art". - return "{}/framework/{}"_format(GetAndroidRoot(), basename); + return ART_FORMAT("{}/framework/{}", GetAndroidRoot(), basename); } std::string OnDeviceRefresh::GetSystemBootImageFrameworkExtensionPath(InstructionSet isa) const { @@ -901,10 +898,10 @@ std::string OnDeviceRefresh::GetBootImageMainlineExtension(bool on_system) const GetBootImageComponentBasename(mainline_bcp_jars[0], /*is_first_jar=*/false); if (on_system) { // Typically "/system/framework/boot-framework-adservices.art". - return "{}/framework/{}"_format(GetAndroidRoot(), basename); + return ART_FORMAT("{}/framework/{}", GetAndroidRoot(), basename); } else { // Typically "/data/misc/apexdata/com.android.art/dalvik-cache/boot-framework-adservices.art". - return "{}/{}"_format(config_.GetArtifactDirectory(), basename); + return ART_FORMAT("{}/{}", config_.GetArtifactDirectory(), basename); } } @@ -952,7 +949,7 @@ std::string OnDeviceRefresh::GetSystemServerImagePath(bool on_system, std::string image_name = ReplaceFileExtension(jar_name, "art"); const char* isa_str = GetInstructionSetString(config_.GetSystemServerIsa()); // Typically "/system/framework/oat/<isa>/services.art". - return "{}/oat/{}/{}"_format(Dirname(jar_path), isa_str, image_name); + return ART_FORMAT("{}/oat/{}/{}", Dirname(jar_path), isa_str, image_name); } else { // Typically // "/data/misc/apexdata/.../dalvik-cache/<isa>/system@framework@services.jar@classes.art". @@ -1097,8 +1094,9 @@ WARN_UNUSED bool OnDeviceRefresh::CheckBuildUserfaultFdGc() const { if (build_enable_uffd_gc && !kernel_supports_uffd) { // Normally, this should not happen. If this happens, the system image was probably built with a // wrong PRODUCT_ENABLE_UFFD_GC flag. - LOG(WARNING) << "Userfaultfd GC check failed (build-time: {}, runtime: {})."_format( - build_enable_uffd_gc, kernel_supports_uffd); + LOG(WARNING) << ART_FORMAT("Userfaultfd GC check failed (build-time: {}, runtime: {}).", + build_enable_uffd_gc, + kernel_supports_uffd); return false; } return true; @@ -1140,14 +1138,18 @@ WARN_UNUSED PreconditionCheckResult OnDeviceRefresh::CheckPreconditionForSystem( WARN_UNUSED static bool CheckModuleInfo(const art_apex::ModuleInfo& cached_info, const apex::ApexInfo& current_info) { if (cached_info.getVersionCode() != current_info.getVersionCode()) { - LOG(INFO) << "APEX ({}) version code mismatch (before: {}, now: {})"_format( - current_info.getModuleName(), cached_info.getVersionCode(), current_info.getVersionCode()); + LOG(INFO) << ART_FORMAT("APEX ({}) version code mismatch (before: {}, now: {})", + current_info.getModuleName(), + cached_info.getVersionCode(), + current_info.getVersionCode()); return false; } if (cached_info.getVersionName() != current_info.getVersionName()) { - LOG(INFO) << "APEX ({}) version name mismatch (before: {}, now: {})"_format( - current_info.getModuleName(), cached_info.getVersionName(), current_info.getVersionName()); + LOG(INFO) << ART_FORMAT("APEX ({}) version name mismatch (before: {}, now: {})", + current_info.getModuleName(), + cached_info.getVersionName(), + current_info.getVersionName()); return false; } @@ -1157,10 +1159,10 @@ WARN_UNUSED static bool CheckModuleInfo(const art_apex::ModuleInfo& cached_info, const int64_t cached_last_update_millis = cached_info.hasLastUpdateMillis() ? cached_info.getLastUpdateMillis() : -1; if (cached_last_update_millis != current_info.getLastUpdateMillis()) { - LOG(INFO) << "APEX ({}) last update time mismatch (before: {}, now: {})"_format( - current_info.getModuleName(), - cached_info.getLastUpdateMillis(), - current_info.getLastUpdateMillis()); + LOG(INFO) << ART_FORMAT("APEX ({}) last update time mismatch (before: {}, now: {})", + current_info.getModuleName(), + cached_info.getLastUpdateMillis(), + current_info.getLastUpdateMillis()); return false; } @@ -1344,12 +1346,12 @@ WARN_UNUSED BootImages OnDeviceRefresh::CheckBootClasspathArtifactsAreUpToDate( } if (boot_images_on_system.Count() == BootImages::kMaxCount) { - LOG(INFO) << "Boot images on /system OK ({})"_format(isa_str); + LOG(INFO) << ART_FORMAT("Boot images on /system OK ({})", isa_str); // Nothing to compile. return BootImages{.primary_boot_image = false, .boot_image_mainline_extension = false}; } - LOG(INFO) << "Checking boot images /data ({})"_format(isa_str); + LOG(INFO) << ART_FORMAT("Checking boot images /data ({})", isa_str); BootImages boot_images_on_data{.primary_boot_image = false, .boot_image_mainline_extension = false}; @@ -1366,7 +1368,7 @@ WARN_UNUSED BootImages OnDeviceRefresh::CheckBootClasspathArtifactsAreUpToDate( // attempt to generate a full boot image even if the minimal one exists. if (PrimaryBootImageExist( /*on_system=*/false, /*minimal=*/true, isa, &error_msg, checked_artifacts)) { - LOG(INFO) << "Found minimal primary boot image ({})"_format(isa_str); + LOG(INFO) << ART_FORMAT("Found minimal primary boot image ({})", isa_str); } } } else { @@ -1396,7 +1398,7 @@ WARN_UNUSED BootImages OnDeviceRefresh::CheckBootClasspathArtifactsAreUpToDate( }; if (boot_images_to_generate.Count() == 0) { - LOG(INFO) << "Boot images on /data OK ({})"_format(isa_str); + LOG(INFO) << ART_FORMAT("Boot images on /data OK ({})", isa_str); } return boot_images_to_generate; @@ -1687,7 +1689,7 @@ WARN_UNUSED CompilationResult OnDeviceRefresh::RunDex2oat( if (staging_file == nullptr) { return CompilationResult::Error( OdrMetrics::Status::kIoError, - "Failed to create {} file '{}'"_format(kind, staging_location)); + ART_FORMAT("Failed to create {} file '{}'", kind, staging_location)); } // Don't check the state of the staging file. It doesn't need to be flushed because it's removed // after the compilation regardless of success or failure. @@ -1700,7 +1702,7 @@ WARN_UNUSED CompilationResult OnDeviceRefresh::RunDex2oat( if (!EnsureDirectoryExists(install_location)) { return CompilationResult::Error( OdrMetrics::Status::kIoError, - "Error encountered when preparing directory '{}'"_format(install_location)); + ART_FORMAT("Error encountered when preparing directory '{}'", install_location)); } std::copy(extra_args.begin(), extra_args.end(), std::back_inserter(args)); @@ -1708,7 +1710,7 @@ WARN_UNUSED CompilationResult OnDeviceRefresh::RunDex2oat( Timer timer; time_t timeout = GetSubprocessTimeout(); std::string cmd_line = Join(args, ' '); - LOG(INFO) << "{}: {} [timeout {}s]"_format(debug_message, cmd_line, timeout); + LOG(INFO) << ART_FORMAT("{}: {} [timeout {}s]", debug_message, cmd_line, timeout); if (config_.GetDryRun()) { LOG(INFO) << "Compilation skipped (dry-run)."; return CompilationResult::Ok(); @@ -1721,14 +1723,15 @@ WARN_UNUSED CompilationResult OnDeviceRefresh::RunDex2oat( return CompilationResult::Dex2oatError( dex2oat_result.exit_code < 0 ? error_msg : - "dex2oat returned an unexpected code: {}"_format(dex2oat_result.exit_code), + ART_FORMAT("dex2oat returned an unexpected code: {}", dex2oat_result.exit_code), timer.duration().count(), dex2oat_result); } if (!MoveOrEraseFiles(staging_files, install_location)) { - return CompilationResult::Error(OdrMetrics::Status::kIoError, - "Failed to commit artifacts to '{}'"_format(install_location)); + return CompilationResult::Error( + OdrMetrics::Status::kIoError, + ART_FORMAT("Failed to commit artifacts to '{}'", install_location)); } return CompilationResult::Dex2oatOk(timer.duration().count(), dex2oat_result); @@ -1772,7 +1775,7 @@ OnDeviceRefresh::RunDex2oatForBootClasspath(const std::string& staging_dir, args.emplace_back(StringPrintf("--dirty-image-objects-fd=%d", file->Fd())); readonly_files_raii.push_back(std::move(file)); } else { - LOG(WARNING) << "Missing dirty objects file: '{}'"_format(dirty_image_objects_file); + LOG(WARNING) << ART_FORMAT("Missing dirty objects file: '{}'", dirty_image_objects_file); } std::string preloaded_classes_file(GetAndroidRoot() + "/etc/preloaded-classes"); @@ -1781,7 +1784,7 @@ OnDeviceRefresh::RunDex2oatForBootClasspath(const std::string& staging_dir, args.emplace_back(StringPrintf("--preloaded-classes-fds=%d", file->Fd())); readonly_files_raii.push_back(std::move(file)); } else { - LOG(WARNING) << "Missing preloaded classes file: '{}'"_format(preloaded_classes_file); + LOG(WARNING) << ART_FORMAT("Missing preloaded classes file: '{}'", preloaded_classes_file); } } else { // Mainline extension. @@ -1790,7 +1793,7 @@ OnDeviceRefresh::RunDex2oatForBootClasspath(const std::string& staging_dir, return RunDex2oat( staging_dir, - "Compiling boot classpath ({}, {})"_format(GetInstructionSetString(isa), debug_name), + ART_FORMAT("Compiling boot classpath ({}, {})", GetInstructionSetString(isa), debug_name), isa, dex_files, boot_classpath, @@ -1933,7 +1936,8 @@ WARN_UNUSED CompilationResult OnDeviceRefresh::RunDex2oatForSystemServer( if (!file->IsValid()) { return CompilationResult::Error( OdrMetrics::Status::kIoError, - "Failed to open classloader context '{}': {}"_format(actual_path, strerror(errno))); + ART_FORMAT( + "Failed to open classloader context '{}': {}", actual_path, strerror(errno))); } fds.emplace_back(file->Fd()); readonly_files_raii.emplace_back(std::move(file)); @@ -1942,7 +1946,7 @@ WARN_UNUSED CompilationResult OnDeviceRefresh::RunDex2oatForSystemServer( } return RunDex2oat(staging_dir, - "Compiling {}"_format(Basename(dex_file)), + ART_FORMAT("Compiling {}", Basename(dex_file)), isa, {dex_file}, boot_classpath_jars_, @@ -1975,7 +1979,7 @@ OnDeviceRefresh::CompileSystemServer(const std::string& staging_dir, if (current_result.IsOk()) { on_dex2oat_success(); } else { - LOG(ERROR) << "Compilation of {} failed: {}"_format(Basename(jar), result.error_msg); + LOG(ERROR) << ART_FORMAT("Compilation of {} failed: {}", Basename(jar), result.error_msg); } } diff --git a/odrefresh/odrefresh_test.cc b/odrefresh/odrefresh_test.cc index 119de6b312..729bdd6c93 100644 --- a/odrefresh/odrefresh_test.cc +++ b/odrefresh/odrefresh_test.cc @@ -33,9 +33,9 @@ #include "arch/instruction_set.h" #include "base/common_art_test.h" #include "base/file_utils.h" +#include "base/macros.h" #include "base/stl_util.h" #include "exec_utils.h" -#include "fmt/format.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "odr_artifacts.h" @@ -57,8 +57,6 @@ using ::testing::Not; using ::testing::ResultOf; using ::testing::Return; -using ::fmt::literals::operator""_format; // NOLINT - constexpr int kReplace = 1; void CreateEmptyFile(const std::string& name) { @@ -434,17 +432,17 @@ TEST_F(OdRefreshTest, AllSystemServerJars) { .WillOnce(Return(0)); EXPECT_CALL( *mock_exec_utils_, - DoExecAndReturnCode( - AllOf(Contains(Flag("--dex-file=", services_jar_)), - Contains(Flag("--class-loader-context=", "PCL[{}]"_format(location_provider_jar_))), - Contains(Flag("--class-loader-context-fds=", FdOf(location_provider_jar_)))))) + DoExecAndReturnCode(AllOf( + Contains(Flag("--dex-file=", services_jar_)), + Contains(Flag("--class-loader-context=", ART_FORMAT("PCL[{}]", location_provider_jar_))), + Contains(Flag("--class-loader-context-fds=", FdOf(location_provider_jar_)))))) .WillOnce(Return(0)); EXPECT_CALL( *mock_exec_utils_, DoExecAndReturnCode(AllOf( Contains(Flag("--dex-file=", services_foo_jar_)), Contains(Flag("--class-loader-context=", - "PCL[];PCL[{}:{}]"_format(location_provider_jar_, services_jar_))), + ART_FORMAT("PCL[];PCL[{}:{}]", location_provider_jar_, services_jar_))), Contains(ListFlag("--class-loader-context-fds=", ElementsAre(FdOf(location_provider_jar_), FdOf(services_jar_))))))) .WillOnce(Return(0)); @@ -453,7 +451,7 @@ TEST_F(OdRefreshTest, AllSystemServerJars) { DoExecAndReturnCode(AllOf( Contains(Flag("--dex-file=", services_bar_jar_)), Contains(Flag("--class-loader-context=", - "PCL[];PCL[{}:{}]"_format(location_provider_jar_, services_jar_))), + ART_FORMAT("PCL[];PCL[{}:{}]", location_provider_jar_, services_jar_))), Contains(ListFlag("--class-loader-context-fds=", ElementsAre(FdOf(location_provider_jar_), FdOf(services_jar_))))))) .WillOnce(Return(0)); @@ -469,17 +467,17 @@ TEST_F(OdRefreshTest, AllSystemServerJars) { TEST_F(OdRefreshTest, PartialSystemServerJars) { EXPECT_CALL( *mock_exec_utils_, - DoExecAndReturnCode( - AllOf(Contains(Flag("--dex-file=", services_jar_)), - Contains(Flag("--class-loader-context=", "PCL[{}]"_format(location_provider_jar_))), - Contains(Flag("--class-loader-context-fds=", FdOf(location_provider_jar_)))))) + DoExecAndReturnCode(AllOf( + Contains(Flag("--dex-file=", services_jar_)), + Contains(Flag("--class-loader-context=", ART_FORMAT("PCL[{}]", location_provider_jar_))), + Contains(Flag("--class-loader-context-fds=", FdOf(location_provider_jar_)))))) .WillOnce(Return(0)); EXPECT_CALL( *mock_exec_utils_, DoExecAndReturnCode(AllOf( Contains(Flag("--dex-file=", services_bar_jar_)), Contains(Flag("--class-loader-context=", - "PCL[];PCL[{}:{}]"_format(location_provider_jar_, services_jar_))), + ART_FORMAT("PCL[];PCL[{}:{}]", location_provider_jar_, services_jar_))), Contains(ListFlag("--class-loader-context-fds=", ElementsAre(FdOf(location_provider_jar_), FdOf(services_jar_))))))) .WillOnce(Return(0)); diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 13966d8d97..56efcabb7c 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -51,7 +51,6 @@ #include "dex/art_dex_file_loader.h" #include "dex/dex_file_loader.h" #include "exec_utils.h" -#include "fmt/format.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/task_processor.h" #include "image-inl.h" @@ -78,8 +77,6 @@ using ::android::base::Join; using ::android::base::StringAppendF; using ::android::base::StringPrintf; -using ::fmt::literals::operator""_format; // NOLINT - // We do not allow the boot image and extensions to take more than 1GiB. They are // supposed to be much smaller and allocating more that this would likely fail anyway. static constexpr size_t kMaxTotalImageReservationSize = 1 * GB; @@ -3446,8 +3443,9 @@ bool ImageSpace::ValidateOatFile(const OatFile& oat_file, if (oat_file.GetOatHeader().GetKeyValueStoreSize() != 0 && oat_file.GetOatHeader().IsConcurrentCopying() != gUseReadBarrier) { *error_msg = - "ValidateOatFile found read barrier state mismatch (oat file: {}, runtime: {})"_format( - oat_file.GetOatHeader().IsConcurrentCopying(), gUseReadBarrier); + ART_FORMAT("ValidateOatFile found read barrier state mismatch (oat file: {}, runtime: {})", + oat_file.GetOatHeader().IsConcurrentCopying(), + gUseReadBarrier); return false; } diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index 3d7bf3f532..1b0f0bc7e9 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -44,7 +44,6 @@ #include "dex/art_dex_file_loader.h" #include "dex/dex_file_loader.h" #include "exec_utils.h" -#include "fmt/format.h" #include "gc/heap.h" #include "gc/space/image_space.h" #include "image.h" @@ -60,8 +59,6 @@ namespace art { using ::android::base::ConsumePrefix; using ::android::base::StringPrintf; -using ::fmt::literals::operator""_format; // NOLINT - static constexpr const char* kAnonymousDexPrefix = "Anonymous-DexFile@"; static constexpr const char* kVdexExtension = ".vdex"; static constexpr const char* kDmExtension = ".dm"; @@ -884,15 +881,15 @@ OatFileAssistant::OatFileInfo& OatFileAssistant::GetBestInfo() { // If the odex is not useable, and we have a useable vdex, return the vdex // instead. - VLOG(oat) << "GetBestInfo checking odex next to the dex file ({})"_format( - odex_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking odex next to the dex file ({})", + odex_.DisplayFilename()); if (!odex_.IsUseable()) { - VLOG(oat) << "GetBestInfo checking vdex next to the dex file ({})"_format( - vdex_for_odex_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking vdex next to the dex file ({})", + vdex_for_odex_.DisplayFilename()); if (vdex_for_odex_.IsUseable()) { return vdex_for_odex_; } - VLOG(oat) << "GetBestInfo checking dm ({})"_format(dm_for_odex_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking dm ({})", dm_for_odex_.DisplayFilename()); if (dm_for_odex_.IsUseable()) { return dm_for_odex_; } @@ -903,7 +900,7 @@ OatFileAssistant::OatFileInfo& OatFileAssistant::GetBestInfo() { // We cannot write to the odex location. This must be a system app. // If the oat location is useable take it. - VLOG(oat) << "GetBestInfo checking odex in dalvik-cache ({})"_format(oat_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking odex in dalvik-cache ({})", oat_.DisplayFilename()); if (oat_.IsUseable()) { return oat_; } @@ -911,29 +908,29 @@ OatFileAssistant::OatFileInfo& OatFileAssistant::GetBestInfo() { // The oat file is not useable but the odex file might be up to date. // This is an indication that we are dealing with an up to date prebuilt // (that doesn't need relocation). - VLOG(oat) << "GetBestInfo checking odex next to the dex file ({})"_format( - odex_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking odex next to the dex file ({})", + odex_.DisplayFilename()); if (odex_.IsUseable()) { return odex_; } // Look for a useable vdex file. - VLOG(oat) << "GetBestInfo checking vdex in dalvik-cache ({})"_format( - vdex_for_oat_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking vdex in dalvik-cache ({})", + vdex_for_oat_.DisplayFilename()); if (vdex_for_oat_.IsUseable()) { return vdex_for_oat_; } - VLOG(oat) << "GetBestInfo checking vdex next to the dex file ({})"_format( - vdex_for_odex_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking vdex next to the dex file ({})", + vdex_for_odex_.DisplayFilename()); if (vdex_for_odex_.IsUseable()) { return vdex_for_odex_; } - VLOG(oat) << "GetBestInfo checking dm ({})"_format(dm_for_oat_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking dm ({})", dm_for_oat_.DisplayFilename()); if (dm_for_oat_.IsUseable()) { return dm_for_oat_; } // TODO(jiakaiz): Is this the same as above? - VLOG(oat) << "GetBestInfo checking dm ({})"_format(dm_for_odex_.DisplayFilename()); + VLOG(oat) << ART_FORMAT("GetBestInfo checking dm ({})", dm_for_odex_.DisplayFilename()); if (dm_for_odex_.IsUseable()) { return dm_for_odex_; } @@ -1154,18 +1151,21 @@ bool OatFileAssistant::OatFileInfo::ShouldRecompileForFilter(CompilerFilter::Fil CompilerFilter::Filter current = file->GetCompilerFilter(); if (dexopt_trigger.targetFilterIsBetter && CompilerFilter::IsBetter(target, current)) { - VLOG(oat) << "Should recompile: targetFilterIsBetter (current: {}, target: {})"_format( - CompilerFilter::NameOfFilter(current), CompilerFilter::NameOfFilter(target)); + VLOG(oat) << ART_FORMAT("Should recompile: targetFilterIsBetter (current: {}, target: {})", + CompilerFilter::NameOfFilter(current), + CompilerFilter::NameOfFilter(target)); return true; } if (dexopt_trigger.targetFilterIsSame && current == target) { - VLOG(oat) << "Should recompile: targetFilterIsSame (current: {}, target: {})"_format( - CompilerFilter::NameOfFilter(current), CompilerFilter::NameOfFilter(target)); + VLOG(oat) << ART_FORMAT("Should recompile: targetFilterIsSame (current: {}, target: {})", + CompilerFilter::NameOfFilter(current), + CompilerFilter::NameOfFilter(target)); return true; } if (dexopt_trigger.targetFilterIsWorse && CompilerFilter::IsBetter(current, target)) { - VLOG(oat) << "Should recompile: targetFilterIsWorse (current: {}, target: {})"_format( - CompilerFilter::NameOfFilter(current), CompilerFilter::NameOfFilter(target)); + VLOG(oat) << ART_FORMAT("Should recompile: targetFilterIsWorse (current: {}, target: {})", + CompilerFilter::NameOfFilter(current), + CompilerFilter::NameOfFilter(target)); return true; } |