Commit Graph

2062 Commits

Author SHA1 Message Date
Lei YU 8d6b474bf6 Add clang-tidy-fix target
Add the `clang-tidy-fix` target to apply clang-tidy fixes to the source
code.
This is done by calling `run-clang-tidy` with `-fix` argument.

Add a test case to run `clang-tidy-fix` and verify the file is changed.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
2023-09-25 16:25:01 +03:00
Xavier Claessens 49e7e3b9cc Allow to fallback to cmake subproject
The method can be overridden by setting the `method` key in the wrap
file and always defaults to 'meson'. cmake.subproject() is still needed
in case specific cmake options need to be passed.

This also makes it easier to extend to other methods in the future e.g.
cargo.
2023-09-22 15:50:26 -04:00
Kunwu.Chan c0da998afa
CPU family support 'sw_64' and remove the compile warning (#12273)
add sw_64 to the list of known cpus
2023-09-22 08:33:19 -07:00
Xavier Claessens 10dcd87d00 Rust: Replace rust_crate_type with rust_abi
Meson already knows if it's a shared or static library, user only need
to specify the ABI (Rust or C).
2023-09-19 13:54:49 -04:00
Dylan Baker 8ccdb88137 Rust: Add a rust.proc_macro() method 2023-09-19 13:54:49 -04:00
yyyyyiiiiii e0c4cffd70 fix links
Wayland, Weston, wlroots migrated to gitlab.freedesktop.org
2023-09-18 10:03:24 -07:00
Eberhard Beilharz 5d8e2f301e Update link to lcov
lcov moved from sourceforge to github, so this change updates the link.
2023-09-18 11:26:43 -04:00
L. E. Segovia ca60f71b2e reference tables: Document how to set compiler paths with spaces in environment variables
See #11128
2023-09-15 07:31:37 -04:00
Arsen Arsenović 0af126fec7 install_{data,headers,subdir}: implement follow_symlinks
This permits users who rely on following symlinks to stay on the old
default of following them.
2023-09-13 21:44:40 -04:00
Charles Brunet d3a26d158e raw printer
this printer preserves all whitespaces and comments in original meson.build file. It will be useful for rewrite and potential auto-formatter
2023-09-11 07:51:19 -04:00
Xavier Claessens 10708676ad gnome.mkenum_simple(): Fix include path when header is in subdir
It was generating #include with the basename of every header file. That
assumes that every directory where there are headers are also included
into search path when compiling the .c file.

Change to use path relative to current subdir, which can be both in
build or source directory. That means that we assume that when the .c
file is compiled, the target has a include_directories pointing to the
directory where gnome.mkenum_simple() has been called, which is
generally '.' and added automatically.

Also fix type annotation to only allow str and File sources, other types
have never been working, it would require to iterate over custom target
outputs, etc.

Fixes: #7582
2023-09-09 21:28:22 -04:00
Nomura 5f46ea116c Add support for padding zeroes in int.to_string() method 2023-09-09 19:03:22 -04:00
Nicholas Vinson b51bce070e Add macro_name option to configure_file
Allow macro_name to be speficied as a parameter to configure_file().
This allows C macro-style include guards to be added to
configure_file()'s output when a template file is not given. This change
simplifies the creation of configure files that define macros with
dynamic names and want the C-style include guards.
2023-09-09 07:30:56 -04:00
Moody Liu 3c47216fe9 clike compilers: fix cross_* functions' include
A standard C library may not exist for cross-compile
environments, thus the existence of <stdio.h> cannot be
guaranteed.

Use <stddef.h> instead, this header contains compiler-specific
defines thus it usually comes from the compiler.
2023-09-09 07:25:27 -04:00
Marvin Scholz 3fc16f05b5 Add compiler.has_define
Adds a new method to the compiler object, has_define.
This makes it possible to check if a preprocessor macro/define
is set or not.

This is especially helpful if the define in question is empty,
for example:

  #define MESON_EMPTY_DEFINE

This would yield the same results as a missing define with
the existing get_define method, as it would return an empty
string for both cases. Therefore this additional method is
needed.
2023-09-07 00:45:38 +03:00
Xavier Claessens fe9af72684 wrap: Use MESON_PACKAGE_CACHE_DIR as default packagecache path
Allow packagecache to contain already extracted directory to match what
some distro does with Cargo source packages in /usr/share/cargo/registry.

Note that there is no need to lock the cache directory because we
download into a temporary name and atomically rename afterward. It means
we could be downloading the same file twice, but at least integrity is
guaranteed.

Fixes: #12211
2023-09-05 09:05:24 +05:30
Michael Gene Brockus (Dreamer) 6b63c4161d
Adding Meson-UI back on IDE-integration.md 2023-09-04 03:23:43 +03:00
Michael Gene Brockus (Dreamer) b504fe1b3e
Add trilo xtest to users 2023-09-04 02:54:55 +03:00
Charles Brunet cf5adf0c64 add json output format to configure file 2023-08-31 07:52:41 -04:00
Bruce Merry cd30d1889f Document that dicts can be indexed with [] 2023-08-31 06:48:41 -04:00
Jussi Pakkanen 08d83a4a97
Merge pull request #10332 from xclaesse/std-opt
c_std, cpp_std: Change to a list of desired versions in preference order
2023-08-30 12:04:09 -07:00
Bruce Merry 83d3bf85cf Add CUDA id and flags to reference tables 2023-08-28 12:04:40 -04:00
Xavier Claessens 237b4c0f41 FAQ: MinGW UCRT are compatible with MSVC and also use libfoo.a
Prior to Windows 10, libfoo.a were usually not usable with MSVC. This is
not true any more since Autotools projects built with UCRT produce
libfoo.a that are compatible with MSVC.

This is another reason for using that naming convention in Meson.
2023-08-27 10:50:43 -04:00
Xavier Claessens e3a71a7b58 msetup: Update options when builddir is already configured
`meson setup -Dfoo=bar builddir` command was returning success ignoring
new option values.

This now also update options. It is useful because it means
`meson setup -Dfoo=bar builddir && ninja -C builddir` works regardless
whether builddir already exists or not, and when done in a script,
changing options in the script will automatically trigger a reconfigure
if needed. This was already possible by always passing --reconfigure
argument, but that triggers a reconfigure even when options did not
change.
2023-08-25 09:43:24 -04:00
Xavier Claessens 18b96cd069 machine file: Add @GLOBAL_SOURCE_ROOT@ and @DIRNAME@ 2023-08-23 11:33:39 -04:00
Tristan Partin 946a3561c2 Revert "Revert "Add fs.relative_to()""
This reverts commit 84c8905d52.

Fixed the cygwin failure...
2023-08-18 07:46:08 -04:00
Charles Brunet 7cbe37ebd9 Add more descriptive description to CustomTarget
Allow modules using CustomTarget to modify the command description used by ninja backend. This result in more precise logs when building a project.
2023-08-18 00:36:49 -04:00
Eli Schwartz 84c8905d52
Revert "Add fs.relative_to()"
This reverts commit f52bcaa27f.

It did not pass CI, and was merged anyway because there were two CI
errors in the same cygwin job. The other error was not the fault of this
commit, and since cygwin errors were glossed over because they were
"expected", the presence of a new error *added* by this commit was
overlooked.

Per the meson development policy, PRs which result in CI errors
can/should be reverted at will, no questions asked.
2023-08-17 23:56:51 -04:00
Eli Schwartz e313f78465
fix style errors in fs.relative_to implementation
In commit f52bcaa27f a few issues were
added:
- doc typo
- imports for utils.universal are not intended to be directly used, it's
  an internal wrapper that exists solely to make mesonlib work well as
  it always did while simultaneously allowing `meson --internal`
  codepaths to avoid importing anything other than an extremely stripped
  down core
- type annotation specific import was imported at runtime scope
2023-08-17 18:01:41 -04:00
Tristan Partin f52bcaa27f Add fs.relative_to()
Returns a relative path from arg 2 to arg 1 similar to
os.path.relpath().
2023-08-17 17:05:49 -04:00
Charlie Ringström cbf8e67f19 Replace deprecated GTK flag 2023-08-17 15:33:35 -04:00
Andrew McNulty c730807696 Python: Add 'limited_api' kwarg to extension_module
This commit adds a new keyword arg to extension_module() that enables
a user to target the Python Limited API, declaring the version of the
limited API that they wish to target.

Two new unittests have been added to test this functionality.
2023-08-14 20:02:09 -04:00
Xavier Claessens 82a8c72187 c_std, cpp_std: Change to a list of desired versions in preference order
Projects that prefer GNU C but can fallback to ISO C can now set for
example `default_options: 'c_std=gnu11,c11'` and it will use gnu11 when
available, fallback to c11 otherwise. It is an error only if none of the
values are supported by the current compiler.

This allows to deprecate gnuXX values from MSVC compiler, that means
that `default_options: 'c_std=gnu11'` will now print warning with MSVC
but still fallback to 'c11' value. No warning is printed if at least one
of the values is valid, i.e. `default_options: 'c_std=gnu11,c11'`.

In the future that deprecation warning will become an hard error because
`c_std=gnu11` should mean GNU is required, for projects that cannot be
built with MSVC for example.
2023-08-07 08:28:00 -04:00
Xavier Claessens 9df1627997 Compiler: Add werror kwarg to compiles(), links() and run() methods
Fixes: #5399
2023-08-07 08:21:05 -04:00
Xavier Claessens e01d53b816 compiler: Add required keyword to has_* methods
add the "required" keyword to the functions

has_function
has_type
has_member
has_members
has_argument
has_multi_arguments
has_link_argument
has_multi_link_argument
has_function_attribute

Co-authored-by: Milan Hauth <milahu@gmail.com>
2023-08-05 07:14:08 -04:00
Nomura 50baf3c626 Add default_options argument to find_program() 2023-08-04 14:46:39 -04:00
Xavier Claessens cec3edc08a Unify message(), format() and fstring formatting
Share a common function to convert objects to display strings for
consistency.

While at it, also add support for formatting user options.
2023-08-02 13:35:29 -04:00
Volker Weißmann 465ad6d261 Fix syntax mistakes in two examples 2023-08-02 11:33:37 -04:00
Eli Schwartz 13f8eba9b6
treewide: internally avoid deprecated machine file uses of "pkgconfig"
We support this in a machine file:

```
[binaries]
pkgconfig = 'pkg-config'
pkg-config = 'pkg-config'
```

and you can use either one, because internally we look up both. If you
only set *one* of them, this plays awkwardly with setting $PKG_CONFIG,
since we don't know which one you set in the machine file and the
*other* one will be initialized from the environment instead.

In commit 22df45a319 we changed program
lookup of config-tool style dependencies to use the regular tool names
and only fall back on the strange internal names. This affected the
pkg-config class too.

The result is that instead of preferring `pkgconfig =` followed by
$PKG_CONFIG followed by `pkg-config =`, we inverted the lookup order.
This is a good idea anyway, because now it behaves consistently with
`find_program('pkg-config')`.

Unfortunately, we documented the wrong name in a bunch of places, and
also used the wrong name in various testsuite bits, which meant that if
you set $PKG_CONFIG and then ran the testsuite, it would fail.

Correct these references, because they are buggy.

One test case expected to find_program() a native copy for convenience
of testing against natively installed glib. Force it to resolve a native
copy.
2023-08-02 01:35:16 -04:00
Alex Rao ce5f2982e4
Fix typo in Cross-compilation.md 2023-08-01 15:33:47 -04:00
Eli Schwartz 1b8dcbcc57
docs: clarify what str.split does
The wording was a bit confusing and misled at least one person into
thinking it behaved like `str.replace('c', '')` operating on the entire
line. Tweak the wording to be more precise and avoid this confusion.
2023-07-28 12:13:42 -04:00
Eli Schwartz 1bca73cc37
docs: fix typo in previous commit 2023-07-20 14:45:30 -04:00
Dylan Baker d7acccd36d interpreter: deprecate 'jar' value of build_target(target_type)
Jar has a very low set of overlap with other target types, including
that jar sources *must* be .java, and no other target allows .java
sources. As such, the difficulty in crafting a useful `build_target`
invocation that allows both `jar` and anything else is high, and the
usefulness is dubious. Just use `jar()` directly instead.

This depends on the changes to make all of the jar() specific keyword
arguments be handled by typed_kwargs so that the deprecation messages
are correct and consistent.
2023-07-20 14:20:46 -04:00
Peter Hutterer 1502b90f3a docs: improve formatting of the Rust module
This brings the formatting more in line with other modules, in
particular the headers do not include the full function signature for
readability, keyword arguments are listed one-by-one, etc.
2023-07-18 19:49:08 -04:00
Peter Hutterer f9debd3ae2 docs: fix typos and keyword markdown for the Rust module page
Two typos and mark the keyword arguments with backticks so they render
nicely.
2023-07-18 19:49:08 -04:00
Jussi Pakkanen 7824ff80dc Whoopsie, forgot to create the release notes. 2023-07-17 00:39:44 +03:00
MiroPalmu 61984bcfa3 Add import instructions for filesystem module 2023-07-13 01:59:04 -04:00
meator a5b74d208b Fix typo in Disabler.md 2023-07-06 13:14:45 -04:00
Dylan Baker 42c68291c4 environment: separate illumos and Solaris kernels in Machines
While both kernels are derived from the OpenSolaris project of Sun, they
have diverged and code that works with one may not work with the other.
As such, we should provide different values for them. This was requested
by both Oracle and the illumos upstreams.

Fixes: #11922
2023-07-04 19:02:03 +03:00
GertyP 36bf53bdfd
Experimental 'genvslite' WIP. (#11049)
* Capture all compile args from the first round of ninja backend generation for all languages used in building the targets so that these args, defines, and include paths can be applied to the .vcxproj's intellisense fields for all buildtypes/configurations.

Solution generation is now set up for mutiple build configurations (buildtypes) when using '--genvslite'.

All generated vcxprojs invoke the same high-level meson compile to build all targets;  there's no selective target building (could add this later).  Related to this, we skip pointlessly generating vcxprojs for targets that aren't buildable (BuildTarget-derived), which aren't of interest to the user anyway.

When using --genvslite, no longer inject '<ProjectReference ...>' dependencies on which a generated .vcxproj depends because that imposes a forced visual studio build dependency, which we don't want, since we're essentially bypassing VS's build in favour of running 'meson compile ...'.

When populating the vcxproj's shared intellisense defines, include paths, and compiler options fields, we choose the most frequent src file language, since this means more project src files can simply reference the project shared fields and fewer files of non-primary language types need to populate their full set of intellisense fields.  This makes for smaller .vcxproj files.

Paths for generated source/header/etc files, left alone, would be added to solution projects relative to the '..._vs' build directory, where they're never generated;  they're generated under the respective '..._[debug/opt/release]' ninja build directories that correspond to the solution build configuration. Although VS doesn't allow conditional src/header listings in vcxprojs (at least not in a simple way that I'm aware of), we can ensure these generated sources get adjusted to at least reference locations under one of the concrete build directories (I've chosen '..._debug') under which they will be generated.

Testing with --genvslite has revealed that, in some cases, the presence of 'c:\windows\system32;c:\windows' on the 'Path' environment variable (via the make-style project's ExecutablePath element) is critical to getting the 'meson compile ...' build to succeed.  Not sure whether this is some 'find and guess' implicit defaults behaviour within meson or within the MSVC compiler that some projects may rely on. Feels weird but not sure of a better solution than forcibly adding these to the Path environment variable (the Executable Path property of the project).

Added a new windows-only test to windowstests.py ('test_genvslite') to exercise the --genvslite option along with checking that the 'msbuild' command invokes the 'meson compile ...' of the build-type-appropriate-suffixed temporary build dir and checks expected program output.

Check and report error if user specifies a non-ninja backend with a 'genvslite' setup, since that conflicts with the stated behaviour of genvslite.  Also added this test case to 'WindowsTests.test_genvslite'

I had problems tracking down some problematic environment variable behaviour, which appears to need a work-around. See further notes on VSINSTALLDIR, in windowstests.py, test_genvslite.
'meson setup --help' clearly states that positional arguments are ... [builddir] [sourcedir].  However, BasePlatformTests.init(...) was passing these in the order [sourcedir] [builddir].  This was producing failures, saying, "ERROR: Neither directory contains a build file meson.build." but when using the correct ordering, setup now succeeds.

Changed regen, run_tests, and run_install utility projects to be simpler makefile projects instead, with commands to invoke the appropriate '...meson.py --internal regencheck ...' (or install/test) on the '[builddir]_[buildtype]' as appropriate for the curent VS configuration.  Also, since the 'regen.vcxproj' utility didn't work correctly with '--genvslite' setup build dirs, and getting it to fully work would require more non-trivial intrusion into new parts of meson (i.e. '--internal regencheck', '--internal regenerate', and perhaps also 'setup --reconfigure'), for now, the REGEN project is replaced with a simpler, lighter-weight RECONFIGURE utility proj, which is unlinked from any solution build dependencies and which simply runs 'meson setup --reconfigure [builddir]_[buildtype] [srcdir]' on each of the ninja-backend build dirs for each buildtype.
Yes, although this will enable the building/compiling to be correctly configured, it can leave the solution/vcxprojs stale and out-of-date, it's simple for the user to 'meson setup --genvslite ...' to fully regenerate an updated, correct solution again. However, I've noted this down as a 'fixme' to consider implementing the full regen behaviour for the genvslite case.

* Review feedback changes -
- Avoid use of 'captured_compile_args_per_buildtype_and_target' as an 'out' param.
- Factored a little msetup.py, 'run(...)' macro/looping setup steps, for genvslite, out into a 'run_genvslite_setup' func.

* Review feedback:  Fixed missing spaces between multi-line strings.

* 'backend_name' assignment gets immediately overwritten in 'genvslite' case so moved it into else/non-genvslite block.

* Had to bump up 'test cases/unit/113 genvslites/...' up to 114; it collided with a newly added test dir again.

* Changed validation of 'capture' and 'captured_compile_args_...' to use MesonBugException instead of MesonException.

* Changed some function param and closing brace indentation.
2023-06-28 15:29:57 +03:00