aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
AgeCommit message (Collapse)AuthorFilesLines
2021-03-13Use find_program also in add_*_script for consistency.progrefactorJussi Pakkanen1-18/+2
2021-03-13Use find_program also in custom_target for consistency.Jussi Pakkanen1-0/+3
2021-03-12interpreter: Cache found dependency before converting for include_typeXavier Claessens1-7/+7
Fixes: #8516.
2021-03-06Refactor subdir visitation to track files instead of dirs.Jussi Pakkanen1-3/+4
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-44/+44
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04various python neatness cleanupsEli Schwartz1-10/+10
All changes were created by running "pyupgrade --py3-only --keep-percent-format" and committing the results. I have not touched string formatting for now. - use set literals - simplify .format() parameter naming - remove __future__ - remove default "r" mode for open() - use OSError rather than compatibility aliases - remove stray parentheses in function(generator) scopes
2021-03-04Simplify module APIXavier Claessens1-87/+31
- ModuleState is now a real class that will have methods in the future for actions modules needs, instead of using interpreter internal API. - New ModuleObject base class, similar to InterpreterObject, that should be used by all objects returned by modules. Its methods gets the ModuleState passed as first argument. It has a `methods` dictionary to define what is public API that can be called from build definition. - Method return value is not required to be a ModuleReturnValue any more, it can be any type that interpreter can holderify, including ModuleObject. - Legacy module API is maintained until we port all modules. In the future modules should be updated: - Use methods dict. - Remove snippets. - Custom objects returned by modules should all be subclass of ModuleObject to get the state iface in their methods. - Modules should never call into interpreter directly and instead state object should have wrapper API. - Stop using ModuleReturnValue in methods that just return simple objects like strings. Possibly remove ModuleReturnValue completely since all objects that needs to be processed by interpreter (e.g. CustomTarget) should be created through ModuleState API.
2021-03-04interpreter: Fix process_new_values()Xavier Claessens1-7/+3
It should recurse on lists and does not need to return a value.
2021-02-27install_man locale supportJason Woodward1-2/+7
Rather than having to manually build the locale aware man paths with `install_data('foo.fr.1', install_dir: join_paths(get_option('mandir'), 'fr', 'man1'), rename: 'foo.1')` Support doing `install_man('foo.fr.1', locale: 'fr')`
2021-02-26interpreter: Clean up and simplify/optimize get_(external|cross)_propertyDylan Baker1-39/+20
These are both way more compilcated than they needed to be, this is a much simpler implementation, and is shared between cross and external properies.
2021-02-26interpreter: correctly track whether a subproject is initializedDylan Baker1-1/+5
The way the tracking is currently done it works if no new subprojects are added to a configured build directory. For cases where we want to add a new subproject, it fails because we don't initialize builtins for that subproject. This corrects that by checking to see if the subproject already exists, and if it doesn't initializes the bultins for it. Fixes: #8421
2021-02-26Allow printing UserOptions in the summaryStephen Gregoratto1-0/+3
2021-02-26meson: add .has_external_property() methodsTim-Philipp Müller1-0/+10
Useful in case of boolean values to distinguish between a boolean value having been set in the native/cross file and not having been provided, which can't be achieved by passing a fallback parameter to .get_external_property().
2021-02-25deprecated `meson.get_cross_property`Dylan Baker1-0/+1
It's a pure subset of `get_external_property`, and has odd behavior in host == build configurations. `get_external_property` is clear, and uses the standard `native : bool` syntax to control host vs build properties
2021-02-25interpreter: stop using hasattr for held_objectDylan Baker1-10/+4
We have unholder or isinsatnce(ObjectHolder) for that
2021-02-25interpreter: Fix ObjectHolder usageDylan Baker1-48/+52
2021-02-25Support multiple args in error()Xavier Claessens1-23/+12
Seems it got forgotten when that was added to warnings() and message(). Fixes: #8414.
2021-02-22minstall: Add --skip-subprojects optionXavier Claessens1-8/+12
By default all subprojects are installed. If --skip-subprojects is given with no value only the main project is installed. If --skip-subprojects is given with a value, it should be a coma separated list of subprojects to skip and all others will be installed. Fixes: #2550.
2021-02-17Do not validate options when finding non-matchingDylan Baker1-5/+2
This is a) useless because it's only used to print which options are not default, and b) harmful because it can result in cases where things break, like in projects that set a standard that the chosen compiler doesn't support, but the project (or some subset) can be built with a different standard. Fixes: #8360
2021-02-07Merge pull request #8162 from dcbaker/wip/2021-01/rust-module-bindgenJussi Pakkanen1-4/+2
Add a wrapper to the rust module for bindgen
2021-02-07Merge pull request #8288 from bonzini/test-setup-exclude-suitesJussi Pakkanen1-2/+5
introduce add_test_setup(exclude suites: ...) keyword argument
2021-02-07Merge pull request #8305 from xclaesse/run-target-envJussi Pakkanen1-3/+4
run_target: Add env kwarg
2021-02-06interpreter: Add annotations for CustomTargetHolderDylan Baker1-1/+1
needed in the rust module
2021-02-06Add a method to IncludeDirs to convert to string listDylan Baker1-3/+1
I'm going to use this in the rust module as well, so having a single source of truth is useful.
2021-02-06interpreter: use noPosArgs and noKwargs instead of opencodingDylan Baker1-8/+6
2021-02-05run_target: Add env kwargXavier Claessens1-3/+4
Re-implement it in backend using the same code path as for custom_target(). This for example handle setting PATH on Windows when command is an executable.
2021-02-04Introduce `fs.read` to read a file as a stringLuke Drummond1-1/+1
Following #7890, this patch introduces the ability to read the contents of a file to the fs module. This patch introduces the ability to read files at configure time, but has some restrictions: - binary files are not supported (I don't think this will prove a problem, and if people are wanting to do something with binary files, they should probably be shelling out to their own script). - Only files outside the build directory allowed. This limitation should prevent build loops. Given that reading an arbitrary file at configure time can affect the configuration in almost arbitrary ways, meson should force a reconfigure when the given file changes. This is non-configurable, but this can easily be changed with a future keyword argument.
2021-02-02interpreter, mtest: introduce add_test_setup(exclude_suites: ...)Paolo Bonzini1-2/+5
This new keyword argument makes it possible to run specific test setups only on a subset of the tests. For example, to mark some tests as slow and avoid running them by default: add_test_setup('quick', exclude_suites: ['slow'], is_default: true) add_test_setup('slow') It will then be possible to run the slow tests with either `meson test --setup slow` or `meson test --suite slow`.
2021-01-30add_install_script: add skip_if_destdir kwargXavier Claessens1-1/+6
It is common, at least in GNOME projects, to have scripts that must be run only in the final destination, to update system icon cache, etc. Skipping them from Meson ensures we can properly log that they have not been run instead of relying on such scripts to to it (they don't always).
2021-01-30Fix executable as script on WindowsXavier Claessens1-9/+6
On Windows this would fail because of missing DLL: ``` mylib = library(...) exe = executable(..., link_with: mylib) meson.add_install_script(exe) ``` The reason is on Windows we cannot rely on rpath to find libraries from build directory, they are searched in $PATH. We already have all that mechanism in place for custom_target() using ExecutableSerialisation class, so reuse it for install/dist/postconf scripts too. This has bonus side effect to also use exe_wrapper for those scripts. Fixes: #8187
2021-01-29Can read project version from a file.Jussi Pakkanen1-4/+24
2021-01-27intepreter: Allow using file objects for the script_name of add_*_scriptDylan Baker1-8/+20
It's a bit silly and conveluted to have to call find_program on the output of configure_file, so let's just allow passing files as the script name.
2021-01-27custom_target: Add env kwargXavier Claessens1-1/+4
2021-01-27test: Make timeout <= 0 infinite duractionXavier Claessens1-2/+6
2021-01-21interpreter: accept external programs and dependencies for summaryPaolo Bonzini1-7/+11
2021-01-21mlog: add __len__ to AnsiDecoratorPaolo Bonzini1-9/+1
2021-01-14Merge pull request #8192 from dcbaker/submit/minstall-type-annotationsJussi Pakkanen1-28/+31
Add type annotations to minstall (and some related cleanups)
2021-01-13build/interpreter: Split InstallDir to fix layering violationDylan Baker1-22/+18
Currently InstallDir is part of the interpreter, and is an Interpreter object, which is then put in the Build object. This is a layering violation, the interperter should have a Holder for build data. This patch fixes that.
2021-01-13build/interperter: Add annotations and move input validation to interpreterDylan Baker1-6/+13
This moves the user input validation to the interpreter, instead of being in the build module, and adds type annotations.
2021-01-13Fix misspellsAntonin Décimo1-1/+1
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-12summary: align left, not align middleEli Schwartz1-2/+2
aligning along the left is, I think, what most projects want to do. Aligning along the middle looks subjectively ugly, and objectively prevents me from further indenting an element, e.g. Build information: prefix : /usr sysconfdir : /etc conf file : /etc/myprogram.conf
2021-01-12Interpreter: Fix nested subsubproject detectionXavier Claessens1-35/+13
A sub-subproject can be configured directly from `subprojects/foo/subprojects/bar/` in the case `bar` is in the same git repository as `foo` and not downloaded separately into the main project's `subprojects/`. In that case the nested subproject violation code was wrong because it is allowed to have more than one "subprojects" in path (was not possible before Meson 0.56.0). Example: - self.environment.source_dir = '/home/user/myproject' - self.root_subdir = 'subprojects/foo/subprojects/bar' - project_root = '/home/user/myproject/subprojects/foo/subprojects/bar' - norm = '/home/user/myproject/subprojects/foo/subprojects/bar/file.c' We want `norm` path to have `project_root` in its parents and not have `project_root / 'subprojects'` in its parents. In that case we are sure `file.c` is within `bar` subproject.
2021-01-05interpreter: split code that creates a Test instanceDylan Baker1-5/+8
For modules to make use of, as they're not allowed to modify the Build instance directly.
2021-01-05interpreter: allow modules to create testsDylan Baker1-0/+2
2021-01-05mtest: Add support for rust unit testsDylan Baker1-2/+2
Rust has it's own built in unit test format, which is invoked by compiling a rust executable with the `--test` flag to rustc. The tests are then run by simply invoking that binary. They output a custom test format, which this patch adds parsing support for. This means that we can report each subtest in the junit we generate correctly, which should be helpful for orchestration systems like gitlab and jenkins which can parse junit XML.
2021-01-04fix LGTM warningsDylan Baker1-1/+0
2021-01-04Use a single coredata dictionary for optionsDylan Baker1-39/+38
This patches takes the options work to it's logical conclusion: A single flat dictionary of OptionKey: UserOptions. This allows us to simplify a large number of cases, as we don't need to check if an option is in this dict or that one (or any of 5 or 6, actually).
2021-01-04use OptionKey for builtin and base optionsDylan Baker1-28/+15
I would have prefered to do these seperatately, but they are combined in some cases, so it was much easier to convert them together. this eliminates the builtins_per_machine dict, as it's duplicated with the OptionKey's machine parameter.
2021-01-04move OptionKey to mesonlibDylan Baker1-1/+1
There's starting to be a lot of things including coredata that coredata needs to itself include. putting it in mesonlib makes more sense
2021-01-04use OptionKey for compiler_optionsDylan Baker1-5/+11