Commit Graph

374 Commits

Author SHA1 Message Date
Jon Turney f3b5c3c27d
Simplify test for x86 targeted MSVC cross-compiler
We can't just do compiler.has_builtin_define('_M_IX86'), because the
VisualStudioCCompiler class doesn't implement has_builtin_define(), and
getting the compiler to disgorge it's builtin defines isn't easy...

But we can now use the target we stored when we identifed the compiler.

Also update comment appropriately
2018-12-06 13:26:51 +00:00
Jon Turney a872b925ea
Store the target architecture for CL-like compilers
Store the MSVC compiler target architecture ('x86', 'x64' or 'ARM' (this
is ARM64, I believe)), rather than just if it's x64 or not.

The regex used for target architecture should be ok, based on this list
of [1] version outputs, but we assume x86 if no match, for safety's
sake.

[1] https://stackoverflow.com/a/1233332/1951600

Also detect arch even if cl outputs version to stdout.

Ditto for clang-cl

Future work: is_64 is now only used in get_instruction_set_args()
2018-12-06 13:25:16 +00:00
Nirbheek Chauhan 0b3a607fd8 Correctly detect 32-bit arm userland on 64-bit arm
This is the same case as 32-bit x86 on x86_64.

Closes https://github.com/mesonbuild/meson/issues/4586
2018-12-05 19:39:01 +02:00
Nirbheek Chauhan 579b5bba12 Reorganize cpu detection code to be more consistent
Use a single point of exit for the detect_cpu* functions, and factor
out the compiler define code into a helper function.
2018-12-05 19:39:01 +02:00
Nirbheek Chauhan b75ff762f8 Fix detection with VS 2017, and fix a bug in detection on VS 2008
Starting with VS 2017, `Platform` is not always set (f.ex., if you use
VsDevCmd.bat directly instead of vcvars*.bat), but `VSCMD_ARG_HOST_ARCH`
is always set, so try that first.
2018-12-05 19:39:01 +02:00
John Preston c17a80f47b Use correct environment for REGEN in VS backend.
Try to guess which VS Command Prompt was used for the Meson call.
If one is chosen invoke it before calling Meson in REGEN command.
2018-12-04 20:19:19 +02:00
John Ericson 2ba97d506d Use more `environment.default_*` for consistency
After we make this work consistently, we can try to abstract the new pattern.
2018-12-03 22:34:53 +02:00
Dylan Baker e338e9ad2f environment: detect compilers from native files 2018-11-14 15:57:37 -08:00
Dylan Baker 3af4407a16 Get basic native config file loading working 2018-11-14 15:57:37 -08:00
Dylan Baker 95403cb615 replace ExternalProgram.from_cross_info with from_bin_list
This more generic method will also be used to check a config file for
binary information.
2018-11-14 15:57:37 -08:00
Michael Forney 50b2ef7354 Consider 'samu' when looking for ninja command
samu prints a different message when the build is a no-op, so make
assertBuildIsNoop consider that as well.

Also, if compile_commands.json cannot be found, just skip the test. This
seems reasonable since meson just produces a warning if `ninja -t compdb`
fails.

Finally, only capture stdout in run_meson_command_tests.py, since the
backend may print messages the tests don't recognize to stderr.

Fixes #3405.
2018-11-11 00:21:47 +02:00
Dylan Baker d405b74caf java: javac 9+ print their version to stdout not stderr
Fixes: #2569
2018-11-07 14:26:03 -08:00
Phillip Cao 68c83cb213 Add support for Renesas CC-RX toolchain 2018-11-08 00:02:22 +13:00
Xavier Claessens 43101489cd Recover when coredata cannot be loaded
Write command line options into a separate file to be able to
reconfigure from scatch in the case coredata cannot be loaded. The most
common case is when we are reconfiguring with a newer meson version.

This means that we should try as much as possible to maintain backward
compatibility for the cmd_line.txt file format.

The main difference with a normal reconfigure is it will use new
default options values and will read again environment variables like
CFLAGS, etc.
2018-11-06 16:37:13 -05:00
John Ericson d178fd0ab3 Begin to factor out logic for getting binaries
This gets the ball rolling, and doesn't depend on any of my other PRs in
flight.

