Commit Graph

700 Commits

Author SHA1 Message Date
Daniel Mensinger 8c364952af
Added dependecy kwargs support 2019-01-31 15:57:02 +01:00
Daniel Mensinger 5655865246
Added test case 2019-01-31 15:43:04 +01:00
Daniel Mensinger 8bb942ef25
Rewriter infodump modifications 2019-01-31 15:43:04 +01:00
Daniel Mensinger 8224ecfbe6
Some fixes and assignment based target find 2019-01-31 15:43:04 +01:00
Nirbheek Chauhan 00b59c9ad6 pkg-config: Fix another case where we were throwing a traceback
Also add a test for it. In the process, also remove an overly-zealous
try..except statement that was catching *all* exceptions, not just
expected ones, which was masking programming errors.
2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 4268e156a3 unit tests: darwin tests must never require pkg-config 2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 3997e8762e unit tests: Fix sdl2 failure test on macOS
Also ensure that the test's no-pkg-config codepath will always be run,
even on the CI where we always have pkg-config available.

This counts as a test case for #4728
2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 58852e6290 unit tests: Simplify get_fake_env()
Almost every test already uses '' for the srcdir/builddir/etc.
Make it official.
2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 36779c0500 unit tests: Run native file tests on the CI
The native file tests were never run on the CI since they were skipped
on Windows and also skipped on Linux and macOS since CC/CXX/etc are
always set by the CI.

