Commit Graph

299 Commits

Author SHA1 Message Date
Eisuke Kawashima
1b90f4a9c4
build: mark CMake variables advanced #31412
The variables are not marked as advanced, thus they appear in e.g. `ccmake`.
2024-12-09 16:10:27 -08:00
dundargoc
07b14c8e2e build: specify POST_BUILD when using add_custom_command
This is needed specifically for the second signature of
add_custom_command, which appends an operation to an existing target.
This will prevent the cmake warning CMP0175.

Reference: https://cmake.org/cmake/help/latest/policy/CMP0175.html
2024-11-09 13:07:16 +01:00
Tom Scogland
e178331488 build(lpeg): search for lpeg.so on MacOS
Problem: Currently Neovim only searches for lpeg.dylib, liblpeg.dylib,
etc. on MacOS, but a normal installation of lpeg will produce lpeg.so
instead.  There are explicit workarounds for this by modifying lpeg's
package in Homebrew, and will shortly be another in spack.

Solution: also search for lpeg.so even if that's not the platform
default, because Lua and luarocks use it anyway.
2024-10-22 14:29:20 +02:00
dundargoc
573bcb2aaf build: remove enforcement of cmake build type
Forcing the build type to be one of the default types was intended to
prevent usage of custom build types which risks unpredictability.
Unfortunately, many distributions patch this check out so they can use
a custom type anyway, making the check moot in the first place. Instead,
allow custom build types but don't try to accomodate them in the code:
we're making the assumption that anyone who wants to use a custom build
type will be able to set any additional necessary flags needed for their
specific system.
2024-10-22 11:21:54 +02:00
dundargoc
327110ff8c build(cmake): remove unnecessary policy code
Policy CMP0092 is by default on for minimum cmake versions above 3.15.
2024-09-22 17:21:10 +02:00
Lewis Russell
688b961d13 feat(treesitter): add support for wasm parsers
Problem: Installing treesitter parser is hard (harder than
climbing to heaven).

Solution: Add optional support for wasm parsers with `wasmtime`.

Notes:

* Needs to be enabled by setting `ENABLE_WASMTIME` for tree-sitter and
  Neovim. Build with
  `make CMAKE_EXTRA_FLAGS=-DENABLE_WASMTIME=ON
  DEPS_CMAKE_FLAGS=-DENABLE_WASMTIME=ON`
* Adds optional Rust (obviously) and C11 dependencies.
* Wasmtime comes with a lot of features that can negatively affect
  Neovim performance due to library and symbol table size. Make sure to
  build with minimal features and full LTO.
* To reduce re-compilation times, install `sccache` and build with
  `RUSTC_WRAPPER=<path/to/sccache> make ...`
2024-08-26 16:44:03 +02:00
Christian Clason
fa79a8ad6d build(deps): vendor libvterm at v0.3.3
Problem: Adding support for modern Nvim features (reflow, OSC 8, full
utf8/emoji support) requires coupling libvterm to Nvim internals
(e.g., utf8proc).

Solution: Vendor libvterm at v0.3.3.
2024-08-10 10:26:07 +02:00
bfredl
1247684ae1 build(deps): remove msgpack-c dependency 2024-08-05 12:22:12 +02:00
dundargoc
32e16cb0b6 build: add utf8proc as dependency
utf8proc contains all the data which is currently in
unicode_tables.generated.h internally, but in quite a different format.
Ideally unicode_tables.generated.h should be removed as well so we rely
solely on utf8proc. We want to avoid a situation where the possibility
of unicode mismatch occurs, e.g a distro using both unicode 12 and
unicode 13.
2024-06-28 19:47:39 +02:00
dundargoc
f09f5c45fa build: reuse code for deps.txt for both deps and main build 2024-05-28 20:58:07 +02:00
dundargoc
c18d7941ef build: allow sccache as compiler cache
Also enable caching for dependencies.

