diff options
Diffstat (limited to 'libgrust')
-rw-r--r-- | libgrust/ChangeLog | 10 | ||||
-rw-r--r-- | libgrust/libformat_parser/.cargo/config.toml (renamed from libgrust/libformat_parser/.cargo/config) | 0 | ||||
-rw-r--r-- | libgrust/libformat_parser/Makefile.am | 11 | ||||
-rw-r--r-- | libgrust/libformat_parser/Makefile.in | 10 | ||||
-rw-r--r-- | libgrust/libformat_parser/generic_format_parser/src/lib.rs | 14 | ||||
-rw-r--r-- | libgrust/libformat_parser/src/lib.rs | 11 |
6 files changed, 42 insertions, 14 deletions
diff --git a/libgrust/ChangeLog b/libgrust/ChangeLog index 76e7dd5..a5641b7 100644 --- a/libgrust/ChangeLog +++ b/libgrust/ChangeLog @@ -1,3 +1,13 @@ +2025-03-31 Arthur Cohen <arthur.cohen@embecosm.com> + + * libformat_parser/Makefile.am: Avoid using --config as it is unsupported by cargo 1.49. + * libformat_parser/Makefile.in: Regenerate. + * libformat_parser/generic_format_parser/src/lib.rs: Use extension trait for missing + features. + * libformat_parser/src/lib.rs: Likewise. + * libformat_parser/.cargo/config: Moved to... + * libformat_parser/.cargo/config.toml: ...here. + 2025-03-17 badumbatish <tanghocle456@gmail.com> * libformat_parser/generic_format_parser/src/lib.rs: diff --git a/libgrust/libformat_parser/.cargo/config b/libgrust/libformat_parser/.cargo/config.toml index 0236928..0236928 100644 --- a/libgrust/libformat_parser/.cargo/config +++ b/libgrust/libformat_parser/.cargo/config.toml diff --git a/libgrust/libformat_parser/Makefile.am b/libgrust/libformat_parser/Makefile.am index e0e1f45..59189c0 100644 --- a/libgrust/libformat_parser/Makefile.am +++ b/libgrust/libformat_parser/Makefile.am @@ -2,12 +2,9 @@ LIBFORMAT_PARSER = debug/liblibformat_parser.a all-local: $(LIBFORMAT_PARSER) +RUST_BUILD_DIR=$(PWD) + # TODO: Improve `cargo` invocation with host specific flags, possibly creating a $(CARGO) variable? $(LIBFORMAT_PARSER): $(srcdir)/Cargo.toml $(srcdir)/src/*.rs - cargo \ - --config $(srcdir)/.cargo/config \ - build \ - --offline \ - --target-dir . \ - --manifest-path $(srcdir)/Cargo.toml \ - # FIXME: Not always '--release', right? + cd $(srcdir) && \ + cargo build --offline --target-dir $(RUST_BUILD_DIR) diff --git a/libgrust/libformat_parser/Makefile.in b/libgrust/libformat_parser/Makefile.in index 526b53d..f6c400d 100644 --- a/libgrust/libformat_parser/Makefile.in +++ b/libgrust/libformat_parser/Makefile.in @@ -263,6 +263,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ LIBFORMAT_PARSER = debug/liblibformat_parser.a +RUST_BUILD_DIR = $(PWD) all: all-am .SUFFIXES: @@ -428,13 +429,8 @@ all-local: $(LIBFORMAT_PARSER) # TODO: Improve `cargo` invocation with host specific flags, possibly creating a $(CARGO) variable? $(LIBFORMAT_PARSER): $(srcdir)/Cargo.toml $(srcdir)/src/*.rs - cargo \ - --config $(srcdir)/.cargo/config \ - build \ - --offline \ - --target-dir . \ - --manifest-path $(srcdir)/Cargo.toml \ - # FIXME: Not always '--release', right? + cd $(srcdir) && \ + cargo build --offline --target-dir $(RUST_BUILD_DIR) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/libgrust/libformat_parser/generic_format_parser/src/lib.rs b/libgrust/libformat_parser/generic_format_parser/src/lib.rs index 25f6b0e..97967a9 100644 --- a/libgrust/libformat_parser/generic_format_parser/src/lib.rs +++ b/libgrust/libformat_parser/generic_format_parser/src/lib.rs @@ -32,6 +32,20 @@ use std::iter; use std::str; use std::string; +// Extension trait for `Option<T>::is_some_and()` which was not a feature in Rust 1.49 +pub trait OptionIsSomeAndExt<T> { + fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool; +} + +impl<T> OptionIsSomeAndExt<T> for Option<T> { + fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool { + match self { + None => false, + Some(x) => f(x), + } + } +} + // Note: copied from rustc_span /// Range inside of a `Span` used for diagnostics when we only have access to relative positions. #[derive(Copy, Clone, PartialEq, Eq, Debug)] diff --git a/libgrust/libformat_parser/src/lib.rs b/libgrust/libformat_parser/src/lib.rs index d920cfa..72e5971 100644 --- a/libgrust/libformat_parser/src/lib.rs +++ b/libgrust/libformat_parser/src/lib.rs @@ -21,6 +21,17 @@ where } } +// Extension trait to provide `String::leak` which did not exist in Rust 1.49 +pub trait StringLeakExt { + fn leak<'a>(self) -> &'a mut str; +} + +impl StringLeakExt for String { + fn leak<'a>(self) -> &'a mut str { + Box::leak(self.into_boxed_str()) + } +} + // FIXME: Make an ffi module in a separate file // FIXME: Remember to leak the boxed type somehow // FIXME: How to encode the Option type? As a pointer? Option<T> -> Option<&T> -> *const T could work maybe? |