Commit Graph

74 Commits

Author SHA1 Message Date
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
H. Vetinari cc5a95a56a detect windows linkers for flang in detect_fortran_compiler 2023-12-11 21:54:47 +02:00
Will Toohey 8c70ce466b More robust linker detection for armar (TI vs non-TI) 2023-12-01 22:11:41 +02:00
Filipe Laíns 025bcc0d9d compilers: fix compiler detection when the "ccache" string is in the path
Signed-off-by: Filipe Laíns <lains@riseup.net>
2023-09-01 02:09:21 -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 e2ce53b6b4
compilers: detect cython version on stdout for newer cython versions
Cython historically, when asked to print the version and exit
successfully, would do so on stderr, which is weird and inconsistent.
Recently, it fixed this UX bug by printing on stdout instead:

https://github.com/cython/cython/issues/5504

This then broke meson detection because we assumed it was on stderr due
to historically being there:

https://github.com/scipy/scipy/issues/18865

Cython is right, and shouldn't have to revert this reasonable change for
backwards compatibility. Instead, check both.
2023-07-12 15:56:51 -04:00
Eli Schwartz a1ef957e34
linkers: delay implementations import until detect is run
This saves on a 1500-line import at startup and may be skipped entirely
if no compiled languages are used. In exchange, we move the
implementation to a new file that is imported instead.

Followup to commit ab20eb5bbc.
2023-06-26 13:10:33 -04:00
Alyssa Ross 8c766f5b5b compilers: don't recommend deprecated env var
RUST_LD was deprecated in Meson 0.54 in favor of RUSTC_LD.
2023-06-19 15:19:41 -04:00
Eli Schwartz d87d912e5d
compilers: fix detection of ifx compiler
The version output scraping for identifying strings checked for "IFORT"
in parentheses after the executable name, which is probably a mistake by
Intel. Current versions of ifx have "IFX" in parentheses there.

Detect both.

Fixes #11873
2023-06-14 01:04:55 -04:00
Eli Schwartz a6bf2c1e2c
compilers: add logging for non c_or_cpp language detection 2023-06-14 01:04:55 -04:00
Eli Schwartz aa13c46822
WIP: refactor loggable popen calls for consistency 2023-06-14 01:04:55 -04:00
Volker Weißmann 2699fd4b8a During reconfigure, show that no compiler was found, if compiler fails sanity check. 2023-05-13 11:06:24 +03:00
Nomura c1fce8f60f Initial support for Metrowerks Assembler 2023-05-06 19:57:06 +03:00
Nomura 18cfa545f0 Initial support for Metrowerks C/C++ compiler 2023-04-24 09:07:37 -04:00
Sebastian Dröge 22960758aa rust: Use the corresponding rustc version when clippy-driver is chosen as Rust compiler
By default clippy-driver will report its own version, which is not very
useful to check the toolchain version. Instead make sure to extract the
actual toolchain version here.
2023-04-14 15:52:54 +05:30
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
Khem Raj 24ea1d3f19 detect.py: Be more precise about detecting xtensa gcc toolchains
clang --version can yield a string like below when its installed into
such a directory

