Commit Graph

26 Commits

Author SHA1 Message Date
ridiculousfish
bee422fea2 Use a faster, deterministic RNG in the string escape tests
This shaves about 9 seconds off of the runtime, and makes the test
deterministic.

We do not touch the test_convert test because there is a known failure and we
need to track it down before making it deterministic.
2023-07-04 13:27:53 -07:00
Henrik Hørlück Berg
7b3637cd1f Port builtins/status to fish
- Also port tests of wdirname and wbasename, as they were bugged
2023-07-01 15:33:01 -07:00
Henrik Hørlück Berg
1f67bcbb39 Update dependencies for asan to work
Rust nightly changed the name of a preview feature, which broke proc-macro2,
see https://github.com/rust-lang/rust/issues/113152
2023-06-29 20:02:43 -05:00
Mahmoud Al-Qudsi
b17124d8d2 Add rsconf build system and check for gettext symbols
This is more complicated than it needs to be thanks to the presence of CMake and
the C++ ffi in the picture. rsconf can correctly detect the required libraries
and instruct rustc to link against them, but since we generate a static rust
library and have CMake link it against the C++ binaries, we are still at the
mercy of CMake picking up the symbols we want.

Unfortunately, we could detect the gettext symbols but discover at runtime that
they weren't linked in because CMake was compiled with `-DWITH_GETTEXT=0` or
similar (as the macOS CI runner does). This means we also need to pass state
between CMake and our build script to communicate which CMake options were
enabled.
2023-05-25 16:54:03 -05:00
Fabian Boehm
90713dd221 build.rs: Remove miette dependency
This wasn't providing a lot of value, and the license compatibility is iffy.

There's a bit of weirdness in that this now uses a `Box<dyn Error>`,
but since currently nothing actually errors out let's punt that for
later.
2023-05-25 17:46:03 +02:00
Xiretza
81cdd51597 Update printf-compat 2023-04-29 19:57:33 +02:00
Johannes Altmanninger
629cbe0115 Env stubs for path port 2023-04-21 13:57:29 +02:00
Xiretza
61028f020c cargo update
This fixes an issue with rust-analyzer always rebuilding even without changes,
which was introduced by b8189da011.
2023-04-16 17:21:54 +02:00
ridiculousfish
dee969bf3a Introduce wcstring_list_ffi_t
wcstring_list_ffi_t is an autocxx-friendly type for passing lists of
strings from C++ to Rust.
2023-04-15 17:53:52 -07:00
Mahmoud Al-Qudsi
d728b884dd Update pinned cxx dependency
Pulls in fish-shell/cxx 00536f3b771c9741bc325b37e7627d52052240a3 which
implements `VectorElement` for `CxxWString`.
2023-04-10 20:51:07 -05:00
ridiculousfish
14c5c94d01 Use hexponent to implement hex float parsing in wcstod
This teaches wcstod to parse hex floats like 0x1.5p3 via a forked
version of hexponent. This support is necessary for printf.
2023-04-06 14:29:18 -07:00
Mahmoud Al-Qudsi
3932ed118e Update cxx dependency
The let_cxx_wstring!() macro now works and can be used to avoid needing an extra
ffi call to obtain a (pinned) wstring object.
2023-04-03 22:03:08 -05:00
Johannes Altmanninger
05bad5eda1 Port common.{h,cpp} to Rust
Most of it is duplicated, hence untested.

Functions like mbrtowc are not exposed by the libc crate, so declare them
ourselves.
Since we don't know the definition of C macros, add two big hacks to make
this work:
1. Replace MB_LEN_MAX and mbstate_t with values (resp types) that should
   be large enough for any implementation.
2. Detect the definition of MB_CUR_MAX in the build script. This requires
   more changes for each new libc. We could also use this approach for 1.

Additionally, this commit brings a small behavior change to
read_unquoted_escape(): we cannot decode surrogate code points like \UDE01
into a Rust char, so use � (\UFFFD, replacement character) instead.
Previously, we added such code points to a wcstring; looks like they were
ignored when printed.
2023-04-02 15:17:06 +02:00
ridiculousfish
dad1290337 Replace the printf implementation
The existing printf implementation is too buggy to back the printf
builtin. Switch to the new implementation based on printf-compat.
2023-03-26 14:07:29 -07:00
ridiculousfish
0e68405ccd Add our fast-float crate
This adds a dependency on https://github.com/fish-shell/fast-float-rust
which is our forked fast-float crate for parsing.
2023-03-26 13:38:09 -07:00
ridiculousfish
b8189da011 Use the rust-pcre2 crate for regex
This adds support for our (forked) rust-pcre2 crate.
2023-03-25 17:01:50 -07:00
ridiculousfish
57f4571a01 Rewrite wait handles and wait handle store in Rust 2023-03-18 18:53:04 -07:00
Victor Song
77fe9933e2 builtins: Rewrite pwd in Rust
Closes #9625.
2023-03-12 15:18:15 -05:00
ridiculousfish
5197bf75cd Point fish autocxx and similar dependencies at new fish-shell location
These crates have been moved into fish-shell org; update Cargo.toml to
reflect that.
2023-03-09 21:01:49 -08:00
Fabian Boehm
4fd1458d85 Port random to rust 2023-02-19 21:01:46 +01:00
Mahmoud Al-Qudsi
0b160ebe71 Drop lazy_static from Cargo.toml
This should have been included as part of the previous commit, mea culpa.
2023-02-05 18:20:26 -06:00
Mahmoud Al-Qudsi
d7febd4f3e Use once_cell instead of lazy_static
lazy_static has better ergonomics at the call/access sites (it returns a
reference to the type directly, whereas with once_cell we get a static Lazy<T>
that we must dereference instead) but the once_cell api is slated for
integration into the standard library [0] and has been the "preferred" way to
declare static global variables w/ deferred initialization. It's also less
opaque and easier to comprehend how it works, I guess?

(Both `once_cell` and `lazy_static` are already in our dependency tree, so this
should have no detrimental effect on build times. It actually negligibly
*improves* build times by not using macros, reducing the amount of expansion the
compiler has to do by a miniscule amount.)

[0]: https://github.com/rust-lang/rust/issues/74465
2023-02-05 17:58:33 -06:00
Mahmoud Al-Qudsi
60bd186e21 Fix linking errors under FreeBSD
The nix crate had all its default features enabled, which included features that
are not present under BSD. We should only enable the select subset of crate
features that we know are available cross-platform (or else use conditional
targeting in Cargo.toml to only enable Linux-only features when compiling for
Linux targets).

For now, it seems we can just use the nix crate with all features disabled as it
still builds under Linux and FreeBSD in this state.
2023-02-03 11:36:21 -06:00
Mahmoud Al-Qudsi
c18fb74fa8 Fix rust-invoked build of c/cpp sources under FreeBSD
Due to an upstream issue with cc-rs [0], the rust-generated C++ interface would
fail to compile. A PR has been opened to patch the issue upstream [1], but in
the meantime `Cargo.toml` has been patched to use a fork of cc-rs with the
relevant fixes.

[0]: https://github.com/rust-lang/cc-rs/issues/463
[1]: https://github.com/rust-lang/cc-rs/pull/785
2023-02-03 11:36:21 -06:00
ridiculousfish
681a165721 Add an FFI test facility
This allow testing Rust functions (from fish_tests.cpp) which need to
cross the FFI. See the example in smoke.rs.
2023-02-02 19:34:48 -07:00
ridiculousfish
d843b67d2d Initial Rust commit 2023-02-02 19:34:47 -07:00