Commit Graph

266 Commits

Author SHA1 Message Date
Fabian Boehm
120dc5c49f cmake: Include PushCheckState again
This was included in one file and used in another. Just include it here.
2024-01-21 12:17:33 +01:00
Fabian Boehm
8cf4d666b3 Remove more cmake configurechecks
PCRE2 is now handled by the crate, we don't need WCHAR_T_BITS anymore
2024-01-21 12:01:38 +01:00
Fabian Boehm
e73d7e26e4 Remove some more cmake bits 2024-01-20 09:13:04 +01:00
Fabian Boehm
5aa622daef Remove some more unused cmake bits 2024-01-20 08:56:29 +01:00
Fabian Boehm
cfeddcedb7 Remove unused bits from config.h 2024-01-20 08:56:29 +01:00
ridiculousfish
9747ab19d1 Eliminate UVAR_FILE_SET_MTIME_HACK checks
This was previously limited to Linux predicated on the existence
of certain headers, but Rust just exposes those functions unconditionally. So
remove the check and just perform the mtime hack on Linux and Android.
2024-01-19 09:33:33 -08:00
ridiculousfish
509d4fa122 Remove mbrtowc_invalid_utf8.cpp
This was used in CMake to detect invalid mbrtowc implementations. The only known
case was on SnowLeopard, which is no longer supported. Remove this file.
2024-01-13 15:35:46 -08:00
David Adam
f65ed782e8 Drop unused CMake module CheckIncludeFiles
This was only needed for certain configure checks, now elided, and for
CMake < 3.11.
2024-01-13 22:55:13 +08:00
David Adam
e59d164658 Drop unused configure checks
All of these checks are handled in external crates now.
2024-01-13 21:15:24 +08:00
David Adam
db9bb96910 Drop CMake PCRE2 download/linking and allow statically-linked PCRE2 crate
pcre2-sys includes a vendored copy of PCRE2, which allows for
statically-linked PCRE2. Hook this up to the CMake build variable, and
remove the C++ integration for PCRE2.
2024-01-13 20:43:12 +08:00
Fabian Boehm
507d634cfa Remove widestring-suffix from Cargo 2024-01-13 08:52:54 +01:00
Johannes Altmanninger
5512f44899 Enable doctests
They are probably not terribly useful for us but let's see what happens.

Unfortunately cargo does not properly forward the combination of "RUSTFLAGS"
and "--target" that is currently required to build with ASan [1].  Hence doctests
will fail to link on ASan builds. Let's disable doctests when ASan is active.

[1]: https://github.com/rust-lang/cargo/issues/10666 et al
2024-01-13 03:58:33 +01:00
David Adam
1683e720a8 Use Rust for executables
Use Rust for executables

Drops the C++ entry points and restructures the Rust package into a
library and three binary crates.

Renames the fish-rust package to fish.

At least on Ubuntu, "fish_indent" is built before "fish".
Make sure export CURSES_LIBRARY_LIST to all binaries to make sure
that "cached-curses-libnames" is populated.

Closes #10198
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
2871f5070f CMake: re-enable cargo-test under ASAN
With autocxx/cxx gone, this seems to work fine now.
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
2d493621f4 test_cargo-test: use Corrosion target dir
This makes "ninja test" write only to the build directory, not to the source
tree. This enables our docker script which mounts the source as read-only.
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
7686c39d76 test_cargo-test: inherit same variables as Corrosion build targets
In particular, pass the build directory, which is required in some test
scenarios (see next commit).
2024-01-13 03:07:29 +01:00
Fabian Boehm
cb51b236f3 cmake: Include GNUInstallDirs earlier for BINDIR etc to take effect
GNUInstallDirs is what defines CMAKE_INSTALL_FULL_BINDIR and such, so
the setting in Rust.cmake didn't work.

