Commit Graph

3211 Commits

Author SHA1 Message Date
Dylan Baker 450b3db378 modules/rust: Add a test that bindgen drops arguments it shouldn't use
This does require hacking up the test pretty badly, since we need to not
ever pass GCC these invalid values. But it's preferable to writing
another project test I think.

Co-Authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
2023-10-20 20:21:08 +05:30
Nirbheek Chauhan 890dd31cb0 test cases/15 llvm: Skip cmake when llvm == 17.0
There's a bug in the zstd find_package module:
e7fc7540da (r130257253)
2023-10-19 09:43:49 +05:30
Dylan Baker 658fe7243b modules/rust: remove rust_crate_type for test() method
This is required to test non-executable targets when they set an
explicit type.
2023-10-16 17:31:12 -07:00
Tristan Partin c0a5da8649 Use -idirafter when adding Apple framework include paths
System headers will continue to "preempt" the framework headers. This
should allow both <GStreamer/gst/gst.h> and <gst/gst.h>
2023-10-12 05:13:55 +05:30
Xavier Claessens dc329f0f04 interpreter: Add support for cargo subproject 2023-10-09 21:13:58 -04:00
Dylan Baker 013536fcb4 interpreter: add <lang>_(static|shared)_args
Which allow passing arguments specifically to the static or shared
libraries.

For design, this is all handled in the interpreter, by the build layer
the arguments are combined into the existing fields. This limits changes
required in the mid and backend layers
2023-10-09 17:33:48 -04:00
Dylan Baker cbca191948 interpreter: Handle BuildTarget.vala_args as Files in the interpreter
Way back in Meson 0.25, support was added to `vala_args` for Files.
Strangely, this was never added to any other language, though it's been
discussed before. For type safety, it makes more sense to handle this in
the interpreter level, and pass only strings into the build IR.

This is accomplished by adding a `depend_files` field to the
`BuildTarget` class (which is not exposed to the user), and adding the
depend files into that field, while converting the arguments to relative
string paths. This ensures both the proper build dependencies happen, as
well as that the arguments are always strings.
2023-10-09 17:33:48 -04:00
Nomura 3cac6ea545 Add env kwarg in generator.process() 2023-10-05 09:59:43 -07:00
Dudemanguy adb1a360b9 build: use suffix when getting target id for exes
When checking target names, meson explictly forbids having multiple
targets with the same name. This is good, but it is strict and it is
impossible to have targets with the same basename and differing suffixes
(e.g. foo and foo.bin) in the same directory. Allow this for executables
by including the suffix (if it exists) in the interal target id. So foo
would be foo@exe and foo.bin would be foo.bin@exe.
2023-10-05 08:43:38 -07:00
Marvin Scholz 00007e197e test: get_define: do not use assert incorrectly
This should be an error, not an assert as it asserts nothing,
in fact, if this wouldn't error out because of the wrong type
passed to the assert, it would even do the wrong thing.

Follow-up to #12223
2023-10-04 08:15:42 -04:00
Eli Schwartz ecf261330c
tests: fix test case to not import distutils on python 3.12
Testing the correctness of the `modules: ` kwarg can be done with other
guaranteed stdlib modules that are even more guaranteed since they
didn't get deprecated for removal.
2023-10-02 23:53:39 -04:00
Alan Coopersmith 710a753c78 nasm tests: skip asm language test on Solaris & illumos
The code in this test to make Linux system calls is not compatible
with the SunOS kernel system call conventions.
2023-10-02 17:55:00 -04:00
Dylan Baker 32be9bd6de add support for vs_module_defs to Executables
fixes: #9254
2023-09-28 14:35:01 -04:00
Dylan Baker 5421c24ea0 fix using a CustomTargetIndex for vs_module_defs
Because `CustomTargetIndex`es don't have a `subdir` property, but they do
implement the `get_subdir()` method
2023-09-28 14:35:01 -04:00
Lei YU dac25ba9a8 unittest: Fix clang-tidy-fix
The unittest case for `clang-tidy-fix` checks if the whole project is in
git or not, and skips if not.

Fix this by creating a temporary git repo, copy the test files and run
the tests, following how `clang-format` does.

It also reverts some help code introduced in the previous test.

Tested: Verify the test case passes.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
2023-09-28 10:54:39 -04:00
Albert Tang fb6fd5aa17 tests: Skip "withIncludeFile" for PCH on Xcode backend
Xcode always fails here because this makes the PCH not be the first
included header, causing Xcode to ignore it completely. There is no
way around this.
2023-09-26 02:34:45 -04:00
Eli Schwartz c3fe1b046d
tests: fix broken promises with linker scripts
This has never, ever, ever worked. You can get away with it a tiny, tiny
bit, iff you magically assume several things about both internal
implementations, as well as the project source layout and builddir
location.

This can be witnessed by the way using files() was mercilessly tortured
through joining the undefined stringified format value of the file to
the current source dir... because it didn't actually *work*, the
stringified value isn't an absolute path or a builddir-relative one, but
it works as long as you do it from the root meson.build file.

Furthermore, this triggers a deprecation warning if you do it. And using
it for files() is frivolous, the "static map file" case was correct all
along.

Fix the configure_file case to demonstrate the same painful hoops we
must jump through to get custom_target outputs to work correctly.

