From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- third_party/rust/encoding_c/build-disabled.rs | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 third_party/rust/encoding_c/build-disabled.rs (limited to 'third_party/rust/encoding_c/build-disabled.rs') diff --git a/third_party/rust/encoding_c/build-disabled.rs b/third_party/rust/encoding_c/build-disabled.rs new file mode 100644 index 0000000000..ebd7493626 --- /dev/null +++ b/third_party/rust/encoding_c/build-disabled.rs @@ -0,0 +1,60 @@ +// Copyright Mozilla Foundation. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate cheddar; + +use std::io::prelude::*; +use std::fs::File; + +fn replace(path: &str) -> std::io::Result<()> { + let mut f = try!(File::open(path)); + let mut s = String::new(); + try!(f.read_to_string(&mut s)); + s = s.replace("#ifndef cheddar_generated_encoding_rs_h", "// Copyright Mozilla Foundation. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. +// Instead, please regenerate using encoding_c/build.rs. + +#ifndef cheddar_generated_encoding_rs_h"); + s = s.replace("uint16_t", "char16_t"); + s = s.replace("uintptr_t", "size_t"); + s = s.replace("Encoding", "ENCODING_RS_ENCODING"); + s = s.replace("Encoder", "ENCODING_RS_ENCODER"); + s = s.replace("Decoder", "ENCODING_RS_DECODER"); + s = s.replace("ENCODING_RS_ENCODING.html", "Encoding.html"); + s = s.replace("ENCODING_RS_ENCODER.html", "Encoder.html"); + s = s.replace("ENCODING_RS_DECODER.html", "Decoder.html"); + s = s.replace("#include ", + "#include \n#include \"encoding_rs_statics.h\""); + let mut f = try!(File::create(path)); + try!(f.write_all(s.as_bytes())); + Ok(()) +} + +fn main() { + println!("cargo:rerun-if-changed=src/lib.rs"); + + let path = "include/encoding_rs.h"; + + cheddar::Cheddar::new() + .expect("could not read manifest") + .run_build(path); + + match replace(path) { + Ok(_) => {} + Err(e) => println!("Performing replacements failed {}.", e), + } +} -- cgit v1.2.3