This also makes build.rs error out if any of these aren't defined
2024-01-10 17:51:23 +01:00
Fabian Boehm
2aee930659 Revert "Remove redundantly set corrosion env vars."
This reverts commit 114ebe3b8f.
2024-01-10 17:21:05 +01:00
Johannes Altmanninger
114ebe3b8f Remove redundantly set corrosion env vars.
They should already be set in Rust.cmake.
See https://github.com/fish-shell/fish-shell/pull/10198#discussion_r1446402611
2024-01-10 09:38:45 +01:00
Johannes Altmanninger
29bd6eebd0 Remove cxx and autocxx
Notably this gets rid of the Cargo target directory inside build directories,
in favor of "target/" at workspace root.
2024-01-07 22:19:56 +01:00
Johannes Altmanninger
ab98566c67 Remove fish_tests
The remaining tests are all obsolete or already ported.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
77550a2f0d Turn FFI tests into native Rust tests
Keep running tests serially to avoid breaking assumptions.

I think many of these tests can run in parallel and/or don't need test_init().
Use the safe variant everywhere, to get it done faster.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
b2d4619125 Link against curses in build.rs too
This will allow to use "cargo test" for unit tests that depend on our
curses.rs.

This means that Rust.cmake depends on ConfigureChecks, so move that one to
the front.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
3e3441429a Port wgettext wrapper from wutil.cpp
This introduces a string allocations on lookups of strings that are not
known at compile time; we should get rid of these allocations in future.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
55fd43d86c Port reader 2024-01-07 00:54:22 +01:00
Johannes Altmanninger
f3dd8d306f Port make_autoclose_pipes, fd_event_signaller_t
This allows to get rid of the C++ autoclose_fd_t.
2023-12-10 14:35:43 +01:00
David Adam
f2f41c6eec drop unused functions and configure checks
Remove the following C++ functions/methods, which have no callers:

common.cpp:
- read_loop
- narrow_string_safe
- escape_string_for_double_quotes
- read_unquoted_escape
- format_size
- format_size_safe
- valid_func_name
- get_executable_path

env.cpp:
- env_stack_t::set_empty
- env_stack_t::set_argv

fallback.cpp:
- fish_mkstemp_cloexec
- flock

proc_util.cpp:
- parse_util_slice_length
- parse_util_argument_is_help

path.cpp:
- path_get_path
- path_as_implicit_cd
- path_apply_working_directory
- path_emit_config_directory_messages
- path_get_data_remoteness
- path_get_config_remoteness
- path_is_valid
- paths_are_same_file

wcstringutil.cpp:
- split_string_tok

wutil.cpp:
- wgetcwd
- wunlink
- wrealpath
- wrename
- file_id_for_path
- fish_wcstoull

Also drop unused configure checks/defines:
- HAVE_FLOCK
2023-11-26 22:35:51 +08:00
ridiculousfish
5e06e80136 Remove angular "partials"
These are no longer used as we are fully on Alpine.js
2023-10-08 12:22:56 -07:00
Fabian Boehm
35baa88334 cmake: Canonicalize binary dir
This would otherwise fail to set $fish_function_path to
share/functions etc if run through a symlink.
2023-09-28 17:34:10 +02:00
Fabian Boehm
d6a6d77429 cmake: Fix SYSCONFDIR and friends 2023-09-06 09:49:24 +02:00
Henrik Hørlück Berg
e4df340f43 Forward CMake configs to Cargo 2023-09-05 11:38:59 +02:00
Henrik Hørlück Berg
5db08e1126 Make CARGO_MANIFEST_DIR for fish-rust equal to src 2023-09-05 11:38:59 +02:00
Henrik Hørlück Berg
c23f419af1 Use the workspace from CMake
- Make CMake use the correct target-path
- Make build.rs use the correct target dir

Workspaces place it in the project root by default, the alternative to making
this change is to add a `.cargo/config.toml` file with

```toml
[build]
target-dir = "fish-rust/target"
```

Which I think is unnecessary, as we likely want to use the new location anyways.
2023-08-19 15:18:38 +02:00
Henrik Hørlück Berg
4728eaf642 Don't specify a min macOS version when not needed
Corrosion does not forward the `CMAKE_OSX_DEPLOYMENT_TARGET` to cargo.
As a result we end up building the Rust-libraries for the default target,
which is usually current macOS-version. But CMake links using the set
target, so we link for a version older than we built for.

