Commit graph

200 commits

Author SHA1 Message Date
Fabian Boehm
84b5701b92 Port fish_test_helper to C
This is the last piece of C++, so now we can remove the need for a C++
compiler.

We need one for C anyway (libc.c).

Fixes #10549
2024-06-12 08:11:16 +02:00
Johannes Altmanninger
ccaf06e9d6 Fix incremental rebuild on added/deleted source file
Looks like "add_custom_command(OUTPUT ...)"  assumes the dependencies are
correct which is not always true. We can use "add_custom_target" to always
re-run Cargo.
2024-03-24 12:18:20 +01:00
Fabian Boehm
721a360707 cmake: Remove a bunch of unnecessary code
We are no longer C++, we no longer support xcode

Note: This will remove a warning "DO NOT EDIT" comment from __fish_build_paths.fish, but
that's unnecessary. The file is typically in /usr or another
package-manager-owned location, so people don't typically edit it.

And if it did we don't actually *care*, it'll work fine.
2024-03-03 20:36:24 +01:00
Fabian Boehm
fc794bab4c Switch to the terminfo crate
This allows us to get the terminfo information without linking against curses.

That means we can get by without a bunch of awkward C-API trickery.

There is no global "cur_term" kept by a library for us that we need to invalidate.

Note that it still requires a "unhashed terminfo database", and I don't know how well it handles termcap.

I am not actually sure if there are systems that *can't* have terminfo, everything I looked at
has the ncurses terminfo available to install at least.
2024-02-22 20:10:16 +01:00
Johannes Altmanninger
2137467f0b Trigger rebuild if builtin source changes 2024-02-12 22:28:29 +01:00
David Adam
59fe52851e CMake: add entry point to binary dependency 2024-02-11 21:07:43 +08:00
Fabian Boehm
06426604b7 cmake: Remove rlib, let cargo build directly
This removes an extra step, should hopefully save some time.
2024-02-10 16:31:54 +01:00
David Adam
2bc197fe74 cmake: add -g to existing RUSTFLAGS if required
Makes it possible to use the sanitizers again.

Note that this requires RUSTFLAGS to be set when running CMake, and will not be
updated when running the build system if the environment variable changes.
2024-02-08 00:28:30 +08:00
David Adam
698be5b9fe cmake: make binaries depend on generated library
Fixes incremental builds by removing the custom target
2024-02-06 20:48:38 +08:00
Fabian Boehm
168d567250 cmake: Make default build type Debug
With LTO, Release builds are now a lot slower.
For development debug builds are much nicer.

We'll ask packagers to pass Release when building a package.
2024-02-04 09:46:05 +01:00
Fabian Boehm
8e73a4c5af cmake: Do add dependencies
Unfortunately ninja does not want to be tricked.

I tried `touch`ing a file and writing the date to a file,
and even removing that file before cargo runs, it doesn't work.

So instead we'll do the imperfect solution of enumerating sources.

And yes, we use a GLOB because listing source files is terrible.
Any build system that wants you not to glob is a build system made for
build system people who like touching build systems, not me.
2024-02-03 09:57:11 +01:00
Johannes Altmanninger
f8ca2b0419 Revert "Bump CMake version for IMPORTED_RUNTIME_ARTIFACTS"
This reverts commit fdc45452b6.

We no longer depend on IMPORTED_RUNTIME_ARTIFACTS.
2024-02-03 08:02:36 +01:00
Fabian Boehm
7c0cc2d2ab cmake: It seems like always_rebuild needs to output something 2024-02-02 21:44:54 +01:00
Fabian Boehm
36efb1ce48 cmake: Fix incremental build
This just always reruns cargo, which is fine.
2024-02-02 16:00:04 +01:00
David Adam
cb46396b67 cmake: build executables by driving cargo directly
Drops the requirement for Corrosion, as almost none of its extensive features
are required.
2024-01-30 18:18:55 +08:00
Fabian Boehm
6f31ec7a61 Remove cmake policies
CMP0066: Honor per-config flags in try_compile() source-file
signature.

CMP0067: Honor language standard in try_compile() source-file signature.

We no longer have any try_compile
2024-01-20 09:02:43 +01:00
Fabian Boehm
6be6890fa3 Remove config.h
We don't actually use anything in there anymore.