Fixes #12259
2023-09-25 23:50:40 -04:00
Dylan Baker d5546bdcea rust: apply global, project, and environment C args to bindgen
This means that arguments set via `add_global_arguments`,
`add_project_arguments` and by either the `-Dc_args` or `CFLAGS` are
applied to bindgen as well. This can be important when, among other
things, #defines are set via these mechanisms.

Fixes: #12065
2023-09-25 13:05:04 -07: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
Xavier Claessens 7592003484 Rust: Prevent linking Rust ABI with C library/executable 2023-09-19 13:54:49 -04:00
Xavier Claessens bdf1f3c0e2 Rust: Remove unit test already covered in "rust/4 polyglot" 2023-09-19 13:54:49 -04: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
Xavier Claessens dec85c41a9 Remove get_configtool_variable()
This also makes it more consistent with get_pkgconfig_variable() which
always return empty value instead of failing when the variable does not
exist. Linking that to self.required makes no sense and was never
documented any way.
2023-09-18 13:51:27 -04:00
Xavier Claessens 30d7f506c7 Remove get_pkgconfig_variable()
Make sure that pkgconfig_define is a pair of strings and not a list with
more than 2 strings.
2023-09-18 13:51:27 -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 923b95f3d1 Fix assertion raised with invalid option name
When option name contains more that one dot, it should be detected
earlier to prevent an assert to be raised.

Fixes #11904.
2023-09-13 16:55:38 +05:30
Jussi Pakkanen d2dfef5205
Merge pull request #12152 from bruchar1/ast-preserve-all
Preserve whitespaces and comments in AST
2023-09-12 17:50:13 +03:00
Charles Brunet 57178e8ae7 fix bug with openssl when cmake is missing
Fixes #12098

DependencyFactory was returning a lambda, but it has no log_tried() function
2023-09-12 17:31:32 +05:30
Charles Brunet 14e35b63c0 parser: allow whitespaces and comments in cont_eol
FIXME: another approach would be to consider cont_eol as comment (i.e.
add backslash and whitespaces to the comment regex). In both cases it
works until we want to parse comments separately.

TODO?: handle eol_cont inside a string (to split long string without
breaking lines). Probably a bad idea and better to simply join a
multiline string.
2023-09-11 07:51:19 -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
Nirbheek Chauhan 6cfd2b4d5b Override config-tool get_variable args for qmake 2023-09-08 13:08:05 +05:30
Charles Brunet 204fe3c577 Fix include_directories test for relative path
- On Windows, it was not detected if include directory was an absolute
  path to source directory, because of the mis of path separators.

- In the edgecase the include directory begins with the exact same
  string as the source directory, but is a different directory, it was
  falsely reported as an error.

Fixes #12217.
2023-09-07 23:38:33 -04:00
Xavier Claessens b2654b2d43 Fix crash when installing a vala library and python sources
Installing python sources causes the python module to call
create_install_data() before Ninja backends adds extra outputs to Vala
targets.

Target objects are supposed to be immutable, adding outputs that late is
totally wrong. Add extra vala outputs immediately, but be careful
because the main output is only added later in post_init(). Luckily
the base class already puts a placeholder item in self.outputs for the
main filename so we can just replace self.outputs[0] instead of
replacing the whole list which would contain vala outputs at that stage.
This is surprisingly what SharedLibrary was already doing.
2023-09-07 10:56:37 -04:00
Xavier Claessens 025aea1dab Compiler checks must use per-subproject options
Fixes: #12202
2023-09-07 06:55:07 -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
Ailin Nemui 0e99c076c4 tests: Test extern'd globals on MacOS with the Apple Archiver
This forces the use of the Apple archiver, since that archiver doesn't
add extern'd variables to the symbol table automatically, and instead
requires that ranlib be used. A native file is used to ensure that
Apple's ar is used even in the presence of llvm or gcc in the path with
their superior archivers.

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2023-09-06 10:01:52 -04:00
Charles Brunet 84466b7359 qt module: add include_directories to moc compile
Fixes #12182
2023-09-06 16:56:43 +05:30
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
Charles Brunet cf5adf0c64 add json output format to configure file 2023-08-31 07:52:41 -04:00
Tristan Partin 9cc18c5f7a Re-enable "11 runpath rpath ldlibrarypath"
The bug it was blocked on was fixed in
a0514a7c41.
2023-08-30 20:41:54 -04:00
Charles Brunet 1b1946c4e1 Disable failing test on cygwin due to broken cmake
See https://gitlab.kitware.com/cmake/cmake/-/issues/25200.
2023-08-30 19:30:00 -04:00
Xavier Claessens 8758e1353e ci: Skip gir test on cygwin 2023-08-30 15:46:00 -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
Xavier Claessens 494bdbd334 gnome: Fix crash in gtkdoc and generate_gir in C++ projects
gtkdoc() and generate_gir() methods assumes there is a C compiler, but
pure C++ projects might not add it explicitly.

Fixes: #12162
2023-08-29 13:34:23 -04:00
Xavier Claessens 4eb9c84cf9 include_directories: Always add both source and build dirs
Compiler checks were not adding build dir side, which prevents using
headers generated with configure_file().
2023-08-28 20:18:26 -04:00
Xavier Claessens f720105e24 find_program: Fallback if version mismatch
Fixes: #11797
2023-08-24 18:51:13 -04:00