Commit graph

49 commits

Author SHA1 Message Date
Fabian Boehm
10ac98e2ea installable: Only panic without sphinx if FISH_BUILD_DOCS=1
It's pretty annoying that this panics without sphinx, because the
install itself would be *working*.

So instead we tell the user that they need to clean or set
$FISH_BUILD_DOCS if they want to try again.
2024-12-15 09:00:16 +01:00
Johannes Altmanninger
0a145cff3c Fix clippy lints 2024-12-14 09:31:20 +01:00
Fabian Boehm
6c852655dd Disable man page building in clippy
This would otherwise break any clippy run if you didn't have sphinx installed.
2024-12-11 16:56:14 +01:00
Fabian Boehm
0e0d56d805 format 2024-12-11 16:51:25 +01:00
Fabian Boehm
2d2f18c159 installable builds: Fail when building man pages fails
This is unfortunately necessary, because otherwise it would not rerun
the build script just because you installed sphinx.

Because we use the man pages for --help output, they're pretty
necessary.

To override it, you can set $FISH_BUILD_DOCS=0, like

```fish
FISH_BUILD_DOCS=0 cargo install --path .
```
2024-12-11 16:49:49 +01:00
Fabian Boehm
0083192fcb Read git SHA ourselves if it is unavailable
`git describe` *may* fail e.g. for `sudo make install`,
so we just read the SHA ourselves.
2024-12-09 16:57:47 +01:00
Fabian Boehm
56a1403350 Revert "Enable gettext without the _nl_msg_cat_cntr gnuism"
This built on my test system, might be version differences.