clang version 14.0.0 (https://github.com/llvm/llvm-project 3f43d803382d57e3fc010ca19833077d1023e9c9)
Target: aarch64-yoe-linux
Thread model: posix
InstalledDir: /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux/gnome-text-editor/42.0-r0/recipe-sysroot-native/usr/bin/aarch64-yoe-linux

as you can see InstallDir has 'xt-' subtring and this trips the check to
guess gcc

if 'Free Software Foundation' in out or 'xt-' in out:

Therefore, check if compiler output starts with xt- then assume
it to be gcc

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-03-09 21:38:13 -08:00
L. E. Segovia c2b0ca0fb9 nasm: Detect and use MSVC linker if present
Fixes #11082
2023-02-20 09:58:34 -05:00
Kleis Auke Wolthuizen 18d2431685 emscripten: remove no longer relevant comment
This was fixed in Emscripten 1.39.16, see:
d4fabf3da4
2022-12-27 06:59:55 -05:00
Xavier Claessens 2961adb8c8 Compilers: Keep ccache and exelist separated
Only combine them in the Compiler base class, this will make easier to
run compiler without ccache.
2022-10-25 17:24:56 -04:00
Robert Cohn 1939e567d6 basic support for oneapi compilers 2022-10-24 18:55:22 +03:00
Xavier Claessens 942aea230f Add MASM compiler
ml and armasm are Microsoft's Macro Assembler, part of MSVC.
2022-10-24 14:52:13 +02:00
Xavier Claessens 4f4076bfc0 nasm: Harcode default path on Windows
NASM's installer does not add itself into PATH, even when installed by
choco.
2022-10-24 11:06:57 +02:00
Xavier Claessens d29ef2b128 Add yasm as fallback for nasm language 2022-10-24 11:06:57 +02:00
Xavier Claessens 01ee141339 Add NASM compiler 2022-10-24 11:06:57 +02:00
Dylan Baker 188c552dcf pylint: enable use-maxsplit-arg
This finds a bunch of places where we can do more efficient string
splitting.
2022-09-19 20:57:52 -04:00
Eli Schwartz edc3e26369
fix odd mypy issue in unreachable code
This used to be fine, until imports were removed from this file. Now a
function annotated as T.NoReturn doesn't actually tell mypy that it
cannot return, though, so we manually do it.
2022-09-19 15:19:01 -04:00
Eli Schwartz 8277a1aba8
simplify type annotation 2022-09-19 15:19:00 -04:00
Eli Schwartz ab20eb5bbc
compilers: avoid importing compilers upfront for detect
We no longer need these upfront at all, since we now import the ones we
need for the language we are detecting, at the time of actual detection.

This avoids importing 28 files, consisting of just under 9,000 lines of
code, at interpreter startup. Now, it is only imported depending on
which languages are invoked by add_languages, which may not even be
anything. And even if we do end up importing a fair chunk of it for
C/C++ projects, spreading the import cost around the interpreter runtime
helps responsiveness.
2022-09-19 15:19:00 -04:00
Eli Schwartz cc5ef6478f
compilers: perform targeted imports for detect
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-19 15:19:00 -04:00
Eli Schwartz f6f876481f
compilers: use more direct checks for what kind of compiler we have
Instead of comparing against specific compiler classes, check the
logical compiler id or language etc.

In a couple cases, we seem to be missing a couple things by being a bit
too strict about the exact class type.
2022-09-19 15:19:00 -04:00
Eli Schwartz 775b67c5c1
compilers/detect: rename potentially conflicting name
Preparation for future commit.
2022-09-19 15:19:00 -04:00
Eli Schwartz 2b90152fe5
compilers: use consistent function signature for objc
e.g. for detect_c_or_cpp we just take the language itself as an
argument.
2022-09-19 15:19:00 -04:00
Eli Schwartz 4487a256e0
compilers: remove dead code
It doesn't matter whether the language is c or cpp, xc16 only has a C
compiler so that's what this has to be.
2022-09-19 15:19:00 -04:00
Eli Schwartz 5c4cd9162e
compilers: single-source compiler class as cls, consistently
It's the style for most, but not all, of this file.
2022-09-19 15:19:00 -04:00
Dylan Baker d6b9d431ec linkers: Add a representation for the Apple AR Linker
Which is old and annoying and doesn't expose global symbols by default,
so we need a work around.

see: https://github.com/mesonbuild/meson/pull/10587
see: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html
2022-07-25 15:36:59 -07:00
Justin Blanchard ec388fe7c2 ar linker: detect the "osx ld" case (where generating thin archives won't work) based on host OS, not build OS. 2022-07-21 22:00:00 -07:00
Eli Schwartz 0eed99318b
compilers: add logging to obscure compiler defines scraper
If this command fails, for example when CXX is something not generic
enough to be a valid universal compiler command (clang -std=c++11
perhaps), we end up with two problems:

- it's impossible to figure out what Meson ran to get that error

- the error report isn't clear on what is stdout and what is stderr, or
  even that that is what the message is about.

  ```
  meson.build:1:0: ERROR: Unable to get clang pre-processor defines:
  error: invalid argument '-std=c++11' not allowed with 'C'
  ```

  What's C doing there and why is Meson talking about it? Answer: that's
  compiler stdout. Say so.
2022-07-21 16:45:01 -04:00
Eli Schwartz 1f527550c6
compilers: include compiler detection output in the debug logs
We do something similar when running get_compiler() method checks from
the DSL. This ensures that if errors happen, the log file we tell people
to check actually works.
2022-07-21 16:45:01 -04:00
Eli Schwartz 93ba937186
compilers: better reporting of command failures
Use join_args to ensure that commands are rendered correctly.
2022-07-21 16:45:00 -04:00
Tristan Partin af846a109f Detect Cython and Vala compilers on the build machine always
Transpilers need to run on the build machine in order to generate their
output, which can then be taken by a cross-compiler to create the final
output.
2022-07-06 12:04:59 -07:00
Stepan Nassyr b0158955b7 ACfL version detection with regex 2022-06-10 08:24:52 -07:00
Stepan Nassyr d045c9f79d Allow for 3-component ACfL versions 2022-06-10 08:24:52 -07:00
Eli Schwartz 1c52ac4e15
move various imports into TYPE_CHECKING blocks for neatness 2022-05-23 16:44:08 -04:00
Fini Jastrow c16fdaeeca linkers: Add support for mold linker
[why]
Support for the relatively new mold linker is missing. If someone wants
to use mold as linker `LDFLAGS="-B/path/to/mold"` has to be added instead
of the usual `CC_LD=mold meson ...` or `CXX_LD=mold meson ...`.

[how]
Allow `mold' as linker for clang and newer GCC versions (that versions
that have support).

The error message can be a bit off, because it is generic for all GNU
like compilers, but I guess that is ok. (i.e. 'mold' is not listed as
possible linker, even if it would be possible for the given compiler.)

[note]
GCC Version 12.0.1 is not sufficient to say `mold` is supported. The
expected release with support will be 12.1.0.
On the other hand people that use the un-released 12.0.1 will probably
have built it from trunk. Allowing 12.0.1 is helping bleeding edge
developers to use mold in Meson already now.

Fixes: #9072

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-04-30 10:06:22 -04:00
Xavier Claessens ebbe4425e7 Debian renamed cython to cython3, support both 2022-03-24 10:16:53 -04:00
Dylan Baker 655746e8b4 compilers: fix mypy warning in Rust detection 2022-03-22 15:15:29 +02:00
Eli Schwartz bfdbf7bf65 remove unused type ignore that mypy 0.940 no longer needs
And now that it doesn't need it, it errors out when you use it.
2022-03-12 00:31:12 +02:00
Eli Schwartz 9daaece785
flake8: fix various whitespace errors with badly aligned code 2022-02-16 23:00:31 -05:00
Eli Schwartz 60c893f1c2
flake8: remove some redundant separators 2022-02-16 18:19:13 -05:00