base: Remove Rust

This commit is contained in:
klzgrad 2025-01-14 19:29:28 +08:00
parent 02c89f1dbb
commit c9c87cb2a4
3 changed files with 7 additions and 59 deletions

View File

@ -1017,12 +1017,6 @@ component("base") {
if (!is_nacl) {
# Used by metrics/crc32, except on NaCl builds.
deps += [ "//third_party/zlib" ]
# NaCl does not support Rust.
deps += [
":rust_logger",
"//third_party/rust/serde_json_lenient/v0_2/wrapper",
]
}
# `raw_ptr` cannot be made a component due to CRT symbol issues.
@ -1059,17 +1053,6 @@ component("base") {
"//third_party/abseil-cpp:absl",
]
if (!is_nacl) {
sources += [
"containers/span_rust.h",
"strings/string_view_rust.h",
]
# Base provides conversions between CXX types and base types (e.g.
# std::string_view).
public_deps += [ "//build/rust:cxx_cppdeps" ]
}
# Needed for <atomic> if using newer C++ library than sysroot, except if
# building inside the cros_sdk environment - use host_toolchain as a
# more robust check for this.
@ -2431,41 +2414,6 @@ component("base") {
}
}
rust_bindgen("logging_log_severity_bindgen") {
# TODO(danakj): Maybe combine all base bindgen targets, or all base/logging
# ones even) into a single GN target? But the GN rule needs to handle multiple
# headers then.
header = "logging/log_severity.h"
cpp = true
visibility = [ ":*" ]
# Transitive generated header dependency.
deps = [ ":debugging_buildflags" ]
}
rust_bindgen("logging_rust_log_integration_bindgen") {
header = "logging/rust_log_integration.h"
cpp = true
visibility = [ ":*" ]
# Transitive generated header dependency.
deps = [ ":debugging_buildflags" ]
}
rust_static_library("rust_logger") {
allow_unsafe = true # Unsafe needed for FFI.
deps = [
":logging_log_severity_bindgen",
":logging_rust_log_integration_bindgen",
"//third_party/rust/log/v0_4:lib",
]
visibility = [ ":base" ]
sources = [ "logging/rust_logger.rs" ]
crate_root = "logging/rust_logger.rs"
cxx_bindings = [ "logging/rust_logger.rs" ]
}
if (is_linux || is_chromeos) {
# Split out as a separate target for two reasons:
# - the line number reader is 2x slower in debug builds if not optimized,

View File

@ -13,7 +13,7 @@
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#if !BUILDFLAG(IS_NACL)
#if 0 // Disables Rust
#include "base/strings/string_view_rust.h"
#include "third_party/rust/serde_json_lenient/v0_2/wrapper/functions.h"
#include "third_party/rust/serde_json_lenient/v0_2/wrapper/lib.rs.h"
@ -23,7 +23,7 @@ namespace base {
// TODO(crbug.com/40811643): Move the C++ parser into components/nacl to just
// run in-process there. Don't compile base::JSONReader on NaCL at all.
#if !BUILDFLAG(IS_NACL)
#if 0 // Disables Rust
namespace {
using serde_json_lenient::ContextPointer;
@ -140,7 +140,7 @@ JSONReader::Result DecodeJSONInRust(std::string_view json,
std::optional<Value> JSONReader::Read(std::string_view json,
int options,
size_t max_depth) {
#if BUILDFLAG(IS_NACL)
#if 1 // Disables Rust
internal::JSONParser parser(options, max_depth);
return parser.Parse(json);
#else // BUILDFLAG(IS_NACL)
@ -173,7 +173,7 @@ std::optional<Value::Dict> JSONReader::ReadDict(std::string_view json,
JSONReader::Result JSONReader::ReadAndReturnValueWithError(
std::string_view json,
int options) {
#if BUILDFLAG(IS_NACL)
#if 1 // Disables Rust
internal::JSONParser parser(options);
auto value = parser.Parse(json);
if (!value) {
@ -213,7 +213,7 @@ bool JSONReader::UsingRust() {
if (!base::FeatureList::GetInstance()) {
return false;
}
#if BUILDFLAG(IS_NACL)
#if 1 // Disables Rust
return false;
#else
return base::FeatureList::IsEnabled(base::features::kUseRustJsonParser);

View File

@ -126,7 +126,7 @@ typedef FILE* FileHandle;
#include "base/fuchsia/scoped_fx_logger.h"
#endif
#if !BUILDFLAG(IS_NACL)
#if 0 // Disables Rust
#include "base/logging/rust_logger.rs.h"
#endif
@ -526,7 +526,7 @@ bool BaseInitLoggingImpl(const LoggingSettings& settings) {
}
#endif
#if !BUILDFLAG(IS_NACL)
#if 0 // Disables Rust
// Connects Rust logging with the //base logging functionality.
internal::init_rust_log_crate();
#endif