Commit Graph

170 Commits

Author SHA1 Message Date
Xiretza
a16e2ecb1b Port echo builtin to Rust 2023-02-07 22:25:47 +01:00
Johannes Altmanninger
83fd7ea7c4 Port future_feature_flags.cpp to Rust
This is early work but I guess there's no harm in pushing it?
Some thoughts on the conventions:

Types that live only inside Rust follow Rust naming convention
("FeatureMetadata").

Types that live on both sides of the language boundary follow the existing
naming ("feature_flag_t").
The alternative is to define a type alias ("using feature_flag_t =
rust::FeatureFlag") but that doesn't seem to be supported in "[cxx::bridge]"
blocks. We could put it in a header ("future_feature_flags.h").

"feature_metadata_t" is a variant of "FeatureMetadata" that can cross
the language boundary. This has the advantage that we can avoid tainting
"FeatureMetadata" with "CxxString" and such. This is an experimental approach,
probably not what we should do in general.
2023-02-03 18:55:06 +01:00
Johannes Altmanninger
517d53dc46 Port util.cpp to Rust
The original implementation without the test took me 3 hours (first time
seriously looking into this)

The functions take "wcharz_t" for smooth integration with existing C++ callers.
This is at the expense of Rust callers, which would prefer "&wstr".  Would be
nice to declare a function parameter that accepts both but I don't think
that really works since "wcharz_t" drops the lifetime annotation.
2023-02-03 18:55:06 +01:00
ridiculousfish
76adfed0e7 Implement builtin_wait in Rust
This implements builtin_wait in Rust.
2023-02-02 19:34:48 -07:00
ridiculousfish
d843b67d2d Initial Rust commit 2023-02-02 19:34:47 -07:00
ridiculousfish
1402bae7f4 Re-implement abbreviations as a built-in
Prior to this change, abbreviations were stored as fish variables, often
universal. However we intend to add additional features to abbreviations
which would be very awkward to shoe-horn into variables.

Re-implement abbreviations using a builtin, managing them internally.

Existing abbreviations stored in universal variables are still imported,
for compatibility. However new abbreviations will need to be added to a
function. A follow-up commit will add it.

Now that abbr is a built-in, remove the abbr function; but leave the
abbr.fish file so that stale files from past installs do not override
the abbr builtin.
2022-12-10 15:29:03 -08:00
ridiculousfish
ceafb65882 Compile with large-file support (LFS)
This adds preprocessor defines for _LARGEFILE_SOURCE and
_FILE_OFFSET_BITS=64 and a few others, fixing a bug that was reported on
gitter. This prevents issues when running fish on 32 bit systems that
have filesystems with 64 bit inodes.
2022-09-20 22:51:44 -07:00
ridiculousfish
2a0e0d6721 Remove the intern'd strings component
Intern'd strings were intended to be "shared" to reduce memory usage but
this optimization doesn't carry its weight. Remove it. No functional
change expected.
2022-08-13 12:51:36 -07:00
ridiculousfish
7ae1727359 Factor out PCRE2 into new re component
This migrates our PCRE2 dependency from builtin/string.cpp to new files
re.h/re.cpp, allowing regexes to be used in other places in fish.

No user-visible behavior change expected here.
2022-07-09 16:37:20 -07:00
Fabian Homborg
17a8dd8f62 Move path to src/builtins 2022-05-29 17:48:11 +02:00
Fabian Homborg
f6fb347d98 Add "path" builtin
This adds a "path" builtin that can handle paths.

Implemented so far:

- "path filter PATHS", filters paths according to existence and optionally type and permissions
- "path base" and "path dir", run basename and dirname, respectively
- "path extension PATHS", prints the extension, if any
- "path strip-extension", prints the path without the extension
- "path normalize PATHS", normalizes paths - removing "/./" components
- and such.
- "path real", does realpath - i.e. normalizing *and* link resolution.

Some of these - base, dir, {strip-,}extension and normalize operate on the paths only as strings, so they handle nonexistent paths. filter and real ignore any nonexistent paths.

All output is split explicitly, so paths with newlines in them are
handled correctly. Alternatively, all subcommands have a "--null-input"/"-z" and "--null-output"/"-Z" option to handle null-terminated input and create null-terminated output. So

    find . -print0 | path base -z

prints the basename of all files in the current directory,
recursively.

With "-Z" it also prints it null-separated.

(if stdout is going to a command substitution, we probably want to
skip this)

All subcommands also have a "-q"/"--quiet" flag that tells them to skip output. They return true "when something happened". For match/filter that's when a file passed, for "base"/"dir"/"extension"/"strip-extension" that's when something about the path *changed*.

Filtering
---------

`filter` supports all the file*types* `test` has - "dir", "file", "link", "block"..., as well as the permissions - "read", "write", "exec" and things like "suid".

It is missing the tty check and the check for the file being non-empty. The former is best done via `isatty`, the latter I don't think I've ever seen used.

There currently is no way to only get "real" files, i.e. ignore links pointing to files.

Examples
--------

> path real /bin///sh
/usr/bin/bash

> path extension foo.mp4
mp4

> path extension ~/.config
  (nothing, because ".config" isn't an extension.)
2022-05-29 17:48:11 +02:00
Aaron Gyes
ce475c0b4c more int -> bool
all the things
2021-12-09 00:52:45 -08:00
ridiculousfish
c78b7b07e7 cmake: move builtins to their own list
This separates the list of builtin sources from the list of other
sources, since it seems like a natural cleavage point. The library
structure is unchanged, it's all just one big fishlib.a.
2021-11-19 19:12:29 -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
54369ba61b use add_compile_options() instead of manipulating CMAKE_CXX_FLAGS 2021-10-01 09:10:32 -07:00
Aaron Gyes
39bdabcd29 Don't add these warnings on GCC. 2021-10-01 05:09:04 -07:00
Aaron Gyes
d0f697be64 Update CMakeLists.txt
Revert the change getting rid of the -UNDEBUG, add some unused-blah
warnings.

We are often using the system assert() because we include other
headers that include assert.h.

I noticed that assert() was being compiled out because I started
getting new warnings printed about unusued variables (that were only
used in the assert()s. Add these warnings to the build.
2021-10-01 04:46:32 -07:00
Aaron Gyes
97bb53e32d Add likely() and unlikely() for our assertions
Allows the compiler to know our bespoke assert functions
are cold paths. This would normally occur somehow for real assert().
Assembly does appear it will save some branches.

Also don't worry about NDEBUG

(This doesn't matter because we rolled our own assert functions.
Thanks @zanchey.)
2021-09-28 23:39:54 -07:00
Aaron Gyes
0b3d3de9bf Just add -UNDEBUG to disable NDEBUG. 2021-09-28 22:02:14 -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
Fabian Homborg
07457bf2f1 cmake: Remove linker override
This was a workaround for an error that has been removed in glibc
2.32 (by removing sys_errlist and friends, which it complained about).

Other than that, it's an attempt at performance optimization that
should just be fixed at the system level - if your linker is bad,
replace it with a better linker. No need for fish to work around it.

Closes #8152
2021-07-20 17:20:14 +02:00
David Adam
210dda2c4c CMake: bump minimum requirement to 3.5
CMake 3.5.0 was released in March 2016.
2021-06-28 23:56:02 +08:00
ridiculousfish
82fd8fe9fb Refactor wait handles
In preparation for using wait handles in --on-process-exit events, factor
wait handles into their own wait handle store. Also switch them to
per-process instead of per-job, which is a simplification.
2021-05-17 15:25:21 -07:00
Fabian Homborg
981a07d4c7 cmake: Error out with "-static"
I'm not entirely sure this *has* to be given via
CMAKE_EXE_LINKER_FLAGS, but this would have stopped at least one
person from trying.

Static linking 1. does not work at the moment, 2. is not *useful*. You
don't get a single-file fish you can just copy somewhere because
you're missing our functions. On glibc systems you also can't
statically link glibc. Given all that, it does not appear to be worth
putting in any effort to make it work (if it's possible at all).

See #7947.
2021-04-25 09:38:04 +02:00
ridiculousfish
be9375e914 Migrate autoclose_fd_t to new file fds.h
fds.h will centralize logic around working with file descriptors. In
particular it will be the new home for logic around moving fds to high
unused values, replacing the "avoid conflicts" logic.
2021-02-05 17:58:08 -08:00
Fabian Homborg
04234a8c6d CMakeLists: Remove outdated comments 2021-01-29 19:05:40 +01:00
Fabian Homborg
005d3a5981 Enable strict-aliasing and implicit-fallthrough warnings
GCC needs to have the comment *right before* the case label... blergh
2021-01-29 18:23:30 +01:00
ridiculousfish
d129ee00a1 Don't compile fish_test_helper with thread sanitizer
Certain TSan versions will modify the blocked signal mask on startup, which
breaks fish's test that it correctly blocks certain signals on nohup.
2020-11-23 19:38:03 -08:00
Mahmoud Al-Qudsi
36ed66beda [cmake] Use lld as a first preference
Like Gold, it doesn't warn about sys_nerr, _sys_errlist, and co.
Unlike Gold, we can use this on all platforms. It's also faster than
both Gold and plain, old ld.
2020-10-26 18:17:53 -05:00
Fabian Homborg
ef9c924960 Make type a builtin
This is too important to not be one.

For one if it couldn't be loaded for any reason it would
break a lot of fish scripts.

Also this is faster by ~20x.

Fixes #7342
2020-09-21 20:58:34 +02:00
Ryan Burns
ca4f2369d1 Fix build when ncurses is in nonstandard prefix 2020-07-25 11:21:36 -07:00
ridiculousfish
54b642bc6f Factor job groups into their own file
Migrate out of proc.h, which has become too long.
2020-07-19 16:42:29 -07:00
ridiculousfish
4840d115b6 Sort the source files in CMakeLists 2020-07-19 16:07:01 -07:00
Mahmoud Al-Qudsi
fe2da0a94f Put -Wno-redundant-move behind a compiler check
This fixes a warning under Ubuntu 18.04's default gcc
(cc++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0)
2020-07-04 21:14:43 -05:00
ridiculousfish
0c22f67bde Remove the old parser bits
Now that everything has been migrated to the new AST, remove as much of
the parse_tree bits as possible
2020-07-04 14:58:05 -07:00
ridiculousfish
4d4455007d Introduce a new fish ast
This is the first commit of a series intended to replace the existing
"parse tree" machinery. It adds a new abstract syntax tree and uses a more
normal recursive descent parser.

Initially there are no users of the new ast. The following commits will
replace parse_tree -> ast for all usages.
2020-07-04 14:58:02 -07:00
ridiculousfish
340c8490f6 Introduce termsize_container_t
fish's handling of terminal sizes is currently rather twisted. The
essential problem is that the terminal size may change at any point from a
SIGWINCH, and common_get_{width,height} may modify it and post variable
change events from arbitrary locations.

Tighten up the semantics. Assign responsibility for managing the tty size
to a new class, `termsize_container_t`. Rationalize locking and reentrancy.

Explicitly nail down the relationship between $COLUMNS/$LINES and the tty
size. The new semantics are: whatever changed most recently takes
precendence.
2020-06-07 20:00:42 -07:00
Lior Stern
d7aeac3c61 Add clang-tidy to build_tools/lint.fish 2020-04-04 14:47:58 -07:00
ridiculousfish
f117addf7c Use lowercase CMake function names
This is a best practice to distinguish them from variables.
2020-03-14 16:11:35 -07:00
ridiculousfish
24bd7e033e Move some Mac specific cmake bits into new Mac.cmake 2020-02-29 15:36:54 -08:00
ridiculousfish
6721bf4031 Add the get-task-allow entitlement
This allows Mac fish to be debugged.
2020-02-29 15:29:50 -08:00
ridiculousfish
fbb0f79992 Set the minimum Mac deployment version
Use 10.9, the first with libc++.
2020-02-18 12:55:11 -07:00
ridiculousfish
ba0c2d48d1 Teach CMake to code sign Mac executables
Perform an ad-hoc code signing with the hardened runtime.
This ensures that these executables can pass notarization.

The code signing ID is controlled by the MAC_CODESIGN_ID CMake
cache variable.
2020-02-18 12:55:11 -07:00
ridiculousfish
057c3a9e75 Introduce fd_monitor
fd_monitor is a new class which can monitor a set of fds, waiting for them
to become readable. When an fd becomes readable, a callback is invoked.
Timeouts are also supported.

This is intended to replace the "bufferfill" threads. Rather than one
thread per bufferfill, we will have a single fd_monitor which can service
multiple bufferfills. This helps today with nested command substitutions,
and will help in the future with concurrent execution.
2020-02-05 12:04:51 -08:00
ridiculousfish
0f7bba5f0e Introduce operation_context_t
This commit recognizes an existing pattern: many operations need some
combination of a set of variables, a way to detect cancellation, and
sometimes a parser. For example, tab completion needs a parser to execute
custom completions, the variable set, should cancel on SIGINT. Background
autosuggestions don't need a parser, but they do need the variables and
should cancel if the user types something new. Etc.

This introduces a new triple operation_context_t that wraps these concepts
up. This simplifies many method signatures and argument passing.
2020-01-16 15:21:28 -08:00
ridiculousfish
6705a2efc6 Migrate a bunch of code out of common.h
Put it into wcstringutil, path, or a new file null_terminated_array.
2020-01-15 13:16:43 -08:00
David Adam
74ab9e72ac cmake: pass C++ standard compiler options to tests
Enables CMake policy 0067.
2019-12-23 22:26:57 +08:00
David Adam
780bac671f cmake: add -latomic on platforms that need it for 64-bit atomic operations
Closes #5865.
2019-12-20 23:00:06 +08:00
Mahmoud Al-Qudsi
664d6fb132 Convert time to a job decorator 2019-12-19 23:02:23 -06:00
Mahmoud Al-Qudsi
5956270015 Add time builtin that understands fish script and external executables
This now works:

```fish
function foo
    for n in (seq 1 100000)
        test $n -eq 42
    end
end

time foo
```
2019-12-18 20:27:08 -06:00
ridiculousfish
2c81229ee6 Remove CMake's NDEBUG definition from release builds 2019-11-13 13:13:08 -08:00
Robin Linden
34e06c4440 Remove overrides of default CMake flags
CMake sets these flags to sane defaults depending on which compiler
you're using, so overriding them isn't very nice.

For example:

with g++, I get
-- Debug: -g
-- RelWithDebInfo: -O2 -g -DNDEBUG
-- MinSizeRel: -O2 -g -DNDEBUG
-- Release: -O3 -DNDEBUG

and with MSVC you get something like
-- Debug: /MDd /Zi /Ob0 /Od /RTC1
-- RelWithDebInfo: /MD /Zi /O2 /Ob1 /DNDEBUG
-- MinSizeRel: /MD /Zi /O2 /Ob1 /DNDEBUG
-- Release: /MD /O2 /Ob2 /DNDEBUG
2019-11-13 13:02:05 -08:00
ridiculousfish
a7f1d2c0c7 Add support for fish_trace variable to trace execution
This adds support for `fish_trace`, a new variable intended to serve the
same purpose as `set -x` as in bash. Setting this variable to anything
non-empty causes execution to be traced. In the future we may give more
specific meaning to the value of the variable.

The user's prompt is not traced unless you run it explicitly. Events are
also not traced because it is noisy; however autoloading is.

Fixes #3427
2019-11-02 14:40:57 -07:00
ridiculousfish
5f6ee7f30f Use the gold linker if available
The big reason to do this is that the gold linker doesn't complain about
_sys_nerr and _sys_errlist.
2019-09-14 15:09:08 -07:00
ridiculousfish
91987a4548 Migrate history file format stuff into new file history_file.cpp
Breaks up the history.cpp monolith.
2019-08-11 12:45:04 -07:00
Fabian Homborg
9cd29e5166 cmake: Add -Wno-redundant-mode
This warns about one bit in env_dispatch, where a comment explains
that the move *is* necessary, on a different libc++.
2019-06-24 22:11:49 +02:00
Fabian Homborg
a75155fd71 Disable strict-aliasing warning
This blows up the output on travis, so it's *worse than useless*.
2019-05-29 21:09:55 +02:00
Fabian Homborg
b574f3fb8f Turn off implicit fallthrough harder
On Travis:

>g++: error: unrecognized command line option ‘-Wimplicit-fallthrough=0’
2019-05-29 20:53:50 +02:00
Fabian Homborg
80afda08d5 cmake: Enable -Wall -Wextra
Not -Werror, just the warnings themselves.

Let's just see what happens. It's warning-free on my system.

Worst case we disable it again, better case we refine the set.
2019-05-29 20:50:35 +02:00
ridiculousfish
63a16befd4 Introduce the fish log, a replacement for debug()
This adds a new mechanism for logging, intended to replace debug().

The entry points are FLOG and FLOGF. FLOG can be used to log a sequence of
arguments, FLOGF is for printf-style formatted strings.

Each call to FLOG and FLOGF requires a category. If logging for a category
is not enabled, there is no effect (and arguments are not evaluated).

Categories may be enabled on the command line via the -d option.
2019-05-27 17:24:52 -07:00
Mahmoud Al-Qudsi
e0e0fe9dd3 Re-implement eval as a regular builtin
I did not realize builtins could safely call into the parser and inject
jobs during execution. This is much cleaner than hacking around the
required shape of a plain_statement.
2019-04-12 07:04:15 -05:00
ridiculousfish
c39950e49a Add benchmark target to CMake
This adds a benchmark target to CMake to run the new benchmarks.

example: ninja benchmark
2019-04-10 14:35:59 -07:00
ridiculousfish
93cc99d6d0 Teach CMake to tell Sphinx where fish_indent is 2019-04-08 19:11:10 -07:00
ridiculousfish
b7fceddfc8 Refactor some environment code into env_dispatch.cpp
This new file is supposed to encapsulate all of the logic around
reacting to variable changes, as opposed to the environment core.
This is to help break up the env.cpp monolith.
2019-04-08 16:22:04 -07:00
ridiculousfish
23d88e0e03 Add fish_test_helper executable
In tests we would like to arrange for an executable to invoke certain
system calls, e.g. to claim or relinquish control of the terminal. This is
annoying to do portably via e.g. perl. fish_test_helper is a little
program where we can add custom commands to make it act in certain ways.
2019-04-07 09:20:19 -07:00
Fabian Homborg
da1b32f0ad
Remove option to use system wcwidth (#5777)
As it turns out it didn't work much better, and it fell behind in
support when it comes to things that wcwidth traditionally can't
express like variation selectors and hangul combining characters, but
also simply $fish_*_width.

I've had to tell a few people now to rebuild with widecharwidth after
sending them on a fool's errand to set X variable.

So keeping this option is doing our users a disservice.
2019-04-01 15:59:33 +02:00
David Adam
f5f6e5307d cmake: add lint/lint-all targets 2019-02-28 22:03:57 +11:00
ridiculousfish
e234856190 Define _REENTRANT
This enables thread-safe errno on Solaris and its descendants.

Fixes #5611
2019-02-20 13:58:36 -08:00
ridiculousfish
177adb6837 Revert "Define _POSIX_C_SOURCE=200809L"
This reverts commit 334eec94f8.

This broke the Mac build
2019-02-20 13:28:46 -08:00
ridiculousfish
334eec94f8 Define _POSIX_C_SOURCE=200809L
This enables thread-safe errno on Solaris and its descendants.

Fixes #5611
2019-02-20 12:58:59 -08:00
Fabian Homborg
c242469e8b cmake: Keep rpath on NetBSD
Otherwise it'd fail to find pcre2 in the invocation tests.
2019-02-18 15:22:30 +01:00
ridiculousfish
fc9d238642 Introduce topic monitoring
topic_monitor allows for querying changes posted to one or more topics,
initially sigchld. This will eventually replace the waitpid logic in
process_mark_finished_children().

Comment from the new header:

Topic monitoring support. Topics are conceptually "a thing that can
happen." For example, delivery of a SIGINT, a child process exits, etc. It
is possible to post to a topic, which means that that thing happened.

Associated with each topic is a current generation, which is a 64 bit
value. When you query a topic, you get back a generation. If on the next
query the generation has increased, then it indicates someone posted to
the topic.

For example, if you are monitoring a child process, you can query the
sigchld topic. If it has increased since your last query, it is possible
that your child process has exited.

Topic postings may be coalesced. That is there may be two posts to a given
topic, yet the generation only increases by 1. The only guarantee is that
after a topic post, the current generation value is larger than any value
previously queried.

Tying this all together is the topic_monitor_t. This provides the current
topic generations, and also provides the ability to perform a blocking
wait for any topic to change in a particular topic set. This is the real
power of topics: you can wait for a sigchld signal OR a thread exit.
2019-02-17 13:01:59 -08:00
ridiculousfish
7f1dfb6284 Set CMAKE_ARCHIVE_OUTPUT_DIRECTORY
This allows Xcode archive builds to succeed.
2019-02-05 22:14:43 -08:00
ridiculousfish
e0396d8ef8 CMake support for building Mac app 2019-02-05 22:14:43 -08:00
ridiculousfish
dbe906b79e Introduce dup2_list_t
This represents a "resolved" io_chain_t, where all of the different io_data_t
types have been reduced to a sequence of dup2() and close(). This will
eliminate a lot of the logic duplication around posix_spawn vs fork, and pave
the way for in-process redirections.
2019-02-03 01:58:49 -08:00
ridiculousfish
6ba0d4c88a Revert io_bufferfill_t stack
This reverts commit 88dc484858 onwards.
2019-02-02 17:53:40 -08:00
ridiculousfish
88dc484858 Introduce dup2_list_t
This represents a "resolved" io_chain_t, where all of the different io_data_t
types have been reduced to a sequence of dup2() and close(). This will
eliminate a lot of the logic duplication around posix_spawn vs fork, and pave
the way for in-process redirections.
2019-02-02 14:21:46 -08:00
Mahmoud Al-Qudsi
d15de117b9 Resolve CMAKE_* directories before saving as build defines
Since fish began resolving symlinks it broke the running-from-build-dir
detection in fish.cpp if the build directory were a symlink (which is
common on some platforms where the default user HOME directory is a
symlink in the first place, e.g. FreeBSD).
2019-01-30 14:27:13 -06:00
Fabian Homborg
26dfca67e5 Fix cmake build
Screwed up a rebase there!
2018-12-30 19:34:45 +01:00
Aaron Gyes
99d56ea2f9 Colorful Ninja error output with Apple's clang
CMake detects the clang that comes with Xcode as AppleClang.
6.0 corresponds to upstream LLVM 3.5svn
2018-12-11 03:53:12 -08:00
Fabian Homborg
47c1144a3c cmake: Enable colors with ninja
Unfortunately this needs a bit of a hack, as the compiler uses isatty(),
and ninja uses a pipe.
2018-11-02 12:26:27 +01:00
Fabian Homborg
a04a37897f cmake: Use tinyexpr as yet another ordinary file
Not a library.
2018-10-22 21:15:05 +02:00
Mahmoud Al-Qudsi
6bc59db721 Detect when running out of cmake build directory
Load fish docs and configuration out of the source and/or build
directories rather from the installed paths when running directly out
of the cmake build directory.

Closes #5255.
2018-10-13 21:48:28 -05:00
Mahmoud Al-Qudsi
1ab9fe663f [cmake] Add flags for different build types and set default value
Default to RelWithDebInfo (-O2 -g) if no custom CMAKE_BUILD_TYPE is
defined. Also add flags for use with CMAKE_BUILD_TYPEs Debug, Release,
and RelWithDebInfo.
2018-06-18 00:34:31 -05:00
ridiculousfish
14f766b66d Add support for feature flags
This introduces a new type features_t that exposes feature flags. The intent
is to allow a deprecation/incremental adoption path. This is not a general
purpose configuration mechanism, but instead allows for compatibility during
the transition as features are added/removed.

Each feature has a user-presentable short name and a short description. Their
values are tracked in a struct features_t.

We start with one feature stderr_nocaret, but it's not hooked up yet.
2018-05-06 11:20:14 -07:00
Fabian Homborg
ad5bbeb3c2
Make wcwidth configurable (#4816)
* Make wcwidth configurable

This adds the cmake option "INTERNAL_WCWIDTH" (to be set to "ON" or
"OFF") and the configure option --[en,dis]able-internal-wcwidth.

Both default to enabling our fallback, but can be set to use the system's wcwidth again.

Sequel to #4554.
See #4571, #4539, #4609.

On my system, this would fix #4306.
2018-03-25 10:19:57 +02:00
Fabian Homborg
b75c3b968c Replace muparser with tinyexpr 2018-03-01 13:09:35 +01:00
David Adam
d28493dba6 [cmake] add variable if building in-tree 2018-02-01 22:46:27 +08:00
David Adam
7b38d0b7cb [cmake] match CMake project name to autotools 2018-01-21 15:28:03 +08:00
ridiculousfish
0f8e8d1cea Migrate tnode implementation to tnode.cpp
Also improve commenting.
2018-01-20 13:33:09 -08:00
David Adam
b6202c3c86 [cmake] actually use libintil headers/libraries if detected
Closes #4663.
2018-01-17 07:50:42 +08:00
David Adam
088fc6003b [cmake] use appropriate configure policies where possible 2018-01-13 22:58:29 +08:00
ridiculousfish
8a67a113d8 Revert "Work around cmake/ninja bug that leads to installation failure"
This reverts commit 36a2f2cc01.

This attempted to modify RPATH when building with Ninja, but the CMake if
statement wasn't actually valid so this wasn't doing anything. This check
couldn't really be tested - let's make sure not to accumulate build system
rules that we don't understand.
2018-01-10 18:47:48 -08:00
ridiculousfish
d09210c08b [cmake] Untangle the CMake versioning
This untangles the CMake versioning issues (I hope) as discussed in #4626.
Note most of the advice found on the Internet about how to inject git
versions into CMake is just wrong.

The behavior we want is to unconditionally run the script
build_tools/git_version_gen.sh at build time (i.e. when you invoke ninja or
make, and not when you invoke cmake, which is build system generation time).
This script is careful to only update the FISH-BUILD-VERSION-FILE if the
contents have changed, to avoid spurious rebuilding dependencies of
FISH-BUILD-VERSION-FILE. Assuming the git version hasn't changed, the script
will run, but not update FISH-BUILD-VERSION-FILE, and therefore
fish_version.o will not have to be rebuilt.

This might normally rebuild more than is necessary even if the timestamp is
not updated, because ninja computes the dependency chain ahead of time. But
Ninja also supports the 'restat' option for just this case, and CMake is rad
and exposes this via BYPRODUCTS. So mark FISH-BUILD-VERSION-FILE as a
byproduct and make the script always update a dummy file
(fish-build-version-witness.txt). Note this is the use case for which
BYPRODUCTS is designed.

We also have fish_version.cpp #include "FISH-BUILD-VERSION-FILE", and do a
semi-silly thing and make FISH-BUILD-VERSION-FILE valid C++ (so there's just
one version file). This means we have to filter out the quotes in other
cases..
2018-01-08 22:28:10 -08:00
ridiculousfish
da8db7f6f0 Revert "Generate FISH_BUILD_VERSION info for cmake builds"
This reverts commit 25839b8c36.

This was an attempt to simplify the version generation, but it
computed the version at build sytem generation time rather than
at build time, requiring another run of CMake to update it.
2018-01-08 22:28:10 -08:00
Mahmoud Al-Qudsi
d31be65a30 Don't add FISH_BUILD_VERSION to the C++ defines
Including it as -DFISH_BUILD_VERSION causes a full re-compile as ninja
detects that the C++ compiler parameters have changed.
2017-12-30 17:42:02 -06:00
Mahmoud Al-Qudsi
25839b8c36 Generate FISH_BUILD_VERSION info for cmake builds
Correctly generate FISH_BUILD_VERSION for use in fish_version.h/cpp and
fish.pc to allow `fish --version` and `echo $version` to work again.

Not needing the same convoluted measures used by Makefile builds to
prevent the regeneration of the fish version file when it hasn't
changed.

Purposely created a new `cmake_git_version_gen.sh` file so that the old
`git_version_gen.sh` remains compatible with the existing Makefile build
script. Same reason why `fish.pc.in` was not modified to use a lowercase
variable name to match the CMAKE variable of the same name.

Closes #4626
2017-12-30 17:38:09 -06:00
Mahmoud Al-Qudsi
36a2f2cc01 Work around cmake/ninja bug that leads to installation failure
CMake originally links build artifacts/results so that they can run from
the target directory. As a result, it must first relink the binaries
before installation so that they can run from the installation target
directory, typically done in the preinstall stage. Ninja does not have a
preinstall stage, and the CMake code that generates the build.ninja file
does not take that into account [0].

Setting `CMAKE_BUILD_WITH_INSTALL_RPATH` [1] makes it originally link
the files with the RPATH settings for the final destination directory,
meaning that relinking is no longer needed.

Technically setting the RPATH is not required for the `fish` binary as
we do not have any relative dependencies; this is the output of
`ldd ./build/fish`:

```
linux-vdso.so.1 =>  (0x00007ffffacdc000)
libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5
(0x00007f6632350000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5
(0x00007f6632120000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2
(0x00007f6631f00000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007f6631b70000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
(0x00007f6631860000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007f6631630000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f6631410000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
(0x00007f6631040000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6632600000)
```

However, since the bug only exists when the build generator is set to
ninja, the workaround is only activated for that specific build
generator to prevent any future problems.

[0]: https://cmake.org/Bug/print_bug_page.php?bug_id=13934
[1]: https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.html
2017-12-28 15:15:58 -06:00
ridiculousfish
f563262cfd Mark tests as USES_TERMINAL
This allows the Ninja build to show the test output live.
This requires bumping the min required CMake version to 3.2 (from 3.1)
2017-12-21 12:48:17 -08:00
ridiculousfish
3099d46736 Disable exception handling in CMake build
Now that muparser no longer relies on exceptions, we can disable them
again.
2017-12-18 23:01:17 -08:00