Commit Graph

245 Commits

Author SHA1 Message Date
Daniel Mensinger f4285f350e
Initial automatic target file generation 2019-01-06 12:19:27 +01:00
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
John Ericson dbf080afe9 Get rid of `need_cross_compiler`
Building a cross compiler (`build == host != target`) is not cross
compiling. As such, it doesn't make sense to handle it under
`is_cross_build`.

(N.B. Building a standard library for a cross compiler would require
cross compiling, but Meson has support to do such a thing as part of a
compiler build currently.)
2019-01-02 16:11:02 -05:00
Daniel Mensinger 10ce5deb71
Introspection refactoring 2018-12-29 23:55:45 +01:00
Phillip Cao 76333d2a1e Add prefix option for link args 2018-11-08 00:02:24 +13: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
Xavier Claessens f0e1342fb2 extract_all_sources: Also include generated object files
Closes #4281.
2018-11-02 21:40:04 +02:00
Marcel Hollerbach 468d1a05ec meson: cache get_target_generated_dir
This reduces the build time about 2 sec. The result itself is not hard
to calculate. However, persistent join calls with the same 2 strings are
not that usefull. This also caused about 600'000 calls to
get_target_dir, we are now down to 60'000 calls form this function to
get_target_dir.
2018-11-02 21:04:13 +02:00
Jon Turney 99b0a7acda Fix flake8 whitespace reports
$ flake8 | grep -E '(E128|E203|E221|E226|E303|W291|W293)'
./mesonbuild/backend/backends.py:32:1: E303 too many blank lines (3)
./mesonbuild/modules/i18n.py:90:56: E128 continuation line under-indented for visual indent
2018-10-24 19:11:46 +03:00
Jon Turney 93f7b83bf5 Fix flake8 'imported but unused' reports
$ flake8 | grep F401
./mesonbuild/minstall.py:15:1: F401 'gzip' imported but unused
./mesonbuild/backend/backends.py:26:1: F401 '..compilers.get_macos_dylib_install_name' imported but unused
./mesonbuild/backend/backends.py:29:1: F401 'functools.lru_cache' imported but unused
./mesonbuild/scripts/dist.py:27:1: F401 'mesonbuild.dependencies.ExternalProgram' imported but unused
2018-10-24 19:11:46 +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
Xavier Claessens c453400d59 Add 'b_pie' compiler option
On Android executables must be position independent, many
distributions enable it by default too for security reasons.
2018-10-20 00:47:27 +03:00
Jon Turney a0a0c244e2 os.path.relpath() can fail on Windows
If builddir and sourcedir have different drive letters, a relative path
doesn't exist, and os.path.relpath fails with a ValueError exception.

This just fixes the places which are hit by test cases in a simple-minded
way.  There are several other uses of os.path.relpath(), which might be
suspect.
2018-10-10 19:43:24 +03:00
Dylan Baker a0e4548c41 backends: allow running host arch binaries on compatible build machines
Meson 0.48.0 some validation for using compiled binaries in custom
targets and generators, which is nice. It didn't take into account
though that as long as the OS is the same, some architectures support
running a related architecture natively (x86_64 can run x86 natively,
for example).

Fortunately we already have a method for covering this case available
through the Environment class.

Fixes #4254
2018-10-04 23:50:31 +03:00
Marcel Hollerbach c53d35aa72 build: generate the mappings in the Targets
Before, the mappings has been created over all the links, while it
actaully only used the Shared or Static Targets. This structure now is
tree like structured and cached, thus the results can be computed a lot
faster.
The generator step generate_install is now for EFL from 6 sec. down to
0.3s. Which improves the overall build time from ~20 sec. to ~14 sec.
2018-10-01 23:47:19 +02:00
Marcel Hollerbach c38544a6ec build: move default_install_dir to the Target classes
there is a huge amount of isinstance calls, this reduces the amount of
these calls while splitting up a rather big function. It also assosiates
every target type with theire default install directory.
2018-10-01 23:47:19 +02:00
Thibault Saunier 533997891e backend: Make sure to normalize paths before checking if it is a system dir
Otherwise if we for some reason get '/usr/lib/../lib' in there
we end up saying it is not a system path.

And for some reason here I got:

```
$ pkg-config --libs libffi                                                                                                             148  ST 117   hotdoc
-L/usr/lib/../lib -lffi
```
2018-09-28 12:58:16 -07: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
Marcel Hollerbach 7ae3fbf88d mesonbuild: move subdir generation along link dep generation
The problem with the earlier position of the generation code was, that
the results could not be cached, because the list of all link_deps was
overall different. However, it shared a special kind of subsets with
other build build targets.

Generating the set of subdirs that are required for linking, alongside
with the link dependencies brings the possibility of caching this.
This reduces the buildting from 1 min. in efl down to 20 sec. And
reduces the amount of 30872534 calls down.

