Commit Graph

83 Commits

Author SHA1 Message Date
Nirbheek Chauhan cfc3605b73 Detect 'ccache' in evars and cross-info files
Then, only use it if it's actually available.

Closes https://github.com/mesonbuild/meson/issues/1471
2017-03-25 17:56:13 +02:00
Jussi Pakkanen b927468137 Use cross stripper when cross compiling and allow overriding native strip executable. Closes #1414. 2017-02-27 16:49:32 -05:00
Nirbheek Chauhan 4f0e204c34 Fix undefined variables in ObjC/C++ detection
Pointed out by Mike Sinkovsky
2017-02-26 07:28:27 -05:00
Nirbheek Chauhan 8e48f23262 Detect GCC type on macOS for ObjC/C++ too
These compilers are available in MinGW and can be built on macOS.

More interestingly, `gcc` is a wrapper around `clang` on macOS, so we
will detect the compiler type incorrectly on macOS without this.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 69e83d6aed Support passing of options to compilers and linkers
If you pass options, the last element in the array won't be the
compiler basename, so just check if the basename is in the exelist
somewhere.

Includes a test.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 003e0a0610 Use the same function for detection of C and C++ compilers
The mechanism is identical which means there's a high likelihood of
unintended divergence. In fact, a slight divergence was already there.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 56a8b2a181 Fix static linker exelist in cross-info and environment
https://github.com/mesonbuild/meson/pull/1406 had an incomplete fix
for this. The test case caught it.

Note: this still doesn't test that setting it in the cross-info works,
but it's the same codepath as via the environment so it should be ok.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 798c349e35 Fix compiler exelist in cross-info and the environment
https://github.com/mesonbuild/meson/pull/1406 had an incomplete fix
for this. The test case caught it.

Note: this still doesn't test that setting it in the cross-info works,
but it's the same codepath as via the environment so it should be ok.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 68eea4818d environment: Use shlex.split() to get AR from the env
That way if the path has spaces, it won't get messed up.
2017-02-21 01:36:08 +05:30
Hase Bastian 283d5e6233 Detect (non-Apple) clang as objc/c++ compiler
See https://github.com/mesonbuild/meson/pull/1388
2017-02-21 01:35:56 +05:30
Nirbheek Chauhan 238d1a37a0 Factor out common code in compiler detection
This was being duplicated across C/C++/ObjC/ObjC++/Fortran and hence
was behaving slightly differently in each.
2017-02-21 01:35:56 +05:30
Jussi Pakkanen c76dcdb62b Fix the rest of them. 2017-02-19 21:56:33 +02:00
Jussi Pakkanen 4dfd9701e3 Fix compiler detection + cross when envvar not set. 2017-02-19 21:04:46 +02:00
Jussi Pakkanen aba099a491 Merge pull request #1396 from fabio-porcedda/cross-ccache
cross_file: add support for "ccache"
2017-02-19 11:42:27 -05:00
Fabio Porcedda 16d4c466fc detect_c_compiler(): support extra commands and arguments in the string
- Hanlde correctly a multi command string in evironment variable, e.g.:
  CC="ccache gcc" meson
- Handle correctly a list for the cross-file option, e.g:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

This commit fixes #1392.
2017-02-17 17:11:17 +01:00
Fabio Porcedda aa7f496144 detect_c_compiler(): use shlex.split() instead of str.split() for env
Use shlex.split() for splitting the env var instead of str.split() to
handle quoting and spaces in paths.
2017-02-17 17:11:02 +01:00
Jussi Pakkanen 5973dcc25b Detect x86/amd64 from the compilers because system info may be incorrect. 2017-02-12 14:55:32 +02:00
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Mike Sinkovsky 1d177fb127 cleanup: Unused local variables 2017-01-18 21:22:47 +02:00
Mike Sinkovsky 5b626ab4cb style: [E1**] Indentation 2017-01-11 12:33:27 -05:00
Mike Sinkovsky 84902cb93a style: [E301] expected 1 blank line, found 0 2017-01-11 12:33:27 -05:00
Jussi Pakkanen 24221d71cc Created a Python 3 module for simpler building of Python extension modules. 2017-01-09 21:07:23 +02:00
Nirbheek Chauhan 747d4f2b03 We only need Ninja 1.5.x for the core code
This change helps us run on older distros such as Ubuntu LTS which is
very lazy in updating even non-core and stable packages such as Ninja.