Closes https://github.com/neovim/neovim/issues/28670
2024-05-09 16:39:45 +02:00
dundargoc
383018dbb8 build: simplify policy-setting for dependencies
Passing `CMAKE_POLICY_DEFAULT_CMP0092=NEW` to all dependencies is
simpler than setting it manually in each file.
2024-05-03 18:22:20 +02:00
zeertzjq
089c8d033d
test: override XDG_STATE_HOME as well (#28604)
This prevents tested Nvim from affecting ~/.local/state/
2024-05-02 20:09:20 +08:00
dundargoc
a1c2da56ec build: do not use GIT_REPOSITORY for local dependencies
This reverts a large portion of
2c1e8f7e96.

The conclusion from that commit is incorrect: local builds are not
used/updated correctly so much as it's not used at all. Instead the
build will always use `master` branch rather than the current files.
2024-04-25 11:17:54 +02:00
dundargoc
7035125b2b test: improve test conventions
Work on https://github.com/neovim/neovim/issues/27004.
2024-04-08 22:51:00 +02:00
dundargoc
624de849de build: add function add_target
It's a combination of add_custom_target and add_custom_command that does
what most users probably expect should happen.

This also fixes `make clean` removing files tracked by git.
2024-04-08 10:52:53 +02:00
dundargoc
036f86feac ci: provide separate macos releases for intel and arm
This will immensely reduce the complexity required to support both
architectures, reduce overall lines of code and unblock follow-up
simplifications.
2024-03-24 20:58:30 +01:00
dundargoc
2c1e8f7e96 build: use GIT_REPOSITORY for local URLs
`GIT_REPOSITORY` will cause cmake to rebuild if local dependency
changes, which isn't the case for `URL`.

Also document how to test a different commits of a dependency.
2024-03-23 13:36:12 +01:00
dundargoc
187ae67735 build: introduce variable DEPS_IGNORE_SHA for skipping dependency hash check
This will reduce friction as developers no longer need to provide a hash
when testing out different commits.

To skip the hash check, set `DEPS_IGNORE_SHA` to `TRUE` in
`cmake.deps/CMakeLists.txt`.
2024-03-19 08:52:03 +01:00
Gregory Anders
a75ef40f4c
build: set deps default build type to Release (#27495)
Debugging dependencies is rare so a Debug build type is usually not
needed. In cases where it _is_ needed it is easy to rebuild in Debug
mode. But since Release builds are more common, it makes more sense as a
default.

For Neovim itself we stick with a Debug build as a default, since
rebuilding and debugging is done _much_ more frequently than with
dependencies (which we _mostly_ expect to "just work").

Also remove the CMAKE_BUILD_TYPE variable in the Makefile, since this is
set by default in CMake.
2024-02-16 11:56:52 -06:00
Christian Clason
83b51b36aa fixup: raise TS min version 2024-01-25 23:39:25 +01:00
dundargoc
ae3eed53d6 build: various build improvements
- remove "ran-" prefix from touch files as it's redundant since the
  they're already in the directory named `touches`.
- Include `contrib` when formatting with `make formatlua`.
- Use TARGET_FILE generator expression instead of assuming the
  executable location.
- reuse logic that determines whether to use lua or luajit.
- add translations to the `nvim` target.

Makefile improvements:
- rename variable `CMAKE_PRG` to `CMAKE` to make it more consistent with
  the builtin `MAKE` variable.
- stop propagating flags to generator. Users should use cmake for
  non-standard use cases.
- remove `+` prefix from targets. If the user for whatever reason wants
  to dry-run a target then they should be able to.
2024-01-24 12:41:09 +01:00
James McCoy
52e6059415
fix(test): call separate_arguments() correctly to honor $BUSTED_ARGS (#26905)
separate_arguments() doesn't operate in place on a variable.  It expects
a string argument to parse and stores the results in the specified
variable.
2024-01-05 14:07:34 -05:00
dundargoc
404fdb0f36 build: cmake fixes
- add EXTERNALPROJECT_OPTIONS variable to main build
- use `REQUIRED` keyword for IWYU.
- remove check_c_compiler_flag checks when `ENABLE_COMPILER_SUGGESTIONS`
  is `ON`. If we explicitly enable it then we probably want it to give
  an error if it doesn't exist, rather than silently skip it.
- Move dependency interface libraries to their find module and use them
  as a pseudo-imported target.
- Remove BUSTED_OUTPUT_TYPE. It's not used and we can reintroduce it
  again if something similar is needed.
- Use LINK_OPTIONS intead of LINK_FLAGS when generating the `--version`
  output.
2023-12-16 21:06:28 +01:00
dundargoc
7840760776 build: bump minimum cmake version to 3.13
The benefits are primarily being able to use FetchContent, which allows
for a more flexible dependency handling. Other various quality-of-life
features such as `-B` and `-S` flags are also included.

This also removes broken `--version` generation as it does not work for
version 3.10 and 3.11 due to the `JOIN` generator expression.

Reference: https://github.com/neovim/neovim/issues/24004
2023-12-16 17:17:24 +01:00
dundargoc
8be24fed8f build: remove config-specific find_package search for libuv
Having two separate find_package calls makes it harder to maintain.
2023-12-09 14:55:37 +01:00
dundargoc
e5d7003b02
build: rework formatting to use add_glob_target
This will ensure that we can pass flags and make adjustments from the
top level cmake file instead of digging through the cmake directory.
More importantly, this will only format files that have been changed.
This has a slightly higher initial cost compared to previous solution as
all files must be initially formatted, but the gained speed up should
more than make up for it quickly.

`make formatlua` is always run due to a quirk of stylua of always changing
modification time of the file regardless if there were any changes. This is not
a major blocker as stylua is very fast.
2023-12-04 20:21:38 +01:00
dundargoc
404043e74c build: vendor libtermkey
This is a proof of concept/WIP to evaluate the viability of vendoring
libtermkey as it's been deprecated.
2023-11-30 12:02:10 -06:00
dundargoc
2c16c6a6c4
docs: small fixes (#26154) 2023-11-27 17:43:13 +08:00
dundargoc
99b8a343e1 fixup: quick update, squash later 2023-11-20 15:21:55 +01:00
dundargoc
7a80e169c5 build: disable all compiler warnings from dependencies 2023-11-20 15:21:55 +01:00
dundargoc
7a5effb0f9 build: bump required minimum libvterm version to 0.3.3
Also add detection for libvterm patch version.
2023-10-28 10:46:58 +02:00
dundargoc
25cfe3fd43 build: enable formatting during rebase
Closes https://github.com/neovim/neovim/issues/25654
2023-10-23 21:48:06 +02:00
dundargoc
b80a8e2c16 build: adjust how find order is prioritized
Ensure bundled libraries and include directories are always searched
first before any others. This will provide a more consistent experience
as the search order of the builtin find_ functions can vary depending on
system. This should make the build process faster when building with
bundled deps as we limit the search to only the .deps directory.
Separating the search between .deps and everything makes debugging
find_-related problems simpler if you need to check how dependencies are
found.

For libraries, we divide the search process into the following order:
1. Only search in .deps directory and only search for static libraries.
2. Only search in .deps directory and search for all libraries.
3. Search everywhere and search for all libraries.

Make an exception for FindLibintl.cmake as changing the search order
seems to break some tests on macos.
2023-10-16 20:15:41 +02:00
Sergey Slipchenko
f859d16aea
fix(tests): set SHELL=sh #24941
Problem:
Some tests fail with $SHELL=fish #6172
Related: https://github.com/neovim/neovim/pull/6176

Solution:
Replace "echo -n" with "printf", because "echo" in sh may be provided
as a shell builtin, which does not accept an "-n" flag to avoid a
trailing newline (e.g. on macos). "printf" is more portable (defined by
POSIX) and it does not output a trailing newline by itself.
Fixes #6172

TODO:
Other test failures may be related to "session leader" issue: https://github.com/neovim/neovim/issues/2354
Checked by running `:terminal ./build/bin/tty-test` from Nvim with
`shell=/bin/fish` (inherited from `$SHELL`) and it indeed complains
about "process does not own the terminal". With `shell=sh` it doesn't complain. And
unsetting `$SHELL` seems to make `nvim` to fall back to `shell=sh`.

    FAILED   test/functional/terminal/tui_spec.lua @ 1017: TUI paste: terminal mode
    test/functional/terminal/tui_spec.lua:1024: Row 1 did not match.
    Expected:
      |*tty ready                                         |
      |*{1: }                                                 |
      |*                                                  |
      |                                                  |
      |{5:^^^^^^^                                           }|
      |{3:-- TERMINAL --}                                    |
      |{3:-- TERMINAL --}                                    |
    Actual:
      |*process does not own the terminal                 |
      |*                                                  |
      |*[Process exited 2]{1: }                               |
      |                                                  |
      |{5:^^^^^^^                                           }|
      |{3:-- TERMINAL --}                                    |
      |{3:-- TERMINAL --}                                    |

    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.

    stack traceback:
        test/functional/ui/screen.lua:622: in function '_wait'
        test/functional/ui/screen.lua:352: in function 'expect'
        test/functional/terminal/tui_spec.lua:1024: in function <test/functional/terminal/tui_spec.lua:1017>

    FAILED   test/functional/terminal/tui_spec.lua @ 1551: TUI forwards :term palette colors with termguicolors
    test/functional/terminal/tui_spec.lua:1567: Row 1 did not match.
    Expected:
      |*{1:t}ty ready                                         |
      |                                                  |
      |*                                                  |
      |                                                  |
      |{2:^^^^^^^                                           }|
      |                                                  |
      |{3:-- TERMINAL --}                                    |
    Actual:
      |*{1:p}rocess does not own the terminal                 |
      |                                                  |
      |*[Process exited 2]                                |
      |                                                  |
      |{2:^^^^^^^                                           }|
      |                                                  |
      |{3:-- TERMINAL --}                                    |

    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.

    stack traceback:
        test/functional/ui/screen.lua:622: in function '_wait'
        test/functional/ui/screen.lua:352: in function 'expect'
        test/functional/terminal/tui_spec.lua:1567: in function <test/functional/terminal/tui_spec.lua:1551>
2023-09-11 10:01:00 -07:00
dundargoc
9f8f287c61 build: remove luarocks
Luarocks is no longer needed after
25e51d393a.
2023-09-10 15:32:47 +02:00
bfredl
25e51d393a build(lua): vendor coxpcall
Do not require luarocks on PUC lua CI just because of this single lua file
2023-09-10 11:43:37 +02:00
Sergey Slipchenko
87db6d894a fix(deps): make sure --force-config takes effect
Fixes #24881

--force-config passed to luarocks' configure script is only taken into
account in case "make install" is used afterwards.

But if "make bootstrap" is used then this flag has no effect. And it can
actually copy an existing config on the system to the new installation.
That existing config can have a different version of Lua set by default.
In which case luarocks will install packages for that version instead of
the one used in tests. And trying to run tests then will fail because of
missing packages.
2023-09-09 18:41:36 +02:00
bfredl
6985e12cae refactor(build): derocksify luacheck 2023-09-07 15:26:30 +02:00
dundargoc
c50951a4d0
build: various fixes
- simplify lua interpreter search
- fix incorrect variable name in BuildLua.cmake
- build PUC Lua with -O2
- silence non-mandatory find_package search for libuv
- simplify Find modules
- Prefer using the explicitly set CI_BUILD over relying on the
  environment variable "CI".
2023-09-04 00:00:26 +02:00
dundargoc
f30844008b
build: download busted from own neovim/deps repository
Downloading the necessary files all at once instead of doing dependency
handling with luarocks speeds up installation immensely. We speed up the
process even more by using luv as a replacement for the C modules in the
busted dependencies, which allows us to skip costly compilation times.

Co-authored-by: bfredl <bjorn.linse@gmail.com>
2023-09-03 00:38:10 +02:00
Justin M. Keyes
43ded8d358
feat(version): unverbose ":version", ":verbose version" #24195
Problem:
`nvim -v` and `:version` prints system vimrc, fallback files, and compilation
info by default, which most people don't care about and just clutters up the
output.

Solution:
Omit extra info unless 'verbose' is set.
2023-07-01 03:45:45 -07:00
dundargoc
46e95909bf
ci: introduce CI_LINT option
This will abort if lint programs are not found, and is meant primarily
for the lint job in CI. Supersedes the REQUIRED argument in
add_glob_target as it's a superior replacement by being a built-in
solution.
2023-06-24 00:29:53 +02:00
treatybreaker
199a990c9e
feat: report "build" in vim.version() #23925
Problem:
Nvim version string typically has a "build" component
but vim.version() doesn't report it.

Solution:
Add the "build" field to vim.version().

Closes #23863
2023-06-11 14:57:23 -07:00
dundargoc
8b8e607284
build: move luarocks and rocks installation to main build
This will ensure luacheck and busted are only installed when they're
actually needed. This cuts total build time by over 50%.

Closes https://github.com/neovim/neovim/issues/22797.
2023-05-21 20:57:39 +02:00
dundargoc
24b60b0f71
build: don't format deleted files
Trying to format deleted files will otherwise throw an error.
2023-05-18 16:28:46 +02:00
dundargoc
826b95203a
build: bundle uncrustify
Uncrustify is sensitive to version changes, which causes friction for
contributors that doesn't have that exact version. It's also simpler to
download and install the correct version than to have bespoke version
checking.
2023-05-18 16:27:47 +02:00
dundargoc
1086016477
build: cmake cleanup
- Simplify error checking when using execute_process.
- Set BUILD_SHARED_LIBS to OFF when building dependencies.
  This is normally not needed, but msgpack interprets an unset
  BUILD_SHARED_LIBS to build a shared library, which is the opposite of
  the cmake behavior.
- Move function check_lua_module to Util.cmake.
- Remove unnecessary code.
- Make variable naming more consistent
2023-05-13 12:12:29 +02:00
Lewis Russell
af040c3a07
feat(treesitter): add support for setting query depths 2023-05-11 11:13:32 +01:00
dundargoc
9f9cef1b56
build: make lpeg an imported library
Cmake truncates the full link path to a shared library if it is missing
an SONAME in some undocumented scenarios. This causes builds in some
systems to fail if "lpeg" isn't a library on the system path.

The path of imported libraries aren't modified by cmake, so we can use
that as a workaround until a proper solution for this has been
identified.

Closes https://github.com/neovim/neovim/issues/23395.
2023-04-30 23:57:15 +02:00