To properly build for older macOS versions, the env variable
`MACOSX_DEPLOYMENT_TARGET` should instead be set, which cargo,
cmake and friends read by default. This can then lead to
warnings if you have libraries (e.g. PCRE2) built for newer
than our minimum version. Therefore we do not set a min-target
by default.
2023-08-02 22:42:52 +08:00
Henrik Hørlück Berg
55b6d7cd74 Revert "Fix built for newer than linked macOS warning"
This reverts commit 69ed2d1ca7. It was never meant
to be merged.
2023-08-02 22:42:52 +08:00
David Adam
861da91bf1 drop unused functions and configure checks
Remove the following C++ functions/methods, which have no callers:

fallback.cpp:
- wcstod_l

proc.cpp:
- job_t::get_processes

wutil.cpp:
- fish_wcstoll
- fish_wcstoull

Also drop unused configure checks/defines:
- HAVE_WCSTOD_L
- HAVE_USELOCALE
2023-07-14 20:48:56 +08:00
Henrik Hørlück Berg
69ed2d1ca7 Fix built for newer than linked macOS warning 2023-07-04 13:27:53 -07: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
Thomas Klausner
67d1d80f94
When using curses, look for libterminfo as well. (#9794)
Supports NetBSD, where libtinfo isn't available but libterminfo is.
2023-05-16 15:02:11 -05:00
Mahmoud Al-Qudsi
3651e0e9d8 Actually report ASAN memory leaks
The new asan exit handlers are called to get proper ASAN leak reports (as
calling _exit(0) skips the LSAN reporting stage and exits with success every
time).

They are no-ops when not compiled for ASAN.
2023-05-02 11:52:41 -05:00
Johannes Altmanninger
ec176dc07e Port path.h 2023-04-21 13:57:29 +02:00
Johannes Altmanninger
454009d13e Rust.cmake: break up long line 2023-04-21 13:57:29 +02:00
David Adam
1c978f7ec5 cmake: add support for vendored cmake
Use a "cmake-vendored" directory if it exists, to avoid accessing the
network if it's available, and a target to create an appropriate tarball
to create that directory.
2023-03-30 12:01:25 +08:00
Mahmoud Al-Qudsi
1bdb7dffaf Use cargo build -Z build-std for ASAN
This is recommended and increases coverage.
2023-03-08 11:27:15 -06:00
Mahmoud Al-Qudsi
91cf526d23
Enable rust address sanitizer for asan ci job (#9643)
Rust has multiple sanitizers available (with llvm integration).
-Zsanitizer=address catches the most likely culprits but we may want to set up a
separate job w/ -Zsanitizer=memory to catch uninitialized reads.

It might be necessary to execute `cargo build` as `cargo build -Zbuild-std` to
get full coverage.

When we're linking against the hybrid C++ codebase, the sanitizer library is
injected into the binary by also include `-fsanitize=address` in CXXFLAGS - we
do *not* want to manually opt-into `-lasan`. We also need to manually specify
the desired target triple as a CMake variable and then explicitly pass it to all
`cargo` invocations if building with ASAN.

Corrosion has been patched to make sure it follows these rules.

The `cargo-test` target is failing to link under ASAN. For some reason it has
autocxx/ffi dependencies even though only rust-native, ffi-free code should be
tested (and one would think the situation wouldn't change depending on the
presence of the sanitizer flag). It's been disabled under ASAN for now.
2023-03-06 18:15:36 -06:00
Akatsuki Rui
5a5cf267b7
cmake/Tests.cmake: Fix failure in cargo test (#9603)
The FISH_RUST_TARGET_DIR is not set for Tests.cmake, the target_dir will set to
$CARGO_MANIFEST_DIR/target. But if build.target-dir or CARGO_TARGET_DIR is set,
the real target_dir doesn't at the $CARGO_MANIFEST_DIR/target. It causes failure
in cargo test. Then, set --target-dir for cargo test.

Closes #9600
2023-02-21 11:44:59 -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
Aaron Gyes
550857ef65 Remove obsolete lynx bug mitigation
a lynx-internal hash of div.contents collided with em>a which caused
built-in styling to render much of entire pages as emphasized links.

Since switching from doxygen, we haven't had a <div class="contents">
so this workaround is no longer needed.
2023-01-01 19:41:41 -08:00
Mahmoud Al-Qudsi
2c0bbb0f82 Revert "cmake: Use pcre2 tag directly"
This reverts commit 2cc4437567.

As pointed out to me, it is safer to use the SHA directly to ~guarantee
the remote resource hasn't changed.
2022-10-28 17:59:08 -05:00