Commit Graph

119 Commits

Author SHA1 Message Date
Nirbheek Chauhan 3a33a8ef49 unit tests: Add class to generate failing tests
It is not feasible to test all failure modes by creating projects in
`test cases/failing` that would be an explosion of files, and that
mechanism is too coarse anyway. We have no way to ensure that the
expected error is being raised.

See FailureTests.test_dependency for an example.
2017-06-09 20:21:01 +05:30
Jussi Pakkanen de1305c9e8 Do not use context managers. Because Windows. 2017-06-08 16:17:20 +03:00
Jussi Pakkanen 7c03bfb463 Merged needs_exe_wrapper branch. 2017-06-07 20:09:43 +03:00
Nirbheek Chauhan 198c2f2d55 unit tests: Skip tests if no readelf found 2017-06-05 13:20:04 +05:30
Nirbheek Chauhan 41f8f1a53b unit tests: Also check RUNPATH when fetching RPATH 2017-06-05 03:09:17 +05:30
Nirbheek Chauhan 264ce6c0bc Use absolute RPATHs while linking due to a binutils bug
Use -rpath-link with the absolute paths to the respective build dirs
to work around a binutils bug that causes $ORIGIN to not be used while
linking.

Includes a unit test that manually checks the RPATH value written out
to ensure that it uses $ORIGIN.

See: https://sourceware.org/bugzilla/show_bug.cgi?id=16936

