Commit Graph

418 Commits

Author SHA1 Message Date
Eli Schwartz 14b2457627 flake8: fix warnings for unused imports
This is supposed to expose all primitives together, but to do that we
need to actually "use" each variable in `__all__`, which we... didn't.
Sorry about that.
2022-08-29 23:32:43 +03:00
Eli Schwartz ff7d86d05f flake8: fix unnecessary f-strings without any format placeholders
These can just be ordinary strings.
2022-08-29 23:32:43 +03:00
Eli Schwartz 520bb7abbc flake8: fix lingering whitespace errors 2022-08-29 23:32:43 +03:00
Alf Henrik Sauge 28dff2ca6d Fix indentation issues reported by flake8, requiring code restructuring
Strictly speaking code restructuring isn't needed, but making this PEP8
compliant results in indentation of the code that reduces the
readability. By moving the offending code on the outside of the method
call, the readability is maintained.
2022-08-26 17:12:40 -04:00
Alf Henrik Sauge 06bf9a5cda Fix purely white space issues reported by flake8 2022-08-26 17:12:40 -04:00
Eli Schwartz f8ebfdf7b1
install modes should not apply sticky bit to files
This is generally a bad idea, e.g. it causes OSError on freebsd.

It also gets ignored by solaris and thus causes unittest failures.

The proper solution is to simply reject any attempt to set this, and log a
warning.

The install_emptydir function does apply the mode as well, and since it
is a directory it actually does something. This is the only place where
we don't reset the mode.

Although install_subdir also installs directories, and in theory it
could set the mode as well, that would be a new feature. Also it doesn't
provide much granularity and has mixed semantics with files. Better to
let people use install_emptydir + install_subdir.

Fixes #5902
2022-08-23 21:07:00 -04:00
Xavier Claessens 75b8dc5c9e pkgconfig: Variables can be a single string
It used to be listified and libxml2 wrap relies on that.
2022-08-23 08:13:55 -04:00
Eli Schwartz 3e73d4d77d
introspection: untangle install_plan implemetation, fix a bunch of wrong ones
Generally plumb through the values of get_option() passed to
install_dir, and use this to establish the install plan name. Fixes
several odd cases, such as:

- {datadir} being prepended to "share" or "include"

- dissociating custom install directories and writing them out as
  {prefix}/share/foo or {prefix}/lib/python3.10/site-packages

This is the second half of #9478
Fixes #10601
2022-08-22 14:15:22 -04:00
Eli Schwartz e19e9ce6f1
interpreter: add a special class to track the lifecycle of get_option() strings 2022-08-22 11:46:34 -04:00
Dylan Baker e84f293f67 modules/pkgconfig: Use typed_kwargs 2022-08-18 21:57:36 -04:00
Dylan Baker 991baf56e9 modules/fs: Replace configure_file(copy:) with fs.copyfile
`configure_file` is both an extremely complicated implementation, and
a strange place for copying. It's a bit of a historical artifact, since
the fs module didn't yet exist. It makes more sense to move this to the
fs module and deprecate this `configure_file` version.

This new version works at build time rather than configure time, which
has the disadvantage it can't be passed to `run_command`, but with the
advantage that changes to the input don't require a full reconfigure.
2022-08-18 16:53:36 -04:00
Dylan Baker 429e7c1edc interpreter: deprecate the ability import unstable modules as `unstable_*`
This was never meant to work, it's an implementation detail of using
`importlib.import_module` and that our modules used to be named
`unstable_` that this ever worked.
2022-08-17 16:25:36 -04:00
Dylan Baker a78992dd81 interpreter: move handling of module stability to interpreter
Thanks to `ModuleInfo`, all modules are just named `foo.py` instead of
`unstable_foo.py`, which simplifies the import method a bit. This also
allows for accurate FeatureNew/FeatureDeprecated use, as we know when
the module was added and if/when it was stabilized.
2022-08-17 16:25:36 -04:00
Dylan Baker 6843f56f6b modules: use module level information about new and deprecation
Instead of using FeatureNew/FeatureDeprecated in the module.