(it's also not enough to make it *work*, but a necessary step)

This reverts commit 6fded249cd.
2024-12-08 22:04:59 +01:00
Fabian Boehm
6fded249cd Enable gettext without the _nl_msg_cat_cntr gnuism
This should allow e.g. musl to be translated.
2024-12-08 21:53:20 +01:00
Fabian Boehm
1599293796 Build man pages into installable fish
This calls sphinx-build from build.rs to include the man pages in the binary.

We don't abort if sphinx doesn't exist, but we do if it failed.
2024-12-06 22:12:26 +01:00
Fabian Boehm
2343a6b1f1 docs: Read version from the version file
Makes it possible to generate the man pages without fish_indent
available.

(not the html docs because they highlight via fish_indent!)
2024-12-06 22:12:26 +01:00
Fabian Boehm
7c73c5fec0 Make fish installable
When built with the default "installable" feature, the data files (share/) are
included in the fish binary itself.

Run `fish --install` or `fish --install=noconfirm` (for
non-interactive use) to install fish's data files into ~/.local/share/fish/install

To figure out if the data files are out of date, we write the current version
to a file on install, and read it on start.

CMake disables the default features so nothing changes for that, but this allows installing via `cargo install`,
and even making a static binary that you can then just upload and have extract itself.

We set $__fish_help_dir to empty for installable builds, because we do not have
a way to generate html docs (because we need fish_indent for highlighting).
The man pages are found via $__fish_data_dir/man
2024-12-06 22:12:26 +01:00
Fabian Boehm
5abd0e46f5 build.rs: Panic if version could not be found
We don't want "fish --version" to print "unknown" or any other fake version
2024-12-06 22:12:26 +01:00
Fabian Boehm
0dfc490721 build.rs: Use Cargo_PKG_VERSION if no version could be found
`cargo build --git` clones a git repo without any tags, so you get a
version like

```
fish, version f3fc743fc
```

which is *just* the commit hash and missing the "3.7.1-NUM-g" part.

So, if we hit that case (detected because it has no ".", under the
assumption that we'll never make a version that's just "4" instead of
"4.0"), we prepend the version from Cargo.toml.
2024-10-15 13:10:07 +02:00
Fabian Boehm
848921a391 build: Forbid linking glibc statically again
Static linking against glibc has crashes depending on the name
resolution setup (I think when it needs to dlopen). It is a fundamental glibc
limitation that we cannot fix on our end.

It will crash when doing `echo ~<TAB>`.

This carves out a specific exception for "gnu", i.e. glibc, targets.

Other targets, including musl and other operating systems, continue to
allow static linking.
2024-08-30 18:35:31 +02:00
Fabian Boehm
980ef6f2f1 Extend small stack workaround to netbsd 2024-08-15 18:32:25 +02:00
Fabian Boehm
2965603e7f Work around eventfd on NetBSD
Revisit if libc gains support
2024-08-15 17:38:02 +02:00
Johannes Altmanninger
f033bccd3c Move fish build dir canonicalization into build.rs, to lower CMake version 2024-08-05 10:41:17 +02:00
Mahmoud Al-Qudsi
b495cffa50 fixup! Add workaround for targets with too small a main stack size 2024-05-30 12:25:06 -05:00
Mahmoud Al-Qudsi
57f558578b Add workaround for targets with too small a main stack size
pthread_get_stacksize_np() is buggy on legacy OS X; make sure you are building
fish with a rust toolchain that correctly patches these functions.

See https://github.com/macports/macports-legacy-support/pull/86
2024-05-30 12:14:37 -05:00
Mahmoud Al-Qudsi
d07d0170ad build.rs: also declare cfgs when we run into a warning
e.g. gettext is found but can't be used
2024-05-21 13:34:24 -05:00
Fabian Boehm
e5d5e00969 Fix missing rename in build.rs 2024-05-13 20:04:08 +02:00
Mahmoud Al-Qudsi
ab68cf1eda Update build.rs formatting a bit 2024-05-13 11:34:07 -05:00
Mahmoud Al-Qudsi
a7bde3921b build.rs: Use rsconf::declare_dependency()
This new feature in rsconf 0.2.0 resolves the compile-time warnings we get under
rustc 1.80+ about unrecognized cfg names by informing cargo of all valid cfg
names/values even when the cfg in question isn't enabled.
2024-05-09 14:22:27 -05:00
Mahmoud Al-Qudsi
2faf1159fa Upgrade to rsconf 0.2.0 2024-05-09 14:20:57 -05:00
Mahmoud Al-Qudsi
2d4e42ee93 Don't use a hardcoded ./build/ path for FISH_BUILD_DIR
We use this fallback value for FISH_BUILD_DIR when `cargo` is not
invoked from `cmake`, but we already have a cargo-defined build
directory and we shouldn't just decide to use $TARGET_MANIFEST_DIR/build
instead.

Tests pass locally!
2024-05-06 19:50:49 -05:00
David Adam
3a98db46bc
build.rs: pick up version file for tarballs from source, not build, directory (#10400) 2024-03-31 00:43:55 -05:00
Fabian Boehm
2a4e776d92 Reimplement git version generation ourselves
This allows us to remove two dependency crates
2024-03-02 10:05:37 +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
Mahmoud Al-Qudsi
cf3d3f6497 Fix incremental compilation of src/libc.c with cargo
src/libc.c changes were not being picked up.
2024-02-01 13:51:04 -06:00
Fabian Boehm
1deb065f59 build.rs: canonicalize CARGO_MANIFEST_DIR
We use this so you can run fish from the build directory and it picks
up its data files.

If this wasn't canonicalized, that would break if you're building with
a $PWD through a symlink.
2024-01-27 20:00:10 +01:00
ridiculousfish
ce19f82c19 Fix some clippy warnings 2024-01-21 19:12:33 -08:00
Mahmoud Al-Qudsi
15a82b462f Remove unnecessary copies in build.rs 2024-01-21 17:20:38 -06:00
Johannes Altmanninger
38397734e2 Fix build on OpenSUSE Tumbleweed
Fix a search & replace gone wrong in 1234c77b1 (Support linking against
reentrant-configured curses, 2024-01-21).
2024-01-21 22:22:30 +01:00
Johannes Altmanninger
1234c77b15 Support linking against reentrant-configured curses
NCurses headers contain this conditional "#define cur_term":

	print  "#elif @cf_cv_enable_reentrant@"
	print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
	print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
	print  "#else"

OpenSUSE Tumbleweed uses this configuration option; For reentrancy, cur_term
is a function.  If the NCurses autoconf variable @NCURSES_WRAP_PREFIX@
is not changed from its default, the function is called _nc_cur_term.

I'm not sure if we have a need to support non-default @NCURSES_WRAP_PREFIX@
but if we do there are various ways;
- search for the symbol with the cur_term suffix
- figure out the prefix based on the local curses installation,
  for example by looking at the header files.

Fixes #10243
2024-01-21 11:26:07 +01:00
Johannes Altmanninger
c52c03b03c Fix clippy warnings 2024-01-20 11:30:13 +01:00
Mahmoud Al-Qudsi
2f30d8f949 Stop caching CURSES_LIBRARY_LIST
Just treat it as if we are building without cmake when it's not present.
2024-01-20 08:56:29 +01:00
Mahmoud Al-Qudsi
66a4beadce Simplify a few things in build.rs 2024-01-20 08:56:29 +01:00
Fabian Boehm
f0af165348 build.rs: Try ncurses if curses couldn't be found
That's gonna be the typical one
2024-01-20 08:56:29 +01:00
Fabian Boehm
a5e35abeba build.rs: Default variables
So we can build without cmake
2024-01-20 08:56:29 +01:00
Johannes Altmanninger
2ffec7463e build.rs: fix formatting 2024-01-19 09:18:02 +01:00
Mahmoud Al-Qudsi
21b4a2e5d6 Simplify rsconf has_symbol() libc lookups 2024-01-18 18:22:07 -06:00
Mahmoud Al-Qudsi
a1147c7c4f Fix outdated build.rs comments 2024-01-18 18:10:47 -06:00
Johannes Altmanninger
10891d2985 build.rs: remove dead code 2024-01-14 13:20:52 +01:00
Mahmoud Al-Qudsi
5233370cda Fix build.rs formatting 2024-01-13 16:04:05 -06:00
Mahmoud Al-Qudsi
33f33c5f41 Simplify (and fix?) build.rs HAVE_XXX detection
Since none of the compiles(xxx) calls are to particularly complex code, we can
just use `rsconf` directly to test for the presence of the symbols or headers as
needed.

Note that it seems at least some of the previous detection was not working
correctly; in particular HAVE_PIPE2 was evaluating to false on my WSL install
where pipe2(2) was available (caught because it revealed some compilation errors
in that conditional compilation path after porting).

I kept the cfg names and the tests themselves mostly as-is, though we might want
to change that to conform with the rust convention of lowercase cfg names and
decide whether we want to prefix all these with have_, fish_, or nothing at all.
Also the posix_spawn() test should probably check for the symbol `posix_spawn()`
rather than the header `spawn.h` since we don't use it via the header but rather
via the symbol (but in reality they're almost certainly going to give the same
result).
2024-01-13 15:45:42 -06:00
Mahmoud Al-Qudsi
6e002b6d80 Use cfg directly instead of going through features
Features should be for user-specifiable build configurations but our dynamic,
target-based conditional compilation is something else.
2024-01-13 15:16:47 -06:00
Mahmoud Al-Qudsi
4f8265db47 Inline the localconv_l test
It's just one line.
2024-01-13 14:58:58 -06:00
Mahmoud Al-Qudsi
30f70f02de Feature-detect localeconv_l() presence 2024-01-13 14:21:14 -06:00
Johannes Altmanninger
3ae20bdba0 Move fish-rust to project root 2024-01-13 03:58:33 +01:00
Renamed from fish-rust/build.rs (Browse further)