Also fix test failure on macOS. The test was assuming that because
/usr/bin/gcc and /usr/bin/clang exist on macOS, they must be different
compilers. They're not. gcc is just a wrapper around clang, and we
correctly detect it as such.
2019-01-30 23:21:59 +02:00
Michael Hirsch, Ph.D da34bea893 pep8 py37 2019-01-29 22:06:11 +02:00
Michael Hirsch, Ph.D 8636f31d9c BUGFIX: broken/missing Fortran code/unit tests 2019-01-27 20:57:21 +02:00
Jussi Pakkanen 733f9a7765
Merge pull request #4814 from mensinda/astVisitor
rewriter: Rewrote the meson rewriter - now works with AST modification
2019-01-27 20:46:29 +02:00
Christoph Reiter 8df5afc98a configure_file: preserve newlines of the input file. Fixes #4817
In some cases (see #4817) it's helpful if the output file uses the
same newlines as the input file without translating them to the
platform defaults.

open() by default recognizes all newline styles and translates them
to "\n" and then to the platform default when writing.
Passing "" to "newline" disables the translation and lets us pass through
the original newline characters.
2019-01-24 21:02:34 +02:00
Nirbheek Chauhan d02ec7111e coredata: Only reject a load if major version differs
Our builddir ABI is stable across minor (stable) releases, so there is
no need to force a wipe. We already release pretty often, no need to
force people to wipe twice as often.
2019-01-23 19:50:50 +05:30
Daniel Mensinger 4b3e21b894
Fixed test case and setup.py 2019-01-22 17:47:51 +01:00
Daniel Mensinger 6fe2c2b209
Fixed flake8 issues 2019-01-22 17:31:15 +01:00
Daniel Mensinger 027c3c9ac7
Added subdir test 2019-01-22 17:04:43 +01:00
Daniel Mensinger b7c6f3ec72
Can now rewrite files 2019-01-22 16:41:25 +01:00
Daniel Mensinger 8dd9b44831
Added support for removing sources from a target 2019-01-22 16:41:25 +01:00
Daniel Mensinger 0ce6632393
Added suport for adding sources to a target 2019-01-22 16:41:25 +01:00
Daniel Mensinger 86d5799bc4
First rewriter test case 2019-01-22 16:41:06 +01:00
Daniel Mensinger 277dc10a5d
AST post processing 2019-01-22 16:09:34 +01:00
Simon McVittie 65192af2ff run_unittests: Use Python 3.5-compatible subprocess invocation
subprocess.run() didn't get the encoding parameter until 3.6.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-17 23:09:17 +02:00
Daniel Mensinger af38722f89 mintro: Introspection interpreter refactoring (#4733)
* Fixed spelling

* Merged the Buildoptions and Projectinfo interpreter

* Moved detect_compilers to Environment

* Added removed test case

* Split detect_compilers and moved even more code into Environment

* Moved set_default_options to coredata

* Small code simplification in mintro.run

* Move cmd_line_options back to `environment`

We don't actually wish to persist something this unstructured, so we
shouldn't make it a field on `coredata`. It would also be data
denormalization since the information we already store in coredata
depends on the CLI args.
2019-01-16 23:42:54 +02:00
Daniel Mensinger 2bb69ad50b Renamed unit test directories 2019-01-16 19:10:47 +02:00
Xavier Claessens 66ac6f6b3d find_external_dependency: Return NotFoundDependency()
The returned not-found object can be from any type because we were
returning the first of the failed attempts. It also can happen that we
don't have any dependency object in which case we should just return
NotFoundDependency() object as well instead of raising an exception.
That exception was happening before, but dependency_impl() was
calling find_external_dependency() in a try block so it was hidden.
2019-01-16 11:16:46 -05:00
Xavier Claessens 815f1205a8 do_subproject: Improve log messages and formatting 2019-01-16 11:16:46 -05:00
Daniel Mensinger 609ecba37f mintro: Added `defined_in` key in the targets introspection 2019-01-15 20:28:12 +02:00
Daniel Mensinger 5c139032b8
Deprecated --target-files API 2019-01-07 22:35:56 +01:00
Daniel Mensinger 29dd57dcbf
Fixed flake8 2019-01-07 22:26:09 +01:00
Daniel Mensinger e67ba0fd64
Also made buildsystem files absolute 2019-01-07 22:26:09 +01:00
Daniel Mensinger a1d8c1d3e9
Changed introspection target format 2019-01-07 22:24:49 +01:00
Daniel Mensinger ab32f1fe00 Added meson-info.json 2019-01-06 22:03:29 +01:00
Daniel Mensinger bd8bad46c3
Code cleanup and renamed variables 2019-01-06 12:19:33 +01:00
Daniel Mensinger 8ac5b36c70
Fixed mac unit test 2019-01-06 12:19:32 +01:00
Daniel Mensinger 02734cc5c3
Better documentation 2019-01-06 12:19:31 +01:00
Daniel Mensinger 2e81631d0c
Keep 'filename' and 'install_filename' as strings 2019-01-06 12:19:31 +01:00
textshell 7eb8621ea6
Update run_unittests.py
Co-Authored-By: mensinda <daniel@mensinger-ka.de>
2019-01-06 12:19:30 +01:00
Daniel Mensinger 7691b0460c
Ninja backend target introspection 2019-01-06 12:19:30 +01:00
Daniel Mensinger d4ac832bf6
Split the monolithic introspection file into chunks 2019-01-06 12:19:29 +01:00
Daniel Mensinger e4e0e89ea8
Fixed mac build 2019-01-06 12:19:29 +01:00
Daniel Mensinger a9ade54707
Should fix azure 2019-01-06 12:19:29 +01:00
Daniel Mensinger c326ae2e75
Fixed flake8 2019-01-06 12:19:29 +01:00
Daniel Mensinger b11df88395
Documentation and unit test update 2019-01-06 12:19:29 +01:00
Daniel Mensinger b034f52656
Filenames are now lists 2019-01-06 12:19:29 +01:00
Daniel Mensinger b91c5aad85
Update intro dump on meson configure 2019-01-06 12:19:29 +01:00
Daniel Mensinger c4eb5c79fe
Added unit test 2019-01-06 12:19:28 +01:00
Daniel Mensinger 24d668bea0
Removed determine_installed_path since it is no longer needed 2019-01-06 12:19:28 +01:00
Daniel Mensinger 98eb7a48ab
Added unit test 2019-01-06 12:19:27 +01:00
Xavier Claessens 83964f64fa pkgconfig: Fix flag deduplication
This is a regression introduced by 2cbf7caf5, generated pkg-config files
have many duplicated '-pthread' flags.
2019-01-05 21:44:53 +02:00
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
Daniel Mensinger e5099357c2
Tests and docs 2018-12-29 23:56:21 +01:00
Jussi Pakkanen 8a6c0aa13d Better error message for rpath test. 2018-12-30 00:51:40 +02:00
Jussi Pakkanen da5da5977a Default libdir is "lib" when cross compiling. Closes #2535. 2018-12-30 00:51:19 +02:00
Jussi Pakkanen 1fca654055 Add a clang-format target. 2018-12-30 00:50:00 +02:00
Jussi Pakkanen c220816350
Merge pull request #4573 from jon-turney/msys2-clang
More clang for Windows support
2018-12-21 00:01:31 +02:00
Daniel Mensinger 6864ed60dd mintro: Bug fix for determine_installed_path for multiple target outputs 2018-12-20 23:03:55 +02:00
Dylan Baker f9a35e08ac msetup: Fix callig meson --wipe inside a build directory
This seems to be related to deleting the current working directory.
Simply deleting all of the trees inside the build directory instead
seems to fix it. This only appears with some combination of generated
targets, running the test case against say "1 trivial" doesn't show the
bug.

See this mesa bug: https://bugs.freedesktop.org/show_bug.cgi?id=109071
2018-12-20 13:30:30 -05:00
Daniel Mensinger b321c32952 Added unit test 2018-12-19 18:04:49 -05:00
Niklas Haas 261ab9b214 pkgconfig: Fix link order of library dependencies
Since `_process_libs` appends the lib's dependencies this list already,
the final return value of `_process_libs` will end up after its
dependencies, which is the wrong way around. (The lib must come first,
then its dependencies)

The easiest solution is to simply pre-pend the return value of
`_process_libs` rather than appending it, so that its dependencies come
after the library itself.

Closes #4091.
2018-12-12 10:42:32 -05:00
Jon Turney 468c4411e1
Skip test_config_tool_dep on MSYS2
llvm-config --libfiles --link-shared wants to link to a bunch of shared
libraries which don't exist, so we end up at dev.py:308, but the guess
that makes ('libLLVM*.dll') doesn't take into account the existence of
implibs (which is fixable), but even if it did 'libLLVM-7.0.dll.a'
doesn't seem to exist... so not sure how to fix this...)

Also some steps towards making that work:

Adjust helper_create_binary_wrapper for MSYS2. The .bat wrapper should
run msys2 python, not try to invoke the 'py' python launcher (which may
not be present)

Suppress echoing of the command in helper_create_binary_wrapper
(otherwise the echoed command can interfere in interpreting the output
of the wrapped command, which seems to be the case when it's
llvm-config)
2018-12-09 20:40:31 +00:00
Jon Turney aff5b3f416
Skip LTO test with Windows clang
This doesn't seem to be working in clang, at the moment.
2018-12-09 20:40:30 +00:00
Jon Turney 65160a969e
Don't rely on -fPIC being ignored where it's meaningless
clang considers it an error to try to use -fPIC for a windows target

v2:
'' isn't consistently elided, use []
2018-12-09 20:40:27 +00:00
Jussi Pakkanen 03311e6d8c Skip if a suitable D alternative is not found. 2018-12-09 19:55:18 +02:00
Jussi Pakkanen c44a5a1aec Deduplicate export-dynamic and pthread. Closes #4567. 2018-12-06 16:20:54 +02:00
John Ericson 0fd548e16f Combine `run_tests` import lines in `run_unittests` 2018-12-03 22:33:20 +02:00
Jussi Pakkanen b0611bdd9a
Merge pull request #3061 from jon-turney/introspect-custom-target-files
Fix 'meson introspect --target-files' for a custom target
2018-11-28 21:58:11 +02:00
Jussi Pakkanen 270f2395d6
Merge pull request #4191 from trilader/feature/projectinfo-from-source
mintro: Allow introspect --projectinfo without build directory
2018-11-27 22:18:13 +02:00
Daniel Mensinger 22fca7589f Fixed unit test (see #4549) 2018-11-27 19:56:40 +02:00
Daniel Schulte f954eee906 Remove name property from introspect --projectinfo as it is not used 2018-11-26 23:12:00 +01:00
Daniel Schulte 0e62193730 mintro: Allow introspect --projectinfo without build directory.
This variant was added to allow introspection before configuring a build
directory. This is useful for IDE integration to allow displaying and/or
setting options for the initial configuration of the build directory.

It also allows showing basic information about the project even if it's
not yet configured or configuring failed.

The project 'name' field in --projectinfo is used inconsistently:
For the top level project it always shows the name configured in
the top level meson.build file. For subprojects it's referring to the
name of the directory the subproject's meson.build is contained in.

To have a consistent output and preserve the existing behavior this adds
the 'descriptive_name' field which always shows the name set in the
project.

To be consistent the 'descriptive_name' field was also added to the
--projectfiles variant that uses an already configured build.

It also extends the information shown with the list of buildsystem-files.
This is currently only implemented in the variant for unconfigured
projects.
2018-11-26 23:12:00 +01:00
Daniel Mensinger 1f48aa595d
Added 'section' key to buildoptions introspection 2018-11-24 09:49:33 +01:00
Aleksey Filippov 1c8c888854 Use first 7 letters of sha256 for subdirectory part of target id
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes #4226.
2018-11-22 23:38:40 +02:00
Marcel Hollerbach 443a4a8c78 pkgconfig: add support for pkgconfig generation for c#
this adds support for generating pkgconfig files for c#.

The difference to c and cpp is that the -I flag is not known to the c#
compiler, but rather the -r flag which is used to link a .dll file into
the compiled library.

However this opens the question of validating which pkgconfig files can
be generated (depending on the language).

This implements 4409.
2018-11-21 21:36:39 +02:00
Jon Turney a33acd31da Fix flake8 'imported but unused' reports
$ flake8 | grep F401
./run_unittests.py:43:1: F401 'mesonbuild.mesonlib.is_linux' imported but unused
./mesonbuild/compilers/c.py:32:1: F401 '.compilers.CompilerType' imported but unused
./mesonbuild/compilers/cpp.py:23:1: F401 '.compilers.CompilerType' imported but unused
2018-11-19 21:07:37 +02:00
Dylan Baker 80f8c9930c unittests: don't override LD_LIBRARY_PATH
part of using ICC is configuring LD_LIBRARY_PATH so that you can link
with several Intel specific .so's. Currently meson blanket overrides the
LD_LIBRARARY_PATH in several tests which breaks them. Instead prepend
the test dir td LD_LIBRARY_PATH. Fixes 6 tests with ICC.
2018-11-15 18:42:25 -08:00
Dylan Baker f2d503ca34 unittests: don't run sanitizer tests for on compilers without sanitizer support
This commit adds a nice decorator helper for skipping tests when they
require the compiler to implement a specific base option, and uses it to
turn off b_sanitize tests, which fixes some tests on ICC.
2018-11-15 18:42:25 -08:00
Dylan Baker e338e9ad2f environment: detect compilers from native files 2018-11-14 15:57:37 -08:00
Dylan Baker 71a5f990d0 modules/python: Allow use of the native file
Currently this just allows setting a "python" variable that always
overrides, probably we want to have the option for "python2" and
"python3" as well.
2018-11-14 15:57:37 -08:00
Dylan Baker 091452f8cd modules/python3: allow specifying in the native file 2018-11-14 15:57:37 -08:00
Dylan Baker caf1066cd1 dependencies: Allow config tool dependencies to use native files
This allows tools like llvm-config to be selected from the config file

Fixes: #3327
2018-11-14 15:57:37 -08:00
Dylan Baker 42ddc30cfe interpreter: allow find_program to use the native file 2018-11-14 15:57:37 -08:00
Dylan Baker cb2a66cdef unittests: Add framework for testing native config files 2018-11-14 15:57:37 -08:00
Stian Selnes 0821462ce3 Add kwarg is_default to add_test_setup()
is_default may be used to set the name of the test setup that will be
used by default whenever the option --setup is not given.

Fixes #4430
2018-11-12 16:23:59 +05:30
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
Xavier Claessens a173dbf772 Add reconfigure/wipe unit test 2018-11-06 16:37:50 -05:00
Lyude Paul 11e3011a6b Don't use host pkg-config for native dependencies
When trying to cross-compile mesa on an aarch64 system, I noticed some
strange behavior. Meson would only ever find the wayland-scanner binary
in my host machine's sysroot (/mnt/amethyst):

  Native dependency wayland-scanner found: YES 1.16.0
  Program /mnt/amethyst/usr/bin/wayland-scanner found: YES (/mnt/amethyst/usr/bin/wayland-scanner)

It should be finding /usr/bin/wayland-scanner instead, since the
wayland-scanner dependency is created as native. On closer inspection,
it turned out that meson was ignoring the native argument passed to
dependency(), and wuld always use the pkgconfig binary specified in my
toolchain instead of the native one (/usr/bin/pkg-config):

  Native dependency wayland-scanner found: YES 1.16.0
  Called `/home/lyudess/Projects/panfrost/scripts/amethyst-pkg-config
  --variable=wayland_scanner wayland-scanner` -> 0

Turns out that if we create a dependency() object with native:false, we
end up caching the pkg-config path for the host machine in
PkgConfigDependency.class_pkgbin, instead of the build machine's
pkg-config path. This results causing in all pkg-config invocations for
dependency() objects to use the host machine's pkg-config binary,
regardless of whether or not 'native: true' was specified when the
dependency() object was instantiated.

So, fix this by never setting PkgConfigDependency.class_pkgbin for cross
dependency() objects. Also, add some test cases for this. Since
triggering this bug can be avoided by creating a dependency() objects
with native:true before creating any with native:false, we make sure
that our test has two modes: one where it starts with a native
dependency first, and another where it starts with a cross dependency
first.

As a final note here: We currently skip this test on windows, because
windows doesn't support directly executing python scripts as
executables: something that we need in order to point pkgconfig to a
wrapper script that sets the PKG_CONFIG_LIBDIR env appropriately before
calling pkg-config.

Signed-off-by: Lyude Paul <thatslyude@gmail.com>
2018-11-06 21:12:10 +02:00
Jon Turney ac6d4338cc
Make use of get_argument_syntax() in another test case 2018-11-04 15:42:06 +00:00
Jon Turney e7bed74ae2
Fix a bug in test_compiler_detection
AR wasn't reset in the environment, so this test could fail if more than one
language compiler was specified in the environment and the linker wasn't
'ar'
2018-11-04 15:42:06 +00:00
Jon Turney c789efb8c8
Use lld-link with clang-cl
Use lld-link dynamic linker with clang-cl
Don't hardcode dynamic linker name in tests
2018-11-04 15:42:06 +00:00
Jon Turney bb0bbfc2ab
Adjust more tests which need to know compiler type 2018-11-04 15:42:06 +00:00
Jon Turney d35034b21b
Use 'rc' resource compiler with clang-cl toolchain
The LLVM toolchain doesn't come with a Windows resource compiler at
the moment. Use 'rc' from the Windows SDK.
2018-11-04 15:42:06 +00:00
Jon Turney 198e869162
Make use of get_argument_syntax() in test cases 2018-11-04 15:42:06 +00:00
Jon Turney 152ea1a91a
Teach unit test test_compiler_detection about clang-cl
v2:
Update for ClangClCcompiler class
v3:
Reorder compilers to simplify
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 c4a9f59dc4 Move VS C++17 test to a unit test since it requires env setup. 2018-10-24 17:19:36 +03:00
Michał Górny e8232c7825 Remove implicit compression of man pages
Remove the code responsible for implicitly compressing manpages as .gz
files.  It has been established that manpage compression is a distro
packager's task, with existing distros already having their own
implementations of compression.

Fixes #4330
2018-10-20 13:16:28 +03:00
David Seifert 87d85c7fcb Add macOS test for duplicate `-delete_rpath` handling
* Without commit 3a8911a07f
  the newly added test `test_duplicate_rpath` in
  `DarwinTests` would fail.

  Example:
    https://travis-ci.org/mesonbuild/meson/jobs/441412556
2018-10-15 00:17:49 -07:00
Jussi Pakkanen 252bf6c52e
Merge pull request #4340 from jon-turney/azure-pipelines
Add Azure pipelines CI
2018-10-14 23:16:46 +03:00
Jon Turney 459b81de46
Use 'CI' environment variable to detect CI environment
Use the 'CI' environment variable to detect CI environment, rather than a
collection of CI-specific ones.
2018-10-14 16:01:36 +01:00
gsobala 0ea626b89d Added .so to list possible darwin dynamic library suffixes (#4364)
Occasionally Darwin libraries can be .so rather than .dylib e.g. tensorflow_cc.so
tensorflow_cc is a c++ API for Tensorflow (https://github.com/FloopCZ/tensorflow_cc)
which was primarily written for Linux but is also compilable on Darwin. Possibly
through laziness, possibly just to have consistent filenames, the developers did not
opt to change the suffix from the Linux default when this is compiled on Darwin.

Also, the Darwin linker will find libraries with a .so suffix if they are
in its path. find_library() needs to match the linker behaviour.
2018-10-13 07:00:06 -07:00
Niklas Claesson 4ef4edee2f tests runners: Refactor out global variables and add argparse 2018-10-10 21:19:06 +02:00
Christoph Behle c0236e10f3 Substitute output file then check for conflict.
Fixes Issue #4323.
The check to see if a call to configure_file() overwrites the output of
a preceding call should perform the substitution for the output file
before doing the check.

Added tests to ensure the proper behaviour.
2018-10-07 19:06:01 +03:00
Dylan Baker 6cf7d2492b compilers/c: don't return -pthread for MacOS with any compiler
With GCC, Clang, or ICC, and for C++

Fixes #2628
2018-10-01 12:34:46 -07:00
Jussi Pakkanen 8d77da839e Use only basename part in test. Closes #4237. 2018-09-22 20:19:01 +03:00
Jan Niklas Hasse d0648ee077 Also check wx-config-gtk3 when looking for wxWidgets
On Arch Linux the wxgtk3 package doesn't provide wx-config.
2018-09-17 21:43:50 +03:00
Alexis Jeandet 32111746ba Fix broken unit test qt5dependency_pkgconfig_detection
-It tests both Qt4 and Qt5 detection -> qtdependency_pkgconfig_detection

-It doesn't need to skip test if Qt4 isn't found and if Qt5 isn't, the
meson.build file already skips the test.

-The regex was outdated and since skipped because of Qt4 it is silently
broken for a long time.

Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
2018-09-17 21:27:49 +03:00
David Seifert 8f16d0f3c9 Fix ICC on macOS 2018-09-16 18:27:19 +03:00
David Seifert 2b9fb36267 Fix GCC on macOS
* `common/40 has function` still fails due
  to alloca being a GCC builtin.
2018-09-16 18:27:19 +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
Jon Turney 73b47e0025 Fix incorrect feature check warning
Fix the special handling of '>=0.nn' constraints in project(meson_version:)
for feature checks when the constraint version contains spaces
2018-09-16 00:46:50 +03:00
Jon Turney 963107b737
Add a test for 'meson introspect --targets|--target-files'
v2:
Use asssertCountEqual for list comparison ignoring order
2018-09-15 15:39:02 +01:00
Jussi Pakkanen f2041405fb
Merge pull request #4017 from jon-turney/version-comparison-rewrite
Use rpmvercmp version comparison
2018-09-13 22:19:35 +03:00
Jon Turney 1394cb9263 Correct version_compare_condition_with_min()
Correct version_compare_condition_with_min() for the case where no minimum
version is established by the version constraint.  Add a simple test.

Also fix test_feature_check_usage_subprojects by escaping regex
metacharacters.

if |condition| is '<', '<=' or '!=', the minimum version satisfying the
condition is 0, so the minimum version for a feature is never met.

if |condition| is '>=' or '==', the minimum version satisfying the condition
is the version compared with, so the minimum version for a feature must be
less than or equal to that.

if |condition| is '>', the minimum version satisfying the condition is
greater than the version compared with, so the minimum version for a feature
must be less than that

(it's this last condition that makes this function necessary, as in all
other cases we could establish a definite minimum version which we could
compare to see if it's less than or equal to the current version)
2018-09-12 15:38:00 +01:00
Jon Turney 8d3881a042 Add more tests of version comparison 2018-09-12 15:38:00 +01:00
Jon Turney da2c4ad3a8 Use the exact current version in obtainMesonOutput
Currently this trims '0.48.0.dev1' to '0.48.0', and then requires exactly
that version in the generated meson.build for the test.

Just use the exact version.

Also only use a 'project(meson_version:)' constraint in the generated
project if a version is specified

Also remove unused grab_leading_numbers
2018-09-12 15:37:52 +01:00
Nirbheek Chauhan 1af704a509 Sprinkle functools.lru_cache() in a few more places
This improves the backend generation time for gst-build from 7.4s to
6.6s. This is probably all the low-hanging fruit we can get, further
improvements will probably require refactoring, moving to pathlib.Path
or reimplementing CompilerArgs:

   222045    0.551    0.000    1.324    0.000 compilers.py:666(__iadd__)
     3691    0.230    0.000    0.885    0.000 ninjabackend.py:99(write)
   233560    0.441    0.000    0.701    0.000 posixpath.py:75(join)
      882    0.141    0.000    0.636    0.001 backends.py:509(generate_basic_compiler_args)
   256301    0.248    0.000    0.576    0.000 compilers.py:562(_can_dedup)
    37369    0.035    0.000    0.466    0.000 compilers.py:652(extend_direct)
    74650    0.067    0.000    0.431    0.000 compilers.py:641(append_direct)
   158153    0.089    0.000    0.405    0.000 ninjabackend.py:129(<lambda>)
      845    0.064    0.000    0.391    0.000 ninjabackend.py:279(get_target_generated_sources)
    58161    0.070    0.000    0.317    0.000 backends.py:217(get_target_generated_dir)
   216825    0.175    0.000    0.275    0.000 ninjabackend.py:48(ninja_quote)
      845    0.058    0.000    0.255    0.000 ninjabackend.py:2289(guess_external_link_dependencies)
      845    0.068    0.000    0.239    0.000 backends.py:793(get_custom_target_provided_libraries)
    52101    0.030    0.000    0.237    0.000 compilers.py:716(append)
  1319326    0.231    0.000    0.231    0.000 {built-in method builtins.isinstance}
  1189117    0.229    0.000    0.229    0.000 {method 'startswith' of 'str' objects}
     3235    0.102    0.000    0.228    0.000 compilers.py:614(to_native)

Note: there are 845 build targets.
2018-09-11 10:19:42 -07:00
Jon Turney 1768b09a12 Improve formatting of dependency details
Also use a more consistent format for qmake details, and adjust a test case
which relies on the specific output
2018-09-10 21:02:18 +03:00
Jon Turney 9a02340afd
Add test case for version_compare_many 2018-09-10 14:27:19 +01:00
Jussi Pakkanen 68f669bd2b Condense test dirs. 2018-09-06 19:09:35 +03:00
Rafael Ávila de Espíndola 07d2d88fa9 Allow override_find_program to use an executable.
With this it is now possible to do

foobar = executable('foobar', ...)
meson.override_find_program('foobar', foobar)

Which is convenient for a project like protobuf which produces both a
dependency and a tool. If protobuf is updated to use
override_find_program, it can be used as

protobuf_dep = dependency('protobuf', version : '>=3.3.1',
                          fallback : ['protobuf', 'protobuf_dep'])
protoc_prog = find_program('protoc')
2018-09-03 21:24:01 +03:00
Mathieu Duponchelle b2f92ea689 gnome: fix generate_gir when linking with libasan
The regression was introduced in my recent refactoring of
that method (8377ea4).

This commit simply restores the ordering of the generated
scan_command, ensuring `-lasan` and other internal linker
flags come before `--library` or `--program`
2018-08-31 08:09:28 -07:00
Nirbheek Chauhan bead8287a5 Improve support for macOS dylib versioning
We now use the soversion to set compatibility_version and
current_version by default. This is the only sane thing we can do by
default because of the restrictions on the values that can be used for
compatibility and current version.

Users can override this value with the `darwin_versions:` kwarg, which
can be a single value or a two-element list of values. The first one
is the compatibility version and the second is the current version.

Fixes https://github.com/mesonbuild/meson/issues/3555
Fixes https://github.com/mesonbuild/meson/issues/1451
2018-08-29 15:51:23 -07:00
Nirbheek Chauhan 8dd2e42de3 CompilerArgs: -Wl,-lfoo is also a valid way to pass a library
Treat it the same as -lfoo by deduping and adding to --start/end-group

Reported at https://gitlab.gnome.org/GNOME/glib/issues/1496

We don't do any advanced transformation for MSVC or de-dup because
this is a very rare syntax.
2018-08-28 19:10:30 +03:00
Jussi Pakkanen fb770e1e3d Add support for custom dist scripts. 2018-08-27 23:35:29 +03:00
Thibault Saunier 731906504e Add a `required` argument to `subproject`
Allowing to use the new "feature" option type and allowing not to fail
on subproject if it is not necessary to fail.

By default subprojects are "required" so previous behaviour is not
changed.

Fixes #3880
2018-08-27 21:37:18 +03:00
Nirbheek Chauhan 79aec5f342 CompilerArgs: Allow calling to_native() multiple times
Add a keyword argument to to_native() to operate on a copy so that we
can call it multiple times instead of modifying the original compiler
args while iterating.

This is used in the unit test, and might be used in Meson at some
point too.
2018-08-23 19:16:02 -07:00
Jussi Pakkanen 54aed1a92c Added "native" kwarg to add_XXX_args. Closes #3669. 2018-08-22 23:22:48 +03:00
Nirbheek Chauhan 5e93393cd9 Test that system shlibs with undefined symbols can be found 2018-08-22 12:24:43 -07:00
Nirbheek Chauhan 05b54b4767 PkgConfigDependency: Parse library paths in a separate step
pkg-config and pkgconf treat additional search paths in
PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR differently when
PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 is set.

pkg-config always outputs -L flags for the additional paths first, and
pkgconf always outputs -L flags for the default paths first.

To account for this inconsistency, we now sort the library paths into
two separate sets: system (default) and prefix (additional) paths. We
can do this because we always query pkg-config twice: once with
PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 set and once without it.

Then, we ensure that the prefix paths are searched before the system
paths.

Closes https://github.com/mesonbuild/meson/issues/4023
Closes https://github.com/mesonbuild/meson/issues/3951
2018-08-21 13:22:29 -07:00
Nirbheek Chauhan 38648bbb9f Fix various small test failures on macOS
These weren't caught by the CI because we have pkg-config on it, and
these were testing non-pkg-config codepaths. The unity build on macOS
now doesn't have pkg-config to ensure that the codepath is tested.
2018-08-19 16:03:22 -07:00
Jussi Pakkanen 972535a6ac Condense test dirs. 2018-08-19 12:39:46 +03:00
Jussi Pakkanen 15243e0acc
Merge pull request #4030 from 3v1n0/broken-symlink-install-with-mode-fix
Fix broken symlinks install when using install_umask or install_mode
2018-08-18 23:39:06 +03:00
Jussi Pakkanen d83f77109a
Convert buildtype to optimization and debug options (#3489) 2018-08-18 20:39:47 +03:00
Marco Trevisan (Treviño) 9f87d5d955 unittests: test_install_subdir_symlinks_with_default_umask
Add test to verify the installation of broken symlinks when a default_umask
is set.

Reusing the same code of other test, thus sharing the actual test code
in a single function.
2018-08-17 16:41:09 +02:00
Daniel Pirch 6ecd31af19 wraptool: fix manual selection of wrap file to promote
Fixed manually promoting wrap files with a full path, e.g.
`meson wrap promote subprojects/s1/subprojects/projname.wrap`,
which resulted in an error before (new test added:
`./run_unittests.py AllPlatformTests.test_subproject_promotion_wrap`).

Additionally, running promote with an invalid subproject path now fails
properly. Before, it just silently did nothing (added to test:
`./run_unittests.py AllPlatformTests.test_subproject_promotion`).
2018-08-17 00:33:38 +03:00
Nirbheek Chauhan d03cf04598 install_subdir: Also copy dangling symlinks
Fixes https://github.com/mesonbuild/meson/issues/3914
2018-08-15 04:57:23 -07:00
Jussi Pakkanen d742e2e891
Merge pull request #4001 from mikezackles/cpp2a
Add support for c++2a and gnu++2a (closes #3997)
2018-08-11 21:25:51 +03:00
Nirbheek Chauhan ecede89b5d Fix FeatureNew false positive in vcs_tag
Fixes https://github.com/mesonbuild/meson/issues/3904
2018-08-11 09:15:05 -07:00
Nirbheek Chauhan 41bb5941e1
Merge pull request #3657 from jon-turney/consolidate-dependency-check-report
Consolidate reporting the result of a dependency check
2018-08-11 06:30:06 -07:00
Nirbheek Chauhan ae5ebd258f PkgConfigDependency: Don't try to resolve internal compiler libs
-lc -lm -ldl -lrt -lpthread are special linker arguments that should
never be resolved to on-disk libraries.

Closes https://github.com/mesonbuild/meson/issues/3879
2018-08-11 04:16:18 -07:00
Zachary Michaels b665db8bb8 Try appleclang 9.1 for both c++17 and c++2a 2018-08-09 12:42:34 -07:00
Zachary Michaels 695b325142 Don't test for c++2a on gcc versions that don't support it 2018-08-09 11:50:06 -07:00
Zachary Michaels 8417c1a20f Add support for c++2a and gnu++2a 2018-08-09 11:09:21 -07:00
Nirbheek Chauhan 6c8f81333a PkgConfigDependency: Fix library path search order
We were searching the library paths in the reverse order, which meant
that we'd pick libraries from the wrong prefix.

Closes https://github.com/mesonbuild/meson/issues/3951
2018-08-08 05:45:45 -07:00
Nirbheek Chauhan 8402a22233 Test that vim syntax highlighting is up-to-date
Needs a `mock` kwarg to Interpreter to not do any parsing of build
files, but only setup the builtins and functions.

Also consolidate the documentation and data tests into one class.
2018-08-07 12:54:56 -07:00
Jussi Pakkanen 867af1264f
Merge pull request #3945 from mesonbuild/dircondenser
Condense directory names with script.
2018-08-04 00:02:29 +03:00
Jon Turney f6b3567fcc
Update a unit test which relies on specific dependency check output 2018-08-01 14:26:02 +01: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
Jussi Pakkanen 17bfbb99e5 Condense test dirs. 2018-07-31 19:22:24 +03:00
Rafael Ávila de Espíndola 941d2c273a Move test from common to unit.
When I initially added the test the intention was to use it from
run_unittests.py only, but I placed it in the wrong directory.
2018-07-27 06:36:04 -07:00
Rafael Ávila de Espíndola c7360dd426 Make the rpath order deterministic. (#3932) 2018-07-25 19:40:54 +03:00
Rafael Ávila de Espíndola 1a27714f97 Make the dependency order deterministic. (#3927)
We were using sets to store the dependencies. Just switch to
OrderedSet.

Fixes #3922.
2018-07-22 22:24:42 -07:00
Jussi Pakkanen f390a0a2f3
Merge pull request #3814 from behlec/configure-file-output
Check if calls to configure_file write to the same output file.
2018-07-19 01:17:34 +03:00
Nirbheek Chauhan 47c68a5993 find_library: Validate and sort globbed shared library files
We need to pick the library with the highest version, which is what
the OpenBSD linker also does.

https://github.com/mesonbuild/meson/issues/3570#issuecomment-403638752
2018-07-10 12:42:52 -07:00
Jussi Pakkanen 09ad29ec56 Fix directory verification. Closes #3857. 2018-07-09 23:14:59 +02:00
Nirbheek Chauhan 8cfb8fd02c
Fix searching of shared libraries on OpenBSD (#3851)
* get_library_naming: Use templates instead of suffix/prefix pairs

This commit does not change functionality, and merely sets the
groundwork for a more flexibly naming implementation.

* find_library: Fix manual searching on OpenBSD

On OpenBSD, shared libraries are called libfoo.so.X.Y where X is the
major version and Y is the minor version. We were assuming that it's
libfoo.so and not finding shared libraries at all while doing manual
searching, which meant we'd link statically instead.

See: https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs

Now we use file globbing to do searching, and pick the first one
that's a real file.

Closes https://github.com/mesonbuild/meson/issues/3844

* find_library: Fix priority of library search in OpenBSD

Also add unit tests for the library naming function so that it's
absolutely clear what the priority list of naming is.

Testing is done with mocking on Linux to ensure that local testing
is easy
2018-07-09 09:45:02 -07:00
Christoph Behle 0f15d7982c Fix regexp for warning 2018-07-09 17:05:57 +02:00
Nirbheek Chauhan e8dae2b966 cross: Be more permissive about not-found exe_wrapper
We used to immediately try to use whatever exe_wrapper was defined in
the cross file, but some people generate the cross file once and use
it for several projects, most of which do not even need an exe wrapper
to build.

Now we're a bit more resilient. We quietly fall back to using
non-exe-wrapper paths for compiler checks and skip the sanity check.
However, if some code needs the exe wrapper, f.ex., if you run a built
executable using custom_target() or run_target(), we will error out
during setup.

Tests will, of course, continue to error out when you run them if the
exe wrapper was not found. We don't want people's tests to silently
"pass" (aka skip) because of a bad CI setup.

Closes https://github.com/mesonbuild/meson/issues/3562

This commit also adds a test for the behaviour of exe_wrapper in these
cases, and refactors the unit tests a bit for it.
2018-07-09 05:39:40 +05:30
Christoph Behle 2428b388db Document options for meson
Document what waring_level 1,2,3 means.
Test if markdown files are in sitemap
Add Builtin-options.md to sitemap.txt

Builtin-options.md:
  Fix tables in Builtin-options.md
  Add documentation for warning options
  Added more options to doc

General documentation:
  Add link to Builtin-options
  Remove obsolete file

Testing:
  Add function test_markdown_files_in_sitemap.
  Checks if each markdown file is contained in sitemap.txt
2018-07-08 10:56:37 -07:00
Christoph Behle dffa7f3564 Add tests for warnings in configure_file()
Add tests to run_unittests.py to assert warnings are printed and not
printed where appropriate.
2018-07-08 18:19:17 +02:00
Nirbheek Chauhan 80392225a6 Raise a MesonException when substituting an invalid value
Avoids throwing a traceback. Also, warn when setting such a value.
2018-07-07 04:33:24 -07:00
Nirbheek Chauhan 77d66fec4b run_unittests.py: Test that empty cdata subst are actually done
Improved test for https://github.com/mesonbuild/meson/issues/3826
2018-07-05 19:01:46 +00:00
Nirbheek Chauhan 602e58d398 configure_file: Don't optimize away substitutions
It's possible that the configuration data object has components added
conditionally, and that sometimes an empty configuration data object
is passed on purpose.

Instead, we do the substitution and also warn if no tokens were found
that could've been substituted.

Closes https://github.com/mesonbuild/meson/issues/3826
2018-07-04 00:25:01 +00:00
Nirbheek Chauhan a1d9adba09 FeatureNew: Make all checks subproject-specific
We now pass the current subproject to every FeatureNew and
FeatureDeprecated call. This requires a bunch of rework to:

1. Ensure that we have access to the subproject in the list of
   arguments when used as a decorator (see _get_callee_args).
2. Pass the subproject to .use() when it's called manually.
3. We also can't do feature checks for new features in
   meson_options.txt because that's parsed before we know the
   meson_version from project()
2018-07-02 19:52:53 +05:30
Mathieu Duponchelle d0c5fddd72 Add some tests for FeatureNew 2018-07-02 07:05:08 +00:00
Andrei Alexeyev f7f5e2a725 Don't let build_always take precedence over build_by_default (#3816)
* Don't let build_always take precedence over build_by_default

* Test for proper interaction of build_by_default with build_always

Fixes #3815
2018-07-01 16:55:38 +00:00
Nirbheek Chauhan ae8d044cb6 Allow command lists for find_program cross file overrides
This is accepted by all other binaries in the cross file. With this
change, we also don't check whether the specified command exists at
configure time, but that's probably a feature anyway.

Fixes https://github.com/mesonbuild/meson/issues/3737
2018-07-01 13:59:48 +00:00
Dylan Baker f3a8f9c34d Options: treat array option -Dopt= and -Dopt=[] as equivalent
Currently the former will be parsed as [''], while the latter is parsed
as [] in python. This makes for some obnoxious special handling
depending on what the user passes. This is even more obnoxious since for
string type arguments this doesn't require special handling.
2018-06-29 10:56:25 +00: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 99dd5f34de Downgrade unknown option from exception to warning
It used to be non-fatal warnings but recent command line refactor made
it fatal. It looks like GNOME continuous would break with this change.
To avoid delaying upcoming 0.47.0 release adoption, let's downgrade this
back to warning for now and reconsider after the release.
2018-06-19 20:29:57 +00:00
Nirbheek Chauhan d7466066e4 meson_install: Don't add DESTDIR to install_name
This was added accidentally. Includes a test for it.

Also fix a rebase error. The variable was defined incorrectly and was
overwritten with the correct value immediately afterwards.
2018-06-18 09:57:18 +00:00
Nirbheek Chauhan d2d1a7c573 unittests: Assert that we have pkg-config on all CI
Our appveyor configuration provides pkg-config when building for
mingw, cygwin, msvc, etc.

Of course, people manually running the tests won't require pkg-config.
2018-06-18 06:33:23 +00:00
Nirbheek Chauhan 96b7fdb723 macos: Rewrite install_name for dependent built libraries on install
On macOS, we set the install_name for built libraries to
@rpath/libfoo.dylib, and when linking to the library, we set the RPATH
to its path in the build directory. This allows all built binaries to
be run as-is from the build directory (uninstalled).

However, on install, we have to strip all the RPATHs because they
point to the build directory, and we change the install_name of all
built libraries to the absolute path to the library. This causes the
install name in binaries to be out of date.

We now change that install name to point to the absolute path to each
built library after installation.

Fixes https://github.com/mesonbuild/meson/issues/3038
Fixes https://github.com/mesonbuild/meson/issues/3077

With this, the default workflow on macOS matches what everyone seems
to do, including Autotools and CMake. The next step is providing a way
for build files to override the install_name that is used after
installation for use with, f.ex., private libraries when combined with
the install_rpath: kwarg on targets.
2018-06-18 06:33:23 +00:00
Nirbheek Chauhan 5467eed186 Test that binaries that use external libraries work
When we link to an external library either with find_library() without
any dirs:, or with dependency(), we should be able to run uninstalled
out of the box without having to set any environment variables or other
shenanigans.

This is especially important on macOS because only the system frameworks
directory is in the default runtime path, and all other frameworks and
libraries need to be found with RPATH or absolute path to the dylib.
2018-06-18 06:33:23 +00:00
Xavier Claessens 18e25b6773 Fix options being reset to default on reconfigure
Closes: #3712
2018-06-09 18:10:23 +00:00
Nirbheek Chauhan df6909a83c Add a unit test for `meson introspect --installed` 2018-06-08 12:18:16 +00:00
Jon Turney 1f5c6d62bf More clearly explain portability issues with linking to a module
Refine #3277

According to what I read on the internet, on OSX, both MH_BUNDLE (module)
and MH_DYLIB (shared library) can be dynamically loaded using dlopen(), but
it is not possible to link against MH_BUNDLE as if they were shared
libraries.

Metion this as an issue in the documentation.

Emitting a warning, and then going on to fail during the build with
mysterious errors in symbolextractor isn't very helpful, so make attempting
this an error on OSX.

Add a test for that.

See also:
https://docstore.mik.ua/orelly/unix3/mac/ch05_03.htm
https://stackoverflow.com/questions/2339679/what-are-the-differences-between-so-and-dylib-on-osx
2018-06-07 12:57:39 +00:00
Xavier Claessens 3f66846b02 Add unit test for option precedence
Closes #3456.
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 b38452636c Fix command line unit test not actually testing failure message
self.init() raise an exception so anything else in the 'with' block is
not executed.
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 fa72cd7173 Move get_args_from_envvars() from environment to compilers 2018-06-06 20:02:37 +00:00
Nirbheek Chauhan 56a7d8b2b3 Warn when Apple bitcode support is enabled and in-use
We have to disable some options, so tell the user about them and point
to the documentation so they can read more about it.
2018-06-06 07:53:10 +00:00
Nirbheek Chauhan 0565262be3 Add documentation for Builtin options and bitcode
Also add a test that ensures that new base options and compiler options
are always documented.
2018-06-06 07:53:10 +00:00
Nirbheek Chauhan 3e1a610702 Add a new option for building with Apple bitcode support
Normally, people would just pass -fembed-bitcode in CFLAGS, but this
conflicts with -Wl,-dead_strip_dylibs and -bundle, so we need it as
an option so that those can be quietly disabled.
2018-06-06 07:53:10 +00:00
Nirbheek Chauhan 68001193d3 meson introspect: Fix --installed argument
Traceback (most recent call last):
  File "meson.py", line 29, in <module>
    sys.exit(mesonmain.main())
  File "mesonbuild/mesonmain.py", line 411, in main
    return run(sys.argv[1:], launcher)
  File "mesonbuild/mesonmain.py", line 320, in run
    return mintro.run(remaining_args)
  File "mesonbuild/mintro.py", line 234, in run
    list_installed(installdata)
  File "mesonbuild/mintro.py", line 72, in list_installed
    for path, installdir, aliases, unknown1, unknown2 in installdata.targets:
ValueError: too many values to unpack (expected 5)
2018-06-06 06:59:06 +00:00
Jon Turney ac480c1857 Extend test_rc_depends_files test case
Extend test_rc_depends_files test case to also cover depfile generation for
a resource file generated by a custom_target
2018-06-03 21:06:23 +00:00
Jon Turney 7a15214a69 Have the windows.resource_compiler() preprocesor write a depfile
When using binutils's windres, we can instruct it to invoke the preprocessor
in such a way that it writes a depfile, so that dependencies on #included
files are automatically tracked.

Not implemented for MSVC tools, so skip testing it in that case.
2018-06-03 21:06:23 +00:00
Filipe Brandenburger 04c39ad562 Add extended unit test for 'install_mode'
This new unit test will use the targets in '198 install_mode' and
confirm that every file and directory gets the expected mode, ensuring
that the setting is properly applied at install time.
2018-06-02 04:50:32 +00:00
Filipe Brandenburger 0ccc0e92d1 Check mode of file, not subdirectory, in install_subdir.
When using an install_mode in install_subdir(), that should apply to the
files and not to the directory tree.

Otherwise, an install_mode not including the executable bit will make
the tree inaccessible, since directories need it to be traversed.

If the mode needs to be applied to both files and directories, then
install_subdir() is only useful to install files with the executable bit
set, which is not really that useful...

So default to just using the umask for the directories and applying
install_mode to the files only.

This can be reviewed in the future, possibly by adding a separate
install_dir_mode attribute, or perhaps adding an optional fourth field
to FileMode with the mode for directories (this is similar to how RPM
handles specifying mode of directory trees recursively added to the
package.)
2018-06-02 04:50:32 +00:00
Jon Turney 6bab3d40a9 Fix assertRebuiltTarget with VS backend
For the VS backend, assertRebuiltTarget() asserts the that target is both
recompiled and relinked.  This isn't correct for test_rc_depends_files, as
changing the rc script's dependencies only causes the executable to be
relinked, and not to also have it's source recompiled.

assertRebuiltTarget already gets this right for the ninja backend.
2018-06-01 20:21:09 +00:00
Jon Turney b7df392e9f Also run Windows unit tests on Cygwin 2018-06-01 20:21:09 +00:00
Jon Turney aa27f7cec9 Add a depend_files: keyword to windows.compile_resources()
Expose depend_files: from the custom_target this creates.

This is the change suggested in #2815, with tests and documentation added.

Fixes #2789 (duplicate #2830)
2018-06-01 20:21:09 +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 f56b402a5b Revert "mesonlib: handle meson exe wrappers"
This reverts commit 0627e9d616.

Breaks installation: https://github.com/mesonbuild/meson/issues/3647

Will be restored once that can be fixed.
2018-05-31 15:40:10 +05:30
Martin Kelly 0627e9d616 mesonlib: handle meson exe wrappers
There are cases when it is useful to wrap the main meson executable with
a script that sets up environment variables, passes --cross-file, etc.
For example, in a Yocto SDK, we need to point to the right meson.cross
so that everything "just works", and we need to alter CC, CXX, etc. In
such cases, it can happen that the "meson" found in the path is actually
a wrapper script that invokes the real meson, which may be in another
location (e.g. "meson.real" or similar).

Currently, in such a situation, meson gets confused because it tries to
invoke itself using the "meson" executable (which points to the wrapper
script) instead of the actual meson (which may be called "meson.real" or
similar). In fact, the wrapper script is not necessarily even Python, so
the whole thing fails.

Fix this by using Python imports to directly find mesonmain.py instead
of trying to detect it heuristically. In addition to fixing the wrapper
issue, this should make the detection logic much more robust.
2018-05-30 18:29:16 +00:00
Martin Kelly b6995aac70 run_unittests: typo fix 2018-05-30 18:29:16 +00:00
Jussi Pakkanen 55a0831bc3
Merge pull request #3383 from mesonbuild/nirbheek/configure-file-nodata
configure_file: Add a new action 'copy'
2018-05-22 21:09:19 +03:00
Nirbheek Chauhan a00433fdbc configure_file: Add a new action 'copy'
This will copy the file to the build directory without trying to read
it or substitute values into it.

Also do this optimization if the configuration_data() object passed to
the `configuration:` kwarg is empty, and print a warning about it.

See also: https://github.com/mesonbuild/meson/issues/1542
2018-05-22 02:36:55 +05:30
Mathieu Duponchelle 5bb863c891 dict: unit test integer key 2018-05-21 00:23:49 +02:00
Mathieu Duponchelle 10e7566ed8 dict: fix CI issues 2018-05-21 00:19:31 +02:00
Mathieu Duponchelle 195c356f91 dict: address review comments 2018-05-20 22:36:18 +02:00
Jon Turney 13e92223be Generalize message about fallback failure
The fallback might be not used not only because it couldn't be found, but
also because something went wrong trying to use it.

Also, update a test which relies on the specific text
2018-05-17 00:26:58 +03:00
Nirbheek Chauhan 0dd4635842 unit tests: Undo accidental disabling of test
Was accidentally merged.

https://github.com/mesonbuild/meson/pull/3240/files#r181593745
2018-05-10 12:30:47 +02:00
Nirbheek Chauhan 86cc4f2707 gdbus_codegen: Guess the output list for docbook generation
We were setting it to a file list that would always be wrong, and
always out of date since it would never exist.

However, the output list is not predictable. It usually has a 1-1
relationship with the input XML files, but it may not.

This must be fixed later with API for users to provide the output
names.

See: https://github.com/mesonbuild/meson/pull/3539
2018-05-09 21:04:55 +05:30
Nirbheek Chauhan 575ffec62e python module: Move tests to test cases/unit
The tests are only run via unit tests, so that's where they should be.
2018-05-03 18:56:34 +05:30
Mathieu Duponchelle 8bda86faab python module: make it work with pypy
pypy installations don't usuallyy ship with pkg-config files,
we thus need to replicate what their version of distutils does.

In addition, we also try our best to build against other
pythons that do not have pkg-config files.
2018-05-03 18:50:40 +05:30
Nirbheek Chauhan badbfa125c pkgconfig: Don't expose internal libraries in .pc files
Libraries that have been linked with link_whole: are internal
implementation details and should never be exposed to the outside
world in either Libs: or Libs.private:

Closes https://github.com/mesonbuild/meson/issues/3509
2018-05-02 11:46:47 +00:00
Jussi Pakkanen 2b5766980b Keep separator spaces in pkg-config declarations. Closes #3479. 2018-05-02 11:46:47 +00: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
Xavier Claessens 5970f1be3c Passing --bindir twice is fine
Unit test was asserting that
"meson --bindir=foo --bindir=bar" must succeed and
"meson configure --bindir=foo --bindir=bar" must fail.
There should be no difference between those 2 command lines.

In this case it's fine to have it twice because there is no ambiguity,
second overrides the first, that's done by python's argparse.
2018-04-27 11:09:14 -04:00
Xavier Claessens 570c108635 Fix --warnlevel being renamed to --warning-level in latest release 2018-04-27 11:09:14 -04:00
Jussi Pakkanen 9b0453d3e9
Merge pull request #3225 from filbranden/fixperms3
Introduce install_umask to determine permissions of files in install tree. Default it to 022
2018-04-26 23:14:00 +03:00
Dylan Baker 185ae3d420 tests: Add the same kind of tests for configure. 2018-04-25 20:59:27 +03:00
Dylan Baker b8f1b84733 Tests: Add some tests for mixing -Dfoo and --foo
These are at least some of the tests that really deserved to be written
for 78e37c4953, but I was lazy.
2018-04-25 20:59:27 +03:00
Jussi Pakkanen 01865899e5 Skip snippet validation if docs dir does not exist. 2018-04-23 03:24:26 +03:00
Jussi Pakkanen 83ffb3ea02 Use the correct file path. Not the wrong one. 2018-04-23 02:16:30 +03:00
Martin Hostettler 247b1a598a regression: pkgconfig module: Fix Fix regression in Requires.private generation.
The fix for Requires generation in #3406 missed a second code path with the same
problem.

Passing a pkgconfig dependency to requires would produce Q, t, 5, C, o,r, e'
instead of 'Qt5Core'.

This was introduced in 8efd940.
2018-04-20 00:59:06 +03:00
Filipe Brandenburger 59b0fa9722 Add a unit test for install_umask.
This test copies a src tree using umask of 002, then runs the build and
install under umask 027. It ensures that the default install_umask of
022 is still applied to all files and directories in the install tree.
2018-04-18 11:44:54 -07:00
Jussi Pakkanen 8d5c33f92f Renamed test dirs so numbers are sequential. 2018-04-18 00:33:41 +03:00
Jussi Pakkanen 3fc1ca8687
Merge pull request #3240 from MathieuDuponchelle/python_module
Implement a generic python module
2018-04-17 23:17:43 +03:00
Aleksey Filippov f4ea6ac454 Add '189 same target name flat layout' test 2018-04-16 22:51:34 +01:00
Aleksey Filippov cb761718f0 Generate target id based on subdirectory instead of subproject
Allows creation of targets with same name in different subdirectories.
Closes #2861 and closes #1867
2018-04-16 22:51:34 +01:00
Nirbheek Chauhan ef81a013a5 cross: Add compiler cross_args after normal args
This way they override all other arguments. This matches the order of
link arguments too.

Note that this means -I flags will come in afterwards and not override
anything else, but this is correct since that's how toolchain paths
work normally too -- they are searched last.

Closes https://github.com/mesonbuild/meson/issues/3089
2018-04-15 22:29:49 +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
Martin Hostettler aff597fb99 ninjabackend: Try to guess library dependencies for linker invocation.
The linkers currently do not support ninja compatible output of
dependencies used while linking. Try to guess which files will be used
while linking in python code and generate conservative dependencies to
ensure changes in linked libraries are detected.

This generates dependencies on the best match for static and shared
linking, but this should not be a problem, except for spurious
rebuilding when only one of them changes, which should not be a problem.

Also makes sure to ignore any libraries generated inside the build, to
keep the optimisation working where changes in a shared library only
cause relink if the symbols have changed as well.
2018-04-15 07:29:21 +00:00
Martin Hostettler 3f7c6cf3d6 Improve generation of pkg-config files for static only libraries.
Previously pkg-config files generated by the pkgconfig modules for static libraries
with dependencies could only be used in a dependencies with `static: true`.

This was caused by the dependencies only appearing in Libs.private even
if they are needed in the default linking mode. But a user of a
dependency should not have to know if the default linking mode is static
or dynamic; A dependency('somelib') call should always pull in all
needed pieces into the build.

Now for meson build static libraries passed via `libraries` to the generate
method automatically promote dependencies to public.
2018-04-14 23:43:29 +03:00
textshell 0535f38af9 pkgconfig module: Fix regression that Requires.private is generated as 'Q, t, 5, C, o, r, e' instead of Qt5Core. (#3406) 2018-04-14 21:57:12 +03:00
Daniel Schulte 57654bf367 Deduplicate dependencies resolved to absolute paths
If paths are absolute the order of search directories is not relevant as the path is already resolved.
2018-04-13 01:05:25 +00:00
Mathieu Duponchelle dce770c0a7 [fixup]: Fix python2 detection and unit test 2018-04-09 02:06:22 +02:00
Mathieu Duponchelle 1105ba3afd [fixup]: rename test after rebase 2018-04-07 16:13:59 +02:00
Mathieu Duponchelle ae460f94ce [fixup]: Add test 2018-04-06 23:48:48 +02:00
Mathieu Duponchelle 1ad8b49755 run_unittests: disable testsetup_selection
It randomly stays stuck and breaks CI
2018-04-06 22:43:36 +02:00
Mathieu Duponchelle e1b138a21b Implement a generic python module
With contributions from Håvard Graff
2018-04-06 22:43:35 +02:00
Jussi Pakkanen 8eadc9d068
Merge pull request #3277 from chitranjali/shared-mod-link 2018-03-29 22:22:51 +03:00
Jussi Pakkanen be3387d937
Merge pull request #3322 from sarum9in/run_timeout 2018-03-29 21:48:09 +03:00
chitranjali cc6be2e43d Fixing flake8 2018-03-29 14:43:56 +05:30
chitranjali 34cb503c85 PR review changes closes #2865 2018-03-29 13:32:36 +05:30
chitranjali 83766313a7 fix2865 2018-03-29 13:26:32 +05:30
Aleksey Filippov 977acc94b8 Do not leave open file handlers, use context manager to clean them up 2018-03-26 23:47:51 +03:00
Aleksey Filippov fa39e1082c Timeout on test subprocesses instead of hanging and failing CI completely 2018-03-26 12:48:40 +00:00
Xavier Claessens 8efd940092 pkgconfig generator: Add required version 2018-03-25 23:20:09 +03:00
Aleksey Filippov af0b569ced Add unittests for b_ndebug=if-release and buildtype interactions 2018-03-21 16:42:35 +00:00
makise-homura e8dff792d6 Removed some confusing chars from 'spaces and fun'
For example, lcc does not understand !, ^, *, and <.
2018-03-21 19:16:02 +03:00
makise-homura 86fa9b133d test_reconfigure switched to b_coverage from b_lto
This is due to some compilers (e.g. lcc) don't support LTO,
and therefore no b_lto meson option is available.
2018-03-21 16:45:22 +03:00
Jussi Pakkanen 58156ef7cf Grab a file lock on the build dir during modifications. 2018-03-20 22:28:37 +02:00
Jussi Pakkanen e984e1072b
Merge pull request #3251 from mesonbuild/fixpkgconfigdeps
Fix pkg-config dependencies leaking out (debbug 892956)
2018-03-19 23:43:35 +02:00
Jussi Pakkanen cf5f1a83d5 Fix existing tests. 2018-03-19 23:21:56 +02:00
Jussi Pakkanen c385f79737 Do not leak out private dependencies for shared libraries. 2018-03-17 00:44:56 +02:00