The goal here is to be able to handle information about modules in a
single place, instead of having to handle it separately. Each module
simply defines some metadata, and then the interpreter handles the rest.
2022-08-17 16:25:36 -04:00
Eli Schwartz 33a5352e3c
make add_project_dependencies respect build version of include dirs
Fixes #10695
2022-08-15 23:27:27 -04:00
Daniel Mensinger ca40dda146 cmake: Add rule relaxations for CMake subprojects
fixes #10566
2022-08-10 22:24:02 -04:00
Dylan Baker 84d06a8f4b interpreter: Add return type to func_dependency 2022-07-17 12:58:17 -04:00
Eli Schwartz e7d87b6f58
implement the new preserve_path kwarg for install_data too
Primarily interesting to me because it is then available for the python
module's install_sources method.

Based on the new feature in install_headers.
2022-07-08 01:58:23 -04:00
Eli Schwartz b89451847a
fix incorrect type annotation
In my attempts at actually using this, I discovered that no, it actually
does take None.
2022-07-08 01:56:14 -04:00
Ralf Gommers 17936686d4 Improve error message for `include_directories(abs_path_intree)`
This error message was quite confusing when triggered by
use of an absolute path to the include dir of an external dependency
(numpy in my case). Changing that to a relative dir also isn't
a solution, because Meson will *not* do the "busywork to make paths
work" that the error message says it will.
2022-07-06 15:17:01 -04:00
Eli Schwartz b05d7db443
fix type checking for declare_dependency to allow linking to executable
We have to handle this, because Windows needs to link to the implib of
the executable (???) in order to create a shared module. This is
explicitly checked for and handled in the backend, and creating a build
target with `link_with: some_exe` still works, even. But updating
declare_dependency to typed_kwargs neglected to take that into account,
so creating a convenience interface for those same arguments failed.
2022-06-21 16:42:06 -04:00
Eli Schwartz 47426f3663
migrate declare_dependency to typed_kwargs 2022-06-17 14:33:02 -04:00
Eli Schwartz ca52dac38b
refactor logic for parsing dependency variables into type_checking module
We will momentarily use this to implement typed_kwargs, but not for all
usage sites.
2022-06-17 14:33:02 -04:00
Eli Schwartz edb38fd6f6
fix confusing incorrect default name for a KwargInfo
We can use this lots of places, and it's always the same kwarg. There
doesn't seem to be a point in naming it badly, then evolving it to the
standard name in the one place it is currently used. This made it not
shareable.
2022-06-17 14:33:01 -04:00
Hemmo Nieminen b49b9f52b2 interpreter: fix a subproject check with symlinks
The check for whether or not a file is allowed to be accessed from a
subproject fails if the subproject is accessed via a symlink. Use the
absolute path of the subproject without resolving symlinks to fix the
check.

Extend unit test 106 to check for this in the future.
2022-06-17 14:18:05 -04:00
Michael Mera 9b21428006 fix parameter expansion in several error messages
At several points in the code base, f-strings are not correctly expanded
due to missing 'f' string prefix. This fixes all the occurrences I could
find.
2022-06-17 12:16:42 -04:00
Xavier Claessens d85a9733e6 Fix crash when a reconfigure adds a new subproject
When a subproject is disabled on the initial configuration we should not
add it into self.coredata.initialized_subprojects because that will
prevent calling self.coredata.init_builtins() on a reconfigure if the
subproject gets enabled.

