Commit Graph

58 Commits

Author SHA1 Message Date
bfredl 3711a0387a refactor(build): make all generated c files headers
There's no "rule" or bad practice or whatever that says we cannot
generate c files. it is is just that we have ~20 generated headers
and ~2 generated sources and there is nothing in these two generated
source files which sets them aparts. Lua bindings are not different from
rpc bindings, and pathdef is not different from versiondef.

So to simplify build logic and ease the future port to build.zig,
streamline the build to only have generated headers, no direct generated
.c files.

Also "nlua_add_api_functions" had its prototype duplicated twice which
defeated the point of having mandatory prototypes (one source of truth).
2024-04-27 18:59:48 +02:00
Famiu Haque 75b80516d5
build: fix link error for `_BitScanForward64` (#28173)
Problem: The usage of `_BitScanForward64` causes linking to fail on some systems.
Solution: Correctly check if it exists using `check_c_source_compiles`.
2024-04-05 09:56:35 +08:00
bfredl de5cf09cf9 refactor(metadata): generate all metadata in lua
Then we can just load metadata in C as a single msgpack blob. Which also
can be used directly as binarly data, instead of first unpacking all the
functions and ui_events metadata to immediately pack it again, which was
a bit of a silly walk (and one extra usecase of `msgpack_rpc_from_object`
which will get yak shaved in the next PR)
2024-02-28 11:00:38 +01:00
dundargoc f936a962d0 build: create separate targets for nvim with and without runtime files
This distinction is important for correct dependency management, as the
nvim binary is used to create some runtime files. The nvim binary (and
the target to build it) is thus called `nvim_bin` and the target to
build all of nvim (binary+runtime) is called `nvim`.
2024-01-20 12:59:27 +01:00
dundargoc 1813661a61 refactor(IWYU): fix headers
Remove `export` pramgas from defs headers as it causes IWYU to believe
that the definitions from the defs headers comes from main header, which
is not what we really want.
2024-01-11 21:37:23 +01:00
dundargoc bf0be0f63e build: various improvements
- Use `#pragma once` for `cmake.config/config.h.in`
- Remove unused variable `CACHED_GENERATED_DIR`
- Reorganize and sort variables
- Introduce `STYLUA_DIRS` variable to ensure the `formatlua` and
  `lintlua-stylua` operates on the same files.
- Adjust variable scope to avoid using hacky directory properties.
- Add more necessary runtime files as test dependencies
2023-12-30 14:22:25 +01:00
dundargoc af93a74a0f refactor: run IWYU on entire repo
Reference: https://github.com/neovim/neovim/issues/6371.
2023-12-21 17:38:42 +01:00
dundargoc 69bc519b53 refactor: move non-symbols to defs.h headers 2023-12-17 19:03:18 +01:00
Daiki Noda f0eb3ca916
build: eliminate semicolons from --version string
Refactor the --version string to remove semicolons. Although semicolons are
present in LINK_OPTIONS, they are not actually included during compilation.
2023-12-17 13:55:15 +01: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 f31f260f0c build: rework --version generation
Having a dynamically generated string is more maintainable than having
multiple files.

Also add linker flags and any potential LTO flags to the --version
output.
2023-12-15 00:19:38 +01:00
dundargoc 79b6ff28ad refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
dundargoc e38a053692 build(IWYU): export generated headers 2023-11-27 19:33:42 +01:00
dundargoc 8b428ca8b7 build(IWYU): fix includes for func_attr.h 2023-11-27 18:06:57 +01:00
dundargoc 40139738eb build: enable IWYU on mac 2023-11-27 15:50:45 +01:00
zeertzjq 38a20dd89f
build(IWYU): replace most private mappings with pragmas (#26247) 2023-11-27 20:58:37 +08:00
zeertzjq 6343d41436
refactor: move autocmd types to autocmd_defs.h (#26239) 2023-11-27 11:17:04 +08:00
zeertzjq 09541d514d
build(IWYU): replace public-to-public mappings with pragmas (#26237) 2023-11-27 09:51:26 +08:00
dundargoc c2a5105e88
build(IWYU): remove arabic_defs.h (#26235)
A _defs header is only needed if it's included by multiple files.
2023-11-27 07:41:43 +08:00
dundargoc 71141e8cf5 build(IWYU): fix headers for arabic.h 2023-11-26 22:15:53 +01:00
zeertzjq 6361806aa2
refactor: move garray_T to garray_defs.h (#26227) 2023-11-26 22:58:52 +08:00
dundargoc 17d81ac2ab build(IWYU): map everything in the C99 specification 2023-11-26 12:13:25 +01:00
dundargoc a827003e30 build: rework IWYU mapping files
Create mapping to most of the C spec and some POSIX specific functions.
This is more robust than relying files shipped with IWYU.
2023-11-25 17:41:33 +01:00
zeertzjq bb4b4576e3
refactor: iwyu (#26062) 2023-11-16 10:55:54 +08:00
dundargoc 353a4be7e8 build: remove PVS
We already have an extensive suite of static analysis tools we use,
which causes a fair bit of redundancy as we get duplicate warnings. PVS
is also prone to give false warnings which creates a lot of work to
identify and disable.
2023-11-12 21:26:39 +01:00
dundargoc 4d757bbfbb refactor: combine regexp files
regext_bt.c and regexp_nfa.c are inlined into regexp.c instead of
included as a header. This makes developer tools like clang-tidy and
clangd be able to understand the code better.
2023-11-05 11:48:42 +01:00
dundargoc 5cefec7349 build: various cmake fixes
- silence false warnings on MSVC
- merge `clang-tidy` cmake target into `lintc` and remove the
  corresponding make target
- use cmake's built-in endianness detection
2023-11-04 18:32:47 +01:00
dundargoc 1094d0c0db build: add CMAKE_C_FLAGS to --version output
Closes https://github.com/neovim/neovim/issues/25754.
2023-10-24 11:09:15 +02:00
zeertzjq 09a17f91d0
refactor: move cmdline completion types to cmdexpand_defs.h (#25465) 2023-10-02 10:45:33 +08:00
zeertzjq 5c60fbe9db vim-patch:9.0.1963: Configure script may not detect xattr
Problem:  Configure script may not detect xattr correctly
Solution: include sys/xattr instead of attr/xattr,
          make Test_write_with_xattr_support() test
          xattr feature correctly

This also applies to the Smack security feature, so change the include
and configure script for it as well.

closes: vim/vim#13229

6de4e58cf2
2023-09-30 22:09:55 +08:00
zeertzjq f6e72c3dfe vim-patch:9.0.1962: No support for writing extended attributes
Problem:  No support for writing extended attributes
Solution: Add extended attribute support for linux

It's been a long standing issue, that if you write a file with extended
attributes and backupcopy is set to no, the file will loose the extended
attributes.

So this patch adds support for retrieving the extended attributes and
copying it to the new file. It currently only works on linux, mainly
because I don't know the different APIs for other systems (BSD, MacOSX and
Solaris).  On linux, this should be supported since Kernel 2.4 or
something, so this should be pretty safe to use now.

Enable the extended attribute support with normal builds.

I also added it explicitly to the :version output as well as make it
able to check using `:echo has("xattr")`, to have users easily check
that this is available.

In contrast to the similar support for SELINUX and SMACK support (which
also internally uses extended attributes), I have made this a FEAT_XATTR
define, instead of the similar HAVE_XATTR.

Add a test and change CI to include relevant packages so that CI can
test that extended attributes are correctly written.

closes: vim/vim#306
closes: vim/vim#13203

e085dfda5d

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-30 22:09:55 +08:00
zeertzjq cf8b2c0e74
build(iwyu): add a few more _defs.h mappings (#25435) 2023-09-30 12:05:28 +08:00
dundargoc c48f94d1f3
build: remove LOG_LIST_ACTIONS option and related code
It has not been used for a long time and the likelihood of it still working is
low.
2023-05-28 16:34:47 +02:00
dundargoc c40872acbd
build: remove duplicate include directories in --version output
Having the same directory listed multiple times makes the --version
output needlessly complicated to visualize. This deduplication will only
work for cmake version 3.15 and above, which should be the majority of
neovim builds by now. For older cmake versions we default to the
previous behavior of listing duplicate include directories.
2023-05-18 16:27:05 +02:00
bfredl e2fdd53d8c refactor(map): avoid duplicated khash_t types for values
This reduces the total number of khash_t instantiations from 22 to 8.

Make the khash internal functions take the size of values as a runtime
parameter. This is abstracted with typesafe Map containers which
are still specialized for both key, value type.

Introduce `Set(key)` type for when there is no value.

Refactor shada.c to use Map/Set instead of khash directly.
This requires `map_ref` operation to be more flexible.
Return pointers to both key and value, plus an indicator for new_item.
As a bonus, `map_key` is now redundant.

Instead of Map(cstr_t, FileMarks), use a pointer map as the FileMarks struct is
humongous.

Make `event_strings` actually work like an intern pool instead of wtf it
was doing before.
2023-05-17 12:26:21 +02:00
Lewis Russell 7bf1a917b7
vim-patch:8.1.2094: the fileio.c file is too big
Problem:    The fileio.c file is too big.
Solution:   Move buf_write() to bufwrite.c. (Yegappan Lakshmanan,
            closes vim/vim#4990)

c079f0fed1

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-04-19 13:15:29 +01:00
dundargoc 7100a80253
build: show build type specific compiler flags when using --version
The build type specific flags are defined in the variables
CMAKE_C_FLAGS_<CONFIG>, where <CONFIG> can be DEBUG, RELEASE,
RELWITHDEBINFO and MINSIZEREL.
2023-03-04 20:04:01 +01:00
bfredl 1b3c1f6c06 refactor(build): graduate HAVE_LOCALE_H feature
Merge locale.h into os/lang.h
Having a source file with the same name as a system header we use is
considered an anti-pattern.
2023-03-03 14:19:46 +01:00
bfredl 166b149d5b refactor(build): remove unused stdlib function and include checks
In addition: merge some checks for the same feature into one
test_compile. This reduces the total number of test compiles
which speeds up the cmake configure stage.
2023-03-03 14:19:46 +01:00
dundargoc 458299df79
fix: remove "Compiled by:" from :version/--version (#22316)
The :version output is already crowded as is, the last thing we need is
extraneous messages about who compiled it.
2023-02-18 20:10:00 +01:00
Gregory Anders bb377afd32
build: use custom command to create single versiondef (#22290)
When using a multi config generator, CMake generates an output file for
each configuration when using file(GENERATE). When the contents of the
file for each configuration are different, CMake fails. Instead, create
separate files for each configuration and add a build time step to copy
the configuration specific file to the generic path "auto/versiondef.h"
which is included at build time.
2023-02-16 21:52:41 +01:00
Gregory Anders ced0cd12d0
build: only use HOSTNAME_PRG if HOSTNAME is undefined (#22288)
Allow specifying the HOSTNAME variable by defining it with -D when
invoking CMake, instead of overriding it with the output of
HOSTNAME_RPG.
2023-02-16 12:36:55 -07:00
dundargoc 4c64cbe99f
build: mark uninteresting variables as advanced (#22208)
Only the most important variables should be shown by default.
2023-02-10 20:20:18 +01:00
dundargoc 964ae205a5
build: unbreak building neovim with multi-config generators (#22104)
file(GENERATE) has surprising behavior as it doesn't allow different
file contents for configurations with the same file name. This results
in an error when building neovim with a multi-config generator. Use a
workaround for now where we set the build type for multi-config
generators to "Unknown".
2023-02-03 10:53:57 +01:00
dundargoc f9826e1dff
build: stop relying on CMAKE_BUILD_TYPE to determine the build type (#22051)
Any logic involving CMAKE_BUILD_TYPE is automatically broken as it won't
work with multi-config generators. The only exception is if we
explicitly check whether the current generator is single-config as well.
Instead, use generator expressions or cmake variables that allows to set
options for certain build types only such as
INTERPROCEDURAL_OPTIMIZATION_<CONFIG>.

Opt to generate all headers with optimization level O2 with no debug
information for all build types as that is the simplest way to make it
behave the same for all generators.
2023-02-03 00:00:15 +01:00
dundargoc 27b81af19c
refactor!: remove has("debug") (#22060)
This value can not be relied on as it doesn't work for
multi-configuration generators. I don't think this undocumented option
is used much, if at all, so I think we should remove it.
2023-01-30 19:06:32 +01:00
Lewis Russell f08051c2e6
feat!: make iconv a non-optional dep 2023-01-23 16:33:45 +00:00
dundargoc 4c531714ff
refactor: replace char_u with char 25 (#21838)
refactor: replace char_u with char

Work on https://github.com/neovim/neovim/issues/459
2023-01-19 22:25:56 +08:00
dundargoc 3269902a13
refactor: fix IWYU mapping file and use IWYU (#21802)
Also add the EXITFREE definition to main_lib rather than the nvim target, as the header generation needs the EXITFREE flag to work properly.
2023-01-15 14:16:33 +01:00
dundargoc 438b4361cc
build: use modern cmake (#21589)
Replace old-school cmake with the so-called "Modern CMake", meaning
preferring using targets and properties over directory settings and
variables. This allows greater flexibility, robustness and clarity over
how the code works.

The following deprecated commands will be replaced with their modern
alternatives that operates on a specific target, rather than all targets
in the current directory:

- add_compile_options -> target_compile_options
- include_directories -> target_include_directories
- link_libraries -> target_link_libraries
- add_definitions -> target_compile_definitions

There are mainly four main targets that we currently use: nvim, libnvim,
nvim-test (used by unittests) and ${texe} (used by
check-single-includes). The goal is to explicitly define the
dependencies of each target fully, rather than having everything be
dependent on everything else.
2023-01-10 18:49:57 +01:00