Ninja 1.6.x is only needed for running the tests.
2017-01-09 14:03:03 -05:00
Philipp Geier 54697b4130 ICC 17.0.0 working for Linux and Ninja Backend.
Added IntelCompiler, IntelCCompiler and IntelCCompiler.
environments.py has been changed to detect icc and icpc.
ninjabackend changed for proper pch generation.

ICC 17.0.0 does not support C++13 (that's why default arguments tests fails).
Test 25 object extraction fails due to some unescaped whitespaces.
Some test with vala fail because of successful build, although they
should fail, as warning do not exit with failure.
2017-01-04 00:40:54 +05:30
Mike Sinkovsky 2d2e3b943c fix for cross-builds targeting macosx 2017-01-02 11:08:30 -05:00
Igor Gnatenko 116da33cdd style: fix E128 violations
E128: continuation line under-indented for visual indent

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko f0b30baa39 style: fix E225 violations
E225: missing whitespace around operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Jussi Pakkanen b55235dfbd Fix space before :. 2016-12-31 16:28:15 +02:00
Jussi Pakkanen a2528a8816 Merge pull request #1233 from mesonbuild/wip/ignatenko/code-style
Trivial cleanups in code
2016-12-21 00:09:44 +02:00
Nirbheek Chauhan 9bc07a0941 Fix several more lint errors
Found by Igor Gnatenko

************* Module mesonbuild.interpreter
E:1232,33: No value for argument 'interp' in constructor call (no-value-for-parameter)
************* Module mesonbuild.dependencies
E: 68, 4: An attribute defined in mesonbuild.dependencies line 39 hides this method (method-hidden)
************* Module mesonbuild.environment
E: 26, 0: class already defined line 19 (function-redefined)
E: 68,18: Undefined variable 'InterpreterException' (undefined-variable)
E:641,39: Undefined variable 'want_cross' (undefined-variable)
E:850,94: Undefined variable 'varname' (undefined-variable)
E:854,94: Undefined variable 'varname' (undefined-variable)
E:860,102: Undefined variable 'varname' (undefined-variable)
E:863,94: Undefined variable 'varname' (undefined-variable)
************* Module mesonbuild.modules.gnome
E:438,26: Undefined variable 'compilers' (undefined-variable)
2016-12-20 00:07:00 +02:00
Igor Gnatenko 139e020ede tree-wide: use proper 'not in' notation
Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 21:48:35 +01:00
Jussi Pakkanen 411e88a5ab Fix PGI Fortran compiler detection. 2016-12-18 18:51:09 +02:00
Nirbheek Chauhan 70f39ee21e unity builds: Assembly and LLVM IR are incompatible
Can't just #include them and use them directly in unity builds. Inline
assembly is a thing, but it's not trivial and is deprecated with some
compilers. Just build them separately and link them in. Ideally the user
would then use LTO to ensure the same result.
2016-12-11 14:54:30 +05:30
Nirbheek Chauhan 04c1909a4d compilers: Implement support for LLVM IR compilation
Also C++ compilers can build .S assembly files. This wasn't noticed
earlier because most people were also using C compilers in their C++
projects and we would fall back to using the C compiler for building the
assembly files. Now we have a test for this.

This was trivial to add; except that we needed a new LLVM IR rule
because the compiler emits warnings if you pass any special arguments to
it such as include arguments or dependency arguments.

Closes #1089
2016-12-11 14:54:30 +05:30
Nirbheek Chauhan 60716fcd6d Use universal_newlines=True for all Popen calls
Instead of adding it everywhere manually, create a wrapper called
mesonlib.Popen_safe and use that everywhere that we call an executable
and extract its output.

This will also allow us to tweak it to do more/different things if
needed for some locales and/or systems.

Closes #1079
2016-12-11 01:59:58 +02:00
Nirbheek Chauhan 09fd24ea78 Always catch PermissionError while looking for Ninja
Also convert a few other generic `except Exception`s to be more specific

Closes #1088
2016-11-26 12:56:08 -05:00
Jussi Pakkanen 951262d759 Removed Valgrind from core. 2016-11-18 22:04:29 +02:00
Paulo Antonio Alvarez 1e54a5e73c environment: Use GNU defines to get version of c, c++, objc and fortran
According to
https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html,
the macros used to get the version are always defined for those
languages, so use them to get the version.
2016-11-11 08:11:43 -02:00
Paulo Antonio Alvarez 582e1ede80 environment: Static method to get gcc version from compiler defines
The method takes a dictionary with defines names as keys and the defines
values as values. From it, we assemble the gcc version, using 0 as a
default value if the define we want is not defined.
2016-11-11 07:26:51 -02:00
Jussi Pakkanen 69aa0091b1 The regex to detect version numbers needs to be a bit more complex. Closes #967. 2016-11-02 13:47:38 -07:00
Nirbheek Chauhan 3df75d696d Directly pass the compiler to get_args_from_envvars
Seems better to do this since the behaviour is compiler-specific. Would
be easier to extend this later too in case we want to do more
compiler-specific things.
2016-10-26 23:16:05 +05:30
Emanuele Aina 6c50253645 Use argv[0] to internally relaunch meson.py
When installing Meson, distutils may choose to put shim scripts in the
`PATH` that only set up the egg requirements before launching the real
`meson.py` contained in the egg.

This means that `__file__` points to the real `meson.py` file, but
launching it directly is doomed to fail as it's missing the metadata
contained in the shim to set up the path egg, resulting in errors when
trying to import the `mesonbuild` module.

A similar issue affects Meson when installed as a zipapp, with the
current code going great lengths to figure out how to relaunch itself.

Using `argv[0]` avoids these issues as it gives us the way the current
executable has been launched, so we are pretty much guaranteed that
using it will create another instance of the same executable. We only
need to resolve relative paths as the current working directory may
get changed before re-launching the script, and using `realpath()` for
that saves us the trouble of manually resolving links and getting caught
in endless loops.

This also mean that `meson_script_file` no longer necessarily point to a
absolute file, so rename it to `_launcher` which hopefully would be less
prone to inducing false assumptions.
2016-10-08 15:41:31 +02:00
Nirbheek Chauhan bcf20af62e environment: Add support for MinGW/GCC to detect_windows_arch() 2016-09-27 00:27:38 +05:30
Nirbheek Chauhan a001fa0fb6 compilers: Make GCC detection more robust on all platforms
Fixes https://github.com/mesonbuild/meson/issues/650

Also adds new has_define and get_define internal API for querying
pre-processor defines provided by GNU compilers.
2016-09-27 00:27:38 +05:30
Nirbheek Chauhan ac8c8c2ba8 Treat 32-bit compiles on 64-bit Windows as native
It's a terrible user experience to force people building 32-bit
applications on 64-bit Windows to use a cross-info file when every other
tool treats it as a 'native' compilation -- it satisfies all the
requirements for a native compile.

This commit also fixes the platform detection on Windows which would
cause the 'native cpu' to be detected as 32-bit if you installed 32-bit
Python on 64-bit Windows, or if you were building with a 32-bit
toolchain on 64-bit Windows.

Doesn't support MinGW yet -- the next commits will add that since the
changes required for that are more involved.
2016-09-26 19:48:46 +05:30
Elliott Sales de Andrade a2321b24f6 Flatten isinstance calls. (#715)
That is, isinstance(x, y) or isinstance(x, z) can be flattened with a
tuple to isinstance(x, (y, z)).
2016-08-27 15:47:29 +03:00
Matthias Klumpp b80bdf65df Simplify D compiler argument translation 2016-08-21 01:39:48 +02:00
Matthias Klumpp 56823272ab Implement D support
This patch adds support for the D programming language[1] to Meson.

The following compilers are supported:
* LDC
* GDC
* DMD

[1]: http://dlang.org/
2016-08-19 03:02:51 +02:00
Nirbheek Chauhan a5e01fa155 Only append compile flags to the link flags when appropriate
We should only append the compiler flags to the link flags when the
compiler is used as a wrapper around the linker during the link process
2016-08-12 15:34:59 +05:30
Nirbheek Chauhan 01b43e5f0a Print the CFLAGS/LDFLAGS/etc inherited from the environment
People can forget it and then wonder what's wrong. Just explicitly print
it.
2016-08-11 16:09:48 +05:30