aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
AgeCommit message (Collapse)AuthorFilesLines
2022-12-15Change double quote doc comment to sinqle quoteTristan Partin1-2/+2
2022-12-15Try to find the jni dependency when javac is a Darwin stubTristan Partin1-11/+25
Darwin-based systems, at least macOS, provide various JDK executable stubs in /System/Library/Frameworks/JavaVM.framework/Versions/*/Commands. These stubs are placed in such a way that they break the heuristics of the JNI system dependency. If a javac being analyzed to find a Java home is a stub, use /usr/libexec/java_home. See https://stackoverflow.com/a/15133344/7572728 for more details. Closes #11173
2022-12-14Deduplicate code in JNISystemDependency conditionalTristan Partin1-2/+2
2022-12-11typing: fix some broken Sequence annotationsEli Schwartz1-2/+2
T.Sequence is a questionable concept. The idea is to hammer out generic, maximally forgiving APIs that operate on protocols, which is a fancy way of saying "I don't care if you use tuples or lists". This is rarely needed, actually, and in exchange for this fancy behavior you get free bugs. Specifically, `somestr` is of type `T.Sequence[str]`, and also `somestr[0]` is another string of type you guessed it. It's ~~turtles~~ strings all the way down. It's worth noting that trying to code for "protocols" is a broken concept if the contents have semantic meaning, e.g. it operates on "the install tags of this object" rather than "an iterable that supports efficient element access". The other way to use T.Sequence is "I don't like that T.List is invariant, but also I don't like that T.Tuple makes you specify exact ordering". This sort of works. In fact it probably does work as long as you don't allow str in your sequences, which of course everyone allows anyway. Use of Sequence has cute side effects, such as actually passing lists around, knowing that you are going to get a list and knowing that you need to pass it on as a list, and then having to re-allocate as `list(mylist)` "because the type annotations says it could be a str or tuple". Except it cannot be a str, because if it is then the application is fatally flawed and logic errors occur to disastrous end user effects, and the type annotations: - do not enforce their promises of annotating types - fail to live up to "minimal runtime penalties" due to all the `list()` Shun this broken concept, by hardening the type annotations. As it turns out, we do not actually need any of this covariance or protocol-ism for a list of strings! The whole attempt was a slow, buggy waste of time.
2022-12-04hdf5 dependency: correctly use machine files and respect crossEli Schwartz1-4/+5
We do some magic to figure out what names of pkg-config dependencies to even search for. This magic simply checked for `pkg-config` the $PATH executable, which was broken in a variety of ways and had a comment to that effect.
2022-12-04refactor pkg-config dependency to allow statically finding the programEli Schwartz1-32/+36
The pkg-config dependency class has some interesting logic for finding a good pkg-config that will be used for dependency lookups. We sometimes need to use it, though, outside of the class. Make that possible.
2022-11-30pylint: enable the set_membership pluginDylan Baker5-12/+12
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-29pylint: enable the bad_builtin checkerDylan Baker1-1/+1
This finds uses of deny-listed functions, which defaults to map and filter. These functions should be replaced by comprehensions in idiomatic python because: 1. comprehensions are more heavily optimized and are often faster 2. They avoid the need for lambdas in some cases, which make them faster 3. you can do the equivalent in one statement rather than two, which is faster 4. They're easier to read 5. if you need a concrete instance (ie, a list) then you don't have to convert the iterator to a list afterwards
2022-11-29pylint: enable implicit-str-concatDylan Baker1-1/+1
Which catches a very real bug. The zlib system dependency failed to work on MSVC since initial implementation in commit c1a3b37ab7e4ccf3a946ee4ba6da81a4c230ecc4 -- it looked for the wrong name.
2022-11-29Fix crash when toolchain is missingSmallWood-D7-13/+23
Add a MissingCompiler class returned by compiler detecting methods intead of None - accessing such an object raises a DependencyException Fixes #10586 Co-authored-by: duckflyer <duckflyer@gmail.com>
2022-11-03dependencies: make the hdf5 dependency use Popen_safeEli Schwartz1-4/+3
It is, after all, "safe". ;) That's why it exists. There's no reason to think listing all pkg-config entries cannot print unicode descriptions, it's absolutely possible, and we should handle it properly if we encounter it.
2022-10-24Move JNISystemDependency to dependencies.base.detect_compilerTristan Partin1-3/+2
Only searches if the project already added that language before.
2022-10-09Fix some wording in a JNISystemDependency commentTristan Partin1-1/+1
2022-10-09Add BSD support to the JNISystemDependencyTristan Partin1-0/+8
Supports all BSDs that Meson currently supports. Fixes #10883
2022-10-06Add handling Qt6's EntryPoint library.Hagen Möbius1-9/+18
- this fixes #10792 - Qt6EntryPoint(d) replaces qtmain(d) from Qt 4 & 5 - uses the same mechanism: `main: true` - uses a special mixin class for pkg-config and config-tool dependency calculation
2022-10-04pylint: enable use-a-generatorDylan Baker2-8/+8
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-09-28Move classes used by scripts to their own moduleXavier Claessens1-2/+1
Those classes are used by wrapper scripts and we should not have to import the rest of mesonlib, build.py, and all their dependencies for that. This renames mesonlib/ directory to utils/ and add a mesonlib.py module that imports everything from utils/ to not have to change `import mesonlib` everywhere. It allows to import utils.core without importing the rest of mesonlib.
2022-09-19compilers: perform targeted imports for detectEli Schwartz2-3/+3
Only import the ones we need for the language we are detecting, once we actually detect that language. This will allow finally dropping the main imports of these files in a followup commit.
2022-09-19compilers: directly import from subpackagesEli Schwartz2-3/+4
It turns out we don't generally need to proxy every compiler ever through the top-level package. The number of times we directly poke at one is negligible and direct imports are pretty clean.
2022-09-12dependencies: log the real reason for a dependency lookup failingEli Schwartz2-3/+6
In the debug logs, always log if a dependency lookup raises a DependencyException. In the `required: false` case, this information would otherwise disappear forever, and we would just not even log that we tried it -- it doesn't appear in "(tried x, y and z)". In the `required: true` case, we would re-raise the first exception if it failed to be detected. Update the raise message with the same information we print to the debug logs, indicating which dependency and which method was used in the failing attempt.
2022-09-12dependencies: use better internal representation of factory methodsEli Schwartz2-8/+7
functools.partial preserves information about how the method was created, lambdas do not. Also, we just want to freeze the first argument and forward the rest anyway. This also lets us get rid of a mypy error that was being ignored.
2022-09-12dependencies: simplify log_tried into a staticmethodEli Schwartz7-12/+21
It doesn't really need class instantiation to just know what type it is, and this way we can get the information early if a dependency fails to init.
2022-09-12dependencies: simplify logging methodsEli Schwartz3-15/+0
A bunch of SystemDependency subclasses overrode log_tried() even though they used the same function anyway. Delete them -- they still print the same thing either way.
2022-08-29flake8: fix typing casts to not have actual objectsEli Schwartz1-1/+1
We use `__future__.annotations` to good effect everywhere we can, and one of the effects of this is that annotations are automatically stringized and don't need to be evaluated, using less memory and computation. But this only affects actual annotations -- a cast is just a function with an argument, so the compiler has no idea that it's an annotation to be stringized. Do this manually.
2022-08-26Remove redundant backslash and fix white space issueAlf Henrik Sauge1-4/+5
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge3-8/+8
2022-08-09dependencies: reject Qt6 pkg-config dependency if libexecdir is not knownEli Schwartz1-0/+7
This is needed for 6.1 support as noted in commit a606ce22eb0dd05eef56384d59954edad7da131d but at the time there was no pkg-config detection method at all. The stub code for Qt6 didn't support libexecdir at all, and the pkg-config files added to newer versions of Qt6 didn't export that information either until a further bugfix release. Enforce that this information is required.
2022-08-09qt: fix qt 6 tools detection for pkg-configKonstantin1-1/+21
Add correct reading of pkgconfig-announced bindir and pkgconfig-announced libexecdir. Will work only on 6.3+
2022-08-04typing: simplify type annotations for librariesEli Schwartz1-2/+2
In a bunch of places we need to list various types of libraries including custom_target outputs, and it gets very long. Use a common T.Union for this.
2022-06-13flake8: fix non-idiomatic ordering of "if not in" checksEli Schwartz1-3/+3
2022-06-13flake8: fix various whitespace nitsEli Schwartz1-3/+3
2022-06-10treewide: various cleanups to move imports for mypy into typechecking blocksEli Schwartz3-4/+6
Along the way, add __future__ annotations where lacking.
2022-06-01dependencies: Fix d_module_version typesDylan Baker1-1/+1
It's a `List[str | int]`, just like in the build module. In fact, we should probably share the same type information between the two.
2022-05-25dependencies: Don't allow as_link_whole to complete with SharedLibrariesDylan Baker1-1/+12
Since a SharedLibrary can't be statically linked in, we shouldn't allow the method to complete.
2022-05-25dependencies: Fix several annotations issuesDylan Baker1-7/+11
- `BuildTarget` should be `SharedLibrary | StaticLibrary` - Needs to take `CustomTargetIndex` as well as `CustomTarget` - don't assign to self until values have been converted to the correct type
2022-05-23move various imports into TYPE_CHECKING blocks for neatnessEli Schwartz1-2/+3
2022-05-09dependencies/boost.py: ignore unknown filesfghzxm1-2/+14
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-03add prefer_static built-in optionDudemanguy4-7/+11
By default, meson will try to look for shared libraries first before static ones. In the meson.build itself, one can use the static keyword to control if a static library will be tried first but there's no simple way for an end user performing a build to switch back and forth at will. Let's cover this usecase by adding an option that allows a user to specify if they want dependency lookups to try static or shared libraries first. The writer of the meson.build can manually specify the static keyword where appropriate which will override the value of this option.
2022-05-03dependencies: cleanup kwargs.get('static') usageDudemanguy2-3/+2
In a couple of spots, kwargs.get('static', False) was being unneccesarily used. In these spots, we can just use self.static instead which is already inherited from the ExternalDependency. In additional, the python system dependency oddly has a kwargs.get('static', False) line which overrides the self.static in that dependency for no real reason. Delete this line too.
2022-05-03interpreter: new function add_project_dependencies()Paolo Bonzini1-0/+6
This function can be used to add fundamental dependencies such as glib to all build products in one fell swoop. This can be useful whenever, due to a project's coding conventions, it is not really possible to compile any source file without including the dependency. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-05-03dependencies: extract code to get all leaf dependenciesPaolo Bonzini2-2/+19
Extract to a separate function the code that resolves dependencies for compiler methods. We will reuse it for add_project_dependencies(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-05-01cmake: Fix CMake LLVM dependency error (fixes #10322)Daniel Mensinger1-2/+9
2022-05-01Merge pull request #10039 from eli-schwartz/wayland-protocols-subproject-filesJussi Pakkanen4-17/+17
dependencies: allow get_variable to expose files from subprojects
2022-04-30pkgconfig: Use EnvironmentVariables to build PKG_CONFIG_* envXavier Claessens1-20/+27
The new get_env() method that returns an EnvironmentVariables object will be needed in next commit that will pass it to CustomTarget. This has the side effect to use the proper os specific path separator instead of hardcoding `:`. It is the obvious right thing to do here, but has caused issues in the past. Hopefully issues have been fixed in the meantime. If not, better deal with fallouts than keep doing the wrong thing forever.
2022-04-13dependencies: tighten type checking and fix cmake API violation for get_variableEli Schwartz4-17/+17
dep.get_variable() only supports string values for pkg-config and config-tool, because those interfaces use text communication, and internal variables (from declare_dependency) operate the same way. CMake had an oddity, where get_variable doesn't document that it allows list values but apparently it miiiiiight work? Actually getting that kind of result would be dangerously inconsistent though. Also, CMake does not support lists so it's a lie. Strings that are *treated* as lists with `;` splitting don't count... We could do two things here: - raise an error - treat it as a string and return a string It's not clear what the use case of get_variable() on a maybe-list is, and should probably be a hard error. But that's controversial, so instead we just return the original `;`-delimited string. It is probably the wrong thing, but users are welcome to cope with that somehow on their own.
2022-04-12qt dependency: adapt to the qmake command changed nameEli Schwartz1-1/+1
Qt now has official guidance for the symlinked names of the tools, which is great. Qt now officially calls the tools `fooX` instead of `foo-qtX` where the major version of Qt is X. Which is not great, because a bit of an unofficial standard had prior art and now needs to change, and we never adapted. Prefer the official name whenever looking up qmake, and in the testsuite, specifically look only for the official name on versions of qt which we know should have that.
2022-04-12qt dependency: find the correct -qtX configtool nameEli Schwartz1-1/+2
Fixes regression in commit c211fea51389728783cf59ae41156a5e0de9c41a. The original dependency lookup looked for `qmake-{self.name}`, i.e. `qmake-qt5`, but when porting to config-tool, it got switched to `qmake-{self.qtname}` i.e. `qmake-Qt6`, which was bogus and never worked. As a result, if `qmake-qt5` and `qmake` both existed, and the latter was NOT qt5, it would only try the less preferred name, and then fail. We need to define self.name early enough to define the configtool names, which means we need to set it before running the configtool __init__() even though configtool/pkgconfig would also set it to the same value. Mark the tests as passing on two distros that were failing to detect qmake due to this issue, and were marked for skipping because we assumed that the CI skipping there was an expected case rather than an old regression.
2022-04-12Add support for Qt 6.1+John Lindgren1-0/+9
Qt 6.1 moved the location of some binaries from QT_HOST_BINS to QT_HOST_LIBEXECS as noted in the changelog: c515ee178f Move build tools to libexec instead of the bin dir - Tools that are called by the build system and are unlikely to be called by the user are now installed to the libexec directory. https://code.qt.io/cgit/qt/qtreleasenotes.git/tree/qt/6.1.0/release-note.txt It's possible to help the 'qt' module find the tools by adding Qt's libexec directory to the PATH environment variable, but this manual workaround is not ideal. To compensate, meson now needs to look for moc, rcc, uic, etc. in QT_HOST_LIBEXECS as well as QT_HOST_BINS. Co-authored-by: Stefan Hajnoczi <stefanha@jammr.net>
2022-04-12cmake: Always use all compilers for LLVM (fixes #10249)Daniel Mensinger3-4/+14
2022-03-29move a bunch of imports into TYPE_CHECKING blocksEli Schwartz1-2/+3
These are only used for type checking, so don't bother importing them at runtime. Generally add future annotations at the same time, to make sure that existing uses of these imports don't need to be quoted.