Closes https://github.com/mesonbuild/meson/issues/1897
2017-06-05 02:19:46 +05:30
Nirbheek Chauhan d79bdb9b6b unit tests: Use only implementation of get_soname 2017-06-05 02:11:07 +05:30
Nirbheek Chauhan 4b428053f4 ninja: Use shlex.quote for quoting on non-Windows
This is more reliable, and more accurate. For instance, this means
arguments in commands aren't surrounded by `'` on Linux unless that
is actually needed by that specific argument.

There is no equivalent helper for Windows, so we keep the old
behaviour for that.
2017-06-02 10:41:13 +05:30
Nirbheek Chauhan ae9b23832e ninja: De-dup libraries and use --start/end-group
Now we aggressively de-dup the list of libraries used while linking,
and when linking with GNU ld we have to enclose all static libraries
with -Wl,--start-group and -Wl,--end-group to force the linker to
resolve all symbols recursively. This is needed when static libraries
have circular deps on each other (see included test).

The --start/end-group change is also needed for circular dependencies
between static libraries because we no longer recursively list out all
library dependencies.

The size of build.ninja for GStreamer is now down to 6.1M from 20M,
and yields a net reduction in configuration time of 10%
2017-06-02 07:10:55 +05:30
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
Ole André Vadla Ravnås b595cda4ed Fix cross environment pollution.
Environment variables like CFLAGS and LDFLAGS should not affect the
cross environment.

Fixes #1772
2017-05-21 23:04:19 +03:00
Jussi Pakkanen 5ec6151e56 Merge pull request #1810 from QuLogic/pycharm-warnings
Fix various warnings found in PyCharm
2017-05-18 19:44:57 +03:00
Jussi Pakkanen a31bc4ede5 Skip unittests that request it rather than mark them as failed. Closes #1804. 2017-05-18 19:44:33 +03:00
Elliott Sales de Andrade 4abe9a9d78 Add missing asserts in unit tests. 2017-05-17 19:43:23 -04:00
Elliott Sales de Andrade ea636fcd51 Remove unused variables. 2017-05-17 04:41:54 -04:00
Elliott Sales de Andrade 65b1d33931 Remove unused imports. 2017-05-17 03:42:16 -04:00
Jussi Pakkanen 8068fc0d1d Add test and release notes. 2017-05-12 14:25:27 +03:00
Peter Hutterer 7ed19902be pkgconfig: add suppport for custom variables during generation
Usage:
    pkgconfig.generate(
      ...
      description : 'A library with custom variables.',
      variables : ['foo=bar', 'datadir=${prefix}/data']
      )

The variables 'prefix', 'libdir' and 'includedir' are reserved, meson will
fail with an error message.

Variables can reference each other with the pkgconfig notation, e.g.

   variables : ['datadir=${prefix}/data',
                'otherdatadir=${datadir}/other']

meson does not check this for correctness or that the referenced variable
exists, we merely keep the same order as specified.
2017-05-11 00:13:30 +03:00
Nirbheek Chauhan 1570a90822 project tests: Also regen before building
This actually caught a cached-dependency related bug for me that the
test-time regen did not. I also increased the ninja wait time to
1 second because that's actually how long you need to sleep to be
guaranteed that a change will be detected.

Must poke upstream about https://github.com/ninja-build/ninja/issues/371
2017-05-09 14:23:15 +05:30
Peter Hutterer ca924451ac Use American English: behaviour -> behavior 2017-05-04 22:09:27 +03:00
Jussi Pakkanen 476c263952 Unset compiler envvars in unit tests. 2017-04-23 02:00:28 +03:00
Nirbheek Chauhan a8f360c5c3 unit tests: Add a test case for LTO + static libraries
Tests https://github.com/mesonbuild/meson/issues/1646
2017-04-20 20:47:10 +05:30
Jussi Pakkanen 0e47e74a77 Do not obliterate old rpath because it might be used due to read only data sharing. Closes #1619. 2017-04-17 12:48:54 +03:00
Jussi Pakkanen b48daeda1a Make it possible to only do unity builds on subprojects. 2017-04-15 18:28:36 +03:00
Jussi Pakkanen eaaaee6421 Merge pull request #1596 from centricular/test-rebuilds
Test that build and custom targets are rebuilt on changes
2017-04-11 22:58:23 +03:00
Jussi Pakkanen 42d1661bd9 Merge pull request #1588 from absmall/method
Add an option to dependencies called 'method'.
2017-04-11 16:41:56 +03:00
Nirbheek Chauhan b603aba3ec Add tests for target and custom_target rebuild
Test that changing src tree headers rebuilds targets, and test that
changing any file used in a custom_target will rebuild it.
2017-04-10 22:32:41 +05:30
Nirbheek Chauhan 36e8291a6a unit tests: Run another linuxlike test on all platforms 2017-04-09 23:11:36 +05:30
Nirbheek Chauhan a51d582c72 unit tests: Skip tests that need Ninja
Such as tests that use the compiler db, or install things.
2017-04-09 23:11:36 +05:30
Nirbheek Chauhan f80d471345 unit tests: Fix running specific targets with MSBuild
/t:targetname syntax doesn't work, but running the vcxproj does work

Also use the Backend enum everywhere.
2017-04-09 23:11:36 +05:30
Nirbheek Chauhan a331bf1162 unit tests: Run on all backends, not just Ninja 2017-04-09 23:11:05 +05:30
Nirbheek Chauhan d755228afe tests: Factor out common code to run_tests
And use generic build/clean/test/install commands in the unit tests,
just like project tests. This sets the groundwork for running the unit
tests with all backends.
2017-04-09 23:08:42 +05:30
Aaron Small 98a0f3ea40 Rename the pkgconfig method to pkg-config 2017-04-09 11:54:20 -04:00
Aaron Small 76c8491d77 Add an option to dependencies called 'method'. This can be used to
configure a detection method, for those types of dependencies that have
more than one means of detection.

The default detection methods are unchanged if 'method' is not
specified, and all dependencies support the method 'auto', which is the
same as not specifying a method.

The dependencies which do support multiple detection methods
additionally support other values, depending on the dependency.
2017-04-09 03:31:39 -04:00
Jon Turney fd47ef3a27 Use '.exe' extension for executables for Cygwin
Use '.exe' extension for executables 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
Jussi Pakkanen 8b73d80792 Merge pull request #1457 from mesonbuild/overrides
Add MVP implementation of overriding options.
2017-04-03 23:31:32 +03:00
Jussi Pakkanen c7f66c3a9e Merge pull request #1505 from centricular/dont-use-c++-for-assembly
Try harder to use the C compiler for compiling asm
2017-04-02 00:15:22 +03:00
Jussi Pakkanen 1b81b32afb Add test for werror which is a boolean type. 2017-04-02 00:07:23 +03:00
Jussi Pakkanen 319398f074 Proxy object for overriding options transparently. 2017-04-02 00:07:23 +03:00
Nirbheek Chauhan 9261243834 tests/common/141: Also test C + asm targets
Ensure that they are all built with and linked with the C compiler
2017-03-30 00:47:00 +05:30
Nirbheek Chauhan 31dc38826d unit tests: Skip static library overwrite on Windows
Test is broken due to https://github.com/mesonbuild/meson/issues/1526
2017-03-28 14:47:55 +05:30
Aaron Small b5e30fd8e0 Fix qt4 tool location detection, which may result in incorrectly picking
up qt5 tools when using the qt4 module.
2017-03-27 21:59:28 +03:00
Nirbheek Chauhan fa09b122b0 wrap: Also capture stderr while running quiet_git()
We want to return the stderr if the command failed.
2017-03-27 15:09:18 +05:30
Nirbheek Chauhan 001cf52c3a Try even harder to use the C compiler for assembly
Now as long as you have a C compiler available in the project, it will
be used to compile assembly even if the target contains a C++ compiler
and even if the target contains only assembly and C++ sources.

Earlier, the order in which sources appeared in a target would decide
which compiler would be used.

However, if the project only provides a C++ compiler, that will be
used for compiling assembly sources.

If this breaks your use-case, please tell us.

Includes a test that ensures that all of the above is adhered to.
2017-03-27 14:40:34 +05:30
Jussi Pakkanen d668bea11d Merge pull request #1496 from centricular/fix-internal-dep-order
Preserve internal-dep include order in build target dependencies
2017-03-25 18:55:47 +02:00
Nirbheek Chauhan d5975cc683 wrap: Implement special wrap modes for use by packagers
Special wrap modes:
  nofallback: Don't download wraps for dependency() fallbacks
  nodownload: Don't download wraps for all subproject() calls

Subprojects are used for two purposes:
1. To download and build dependencies by using .wrap files if they
   are not provided by the system. This is usually expressed via
   dependency(..., fallback: ...).
2. To download and build 'copylibs' which are meant to be used by
   copying into your project. This is always done with an explicit
   subproject() call.

--wrap-mode=nofallback will never do (1)
--wrap-mode=nodownload will do neither (1) nor (2)

If you are building from a release tarball, you should be able to
safely use 'nodownload' since upstream is expected to ship all
required sources with the tarball.

If you are building from a git repository, you will want to use
'nofallback' so that any 'copylib' wraps will be download as
subprojects.

Note that these options do not affect subprojects that are git
submodules since those are only usable in git repositories, and you
almost always want to download them.
2017-03-25 06:57:30 +05:30
Nirbheek Chauhan 7f80f81ac9 Preserve the order of internal deps in a target
We were adding them to the CompilerArgs instance in the order in which
they are specified, which is wrong because later dependencies would
override previous ones. Add them in the reverse order instead.

Closes https://github.com/mesonbuild/meson/issues/1495
2017-03-23 10:26:29 +05:30
Nirbheek Chauhan 50e0543cd7 unittests: Print output for failing commands
Because we are using check_output, if the command fails no output will
be printed at all. So, we use subprocess.run instead.

Also, on configure failures, print the meson-log.txt instead of stdout.
2017-03-13 03:25:57 +05:30