Commit Graph

966 Commits

Author SHA1 Message Date
Jussi Pakkanen fe4ddb5268 Warn when grabbing internals of subprojects with include_directories. 2021-03-17 15:10:30 +02:00
Xavier Claessens a45f939092 Add range() function
Fixes: #5026.
2021-03-16 20:50:16 -04:00
Paolo Bonzini 5cd7f5f8c5 msetup: do not print bogus "Option ... is:" messages
get_non_matching_default_options is checking a string from
project_default_options against a validated value from
coredata.options.

Passing the string to validate_value ensures that the comparison
is sound; otherwise, "false" might be compared against False
and a bogus difference is printed.
2021-03-16 09:35:48 -04:00
Xavier Claessens 598e968993 Add `meson devenv` command and meson.add_devenv() 2021-03-16 09:00:50 -04:00
Xavier Claessens e0fcccc6e2 EnvironmentVariables: Simplify and annotate 2021-03-16 09:00:50 -04:00
Jussi Pakkanen be86199221 Fix run_targets running scripts from different subdirs. 2021-03-14 13:17:19 +02:00
Xavier Claessens 1f3bf0f135 interpreter: Cache found dependency before converting for include_type
Fixes: #8516.
2021-03-12 22:08:33 +01:00
Jussi Pakkanen fcbab5948c Refactor subdir visitation to track files instead of dirs. 2021-03-06 13:11:20 +02:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
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-04 17:11:26 -05:00
Xavier Claessens ba9bfd2bd8 Simplify module API
- 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-04 11:33:22 -05:00
Xavier Claessens 1e69908be5 interpreter: Fix process_new_values()
It should recurse on lists and does not need to return a value.
2021-03-04 11:33:22 -05:00
Jason Woodward 50af09de03 install_man locale support
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-27 14:35:23 +02:00
Dylan Baker 219535aad4 interpreter: Clean up and simplify/optimize get_(external|cross)_property
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-26 15:31:15 -08:00
Dylan Baker e079553959 interpreter: correctly track whether a subproject is initialized
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-26 09:05:30 -08:00
Stephen Gregoratto ec5fe58e6d Allow printing UserOptions in the summary 2021-02-26 10:28:00 -05:00
Tim-Philipp Müller ace22f21a7 meson: add .has_external_property() methods
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-26 10:15:17 -05:00
Dylan Baker aa4efc709e deprecated `meson.get_cross_property`
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-25 15:18:39 -08:00
Dylan Baker eba9535428 interpreter: stop using hasattr for held_object
We have unholder or isinsatnce(ObjectHolder) for that
2021-02-25 23:08:23 +02:00
Dylan Baker 69c22181f7 interpreter: Fix ObjectHolder usage 2021-02-25 23:08:23 +02:00
Xavier Claessens cef5cab23c Support multiple args in error()
Seems it got forgotten when that was added to warnings() and message().

Fixes: #8414.
2021-02-25 22:58:45 +02:00
Xavier Claessens 2fabd4c7dc minstall: Add --skip-subprojects option
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-22 23:03:55 +02:00
Dylan Baker 867963f131 Do not validate options when finding non-matching
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-17 14:51:26 +02:00
Jussi Pakkanen a855bcab1c
Merge pull request #8162 from dcbaker/wip/2021-01/rust-module-bindgen
Add a wrapper to the rust module for bindgen
2021-02-07 16:57:39 +00:00
Jussi Pakkanen 034b81a09f
Merge pull request #8288 from bonzini/test-setup-exclude-suites
introduce add_test_setup(exclude suites: ...) keyword argument
2021-02-07 12:03:10 +00:00
Jussi Pakkanen 8b82ffa9e4
Merge pull request #8305 from xclaesse/run-target-env
run_target: Add env kwarg
2021-02-07 11:46:41 +00:00
Dylan Baker 9d441d26d2 interpreter: Add annotations for CustomTargetHolder
needed in the rust module
2021-02-06 10:27:04 -08:00
Dylan Baker 5f624657a0 Add a method to IncludeDirs to convert to string list
I'm going to use this in the rust module as well, so having a single
source of truth is useful.
2021-02-06 10:27:04 -08:00
Dylan Baker bb2124084d interpreter: use noPosArgs and noKwargs instead of opencoding 2021-02-06 13:11:25 -05:00
Xavier Claessens 522392e755 run_target: Add env kwarg
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-05 17:53:09 -05:00
Luke Drummond 46e3480f7c Introduce `fs.read` to read a file as a string
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-04 17:34:11 +00:00
Paolo Bonzini c7c2bc8db1 interpreter, mtest: introduce add_test_setup(exclude_suites: ...)
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-02-02 11:23:33 +01:00
Xavier Claessens 6c6b5d77d6 add_install_script: add skip_if_destdir kwarg
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-30 21:28:21 +00:00
Xavier Claessens 0626465ea8 Fix executable as script on Windows
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-30 09:51:06 +00:00
Jussi Pakkanen 3f0a0c1582 Can read project version from a file. 2021-01-29 16:42:59 +00:00
Dylan Baker f808c955ea intepreter: Allow using file objects for the script_name of add_*_script
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-27 21:59:55 +00:00
Xavier Claessens 633264984b custom_target: Add env kwarg 2021-01-27 09:00:54 -05:00
Xavier Claessens e4137ae3ec test: Make timeout <= 0 infinite duraction 2021-01-27 08:26:20 -05:00
Paolo Bonzini adb1b2f3f6 interpreter: accept external programs and dependencies for summary 2021-01-21 08:54:35 -05:00
Paolo Bonzini 021068a8b7 mlog: add __len__ to AnsiDecorator 2021-01-21 08:54:35 -05:00
Jussi Pakkanen 4b3d48a8c9
Merge pull request #8192 from dcbaker/submit/minstall-type-annotations
Add type annotations to minstall (and some related cleanups)
2021-01-14 15:17:49 +00:00
Dylan Baker e36aca42d0 build/interpreter: Split InstallDir to fix layering violation
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-13 13:32:48 -08:00
Dylan Baker 022632c91b build/interperter: Add annotations and move input validation to interpreter
This moves the user input validation to the interpreter, instead of
being in the build module, and adds type annotations.
2021-01-13 13:32:48 -08:00
Antonin Décimo 39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Eli Schwartz adfcf77109
summary: align left, not align middle
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-12 19:19:00 -05:00
Xavier Claessens c659be6928 Interpreter: Fix nested subsubproject detection
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-12 15:51:28 +00:00
Dylan Baker b2c2549b93 interpreter: split code that creates a Test instance
For modules to make use of, as they're not allowed to modify the Build
instance directly.
2021-01-05 10:23:57 -08:00
Dylan Baker 8d19beccb2 interpreter: allow modules to create tests 2021-01-05 10:23:57 -08:00
Dylan Baker d89ec98b47 mtest: Add support for rust unit tests
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-05 10:23:41 -08:00
Dylan Baker a539fda0cf fix LGTM warnings 2021-01-04 12:20:59 -08:00