Progress towards #4332
2018-11-06 21:06:50 +02:00
Jon Turney 2993fc4e8a
Use llvm-lib as an alternative to lib
Detect llvm-lib as an alternative Windows static linker to lib
2018-11-04 15:42:06 +00:00
Jon Turney 64edfd5069
Detect clang-cl as msvc-like, not clang-like
Handle clang's cl or clang-cl being in PATH, or set in CC/CXX

Future work: checking the name of the executable here seems like a bad idea.
These compilers will fail to be detected if they are renamed.

v2:
Update compiler.get_argument_type() test
Fix comparisons of id inside CCompiler, backends and elsewhere

v3:
ClangClCPPCompiler should be a subclass of ClangClCCompier, as well

Future work: mocking in test_find_library_patterns() is effected, as we
now test for a subclass, rather than self.id in CCompiler.get_library_naming()
2018-11-04 15:42:00 +00:00
Jussi Pakkanen 6f6afe24a7
Merge pull request #4326 from Ericson2314/per-machine
Start leveraging MachineInfo with for_* methods
2018-10-25 19:48:42 +03:00
Jussi Pakkanen 0a217f40d7 Detect powerpc processors on FreeBSD. Closes #4397. 2018-10-25 19:44:16 +03:00
Aki Van Ness 3ad99d2769 Added basic detection for AIX linker (not really a better way) 2018-10-17 10:45:52 +03:00
John Ericson 4efb361d47 Move some cross file parsing validition to MachineInfo
This is a domain-specific validation not tied to the surface syntax, so
it belongs here in the pipeline.
2018-10-14 20:20:06 +03:00
Mohammed Amer Khalidi 18204b8ed6 Adding "compiler_type" flag to ARM compilers. 2018-10-07 19:21:26 +03:00
John Ericson 68d0adf4d2 Rewrite `for_*` machine checks in terms of MachineInfo and phase out
It's much better to directly query the machine in question rather than
do some roundabout "is_cross" thing. This is the first step for much
natve- and cross- code path deduplication.
2018-10-05 23:31:16 -04:00
John Ericson 0b1fb51b66 MachineInfo: Make equality structural
For existing use cases, pointer equality sufficies, but structural is
much better going forward: these are intended to be immutable
descriptors of the machines.
2018-10-05 23:31:16 -04:00
John Ericson d69d2697cd Pull out essence total map essence of MachineInfos into PerMachine
We'll eventually have many other data structure duplicated for each
build, host, and target machines. This sets up the infrastructure for
that.
2018-10-05 23:31:15 -04:00
John Ericson 1c6b8b72cb Centralize description of build, host, and target, machines
Instead of just putting these together in the interpreter, put them
together in `environment.py` so Meson's implementation can also better
take advantage of them.
2018-10-05 00:14:44 +03:00
Masanori Kakura 99ecedc093 environment: Use os.path.basename() when checking mesonlib.meson_command
Without this, when one of Meson's parent directories contains
"python", unexpected option "-u" will be passed to Meson.
2018-09-25 20:38:35 -07:00
Ross Burton 89e0414efd environment: validate endian value from cross file
When reading the endian from a cross file, validate that the value is either
'big' or 'little'.
2018-09-25 02:42:49 +03:00
Alexey Brodkin 9453ac6182 mesonbuild: Recognise ARC architecture
-------------------------->8-----------------------
root@nsimhs:~# python

