aboutsummaryrefslogtreecommitdiff
path: root/test cases/common
AgeCommit message (Collapse)AuthorFilesLines
2023-08-05compiler: Add required keyword to has_* methodsXavier Claessens2-0/+68
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-04Add default_options argument to find_program()Nomura5-0/+20
2023-08-02Unify message(), format() and fstring formattingXavier Claessens3-0/+49
Share a common function to convert objects to display strings for consistency. While at it, also add support for formatting user options.
2023-08-02treewide: internally avoid deprecated machine file uses of "pkgconfig"Eli Schwartz1-1/+1
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 22df45a31981874310a78dde0df59a6a7c5ebb29 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-07-26Fix install_data() default install pathDaniele Nicolodi5-1/+11
This fixes two issues in constructing the default installation path when install_dir is not specified: - inside a subproject, install_data() would construct the destination path using the parent project name instead than the current project name, - when specifying preserve_path, install_data() would construct the destination path omitting the project name. Fixes #11910.
2023-07-14compiler.compiles/links: fix failure when compiling a built File objectEli Schwartz1-5/+12
In order to pass a File object down into the compiler impl and compile it, we cannot pass a string with the filename, and we cannot either pass the File object as-is, since it relies on being given Environment attributes to calculate the relative location. So we build a fresh File object as an absolute path. But the code to do this was totally broken. Instead of using the File method to get an absolute path, we used one that expected to create builddir-relative paths... and then gave it the absolute source dir as the "relative path portion" prefix. This worked by accident as long as it wasn't a built File, but if it was a built file then we intentionally didn't include that prefix -- which was wrong anyway, since we need the build directory! Use the correct method to get an absolute path in all cases, and emit a warning if it was a built file. This never worked. Sometimes it crashed, sometimes it silently returned false. Fixes #11983
2023-07-13Silence some encoding warningsTristan Partin2-4/+4
By specifiying explicit encodings, we can silence warnings like: /__w/meson/meson/test cases/common/100 postconf with args/postconf.py:15: EncodingWarning: 'encoding' argument not specified with open(input_file) as f: in CI.
2023-07-05comp.preprocess(): Do not treat every file as assemblyXavier Claessens2-1/+4
Fixes: #11940
2023-07-04tests: add standard option to get_define() testKacper Michajłow1-0/+10
This properly tests MSVC case which produce different preprocessed output depending on language version.
2023-06-28Condense test directory names for release.Jussi Pakkanen3-0/+0
2023-06-20interpreter: Accept more types in default_options dict valuesXavier Claessens3-0/+27
2023-06-20add str.splitlines methodMartin Dørum1-0/+12
The new splitlines method on str is intended to replace usage of fs.read('whatever').strip().split('\n'). The problem with the .strip().split() approach is that it doesn't have a way to represent empty lists (an empty string becomes a list with one empty string, not an empty list), and it doesn't handle Windows-style line endings.
2023-06-01pkgconfig: Add include directories from internal deps in -uninstalled.pcXavier Claessens6-0/+29
Fixes: #8651
2023-05-31preprocess: Allow preprocessing any file extensionsXavier Claessens1-3/+3
2023-05-21Allow generator.process(generator.process(...))Volker Weißmann4-0/+32
Fixes #1141
2023-05-02python module: add an automatic byte-compilation stepEli Schwartz1-1/+1
For all source `*.py` files installed via either py.install_sources() or an `install_dir: py.get_install_dir()`, produce `*.pyc` files at install time. Controllable via a module option.
2023-04-27Specify c++ 11 flag as code uses c++ 11 featuresPeter Hull1-1/+2
2023-04-18pkgconfig module: fix traceback on invalid missing descriptionEli Schwartz1-0/+9
If the optional first "mainlib" argument is there, then we infer several values. Otherwise, some of those values fall back to a generic default, and two of them -- name and description -- fall back to being mandatory. In commit e84f293f672a372d2434d0ce4fa39d3f902b6ce8, we removed validation for description as part of refactoring that never actually validated anything.
2023-04-14minstall: Fix install_subdir() excludes with path separators on WinDaniele Nicolodi5-0/+10
The paths in meson.build use / as path separator, however, the paths constructed during the directory structure walk use native path separators, thus the path never compare equal to the excluded ones. Normalize the exclusion paths before the comparison.
2023-04-11fix various spelling issuesJosh Soref24-22/+22
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11Change "can not" to "cannot" throughout projectHiPhish5-5/+5
The word "cannot" expresses inability to do something whereas "can not" expresses the ability to refrain from doing something.
2023-04-04propagate the most accurate node to error messagesEli Schwartz1-1/+1
During evaluation of codeblocks, we start off with an iteration of nodes, and then while evaluating them we may update the global self.current_node context. When catching and formatting errors, we didn't take into account that the node might be updated from the original top-level iteration. Switch to formatting errors using self.current_node instead, to ensure we can point at the likely most-accurate actual cause of an error. Also update the current node in a few more places, so that function calls always see the function call as the current node, even if the most recently parsed node was an argument to the function call. Fixes #11643
2023-04-03tests/94 threads: fix build error with clang 16Christoph Reiter1-1/+1
It fails with "incompatible-function-pointer-types" otherwise
2023-03-30tests: add test to ensure that build dir is preferred to src dirBarnabás Pőcze4-1/+7
Extend the "common/include order" test to ensure that the build directory is preferred over the source directory. For example, when using `configure_file()`, the resulting file should be preferred over a file with the same name in the source directory.
2023-03-28test cases: make various things werror-safeEli Schwartz4-4/+9
Allows getting closer to `./run_project_tests.py -- -Dwerror=true`. - when argc and argv are not *both* used, there's a standard, compliant mechanism to mark the variable as unused - generated code should not build as -Werror - more thoroughly comment out some commented code
2023-03-28backends: fix bug where meson_exe crashed if constructed with found programsEli Schwartz2-1/+1
Because we base the pickled data name on the name property of the command being run... and for built targets, `exe.name` is always just the name. However, for an ExternalProgram this is just whatever string we searched for, so, NOT just the basename. This became a bigger issue once we started using generator() with the actual program in commit 6aeec808367f05463394e30a8d40834e97c7afc0, rather than first casting it to a string, because the VS backend *always* uses the meson_exe approach for various reasons related to VS being VS. Outside of that, it's difficult to actually get an ExternalProgram object passed to meson_exe -- CustomTarget lowers it to a string, capture is handled via argparse instead of pickling, etc. Fixes #11593
2023-03-27custom_target: libfoo.so.1 is linkableXavier Claessens1-1/+8
2023-03-11Make generator exe more resilient.Jussi Pakkanen1-2/+10
2023-03-09tests: allow a long test to have more time to complete before timing outEli Schwartz1-2/+2
This test is intended to test really long output, so it prints 100k lines of stdout/stderr. It completes in two seconds on my machine, but the default 30-second timeout is apparently too much for CI, because on Windows we often get flaky tests due to this. e.g. we'll get within 200 lines of the end. Bump the CI time by x2. We know this isn't particularly surprising behavior, and allowing it to request another 30 seconds won't hang the CI. But it will save us from some spurious failures and restarted jobs.
2023-03-09re-deduplicate feature warnings printed at the end of setupEli Schwartz1-1/+1
In commit eaf365cb3ef4f1c2ba66e07237d86a44089aff4f we explicitly sorted them for neatness, with the rationale that we were restoring intentional behavior and we only need a set for stylistic purposes. This actually wasn't true, because we never sorted them to begin with (we did sort the version numbers), but sorting them is fine. The bigger issue is that we actually used a set to avoid printing the same feature type multiple times. Now we do print them multiple times -- because each registered feature includes the unique node. Fix this by using both sorted and a set. Fix tests that should in retrospect have flagged this as an issue, but were added later on in the same series to check something else entirely, happen to cover this too, and were presumably copied directly from stdout as-is...
2023-03-04typed_kwargs: Extend since_values and deprecated_values for typesXavier Claessens1-1/+1
2023-03-01interpreter: report FeatureNew for kwargs to project()Eli Schwartz2-1/+9
We need to know the project minimum version before evaluating the rest of the function. There's three basic approaches: - try to set it inside KwargInfo - just run a minimal version of func_project for this, then load everything after - drop down to the AST and set it before anything else In order to handle FeatureNew emitted by a FunctionNode evaluated before project() due to being inlined, such as `version: run_command()`, only option 3 suffices, the rest all happen way too late. Since we have just added AST handling support for erroring out, we can do that to set the version as well.
2023-03-01interpreter: Add testcase..endtestcase clause supportXavier Claessens2-0/+46
This is currently only enabled when running unit tests to facilitate writing failing unit tests. Fixes: #11394
2023-02-24test cases: use best practices method to find the python3 programEli Schwartz2-2/+2
We do not need the python module's find_installation() for this, as this does various things to set up building and installing python modules (pure python and C-API). This functionality is already tested in the python tests. Elsewhere, when we just need an interpreter capable of running python scripts in order to guarantee a useful scripting language for custom commands, it suffices to use find_program(), which does not run an introspection script or do module imports, and is thus faster and a bit cleaner. Either way, both methods are guaranteed to find the python3 interpreter, deferring to mesonlib.python_command for that guarantee. test "71 summary" can sometimes return the python command with the ".exe" part all uppercased for mysterious Windows reasons. Smooth this over with ExternalProgram.
2023-02-15interpreter: add FeatureOption.enable_if and .disable_ifDylan Baker1-0/+10
This adds two new methods, that are conceptually related in the same way that `enable_auto_if` and `disable_auto_if` are. They are different however, in that they will always replace an `auto` value with an `enabled` or `disabled` value, or error if the feature is in the opposite state (calling `feature(disabled).enable_if(true)`, for example). This matters when the feature will be passed to dependency(required : …)`, which has different behavior when passed an enabled feature than an auto one. The `disable_if` method will be controversial, I'm sure, since it can be expressed via `feature.require()` (`feature.require(not condition) == feature.disable_if(condition)`). I have two defences of this: 1) `feature.require` is difficult to reason about, I would expect require to be equivalent to `feature.enable_if(condition)`, not to `feature.disable_if(not condition)`. 2) mixing `enable_if` and `disable_if` in the same call chain is much clearer than mixing `require` and `enable_if`: ```meson get_option('feat') \ .enable_if(foo) \ .disable_if(bar) \ .enable_if(opt) ``` vs ```meson get_option('feat') \ .enable_if(foo) \ .require(not bar) \ .enable_if(opt) ``` In the first chain it's immediately obvious what is happening, in the second, not so much, especially if you're not familiar with what `require` means.
2023-02-15interpreter: add a feature.enable_auto_ifDylan Baker1-0/+6
It's always been strange to me we don't have an opposite method of the `disable_auto_if` method, but I've been pressed to find a case where we _need_ one, because `disable_auto_if` can't be logically contorted to work. I finally found the case where they're not equivalent: when you don't want to convert to a boolean: ```meson f = get_option('feat').disable_auto_if(not foo) g = get_option('feat').enable_auto_if(foo) dep1 = dependency('foo', required : f) dep2 = dependency('foo', required : g) ```
2023-02-15preprocess: Add dependencies kwargXavier Claessens2-2/+4
2023-02-15preprocess: Allow custom_tgt, custom_idx and generated_listXavier Claessens2-2/+11
It was documented to be supported but only File and str were actually working.
2023-02-14allow install script to run in dry-run modeCharles Brunet2-5/+15
2023-02-01add cc.has_function_attribute('vector_size')Dudemanguy1-0/+1
2023-01-20Deprecate passing strings to non-string optionsDylan Baker4-2/+16
Currently Meson allow the following (Muon does not): ```meson option('foo', type : 'boolean', value : 'true') option('bar', type : 'integer', value : '42') ``` This is possibly a holdover from very old code, but it's a bad idea and we should stop doing it. This deprecation is the first stop on that journey.
2023-01-10backends: Stop passing generator exes to ExecutableSerialisation as stringsDylan Baker3-0/+60
The code below this already handles being passed an Executable or ExternalProgram, and it does it correctly, since it handles host binaries that need an exe_wrapper correctly, while the code in the generator paths doesn't. The xcode backend is, like always, problematic, it doesn't handle things the same way as the ninja and vscode backends, and generates a shell script instead of using meson as a wrapper when needed (it seems likely that just forcing the meson path for xcode would be better). I don't have a working mac to develop a fix for, so I've left a todo comment there. Fixes: #11264
2023-01-04add testcase for declare_dependency(objects: ...)Paolo Bonzini4-0/+30
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-12-27add license_files kwarg to projectEli Schwartz6-3/+10
Hook this up to installed dependency manifests. This is often needed above and beyond just an SPDX string -- e.g. many licenses have custom copyright lines.
2022-12-27tests: fix test that has source code incompatible with modern CEli Schwartz2-1/+12
Delayed until clang 16, -Werror=incompatible-function-pointer-types is the default. GCC 14 is "likely to do the same". See https://wiki.gentoo.org/wiki/Modern_C_porting
2022-12-11fix broken fs.copyfile function that crashed if you tried to use itEli Schwartz2-2/+7
At least, if you tried to use it when passing an install_dir. Because T.Sequence is horrible and we should never use it, and the annotations are a lie that produces bugs. So, fix the annotations on CustomTarget to never allow this to happen again, and also fix the function too. Move some definitions elsewhere inline to satisfy the linter. Fixes #11157
2022-12-06test: Add get_define test with prefix arrayMarvin Scholz1-0/+7
2022-12-05when generating optional utility targets in ninja, skip existing aliases tooEli Schwartz3-2/+8
When auto-generating e.g. a `clang-format` target, we first check to see if the user has already defined one, and if so we don't bother creating our own. We check for two things: - if a ninja target already exists, skip - if a run_target was defined, skip The second check is *obviously* a duplicate of the first check. But the first check never actually worked, because all_outputs was only generated *after* generating all utility rules and actually writing out the build.ninja file. The check itself compares against nothing, and always evaluates to false no matter what. Fix this by reordering the target creation logic so we track outputs immediately, but only error about them later. Now, we no longer need to special-case run_target at all, so we can drop that whole logic from build.py and interpreter.py, and simplify the tracked state. Fixes defining an `alias_target()` for a utility, which tried to auto-generate another rule and errored out. Also fixes doing the same thing with a `custom_target()` although I cannot imagine why anyone would want to produce an output file named `clang-format` (unless clang itself decided to migrate to Meson, which would be cool but feels unlikely).
2022-11-24Fix various spelling errorsDavid Robillard1-2/+2
Found with codespell.
2022-11-06Implement `in` operator on stringXavier Claessens1-0/+3