diff --git a/MODULE.bazel b/MODULE.bazel index fc6acfc1137f..fc9d609f65ce 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -23,7 +23,7 @@ bazel_dep(name = "rules_shell", version = "0.5.0") bazel_dep(name = "bazel_skylib", version = "1.8.1") bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "absl") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json") -bazel_dep(name = "fmt", version = "10.0.0") +bazel_dep(name = "fmt", version = "12.1.0-codeql.1") bazel_dep(name = "rules_kotlin", version = "2.1.3-codeql.1") bazel_dep(name = "gazelle", version = "0.40.0") bazel_dep(name = "rules_dotnet", version = "0.19.2-codeql.1") diff --git a/misc/bazel/registry/fix.py b/misc/bazel/registry/fix.py index a2b947e19e20..863c832be59d 100755 --- a/misc/bazel/registry/fix.py +++ b/misc/bazel/registry/fix.py @@ -35,6 +35,9 @@ def patch_json(file, **kwargs): def update(data): data = json.loads(data) if data else {} data.update(kwargs) + for k, v in kwargs.items(): + if v is None: + data.pop(k) return json.dumps(data, indent=4) + "\n" patch_file(file, update) @@ -48,8 +51,21 @@ def update(data): patch_json(entry / "metadata.json", versions=[v.name for v in versions]) for version in versions: - patch_json(version / "source.json", patches={ - p.name: sha256(p) for p in version.joinpath("patches").iterdir() - }) - patch_file(version / "MODULE.bazel", - lambda s: re.sub(r'''version\s*=\s*['"].*['"]''', f'version = "{version.name}"', s, 1)) + patches = version.joinpath("patches") + overlay = version.joinpath("overlay") + modules = [version / "MODULE.bazel", overlay / "MODULE.bazel"] + for module in modules: + if module.is_file(): + patch_file( + module, + lambda s: re.sub(r'''version\s*=\s*['"].*['"]''', f'version = "{version.name}"', s, 1)) + patch_json( + version / "source.json", + patches={ + p.name: sha256(p) for p in patches.iterdir() + } if patches.is_dir() else None, + patch_strip=1 if patches.is_dir() else None, + overlay={ + o.name: sha256(o) for o in overlay.iterdir() + } if overlay.is_dir() else None, + ) diff --git a/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/MODULE.bazel b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/MODULE.bazel new file mode 100644 index 000000000000..898d1bed0fc2 --- /dev/null +++ b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/MODULE.bazel @@ -0,0 +1,9 @@ +module( + name = "fmt", + version = "12.1.0-codeql.1", + bazel_compatibility = [">=7.2.1"], + compatibility_level = 10, +) + +bazel_dep(name = "rules_cc", version = "0.2.13") +bazel_dep(name = "rules_license", version = "1.0.0") diff --git a/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/overlay/BUILD.bazel b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/overlay/BUILD.bazel new file mode 100644 index 000000000000..bde3d4a3d31d --- /dev/null +++ b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/overlay/BUILD.bazel @@ -0,0 +1,40 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("@rules_license//rules:license.bzl", "license") + +package( + default_applicable_licenses = [":license"], +) + +exports_files([ + "LICENSE", +]) + +license( + name = "license", + license_kinds = ["@rules_license//licenses/spdx:MIT"], + license_text = "LICENSE", +) + +cc_library( + name = "fmt", + srcs = [ + #"src/fmt.cc", # No C++ module support, yet in Bazel (https://github.com/bazelbuild/bazel/pull/19940) + "src/format.cc", + "src/os.cc", + ], + hdrs = glob([ + "include/fmt/*.h", + ]), + # codeql change: disable UTF8 support, it's causing issues on Windows + # copts = select({ + # "@rules_cc//cc/compiler:msvc-cl": ["/utf-8"], + # "//conditions:default": [], + # }), + defines = select({ + "@rules_cc//cc/compiler:msvc-cl": ["FMT_UNICODE=0"], + "//conditions:default": [], + }), + includes = ["include"], + strip_include_prefix = "include", # workaround: only needed on some macOS systems (see https://github.com/bazelbuild/bazel-central-registry/issues/1537) + visibility = ["//visibility:public"], +) diff --git a/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/overlay/MODULE.bazel b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/overlay/MODULE.bazel new file mode 100644 index 000000000000..898d1bed0fc2 --- /dev/null +++ b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/overlay/MODULE.bazel @@ -0,0 +1,9 @@ +module( + name = "fmt", + version = "12.1.0-codeql.1", + bazel_compatibility = [">=7.2.1"], + compatibility_level = 10, +) + +bazel_dep(name = "rules_cc", version = "0.2.13") +bazel_dep(name = "rules_license", version = "1.0.0") diff --git a/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/source.json b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/source.json new file mode 100644 index 000000000000..91a417baba58 --- /dev/null +++ b/misc/bazel/registry/modules/fmt/12.1.0-codeql.1/source.json @@ -0,0 +1,9 @@ +{ + "url": "https://github.com/fmtlib/fmt/releases/download/12.1.0/fmt-12.1.0.zip", + "integrity": "sha256-aV/Rl/pa/4/Ge18rvBEEkKh1zfekFoashRL7SA+orac=", + "strip_prefix": "fmt-12.1.0", + "overlay": { + "BUILD.bazel": "sha256-T6CBBdPY92Iloq9NrMjm9kQeQA3nTZJeym6xG5cclOQ=", + "MODULE.bazel": "sha256-Dgke/2OMsffv9jPSDxIwIgJIb4L77VW6lR8TsNHsekg=" + } +} diff --git a/misc/bazel/registry/modules/fmt/metadata.json b/misc/bazel/registry/modules/fmt/metadata.json new file mode 100644 index 000000000000..ca5dd4861536 --- /dev/null +++ b/misc/bazel/registry/modules/fmt/metadata.json @@ -0,0 +1,22 @@ +{ + "homepage": "https://github.com/fmtlib/fmt", + "maintainers": [ + { + "email": "julian.amann@tum.de", + "github": "Vertexwahn", + "github_user_id": 3775001, + "name": "Julian Amann" + }, + { + "github": "mering", + "github_user_id": 133344217 + } + ], + "repository": [ + "github:fmtlib/fmt" + ], + "versions": [ + "12.1.0-codeql.1" + ], + "yanked_versions": {} +} diff --git a/swift/logging/Formatters.h b/swift/logging/Formatters.h deleted file mode 100644 index 9dc003b9ffe3..000000000000 --- a/swift/logging/Formatters.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -// Provides formatters for standard library types to be used with fmtlib. -// TODO: Patch fmtlib to support using `fmt/std.h` without RTTI -// (https://github.com/fmtlib/fmt/issues/3170). - -#include -#include -#include - -namespace fmt { -FMT_FORMAT_AS(std::filesystem::path, std::string); -} - -template <> -struct fmt::formatter : fmt::formatter { - auto format(const std::error_code& e, format_context& ctx) const { - return fmt::formatter::format(e.message(), ctx); - } -}; diff --git a/swift/logging/SwiftLogging.h b/swift/logging/SwiftLogging.h index e94ceb0f6f8b..16275858203c 100644 --- a/swift/logging/SwiftLogging.h +++ b/swift/logging/SwiftLogging.h @@ -8,8 +8,7 @@ #include #include - -#include "swift/logging/Formatters.h" +#include #include #include