Fixes: #10225.
2022-06-14 16:01:20 -04:00
Eli Schwartz 462b35e4b1 flake8: fix various whitespace nits 2022-06-13 13:34:39 +03:00
Eli Schwartz f380862284
add Feature checks for install_subdir creating an empty directory
Most importantly, tell people it's broken and to stop using it for
0.62.0
2022-06-10 17:56:02 -04:00
Dylan Baker b69d4f38e6 interpreter/kwargs: fix typo 2022-06-08 19:18:03 -04:00
Dylan Baker 27bde338fb interpreter: add missing type annotation 2022-06-01 22:49:10 -04:00
Dylan Baker 2e5a2f6a48 interpreter: add location to a FeatureNew call 2022-06-01 22:49:10 -04:00
Dylan Baker 618b187f70 interpreter: use a shared KwargInfo for install_dir
CustomTarget allows multiple install dirs, while basically everything
else allows only one. So this provides a shared instance for that.
2022-06-01 22:49:10 -04:00
Vili Väinölä 18e2f8b2b3 Fix sandbox violation when using subproject as a symlink
Fix "Tried to grab file outside current (sub)project" error when subproject exists within
a source tree but it is used through a symlink. Using subprojects as symlinks is very useful
feature when migrating an existing codebase to meson that all sources do not need to be
immediately moved to subprojects folder.
2022-06-01 12:32:53 -07:00
Eli Schwartz 52d01dbf38
rename a badly named KwargInfo
CT_OUTPUT_KW is the same OUTPUT_KW we use in lots of places. The most
distinctive thing about it is not that it's part of custom_target
(basically any other function that uses such a kwarg follows the same
rules due to using CustomTarget under the hood), but the fact that it
takes multiple outputs.
2022-05-31 17:49:29 -04:00
Eli Schwartz e3d70d89b1
fix regression that broke type checking of CustomTarget outputs
We validate a few things here, such as the non-presence of '@INPUT' in
an output name. These got moved out of the CustomTarget constructor in
commit 11f9638035 and into KwargInfo, but
only for kwargs that took multiple values. This caused configure_file()
and unstable_rust.bindgen() to stop checking for this.

Add a shared single-output KW and use it in both places. This now
dispatches to _output_validator.

configure_file now validates subdirectories in output names the same way
we do elsewhere, directly in the typed_kwargs and by specifying the
erroring kwarg.
2022-05-31 17:49:29 -04:00
Eli Schwartz ae0b40945b
make sure no custom_target outputs are named "all" or "meson-internal__*"
Or any other reserved names. We check in add_target that the primary
name of any build target isn't on the forbidden list, but custom_target
allows names that are distinct from the output filenames, so we need to
check those too.

We would eventually still error out all the way at the end, with:

```
ERROR: Multiple producers for Ninja target "all". Please rename your targets.
```

But, if we can check that early and provide the underlying reason
(reserved name) alongside actually useful debugging info (a line
number), then why not?

Refactor the check into a small helper function in the process.
2022-05-31 17:49:29 -04:00
Eli Schwartz 38c00feb9d
relax target name restrictions to cater to internal use
We don't want to allow targets that conflict with:
- our aliased meson-* targets for phony commands
- any meson-*/ directories we create for internal purposes

We do want to allow targets such as:
- our own meson-*.X manpages

There are a couple routes we could take.

Using a better restriction, such as `meson-internal__*`, is trivially
done for our aliased targets, but changing directory names is...
awkward. We probably cannot do this, and doing the former but not the
latter is not very useful.

We could also carefully allow patterns we know we won't use, such as
file extensions, but which the manpages need, which works for our
directories and for many aliased targets, but run_target() is
user-specified and can be anything.

Use a hybrid approach to cover both use cases. We will now allow target
names that fulfill *all* the following criteria:
- it begins with "meson-"
- it doesn't continue with "internal__"
- it has a file extension
2022-05-31 17:49:29 -04:00
Florian "sp1rit"​ ad8f24f232 Implement `preserve_path` for install_headers
The `install_headers` function now has an optional argument
`preserve_path` that allows installing multi-directory
headerfile structures that live alongside sourcecode with a
single command.

For example, the headerfile structure

headers = [
  'one.h',
  'two.h',
  'alpha/one.h',
  'alpha/two.h',
  'alpha/three.h'
  'beta/one.h'
]