Python 2.7.15 (default, Sep 20 2018, 21:44:15)
[GCC 8.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import platform
>>> print platform.machine()
arc
-------------------------->8-----------------------

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2018-09-23 11:22:38 +03:00
GoaLitiuM bc4bf03871 D: Fix incorrect arch handling in D linkers 2018-09-20 19:00:12 +03:00
David Seifert 8f16d0f3c9 Fix ICC on macOS 2018-09-16 18:27:19 +03:00
Jussi Pakkanen b9f229a494
Merge pull request #4175 from GoaLitiuM/d-archfixes
D: Improve target architecture handling
2018-09-16 14:40:55 +03:00
David Seifert 69ec001b06 Use enum instead of `int` for compiler variants
* Enums are strongly typed and make the whole
  `gcc_type`/`clang_type`/`icc_type` distinction
  redundant.
* Enums also allow extending via member functions,
  which makes the code more generalisable.
2018-09-16 00:47:32 +03:00
GoaLitiuM 5b0ad0f8ad Refactor D target architecture handling
The stored architecture matches the same format accepted by dub.
2018-09-14 05:18:50 +03:00
GoaLitiuM 8fa7c29661 D: Fix linker detection when static linker is missing
Fallback to using D compilers as static linkers when no suitable static linker were found.
2018-09-13 22:07:19 +03:00
FFY00 234bb45b02 d: fix how the DC variable is handled 2018-08-27 23:48:51 +03:00
Jussi Pakkanen 1ffc8de5e8
Merge pull request #3981 from GoaLitiuM/d-win-fixes
Fix D support on Windows
2018-08-27 22:30:23 +03:00
FFY00 ac07ae7d41 d: disallow dmd frontends (ldmd and gdc) 2018-08-27 00:57:35 +03:00
GoaLitiuM 82b38b6071 Fallback to LDC as static linker when not in MSVC build environment 2018-08-20 22:27:31 +03:00
GoaLitiuM 79f05b189a Follow target platform defined in MSVC environment for Windows D compilation 2018-08-20 22:27:31 +03:00
mohdamerkhalidi 28754ea621 Adding a new AR Linker Class for the ARM Compiler. (#3949) 2018-08-14 23:04:43 +03:00
Jussi Pakkanen 1b2f8acbeb Add support for s390x CPUs. Closes #3897. 2018-08-11 04:21:55 -07:00
John Ericson 9f5c84279e Fix bug and clarify error message in cross file validation
I believe the intent (from 30d0c2292f) is
that `[binaries]` isn't needed just for "target-only cross" (build ==
host != target). This fixes the code to match that, hopefully clarifying
the control flow in the process, and also improves the message to make
that clear.
2018-08-10 00:20:55 +03:00
George Koehler e0ed1ceae2 Refactor getting the host system of a cross compiler
Use mesonlib.for_windows or mesonlib.for_cygwin instead of
reimplementing them.

Add CrossBuildInfo.get_host_system to shorten the repeated the code in
the mesonlib.for_<platform> methods.
2018-08-07 04:19:35 -07:00
Jussi Pakkanen ecf4024592 Add 32 bit sparc processor support. Closes #3901. 2018-08-03 00:27:33 +03:00
Jussi Pakkanen e75f6e4305
Merge pull request #3850 from mesonbuild/nirbheek/exe-wrapper-compiler-fallbacks
Be more permissive about not-found exe_wrapper
2018-07-31 19:33:06 +03:00
Nirbheek Chauhan 9e8566a277 Print a useful error when a compiler is not found in the cross file 2018-07-24 18:54:52 -07:00
Khem Raj 6fafbad6d5 mesonbuild: Recognise risc-v architecture
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2018-07-21 22:02:25 +03:00
Nirbheek Chauhan 416a00308f cross: Use ExternalProgram for cross-file exe_wrapper
We already have code to fetch and find binaries specified in a cross
file, so use the same code for exe_wrapper. This allows us to handle
the same corner-cases that were fixed for other cross binaries.
2018-07-09 04:09:46 +05:30
Nirbheek Chauhan 9bc9e9f306 Ask for more details when warning about unknown arch [skip appveyor] 2018-07-07 11:47:42 +03:00
Ross Burton e3e2e4ca14 Canonicalise 64-bit PowerPC CPU families to "ppc64"
Instead of exposing the endianness in the CPU family, canonicalise the CPU
family to just "ppc64" to match MIPS (which is also bi-endian).

Part of the work for #3842.
2018-07-07 11:47:42 +03:00
Jussi Pakkanen c08c8117ab Warn if compiler envvars point to cross compilers. Closes #3782. 2018-06-24 21:19:49 +03:00
Vasu Penugonda 7140afc0a8 Added ARMCLANG compiler support for C/C++ (#3717) 2018-06-21 00:55:39 +03:00
Ross Burton ecde1789b2 Validate cpu_family (#3753)
* environment: validate cpu_family in cross file

* run_unittests: add unittest to ensure CPU family list in docs and environment matches

* run_unittests: skip compiler options test if not in a git repository

* environment: validate the detected cpu_family

* docs: add 32-bit PowerPC and 32/64-bit MIPS to CPU Families table

Names gathered by booting Linux in Qemu and running:

$ python3
import platform; platform.machine()

Partial fix for #3751
2018-06-20 12:45:44 +00:00
Xavier Claessens 6ed7a31402 environment: copy self.cmd_line_options to not modify original options
That dict gets modified when adding default_options, but mesonmain will
need to keep the original values.
2018-06-06 20:02:37 +00:00
Xavier Claessens 7c4736d27f Convert args.projectoptions into a dict
This simplifies a lot of code, and centralize "key=value" parsing in a
single place.

Unknown command line options becomes an hard error instead of
merely printing warning message. It has been warning it would become an
hard error for a while now. This has exceptions though, any
unknown option starting with "<lang>_" or "b_" are ignored because they
depend on which languages gets added and which compiler gets selected.
Also any option for unknown subproject are ignored because they depend
on which subproject actually gets built.

Also write more command line parsing tests. "19 bad command line
options" is removed because bad cmd line option became hard error and
it's covered with new tests in "30 command line".
2018-06-06 20:02:37 +00:00
Xavier Claessens f4d60acaa9 Remove had_argument_for() it is not used anymore
This also means we don't need to keep original command line arguments
anymore.
2018-06-06 20:02:37 +00:00
Xavier Claessens 8fb72510c3 Move to coredata some methods handling options
Those methods only use coredata object, so better just move them as a
coredata method.
2018-06-06 20:02:37 +00:00
Xavier Claessens fa72cd7173 Move get_args_from_envvars() from environment to compilers 2018-06-06 20:02:37 +00:00
Chun-wei Fan 3c4c8bf775 environment.py: Properly check platform on MSVC 2008
The 'Platform' envvar may not be set on Visual Studio 2008, at least
when using the SDK 7.0 compilers, so check the 'BUILD_PLAT' envvar so
that we do not mis-detect x64 build environments as x86.
2018-06-06 18:37:29 +00:00
Nirbheek Chauhan eb383ef4a2 Automatically add cross-mingw root and sysroot bindir to WINEPATH
This ensures that all the system DLLs required by executables such as
libstdc++-6.dll can be found out of the box and tests can run
2018-06-05 10:50:22 +00:00
Niklas Claesson 7fbab2c6e9 Update environment.py
Fix typo in environment.py
2018-06-04 23:46:14 +03:00
Nirbheek Chauhan 107e061506 Error out when someone tries to use msys/python to run Meson
This mistake seems to be a very common hiccup for people trying to use
Meson with MSYS2 on Windows from git or with pip.

msys/python uses POSIX paths with '/' as the root instead of a drive
like `C:/`, and also does not identify the platform as Windows.

This means that configure checks will be wrong, and many build tools
will be unable to parse the paths that are returned by functions in
Python such as shutil.which.

Closes https://github.com/mesonbuild/meson/issues/3653
2018-06-03 18:59:24 +00:00
Nirbheek Chauhan 0a035dea6d Set the meson command to use when we know what it is
Instead of using fragile guessing to figure out how to invoke meson,
set the value when meson is run. Also rework how we pass of
meson_script_launcher to regenchecker.py -- it wasn't even being used

With this change, we only need to guess the meson path when running
the tests, and in that case:

1. If MESON_EXE is set in the env, we know how to run meson
   for project tests.
2. MESON_EXE is not set, which means we run the configure in-process
   for project tests and need to guess what meson to run, so either
   - meson.py is found next to run_tests.py, or
   - meson, meson.py, or meson.exe is in PATH

Otherwise, you can invoke meson in the following ways:

1. meson is installed, and mesonbuild is available in PYTHONPATH:
   - meson, meson.py, meson.exe from PATH
   - python3 -m mesonbuild.mesonmain
   - python3 /path/to/meson.py
   - meson is a shell wrapper to meson.real
2. meson is not installed, and is run from git:
   - Absolute path to meson.py
   - Relative path to meson.py
   - Symlink to meson.py

All these are tested in test_meson_commands.py, except meson.exe since
that involves building the meson msi and installing it.
2018-06-01 19:20:04 +00:00
Nirbheek Chauhan a6c9f98c57 depfixer: We no longer run this as a script 2018-05-24 14:38:28 +00:00
Jussi Pakkanen e3be7f7021 Write coredata transactionally. Closes #3511. 2018-05-21 00:48:25 +03:00
Xavier Claessens 6de68e5201 Passing --default-library=both should override project value
Looks like this has always been broken, had_argument_for() was checking
if we have --default_library instead of --default-library.
2018-04-27 11:19:12 -04:00
Jussi Pakkanen c58dd64f8e Merged Arm CC support. 2018-04-16 23:02:09 +03:00
Jussi Pakkanen 86f725c1e5
Merge pull request #3115 from makise-homura/e2k-lcc-support
Support lcc compiler for e2k (Elbrus) architecture
2018-04-15 17:18:44 +03:00
makise-homura 495f47b12b Make more precise CPU detection for Elbrus platform 2018-04-12 22:40:53 +03:00
Jussi Pakkanen 3e23f36a3c Fix detection to work with newer Java compilers. 2018-04-02 12:20:45 +03:00
makise-homura 67f067d5b2 Added version detection for lcc compiler 2018-03-28 21:35:45 +03:00
Somasekhar Penugonda e62b8109eb Updates to CPP support and update review changes 2018-03-27 17:04:26 -05:00
makise-homura 7cc41baa98 Added Elbrus lcc compilers support as inheritance from gcc ones 2018-03-19 23:30:00 +03:00
Bedarkar, Malhar 831d1e4c2e - Updating cpp_std options similar to other compiler classes
- Updating environment.py for selecting '--vsn' option for armcc only.
- Updating build type arguments from GitHub pull request - 3157

Change-Id: Id3151e7715ec1016afdbd65391bb0d414ec7de13
2018-03-14 22:42:06 -05:00
Jussi Pakkanen ae0e469b06
Merge pull request #3145 from thejk/gcovr
Support gcovr >= 3.1 and add gcovr html report as fallback
2018-03-13 21:12:16 +02:00
Joel Klinghed dfc0655bcd fixup! Fix coverage-xml and coverage-text targets for gcovr >= 3.1
Fix fail cases of detect_gcovr
2018-03-13 08:31:50 +01:00
Joel Klinghed ed8197207e fixup! Fix coverage-xml and coverage-text targets for gcovr >= 3.1
Rename gcovr_3_1 to gcovr_new_rootdir
2018-03-12 22:18:26 +01:00
Bedarkar, Malhar a2ee76228e First cut of ARMCC support for MESON.
Change-Id: I15d8258e84d392baaccb8f670e33eefcfe8cd49a
2018-03-05 18:26:39 -06:00
Hemmo Nieminen 7fb8e518b2 Harmonize data pickling.
Try to be more consistent on using save() and load() methods to pickle
data.
2018-03-01 01:06:51 +02:00
Hemmo Nieminen b0446075ec Remove some unused variables. 2018-03-01 01:06:51 +02:00
Joel Klinghed da01770261 Fix coverage-xml and coverage-text targets for gcovr >= 3.1
In gcovr 3.1 the -r/--rootdir argument changed meaning causing
reports generated with gcovr 3.1 to not find the source files
and look for *.gcda in the whole source tree rather than the
build dir.

So, detect gcovr version and if 3.1 give build_root to -r instead
of source_root.
2018-02-27 21:48:42 +01:00
Thibault Saunier c48b9594ff Add support for Visual Studio csc c# compiler 2018-02-25 01:10:52 +02:00
makise-homura 22a83817c8 Fixed syntax issues (for 'in' operator) 2018-02-21 18:29:25 +03:00
makise-homura 8236bed11b Support lcc compiler for e2k (Elbrus) architecture 2018-02-21 16:53:15 +03:00
Jon Turney f37692bedb Fix exception in 'test cases/failing/55 wrong shared crate type' when rustc is missing
Fix exception handling of missing rustc, by making it look like the other
compiler detectors

Traceback (most recent call last):
  File "/wip/meson/mesonbuild/environment.py", line 699, in detect_rust_compiler
    p, out = Popen_safe(compiler + ['--version'])[0:2]
[...]
FileNotFoundError: [Errno 2] No such file or directory: 'rustc': 'rustc'

During handling of the above exception, another exception occurred:

[...]
  File "/wip/meson/mesonbuild/environment.py", line 701, in detect_rust_compiler
    popen_exceptions[compiler] = e
TypeError: unhashable type: 'list'
2018-02-15 12:51:25 +00:00
Jussi Pakkanen bfa6c8d074
Merge pull request #2938 from acfoltzer/rust-cross-merge
Add cross-compilation support for `rustc`
2018-02-04 00:44:09 +02:00
Adam C. Foltzer 1d81efb03d Add cross-compilation support for `rustc`
This patch is largely modeled on the relatively-straightforward code
for Fortran cross-compilation, so there might be some intricacies
missing.
2018-01-29 15:47:05 -08:00
Aleksey Filippov 2cf85ae16f Use os.path: basename() and dirname() instead of split()
According to Python documentation[1] dirname and basename
are defined as follows:
    os.path.dirname() = os.path.split()[0]
    os.path.basename() = os.path.split()[1]
For the purpose of better readability split() is replaced
by appropriate function if only one part of returned tuple
is used.

[1]: https://docs.python.org/3/library/os.path.html#os.path.split
2018-01-30 07:08:22 +11:00
Edward Betts bdfcecd2c6 Correct spelling mistakes. 2018-01-19 15:53:00 +02:00
Matthias Klumpp 5133d8650f d: Detect recent DMD compilers
They now are published by the D Language Foundation, and not Digital
Mars. Therefore, their signature has changed slightly.
(We can not check for 'DMD', because that string appears in every
compiler version output to denote the frontend version used by the
compiler).
2018-01-07 19:52:07 +02:00
Nirbheek Chauhan ae0f4ef055 compilers: Fix error when objc/objc++ compilers are not found
Earlier it would exit with a traceback:

UnboundLocalError: local variable 'out' referenced before assignment
2017-12-30 18:02:28 +02:00
Christoph Behle 7bd30c522b Fix flake8 issues. 2017-12-16 16:12:46 +01:00
Christoph Behle 1f3b41021d More version information for Fortran. 2017-12-16 15:38:31 +01:00
Christoph Behle 5b83894b77 More version information for D 2017-12-16 15:07:08 +01:00
Christoph Behle 783263b9f4 More version information for C# 2017-12-16 15:05:09 +01:00
Christoph Behle c6acf75617 More version information for compilers.
See issue #2762
Adds full_version to class Compiler. If set full_version will be printed
additionally.
Added support for CCompiler and CPPCompiler
Added support for gcc/g++, clang/clang++, icc.
2017-12-16 14:52:08 +01:00
Josh Soref 2b0505f222 spelling: targeting 2017-11-26 06:15:13 +00:00
Jussi Pakkanen 22adda1617 Review fixes. 2017-11-21 23:29:06 +02:00
Jussi Pakkanen 5d51bc79c7 Replaced sys.executable use with the mesonlib equivalent. 2017-11-20 23:08:17 +02:00
Nirbheek Chauhan d2a250412c compilers: Improve manual library searching
We can now specify the library type we want to search for, and whether
we want to prefer static libraries over shared ones or the other way
around. This functionality is not exposed to build files yet.
2017-11-11 23:06:48 +05:30
Elliott Sales de Andrade 6715087598 Dump coredata earlier.
Unfortunately, `time.time` and file timestamps are not guaranteed to be
in sync and due to various kernel caches may be different enough to
cause rebuilds to fail [1]. This was masked by older ninja versions that
could not read sub-second timestamps.

[1] https://travis-ci.org/mesonbuild/meson/jobs/296797872
2017-11-06 20:56:53 +02:00
Dylan Baker 4e394b3341 dependencies: Add function to strip system -L paths
PkgConfig automatically removes -L paths from libdirs if the -L points
to a system path. It knows what these paths are by taking this as a
configure option at build time, which the distro maintainers set
appropriately and everything works. This allows one to have two
versions of a package installed, a system and non system, and then
override PKG_CONFIG_PATH to use the non system version, and everything
just works. For non-pkgconfig dependencies (such as LLVM) meson needs to
strip these themselves to avoid breaking the above use case.
2017-10-21 10:36:00 -07:00
Nirbheek Chauhan 7c2ae55fab Revert "Revert "Merge pull request #1931 from centricular/use-patched-ninja""
This reverts commit 5eb64a6f3e.

Let's try again, with a fixed Ninja by QuLogic.
2017-09-18 18:40:24 +03:00
William D. Jones 48e7398add Check if Watcom version of cl exists in the path and avoid using it. (#2237) 2017-08-23 15:39:09 +03:00
Philippe Payant f83be23d55 Remove trailing spaces. 2017-08-23 15:22:02 +03:00
Philippe Payant fc92991e34 Fix detection of MSVC 2008 version. 2017-08-23 15:22:02 +03:00
Jussi Pakkanen 50fb7d37ab Make all functionality invokable via the main Meson binary,
which can be a Windows .exe file.
2017-08-18 12:08:20 +03:00
YmrDtnJu 0929812eb5 Do not ignore stderr on gcc type check in get_gnu_compiler_defines.
As stderr may contain information the user can use to solve the problem with
the gcc installation, it should not be ignore but added to the error message.
2017-08-10 10:43:39 +03:00
Paulo Antonio Alvarez bc30ad6dba environment: Read VALAC from the environment and use it if set
The valac binary was hard coded in meson. We now check if VALAC is
defined in the environment, and if it is, use its value as the vala
compiler, if not, we proceed with the hard coded binary name.
2017-08-09 21:47:19 +03:00
Jussi Pakkanen 7f307fd5ef Update list of compiler executable names to try. 2017-07-31 07:08:07 -04:00
Jussi Pakkanen e89b6cdd10 Merge pull request #1374 from mesonbuild/simd
Add support for SIMD detection
2017-07-19 15:50:04 +03:00
Jussi Pakkanen db34a3a701 Close files reliably. 2017-07-18 00:33:08 +02:00
Jussi Pakkanen 5eb64a6f3e Revert "Merge pull request #1931 from centricular/use-patched-ninja"
This reverts commit aab7ada356, reversing
changes made to e1b24765af.
2017-07-18 00:30:52 +02:00
Nirbheek Chauhan afdaedea01 msvc: Split stderr by line and raise exception if empty
std.split() splits on whitespace, but we want the first line.
2017-07-17 19:20:00 +03:00
Jussi Pakkanen 8396c4f3e6 Added VS support to simd detector. 2017-07-17 19:15:04 +03:00
Nirbheek Chauhan e307865596 ninja backend: Detect ninja only once and log it
Needed for the CI, but good to have in general too.
2017-07-17 17:26:21 +05:30
Elliott Sales de Andrade b52955ff3d Run postconf scripts after dumping coredata.
MESONINTROSPECT is set when running postconf scripts, which implies that
introspection is possible. But it isn't really possible because coredata
hasn't been written yet. We also still need to make sure to delete
coredata if any postconf scripts fail.
2017-07-15 13:47:17 +02:00
Jehan d80787ae28 Output an appropriate warning when a cross info file does not exist.
If making a typo, it used to output:
>  Cross info file must have either host or a target machine.
This was not useful at all and looked like there could be a file format
error or some other issue with the content. Let's have an appropriate
error:
> File not found: /some/path
2017-07-02 10:08:08 -04:00
Nirbheek Chauhan 5dab5f1600 environment: Fix exception when no defines were found
Lists are not hashable.

Closes https://github.com/mesonbuild/meson/issues/1989
2017-06-26 14:16:13 -04:00
Alistair Thomas 117f4ab8b5 Split out languages from compilers.py 2017-06-23 00:42:41 +01:00
Alistair Thomas d71da5bdb3 Converted compilers.py to a sub-package 2017-06-22 20:12:42 +01:00
Alistair Thomas e5559903b3 Split linkers out from compilers.py 2017-06-22 20:09:58 +01:00
Jussi Pakkanen 7c03bfb463 Merged needs_exe_wrapper branch. 2017-06-07 20:09:43 +03:00
Alan 53e47d42f0 Set clang_type to CLANG_WIN on windows. 2017-06-03 23:45:59 +03:00
Ole André Vadla Ravnås b32c757073
environment: Add needs_exe_wrapper for overriding auto-detection.
This is useful when build_machine appears to be compatible with
host_machine, but actually isn't. For example when:
- build_machine is macOS and host_machine is the iOS Simulator
- the build_machine's libc is glibc but the host_machine libc is uClibc
- code relies on kernel features not available on the build_machine
2017-05-29 21:05:57 +02:00
Elliott Sales de Andrade 00f89b0f6e Fix undefined variables/methods. 2017-05-17 19:43:14 -04:00
Elliott Sales de Andrade 83d1c7f063 Rearrange trys to avoid possible undefined vars. 2017-05-17 05:37:02 -04:00
Elliott Sales de Andrade 65b1d33931 Remove unused imports. 2017-05-17 03:42:16 -04:00
Jussi Pakkanen b65b9fe271 More strict eval. 2017-05-01 19:30:55 +03:00
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
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
Jussi Pakkanen 1d36f68629 Merge pull request #660 from mesonbuild/libdirfix
Fix library directory handling
2016-07-30 20:09:49 +03:00
Jussi Pakkanen 10ab88710b Determine lib paths on demand rather than up front because they might change during build file parsing. 2016-07-30 19:42:01 +03:00
Nirbheek Chauhan 018fa4b90f vs: Fix regen_checker by using the correct coredata mtime
After c01b183e5, the mtime of coredata.dat is always newer than all the
other build files, which made regen_checker think that they always had
to be regenerated. Now we set the mtime of the file to a value before
the build files are generated and that makes everything behave as it did
earlier.
2016-07-29 08:18:59 +05:30
Jussi Pakkanen b072d72f94 Properties is no longer mandatory in cross files so do not require it. 2016-07-20 22:53:26 +03:00
Nirbheek Chauhan 88aafd363e Normalize the path of a configured file to avoid dupes (#640) 2016-07-19 20:10:57 +03:00
Nirbheek Chauhan 69d9c2228d vs: Fix Meson invocation while doing regen (#646)
The Meson script is not always in $scriptdir/../../ -- for instance if
installed with pip on Windows, the scriptdir is in:

C:/Python35/Lib/site-packages/meson-0.33.0.dev1-py3.5.egg/mesonbuild/scripts

and the meson.py script is in:

C:/Python35/Scripts

So, let's save the path available as Environment().meson_script_file
into the coredata.dat private file and use that to invoke Meson when
doing regen.

Also, let's fetch the backend that was used from the coredata too
instead of hard-coding vs2010.

Both these were causing a hard failure while doing regen with msbuild or
visual studio.
2016-07-19 00:00:17 +03:00
Jussi Pakkanen 64919b1c74 Merge pull request #417 from nirbheek/dll-paths
Fix filenames and paths used in DLL shared library generation
2016-07-13 22:18:50 +03:00
Jussi Pakkanen c0057da133 Can get arbitrary data from cross file properties. 2016-07-02 00:00:03 +03:00
Nirbheek Chauhan 0143c32c7c Overhaul versioning and naming of libraries
This commit contains several changes to the naming and versioning of
shared and static libraries. The details are documented at:
https://github.com/mesonbuild/meson/pull/417

Here's a brief summary:

* The results of binary and compiler detection via environment functions
  are now cached so that they can be called repeatedly without
  performance penalty. This is necessary because every
  build.SharedLibrary object has to know whether the compiler is MSVC or
  not (output filenames depend on that), and so the compiler detection
  has to be called for each object instantiation.

* Linux shared libraries don't always have a library version. Sometimes
  only soversions are specified (and vice-versa), so support both.

* Don't use versioned filenames when generating DLLs, DLLs are never
  versioned using the suffix in the way that .so libraries are. Hence,
  they don't use "aliases". Only Linux shared libraries use those.

* OS X dylibs do not use filename aliases at all. They only use the
  soversion in the dylib name (libfoo.X.dylib), and that's it. If
  there's no soversion specified, the dylib is called libfoo.dylib.
  Further versioning in dylibs is supposed to be done with the
  -current_version argument to clang, but this is TBD.

  https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW23

* Install DLLs into bindir and import libraries into libdir

* Static libraries are now always called libfoo.a, even with MSVC

* .lib import libraries are always generated when building with MSVC

* .dll.a import libraries are always generated when building with
  MinGW/GCC or MinGW/clang

* TODO: Use dlltool if available to generate .dll.a when .lib is
  generated and vice-versa.

* Library and executable suffix/prefixes are now always correctly
  overriden by the values of the 'name_prefix' and 'name_suffix' keyword
  arguments.
2016-07-01 20:50:47 +05:30