Commit Graph

74 Commits

Author SHA1 Message Date
Artturin c21b886ba8 dependencies/boost.py: Allow getting `lib_dir` and `include_dir` via pkg-config
`boost_root` doesn't work if lib and include are in different directories like in the `nix` `boost` package.

The `prefix` checking could probably be removed, in 2019 conan (the
reason why the check was added) had `libdir` and `includedir` in its
generated pkg-config file
https://www.github.com/mesonbuild/meson/issues/5438#issuecomment-498761454

If there's no return then boost isn't found for some reason, further
logic is unnecessary in any case if direct paths are passed.

`roots += [Path(boost_lib_dir), Path(boost_inc_dir)]` did not work
2024-06-23 12:30:34 +03:00
Jussi Pakkanen 9a6fcd4d9a Replace direct indexing with named methods. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen c0d86024f5 Rename option variable to optstore to make it unique. 2024-06-14 17:19:53 +03:00
Dylan Baker 80b9b125f4 dependencies/boost: Add new homebrew root
On Apple Silicon the default search path is /opt/homebrew instead of
/usr/local.
2024-04-25 16:07:17 -04:00
Otto Moerbeek 24a96a3c95
On OpenBSD there's no convention the .so numbers equal the boost version.
Skip the check filtering on that condition.
2024-04-06 21:34:24 -04:00
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.

This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.

SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field
2023-12-13 15:19:21 -05: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
Eli Schwartz 90ce084144
treewide: automatic rewriting of all comment-style type annotations
Performed using https://github.com/ilevkivskyi/com2ann

This has no actual effect on the codebase as type checkers (still)
support both and negligible effect on runtime performance since
__future__ annotations ameliorates that. Technically, the bytecode would
be bigger for non function-local annotations, of which we have many
either way.

So if it doesn't really matter, why do a large-scale refactor? Simple:
because people keep wanting to, but it's getting nickle-and-dimed. If
we're going to do this we might as well do it consistently in one shot,
using tooling that guarantees repeatability and correctness.

Repeat with:

```
com2ann mesonbuild/
```
2023-08-11 13:41:03 -04:00
Eli Schwartz a01418db0a
remove useless type annotations
These annotations all had a default initializer of the correct type, or
a parent class annotation.
2023-08-11 13:37:17 -04:00
Eli Schwartz 7afc69254d
fix implicit_reexport issues and enforce them going forward
This detects cases where module A imports a function from B, and C
imports that same function from A instead of B. It's not part of the API
contract of A, and causes innocent refactoring to break things.
2023-07-19 18:31:37 -04:00
Eli Schwartz b8b2d87567
dependencies: switch the delayed-import mechanism for custom dependencies
Simply store the module it is expected to be found in. That module then
appends to the packages dict, which guarantees mypy can verify that
it's got the right type -- there is no casting needed.
2023-06-26 13:10:33 -04:00
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -04:00
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).

Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
2022-11-30 16:23:29 -05:00
Dylan Baker a72840cd2e
pylint: enable use-a-generator
This catches some optimization problems, mostly in the use of `all()`
and `any()`. Basically writing `any([x == 5 for x in f])` vs `any(x == 5
for x in f)` reduces the performance because the entire concrete list
must first be created, then iterated over, while in the second f is
iterated and checked element by element.
2022-10-04 00:33:04 -04:00
Eli Schwartz a49cd00d64 treewide: various cleanups to move imports for mypy into typechecking blocks
Along the way, add __future__ annotations where lacking.
2022-06-10 09:15:48 -04:00
fghzxm 7650f32828 dependencies/boost.py: ignore unknown files
If we encounter a file under the Boost library directory that doesn't
look like a Boost library binary, we should ignore it.

We log a warning for each file we ignore, except for ones we know are
safe to ignore (e. g. PDB files from the SourceForge Windows
distribution).  This should avoid polluting the log.

Fixes #8325.
2022-05-09 21:42:02 +02:00
Hemmo Nieminen ceb6e26ff1 boost: preserve compiler/linker argument order
Looks like boost dependency mixes up it's compiler and linker argument
order when it is removing duplicates (?) from those. This causes
unnecessary recompilations of everything depending on those components.

Use OrderedSet to remove the duplicates while also maintaining
consistent order for them.
2022-03-23 20:46:59 +02:00
Dylan Baker 6b272973e0 dependencies: don't pass kwargs from get_pkgconfig_variable
This is a layering violation, we're relying on the way the interpreter
handles keyword arguments. Instead, pass them as free variables,
destructuring in the interpreter
2022-01-18 17:53:29 -05:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Dylan Baker 4d7031437c pylint: turn on superflous-parens
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
2021-08-31 16:28:54 -04:00
Kevin Meagher 3c3fa0a12c add boolean parameter use_system for searching boost
This boolean parameter is added to check_and_set_roots() and detect_lib_dirs()
when true it will first search the compiler library directories before checking
the standard lib directories. This is set to false when using BOOST_ROOT and
set to true when useing other system directories like /usr/local

Also simplify using a set to remove duplicate lib files

Also remove the part where you search the Cellar in homebrew, this is
unnescessary now that symlinks can be followed it should find boost
when searching /usr/local so no need to search the Cellar
2021-08-04 19:29:05 +02:00
Kevin Meagher f781c30700 Make libs a set from the begining 2021-08-04 19:29:05 +02:00
Kevin Meagher 7ce29e1eda Relax restrictions on detecting boost dependency
This does two things:
* allows the library files to be symlinks
* searches `lib` and `lib64` in `BOOST_ROOT` even if it finds lib
  directories from the compiler

