Commit graph

211 commits

Author SHA1 Message Date
Fabian Boehm
5e0f5eff37 Remove wcsdup fallback
2a0e0d6721 removed the last use of it,
and in most cases we'd probably prefer to use a wcstring instead
2022-08-27 11:36:15 +02:00
ridiculousfish
deec78cdd3 cmake: Unset GIT_WORK_TREE and GIT_DIR before FetchContent_Populate
GIT_WORK_TREE is an environment variable which tells git where the
worktree is. It may be set by the user or by git itself, e.g. when
running `git rebase -i --exec ...`. If it is set, it overrides the
working directory, causing the `git checkout` from FetchContent_Populate
to fail. Clear this variable.

Do the same for GIT_DIR for the same reason.

A way to reproduce the failure that this commit fixes is:

    git rebase -i HEAD^^^ --exec 'ninja -C /path/to/build/dir fish'

prior to this commit, using the fetched PCRE2, this would fail in CMake.
2022-08-06 13:07:22 -07:00
Fabian Boehm
e04785604a Make static_assert C++11 compatible
static_assert without a message is C++17. Which we can't use 5 years later.
2022-07-24 16:53:53 +02:00
Fabian Boehm
bcd84c6908 Check for waitstatus orientation via cmake
Yeah we need the long way around because old glibc versions have weird WEXITSTATUS.
2022-07-24 16:40:33 +02:00
Aaron Gyes
dbb4e05254 Revert "PCRE2.cmake: update minimum system PCRE2 version, use GIT_SHALLOW"
This was in response to a feature we were using that required a
very new PCRE2: that was backed out.

So this reverts commit e63af7d006.
2022-07-10 12:44:35 -07:00
Aaron Gyes
e63af7d006 PCRE2.cmake: update minimum system PCRE2 version, use GIT_SHALLOW
GIT_SHALLOW 1 here improves generation speed and _deps in the build
dir like is 6 or 7 MB less according to `du`.

Bump the minimum PCRE2 to 10.35 on account of we use
PCRE2_SUBSTITUTE_LITERAL.
2022-07-09 20:00:53 -07:00
ridiculousfish
5b1e106d87 cmake: Download and fetch PCRE2 rather than using vendored sources
This switches to using the CMake FetchContent path to dynamically download
and build PCRE2, allowing us to drop the vendored sources.

The FISH_USE_SYSTEM_PCRE2 CMake option is kept, but if false it now means
fetch-and-build PCRE2 rather than building vendored sources.

Note FetchContent was introduced in CMake 3.11. That is now a prerequisite
for building fish with FISH_USE_SYSTEM_PCRE2 disabled.
2022-07-02 18:46:58 -07:00
ridiculousfish
5beb3a1141 Mark FISH_FORCE_COLOR in individual test targets
This allows running individual tests to produce colorized output.
No need to relnote this.
2022-04-10 13:41:21 -07:00
Raymond Wong
9f98d2ec5d cmake: check for 8-bit atomic operation
Fix building on RISC-V.
Closes #8850.

Signed-off-by: Raymond Wong <infiwang@pm.me>
2022-04-03 10:20:51 -07:00
Raymond Wong
1f393c627b cmake: alter check for 64-bit atomic operation
Signed-off-by: Raymond Wong <infiwang@pm.me>
2022-04-03 10:20:51 -07:00
ridiculousfish
793aff3891 Use -fno-c++-static-destructors
Static destructors cause the destructor for a global object to run when
the program exits. They are bad because:

1. Registering them takes time and memory at startup

2. Running them takes time at shutdown and also they may have weird
   interactions.

This shaves about 12k off of the binary size.

Unfortunately gcc does not support this flag.
2022-04-02 13:45:01 -07:00
David Adam
970a963896 cmake: disable frameworks when searching for libintl
This is a less-intrusive version of 95845b1, and only disables the
search for frameworks for libintil (sometimes shipped with Mono, but not
usable for compilation).

Closes #5244.
2022-03-26 22:00:44 +08:00
David Adam
73cade558a Revert "cmake: disable use of frameworks on macOS"
This reverts commit 95845b16c9.
2022-03-26 21:49:44 +08:00
David Adam
95845b16c9 cmake: disable use of frameworks on macOS
Prevents an issue where libintl from Mono gets picked up.