We keep the WCHAR_T_BITS define in cmake because that's
used to find pcre2.
2024-01-20 08:56:29 +01:00
Johannes Altmanninger
fdc45452b6 Bump CMake version for IMPORTED_RUNTIME_ARTIFACTS
This was added in CMake 3.21 which is only 1.5 years old.
2024-01-15 21:35:06 +01:00
David Adam
a533d836dd bump minimum CMake version 2024-01-13 22:55:13 +08:00
David Adam
c9712aeda2 Drop additional unused CMake directives 2024-01-13 22:55:12 +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
David Adam
5e8a7fb862 Drop unused C++ fishlib 2024-01-13 11:12:02 +08: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
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
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
8a67abfeaa CMake: remove stale lint targets 2024-01-07 22:19:56 +01:00
Johannes Altmanninger
102ab2c90d Remove FFI code and C++ files
There's a lot more to remove, like
- cxx/autocxx
- now-unused CMake code
- C++ pcre
- C++ entry points
- remaining mentions of "ffi"
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
55fd43d86c Port reader 2024-01-07 00:54:22 +01:00
ridiculousfish
8190e3419d Add remaining input FFI bits and port builtin_bind
This implements input and input_common FFI pieces in input_ffi.rs, and
simultaneously ports bind.rs. This was done as a single commit because
builtin_bind would have required a substantial amount of work to use the input
ffi.
2023-12-31 17:17:43 -08: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
Johannes Altmanninger
b28521c3d5 Port fish_indent 2023-12-06 09:59:16 +01:00
Thomas Queiroz
a64324421f Port builtin ulimit
Closes #10121
2023-12-03 11:39:15 +01:00
Johannes Altmanninger
43e2d7b48c Port pager.cpp 2023-12-03 11:02:04 +01:00
Johannes Altmanninger
31ad182aa5 Port screen.cpp 2023-12-01 11:59:33 +01:00
ridiculousfish
9b54e243b1 Add FFI bindings to universal notifiers and adopt in input_common
This removes the C++ bits for universal notifiers.
2023-11-26 17:29:53 -08:00
ridiculousfish
c1e4a447fd Remove C++ UTF-8 bits
These are no longer used.
2023-11-18 19:21:25 -08:00
ridiculousfish
377ef9786e Remove null_terminated_array C++ bits
These are now unused.
2023-11-18 10:28:52 -08:00
Johannes Altmanninger
6569943cb8 Port builtin read 2023-11-15 11:09:48 +01:00
Johannes Altmanninger
77aeb6a2a8 Port execution
Drop support for history file version 1.

ParseExecutionContext no longer contains an OperationContext because in my
first implementation, ParseExecutionContext didn't have interior mutability.
We should probably try to add it back.

Add a few to-do style comments. Search for "todo!" and "PORTING".

Co-authored-by: Xiretza <xiretza@xiretza.xyz>
(complete, wildcard, expand, history, history/file)
Co-authored-by: Henrik Hørlück Berg <36937807+henrikhorluck@users.noreply.github.com>
(builtins/set)
2023-11-15 11:09:48 +01:00
Johannes Altmanninger
55683b29cd CMakeLists: sort 2023-10-07 19:30:46 +02:00
ridiculousfish
555171cb55 Adopt Rust postfork code
This adopts the Rust postfork code, bridging it from C++ exec module.

We use direct function calls for the bridge, rather than cxx/autocxx, so that we
can be sure that no memory allocations or other shenanigans are happening.
2023-09-24 13:04:00 -07:00
ridiculousfish
2b25cd1654 Complete the transition of the kill ring and remove kill.cpp
This finishes off the transition of the kill ring from C++ to Rust, and removes
the C++ bits.
2023-08-13 13:06:06 -07:00
Fabian Boehm
5f0df359b8 Remove C++ version of builtin functions
And the C++ reformat_for_screen and event_filter_names as there are no more users.
2023-08-13 14:17:44 +02:00
Henrik Hørlück Berg
f4a5de1fbf Port builtins/path to Rust 2023-08-07 21:01:11 -07:00
Henrik Hørlück Berg
20be990fd9 Port builtins/string to Rust
- Add test to verify piped string replace exit code

Ensure fields parsing error messages are the same.

Note: C++ relied upon the value of the parsed value even when `errno` was set,
that is defined behaviour we should not rely on, and cannot easilt be replicated from Rust.
Therefore the Rust version will change the following error behaviour from:

```shell
> string split --fields=a "" abc
string split: Invalid fields value 'a'
> string split --fields=1a "" abc
string split: 1a: invalid integer
```

To:

```shell
> string split --fields=a "" abc
string split: a: invalid integer
> string split --fields=1a "" abc
string split: 1a: invalid integer
```
2023-07-27 22:00:03 -07:00
ridiculousfish
a672edc0d5 Adopt the new function store and rewrite builtin_function
This adopts the new function store, replacing the C++ version.

It also reimplements builtin_function in Rust, as these was too coupled to
the function store to handle in a separate commit.
2023-07-23 17:18:36 -07:00
David Adam
289fbecaa9 Rewrite cd builtin in Rust
Note this is slightly incomplete - the FD is not moved into the parser, and so
will be freed at the end of each directory change. The FD saved in the parser is
never actually used in existing code, so this doesn't break anything, but will
need to be corrected once the parser is ported.
2023-07-10 21:30:37 +08:00
Henrik Hørlück Berg
cee2b7c4a2 Remove C++ code 2023-07-01 15:33:01 -07:00
Henrik Hørlück Berg
292f7b2be1 Port builtins/argparse to Rust 2023-06-19 13:45:54 -07:00