Commit Graph

94 Commits

Author SHA1 Message Date
Dylan Baker 6944d06116 Don't use dict.keys() to check membership
It's much faster to do 'if a in dict' instead of 'if a in dict.keys()',
since the latter constructs an iterator and walks that iterator and then
tests equality at each step, and the former does a single hash lookup.
2017-04-28 22:42:39 +03:00
Thomas Hindoe Paaboel Andersen fbbd7289db Detect intel fortran compiler
The intel fortran compiler "ifort" was not listed in the list of
default fortran compilers. This caused it to not be found unless
explicitly set via the FC.
2017-04-28 22:30:26 +03:00
Jussi Pakkanen 476c263952 Unset compiler envvars in unit tests. 2017-04-23 02:00:28 +03:00
Guillaume Poirier-Morency aa486f5bb2 vala: Add 'VALAFLAGS' to considered environment variables
Fix precedence of arguments for Vala tasks and include those considered
external (i.e. '-Dvala_args' and 'VALAFLAGS').
2017-04-22 21:56:43 +03:00
Nirbheek Chauhan bf2af8b7f1 Use gcc-ar/llvm-ar as the static linker if available
Closes https://github.com/mesonbuild/meson/issues/1646
2017-04-21 17:05:21 +05:30
Nirbheek Chauhan 878b0f1401 Fix shared module installation directory on Windows 2017-04-10 03:38:04 +05:30
Jon Turney 5af98a5ee8 Use correct shared library naming for Cygwin
Use correct shared library naming for Cygwin when building and installing
2017-04-06 22:47:15 +01:00
Jon Turney cbc5064a67 Don't use -fPIC on Cygwin, either
Identify Cygwin-targetted gcc as sui generis (don't use -fPIC, but don't
link with standard Windows libraries, either)

Update tests appropriately
2017-04-06 22:47:15 +01:00
Nirbheek Chauhan 6042e21e25 Use CPPFLAGS for pre-processor compiler checks
Also don't add CFLAGS twice for links() checks

Includes a test for this.
2017-04-04 23:38:36 +05:30
Nirbheek Chauhan 09fee02dd9 Use shlex.split() to split CFLAGS/LDFLAGS/etc
This allows people to use spaces in the environment variables as long
as they use the correct quoting.
2017-04-04 22:30:13 +05:30
Nirbheek Chauhan d0d7cbd88b compilers: Rename 'get_define' to 'get_builtin_define'
We will use `get_define` to implement a function that fetches the
values of defines from headers.
2017-04-04 22:30:13 +05:30
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