Closes #5244.
2022-03-26 21:38:12 +08:00
Fabian Homborg
d751b00504 Remove getifaddrs check
Not used anymore
2022-03-17 18:15:11 +01:00
Fabian Homborg
03c188086c Remove wcsndup and wcslcpy
We no longer use these anywhere.
2022-03-17 18:15:11 +01:00
Mahmoud Al-Qudsi
372f03ba20 Fix sys/sysctl.h depreciation error under glibc 2.30+
glibc 2.30 and up emit an ugly depreciation warning on
`#include <sys/sysctl.h>` - this patch makes the build system fail the
include test for `sys/sysctl.h` by forcibly setting `-Werror` before the
call to `check_include_files` (which internally uses `try_compile`) to
get `HAVE_SYS_SYSCTL` to not be defined (even if it's there) if it would
cause such a depreciation message to be emitted.

Ideally, we would not have to manually massage `CMAKE_C_FLAGS` before
calling `check_include_files` and could just tweak that to either always
or conditionally try compilation with `-Werror`, but try_compile doesn't
actually use any overridden `CMAKE_C_FLAGS` values [0] (dating back to
2006).

[0]: https://cmake.org/pipermail/cmake/2006-October/011649.html
2022-01-20 11:04:40 -06:00
Aaron Gyes
401d302179 :Revert "Remove CheckIncludeFiles.cmake"
This reverts commit 398f3213d2.
2022-01-19 11:41:16 -08:00
Aaron Gyes
398f3213d2 Remove CheckIncludeFiles.cmake
We apparently vendored it for the sake of attempting to support
old cmake versions:
7aefaff298.
"This file can be dropped once the minimum version of CMake for fish is 3.11.0"

So, drop it like it's hot.
2022-01-19 11:38:41 -08:00
Johannes Altmanninger
c0d1e41313 docs synopsis: add HTML highlighing and automate manpage markup
Recent synopsis changes move from literal code blocks to
[RST line blocks].  This does not translate well to HTML: it's not
rendered in monospace, so aligment is lost.  Additionally, we don't
get syntax highlighting in HTML, which adds differences to our code
samples which are highlighted.

We hard-wrap synopsis lines (like code blocks). To align continuation
lines in manpages we need [backslashes in weird places]. Combined with
the **, *, and `` markup, it's a bit hard to get the alignment right.

Fix these by moving synopsis sources back to code blocks and compute
HTML syntax highlighting and manpage markup with a custom Sphinx
extension.

The new Pygments lexer can tokenize a synopsis and assign the various
highlighting roles, which closely matches fish's syntax highlighing:
- command/keyword (dark blue)
- parameter (light blue)
- operator like and/or/not/&&/|| (cyan)
- grammar metacharacter (black)

For manpage output, we don't project the fish syntax highlighting
but follow the markup convention in GNU's man(1):

	bold text          type exactly as shown.
	italic text        replace with appropriate argument.

To make it easy to separate these two automatically, formalize that
(italic) placeholders must be uppercase; while all lowercase text is
interpreted literally (so rendered bold).
This makes manpages more consistent, see string-join(1) and and(1).

Implementation notes:
Since we want manpage formatting but Sphinx's Pygments highlighing
plugin does not support manpage output, add our custom "synopsis"
directive.  This directive parses differently when manpage output is
specified. This means that the HTML and manpage build processes must
not share a cache, because the parsed doctrees are cached.  Work around
this by using separate cache locations for build targets "sphinx-docs"
(which creates HTML) and "sphinx-manpages".  A better solution would
be to only override Sphinx's ManualPageBuilder but that would take a
bit more code (ideally we could override ManualPageWriter but Sphinx
4.3.2 doesn't really support that).

---

Alternative solution: stick with line blocks but use roles like
:command: or :option: (or custom ones). While this would make it
possible to produce HTML that is consistent with code blocks (by adding
a bit of CSS), the source would look uglier and is harder to maintain.
(Let's say we want to add custom formatting to the [|] metacharacters
in HTML.  This is much easier with the proposed patch.)

---

[RST line blocks]: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#line-blocks
[backslashes in weird places]: https://github.com/fish-shell/fish-shell/pull/8626#discussion_r782837750
2022-01-19 22:56:41 +08:00
Aaron Gyes
1552c526ba Revert "Update Mac.cmake"
This reverts commit 01919f1785.
2022-01-03 08:08:41 -08:00
ridiculousfish
fecc022030 Rename the top-level test target to fish_run_tests
This keeps 'test' as an alias target. The reason is for compatibility
with CMake 3.10  and earlier, where one cannot make a target named
'test'.
2021-11-26 13:13:42 -08:00
Aaron Gyes
eb990c07c8 Let's make src/ easier to grok, move builins to src/builtins
+ No functional change here, just renames and #include changes.
+ CMake can't have slashes in the target names. I'm suspciious of
  that weird machinery for test, but I made it work.
+ A couple of builtins did not include their own headers, that
  is no longer the case.
2021-11-09 17:39:10 -08:00
Aaron Gyes
901dbd71b0 fix build when path has spaces in it.
Now it works.
2021-10-22 02:27:19 -07:00
Fabian Homborg
eba5352576 Also remove the languages from cmake
I'm not sure why this list is hardcoded?
2021-10-18 18:39:07 +02:00
Fabian Homborg
5e3c40207d cmake: Pass the source directory to the tests
Our tests typically run in their own environment, which is great for
normal tests.

However for the coming translation test, we don't want to copy the .po
files into the test environment, so it's nice to have a way out.
2021-10-18 17:02:17 +02:00
Aaron Gyes
87b2c2fdec install the fish.png file itself 2021-10-17 09:20:06 -07:00
Aaron Gyes
5accc67f1a don't install .desktop file and icon on macOS 2021-10-16 14:20:47 -07:00
ridiculousfish
d6d0723e0d cmake: Disable -Wunused-macros for bundled PCRE2
This is a noisy warning when building PCRE2
2021-10-16 13:50:33 -07:00
Fabian Homborg
8dc3982408
Always use LC_NUMERIC=C internally (#8204)
In most cases, like math, we want C-semantics for floating point
numbers. In particular "." needs to be the decimal separator.

Instead, we pay the price in printf, which is currently the sole place
to output in locale-specific numbers and attempt to read them and
C-style ones.
2021-10-13 21:09:40 +02:00
Aaron Gyes
01919f1785 Update Mac.cmake 2021-10-06 19:42:25 -07:00
Aaron Gyes
6fde56ff2d Mac.cmake: set deployment target to 10.10 per new min requirement 2021-10-06 16:51:11 -07:00
Aaron Gyes
f9def20180 Update ConfigureChecks, only do the mtime hack for Linux.. on Linux
- Only check for HAVE_CLOCK_GETTIME and HAVE_FUTIMENS on Linux, since
they are only used to implement a Linux-specific workaround related
to mtime precision.
- Make sure that hack is limited to Linux builds
- HAVE_SYS_SYSCTL_H was unused, but we should have been using it
- HAVE_TERMIOS_H was unused, remove it

The only functional change is that unix machines with clock_gettime
and futimens will not bother with a Linux-specific hack, and won't
waste time checking for either during cmake configuration either.
2021-10-02 17:02:53 -07:00
Aaron Gyes
3fd2da951e remove unused futimes check 2021-09-28 22:02:14 -07:00
ridiculousfish
ecaf455277 sphinx-build to use multiple processes
sphinx-build supports the -j option to use multiple processes. Start using
it. This reduces the time to build the docs on my Linux box from 11 seconds
to about 4.

Note this doesn't work on macOS since -j is ignored there (see sphinx-build
PR 6879).
2021-09-25 12:17:46 -07:00
Fabian Homborg
82a809e2db Check for tputs type via cmake
Instead of testing for ncurses and netbsd.

Fixes #8087.
2021-09-23 10:41:54 +02:00
ridiculousfish
0a277bf8c3 cmake: Group test targets into tests folder in IDEs
This simplifies fish project as shown in IDEs. No change to command line
build systems.
2021-09-20 12:53:12 -07:00
ridiculousfish
dc3e5a233b Generate Xcode schemes in CMake
This makes Xcode a little more pleasant, since we suppress generating a
bunch of schemes for tests.
2021-09-18 22:09:31 -07:00
Mahmoud Al-Qudsi
e0476cf219 Hack around CMake < 3.9 reporting skipped tests as failed 2021-09-07 12:04:05 -05:00
Mahmoud Al-Qudsi
9151acc498 Split test_driver.sh into test_env.sh + test_driver.sh
This lets us run non-fish targets (such as `fish_tests`) under a clean
test environment without running into the fish-specific payload
configuration now carried out by `test_driver.sh` which expects a
`.fish` payload that it will run under a deterministically configured
instance of fish, running in an environment initialized by
`test_env.sh`.

This should fix the problem with in-tree builds leaving detritus behind
after a `make test` when `fish_tests` would be executed without
`test_driver.sh` - it is now executed under `test_env.sh` instead.
2021-09-07 11:33:56 -05:00
Fabian Homborg
4c98757f85 Stop tests from creating a share/functions/functions link 2021-09-02 17:27:10 +02:00
Fabian Homborg
23e6698dc8 cmake: Force color in the tests
For littlecheck/pexpect this just unconditionally enables color.

I have no idea what happens if you run cmake outside of a terminal
, but the worst that can happen is that *errors* have color
escapes in them.

If someone figures out how to get cmake to tell us if it's running in
a terminal, we can add a check.
2021-08-30 17:16:19 +02:00
Fabian Homborg
0bcf5ac88d cmake: Use progress output for tests
This means instead of printing at least two lines per successful test,
we overwrite one line again and again with the current status, and
for *failed* (i.e interesting) tests we print the output.

Makes test failures much more visible.
2021-08-29 23:04:11 +02:00
Mahmoud Al-Qudsi
6fc8038b4e Prefix all ninja/cmake test target names with test_
`test:foo` is not allowed by CMake ("reserved name") and `test/foo`
won't work since CMake doesn't allow targets to have a directory
separator in their name.
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
1f4d16cb07 Add support for bubbling up skipped tests to cmake
This prevents tests that were skipped (e.g. because of a missing
REQUIRES) from being reported as successes in the CTest overall run
results list.
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
1fd92f493a Try disabling CMP00037 regardless of CMake version 2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
2962fbcf7a Add pexpect tests to new test driver 2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
aaac759d9a Make test a custom target again and add top-level test targets
Even though we are using CMake's ctest for testing, we still define our
own `make test` target rather than use its default for many reasons:

 * CMake doesn't run tests in-proc or even add each tests as an
   individual node in the ninja dependency tree, instead it just bundles
   all tests into a target called `test` that always just shells out to
   `ctest`, so there are no build-related benefits to not doing that
   ourselves.
 * CMake devs insist that it is appropriate for `make test` to never
   depend on `make all`, i.e. running `make test` does not require any
   of the binaries to be built before testing.
 * The only way to have a test depend on a binary is to add a fake test
   with a name like "build_fish" that executes CMake recursively to
   build the `fish` target.
 * It is not possible to set top-level CTest options/settings such as
   CTEST_PARALLEL_LEVEL from within the CMake configuration file.
 * Circling back to the point about individual tests not being actual
   Makefile targets, CMake does not offer any way to execute a named
   test via the `make`/`ninja`/whatever interface; the only way to
   manually invoke test `foo` is to to manually run `ctest` and specify
   a regex matching `foo` as an argument, e.g. `ctest -R ^foo$`... which
   is really crazy.

With this patch, it is now possible to execute any single test by name,
by invoking the build directly, e.g. to run the `universal.fish` check:
`cmake --build build --target universal.fish` or
`ninja -C build universal.fish`. Unfortunately, this is not integrated
into the Makefile wrapper, so `make universal.fish` won't work (although
this can potentially be hacked around).
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
26092456d4 Add CMake enumeration of low-level fish_tests.cpp tests
Instead of compiling `fish_tests.cpp` dynamically with weakly-linked
symbols and asking it to print the list of all available tests, we
use a magic string `#define`'d as a no-op to allow CMake to regex search
for matching test groups. This speeds up configuration somewhat (by not
compiling anything), but more importantly, it's much less brittle and
doesn't involve and linker dark magic.

There's of course still no getting around the fact that it's really ugly.
2021-08-29 08:56:12 +02:00
Mahmoud Al-Qudsi
7bcf527f84 Remove cmake test_prep target
This is now carried out more cleanly and more correctly by
test_driver.sh
2021-08-29 08:56:12 +02:00