can now be passed to `install_headers(headers, subdir: 'mylib', preserve_path: true)`
and the resulting directory tree will look like

{prefix}
└── include
    └── mylib
        ├── alpha
        │   ├── one.h
        │   ├── two.h
        │   └── three.h
        ├── beta
        │   └── one.h
        ├── one.h
        └── two.h

Fixes #3371
2022-05-30 18:03:01 -04:00
Eli Schwartz 37fea63033 fix invalid type for default_options
We have two checks for the type accepted here. One is the basic
typed_kwargs type-checking, which declares it accepts:

  str | include_directories

The other is the custom validator which further narrows it to strings
with certain option-like properties (needs to be an = assignment).

The former is obviously wrong, which doesn't really matter all that much
but still isn't very nice...

Introduced in commit f34013fb08.
2022-05-30 12:26:19 -04:00
Eli Schwartz 194c28297f fix incorrectly allowed kwarg for custom_target
override_options makes no sense for custom_target as we don't use it for
anything. Also, this was added in commit c3c30d4b06
despite not being allowed in permittedKwargsc3c30d4b0.

For inexplicable reasons, we had a known_kwargs for custom_target that
looped over kwargs and issued a warning, not an error, for unknown
kwargs. It was impossible to ever hit that check to begin with, though,
ever since commit e08d735105 which added
permittedKwargs and obsoleted those manual checks with real errors.

So at one point override_options was specially permitted to be used
without emitting a warning, and then for about half a decade it was an
error, and then based on some dead code it was allowed again for a bit.
But through all this it doesn't do anything and isn't documented.
2022-05-30 12:26:19 -04:00
Eli Schwartz fda4c49c34
fix custom_target crash if boolean true is specified in install_dir
We accept boolean false to indicate "do not install this one particular
output", but the type checking simply checked if it is a bool. We do
this correctly for configure_file, so copy the same validator from
there.
2022-05-26 17:42:14 -04:00
Xavier Claessens 9b9154017e Make a copy of auto_features options when changing its name
This fixes bogus messages "skipped: feature foo disabled" when
auto_features=disabled. It was reporting the name of the latest
get_option() call instead of the name of the current feature option.

This is especially visible in GStreamer summary where it should show a
different option name for every subproject but instead shows "tools"
everywhere:
```
  Subprojects
    gst-devtools              : NO Feature 'tools' disabled
    gst-editing-services      : NO Feature 'tools' disabled
    ...
```
2022-05-25 22:52:30 -04:00
Dylan Baker 8f68f5435d interpreter: add type restrictions to declare_dependency link_whole
Including that we don't accept SharedLibraries or CustomTarget[Index]s
that are a shared library
2022-05-25 22:41:03 -04:00
Dylan Baker 5926190cbb interpreter: add annotations to extract_variables 2022-05-25 22:41:03 -04:00
Daniel Mensinger 7ef73e8f6a ast: cmake: Generate line numbers while printing the AST for better debugging 2022-05-24 18:00:49 -04:00
Peter Eisentraut 8e4fecdd0f Tweak "header has symbol" message
Change message

    Header <foo.h> has symbol "BAR"

to

    Header "foo.h" has symbol "BAR"

with the first part also now in bold.  This is more consistent with
other messages like

    Has header "foo.h"

and

    Checking whether type "foo" has member "bar"
2022-05-24 20:18:19 +03:00
Eli Schwartz 950fd06bc3 fix traceback when run_command has a find_program as the inline arg
We were poking directly at the node, so if it was a FunctionNode then
this broke. Instead, just do a reverse lookup in the overrides table to
get the original find_program name.
2022-05-24 20:16:16 +03:00
Dylan Baker d97d3721a3 interpreter: Add another overload to source_strings_to_files
Which doesn't have `StructuredSources`, as is actually quite common.
2022-05-23 23:32:47 -04:00
Eli Schwartz 1c52ac4e15
move various imports into TYPE_CHECKING blocks for neatness 2022-05-23 16:44:08 -04:00