The first condition is needed for the homebrew on macOS because boost and boost
python are provided in seperate packages and are put together in /usr/local/lib
with symlinks to the library files. The both conditions are needed for high
performace computing environments where dependencies are often provided in
nonstandard directories with symlinks

A test case was added which looks for boost libraries in seperate directories
which have been symlinked to BOOST_ROOT/lib
2021-08-04 19:29:05 +02:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Eli Schwartz 493dc6ed10
move base class for system dependencies into base.py
In accordance with review comments; it's small enough this seems fitting.
2021-06-17 13:22:25 -04:00
Dylan Baker 203a548d60 dependencies: Use the SystemDependency
This fixes these dependencies, which currently return the name of the
dependency as the type.

Fixes #8877
2021-06-14 09:09:32 -07:00
Daniel Mensinger 95b70bcb97 deps: Split dependencies.base
Split the Factory and dependency classes out
of the base.py script to improve maintainability.
2021-06-03 10:23:27 -07: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
Antonin Décimo 39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Dylan Baker f3fcbba1f8 boost: default machine file properties to env var values
This both moves the env reading to configuration time, which is useful,
and also simplifies the implementation of the boost dependency. The
simplification comes from being able to delete basically duplicated code
since the values will be in the Properties if they exist at all.
2021-01-11 11:15:07 -08:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
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-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
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-04 12:20:40 -08:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Daniel Mensinger e681235e5f
typing: fix code review 2020-09-08 20:15:58 +02:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
Daniel Mensinger 1217cf9a3b
typing: fully annotate boost and hdf5 deps 2020-09-08 20:15:57 +02:00
cmcneish a7a6a4833f
Add boost_root support to properties files (#7210)
* Add boost_root support to properties files

This commit implements `boost_root`, `boost_includedir`, and
`boost_librarydir` variable support to native and cross properties
files. The search order is currently environment variables, then
these variables, and finally a platform-dependent search.

* Add preliminary boost_root / boost_includedir tests

Each test contains a fake "version.hpp", as that's how boost detection is
currently being done. We look for this file relative to the root directory,
which probably shouldn't be allowed (it previously was for BOOST_LIBRARYDIR
but not for BOOST_ROOT). It also cannot help with breakage detection in
libraries, however it looks like this wasn't getting tested beforehand.

I've given the two unique version numbers that shouldn't be present in any
stock version of boost (001 and 002).

* Add return type to detect_split_root

* Return empty list when nothing found in BOOST_ROOT, rather than None

* Update boost_root tests

* Create nativefile.ini based on location of run_project_tests.py
* Add fake libraries to ensure boost_librarydir is being used

* Require all search paths for boost to be absolute

* Redo boost search ordering

To better match things like pkg-config, we now look through native/cross files,
then environment variables, then system locations for boost installations.

Path detection does not fall back from one method to the next for properties or
environment variables--if boost_root, boost_librarydir, or boost_includedir is
specified, they must be sufficient to find boost. Likewise for BOOST_ROOT and
friends. pkg-config detection is still optional falling back to system-wide
detection, for Conan.

(Also, fix a typo in test 33's nativefile)

* Correct return type for detect_roots

* Correct boost dependency search order in documentation

* Print debug information for boost library finding, to resolve CI issues

* Handle native/cross file templates in a more consistent way

All tests can now create a `nativefile.ini.in` if they need to use some
parameter that the testing framework knows about but they can't.

* Pass str--rather than PosixPath--to os.path.exists, for Python35

* Look for boost minor versions, rather than boost patch versions in test cases

* Drop fake dylib versions of boost_regex

* Prefer get_env_var to use of os.environ

* Correct error reporting for relative BOOST_ROOT paths

* Bump version this appears in. Also, change "properties file" to "machine file" as that appears to be the more common language.
2020-07-21 16:40:29 +02:00
Daniel Mensinger 2fd838d62d boost: Try extracting BOOST_ROOT from boost.pc
This is especially useful for Conan, where only the boost.pc
file is provided and manually setting BOOST_ROOT is not a
good solution since it is in a private cache directory.

See #5438
2020-05-22 17:08:02 +03:00
Daniel Mensinger 5862ad6965 boost: Always sort shared before static (fixes #7171) 2020-05-22 17:07:04 +03:00
Daniel Mensinger 8f1db99cec boost: always use compiler include paths 2020-05-14 18:49:37 +00:00
Daniel Mensinger 57e55b1a9d boost: Try finding libraries with the matching arch (fixes #7110) 2020-05-14 02:16:35 +03:00
Daniel Mensinger d298a00afb boost: Do not be strict about static if not specified (fixes #7057) 2020-05-10 19:06:00 +03:00
Daniel Mensinger b75dcd05c5 boost: Do not set BOOST_ALL_DYN_LINK (fixes #7056) 2020-05-03 13:58:52 +03:00
Daniel Mensinger 59db1f18ea boost: Only use usage-requirements defines (fixes #7046) 2020-05-01 22:08:59 +03:00
Daniel Mensinger d290301b4d boost: Fix library version (fixes #6899) 2020-04-05 23:30:50 +03:00
Daniel Mensinger 9f2f27a49d boost: Fix boost_python detection on bionic (fixes #6886 #4788) 2020-04-01 20:39:46 +03:00
Daniel Mensinger 4e52a0f7fd boost: Better python module detection 2020-03-28 00:56:58 +02:00
Daniel Mensinger 1bfd5e9dd2 boost: Better log found and missing modules 2020-03-28 00:56:58 +02:00
Dylan Baker 6329393db5 dependencies/boost: Fix a number of mypy issues
Since mypy can now see type information for mesonlib it can determine a
number of potential errors in the boost module, this fixes those.
2020-03-05 09:58:52 -08:00