this saves ~40 sec.
2018-09-11 03:03:30 -07:00
Marcel Hollerbach c68460e2ee backends: save up the dylib generated names
this saves about 6 sec.
2018-09-11 03:03:30 -07:00
GoaLitiuM 6e160995b0 Improve D link argument handling 2018-09-06 03:57:45 +03:00
Jussi Pakkanen 54aed1a92c Added "native" kwarg to add_XXX_args. Closes #3669. 2018-08-22 23:22:48 +03:00
Bruce Richardson 8c9296e8e6 find_library: Use _build_wrapper to get library dirs
This means that we will take into account all the flags set in the
cross file when fetching the list of library dirs, which means we
won't incorrectly look for 64-bit libraries when building for 32-bit.

Signed-off-by: Nirbheek Chauhan <nirbheek@centricular.com>

Closes https://github.com/mesonbuild/meson/issues/3881
2018-08-22 12:24:43 -07:00
Jussi Pakkanen d83f77109a
Convert buildtype to optimization and debug options (#3489) 2018-08-18 20:39:47 +03:00
Nirbheek Chauhan c69030c123 Don't require an import library for shared modules
Shared modules may be resource-only DLLs, or might automatically
self-initialize using C constructors or WinMain at DLL load time.

When an import library is not found for a shared module, just print
a message about it instead of erroring out.

Fixes #3965
2018-08-09 18:39:19 +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
Jussi Pakkanen 8c735069b3
Merge pull request #3898 from mesonbuild/vsinstall
Add install target to VS
2018-07-27 14:38:50 +03:00
Rafael Ávila de Espíndola c7360dd426 Make the rpath order deterministic. (#3932) 2018-07-25 19:40:54 +03:00
Jussi Pakkanen 7bb5f82736 Added install target to VS. Closes #3841. 2018-07-22 16:05:09 +03:00
Jussi Pakkanen 808d229c37 Moved install data file generation to base class. 2018-07-17 13:04:07 +03: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
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 58ae2c9a8c Rename clike_langs to clink_langs for clarity
D is not a 'c-like' language, but it can link to C libraries. The same
might be true of Rust in the future and Go when we add support for it.

This contains no functionality changes.
2018-06-20 11:27:08 +00:00
Jon Turney d17ce4ffd0 Correctly substitute the internal @BUILD_ROOT@ token with MSVC backend
To me, this looks like a mistake in 976c9abc, but perhaps there's something
I don't understand going on here.
2018-06-18 10:52:21 +00:00
Alex Hirsch cbe18e01e4 Deprecate `build_always`, add `build_always_stale`
Since `build_always` also adds a target to the set of default targets,
this option is marked deprecated in favour of the new option
`build_always_stale`.

`build_always_stale` *only* marks the target to be always considered out
of date, but does *not* add it to the set of default targets.

The old behaviour can still be achieved by combining
`build_always_stale` with `build_by_default`.

fixes #1942
2018-06-18 10:49:40 +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 61c6f589f3 backends: Don't exclude system libraries for PATH
We reuse the same function for generating PATH, and we don't want to
exclude system paths there for obvious reasons.
2018-06-07 12:57:56 +00:00
Nirbheek Chauhan 6b7dba7f06 backends: Don't hardcode system library paths
Lookup the library paths using the available compilers instead.

This makes the code work on non-Linux platforms too.
2018-06-07 12:57:56 +00:00
Xavier Claessens aa879b7f0c Fix issues found by flake8 2018-06-06 20:02:37 +00:00
Xavier Claessens b7d442150d Move <lang>_args to coredata.compiler_options 2018-06-06 20:02:37 +00:00
Nirbheek Chauhan ad0121d259 Add prog/lib dirs from the mingw cross-compiler to PATH
These directories contain DLLs that the executable may need, such as
libstdc++-6.dll, libwinpthread, etc.
2018-06-05 10:50:22 +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
Nirbheek Chauhan efa9b75d5d Set WINEPATH when running serialized executables
When the exe runner is `wine` or `wine32` or `wine64`, etc.
This allows people to run tests with wine.

Note that you also have to set WINEPATH to point to your custom
prefix(es) if your tests use external dependencies.

Closes https://github.com/mesonbuild/meson/issues/3620
2018-06-05 10:50:22 +00:00
Mathieu Duponchelle b3feff3032 test extra paths: add extra paths for all build targets 2018-06-02 11:42:48 +00:00
Mathieu Duponchelle 35ab34d6cd test serialisation: determine windows extra paths ..
..  for executable arguments too.

This makes it possible to pass an executable to a test, which
can then run it in an appropriate environment.
2018-06-02 11:42:48 +00:00
Nirbheek Chauhan 1ffbddc31a backends: Also accept dylibs while finding RPATHs 2018-05-24 14:38:28 +00:00
Nirbheek Chauhan fecd580687 backends: Simplify loop getting rpaths for bundled libs
No functionality changes
2018-05-24 14:38:28 +00:00
Nirbheek Chauhan 165da6fb65 backends: Use a set while gathering RPATHs 2018-05-24 14:38:28 +00:00
Jussi Pakkanen 1918c0d231 Can combine D and C++ in a single target. Closes #3125. 2018-05-02 22:50:15 +03:00
Niklas Claesson 4f4cdee687 Allow custom_target do depend on indexed output of custom_target
Fixes: #3494
2018-05-01 11:51:55 +00:00