aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-20backends: add a new "none" backendEli Schwartz1-0/+3
It can only be used for projects that don't have any rules at all, i.e. they are purely using Meson to: - configure files - run (script?) tests - install files that exist by the end of the setup stage This can be useful e.g. for Meson itself, a pure python project.
2023-03-20backends: simplify class setupEli Schwartz1-1/+1
2023-03-01backends: fix source dir stripping from rpathsStefan Hajnoczi1-2/+9
Commit e88887be4a08 ("Only remove substring if it is part of string") removed the source dir from the rpath when the following check succeeds: if absdir.startswith(self.environment.get_source_dir()): rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] For example, absdir '/myproject/foo' starts with source dir '/myproject', so we want to generate the relative path 'foo'. This code doesn't work with absdir '/myproject-libs/foo' though, because we'll incorrectly turn it into a relative path 'libs/foo' after stripping away '/myproject-'. Use os.path.commonpath() instead of str.startswith() so path components are correctly handled. Cc: Niklas Claesson <niklas.claesson@cosylab.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2023-01-03backends/backends: Add helpful message for getting rid of warningDylan Baker1-1/+1
2022-12-27add builtin option to install licensesEli Schwartz1-6/+12
Unless `meson.install_dependency_manifest()` is explicitly used, this will cause a default implied one to be installed.
2022-12-27add license_files kwarg to projectEli Schwartz1-0/+8
Hook this up to installed dependency manifests. This is often needed above and beyond just an SPDX string -- e.g. many licenses have custom copyright lines.
2022-12-07Remove useless EmptyExternalProgramXavier Claessens1-4/+1
It is only used by Environment.get_exe_wrapper() and every callers were handling None already. Type annotation was wrong, it already could return None for the case an exe wrapper is needed but none is provided.
2022-12-07devenv: Always include env for HOST machineXavier Claessens1-3/+1
Cross compiled executables could still be run with an exe wrapper, or with proper binfmt installed. Fixes: #10999
2022-12-07devenv: Add executables locations to both PATH and WINEPATHXavier Claessens1-7/+12
Handles the case when wine-binfmt is installed, which makes .exe files executable without without specifying an exe wrapper.
2022-11-30tests: Write out LD_LIBRARY_PATH for built shared librariesDaniel Stone1-1/+14
When a test executable references a local shared library, make sure that we apply the appropriate $LD_LIBRARY_PATH so that the linker can find it at runtime. The DT_RUNPATH entry does ensure that the binary references the path to the shared library build, however the RUNPATH list is only searched after $LD_LIBRARY_PATH. So if the user has a shared library of the same name in their $LD_LIBRARY_PATH, this will be the version found and used for running the test. This is bad if you're trying to use Meson to test a shared library you're developing and have installed in a local prefix which is under $LD_LIBRARY_PATH. Fixes #1635
2022-11-24Fix various spelling errorsDavid Robillard1-1/+1
Found with codespell.
2022-11-02backends: Try guessing install tag for all installed filesXavier Claessens1-3/+11
It was only trying to guess install tag, and log missing tags, for files installed by install_data(). Do it also for all other files, especially custom_taget() that commonly installs generated headers.
2022-10-23vs backend: Add support for CompileTargetXavier Claessens1-0/+27
Since vs backend only support the C compiler, everything else are custom targets. Convert CompileTarget into a Generator to reuse existing code. This will be useful in the future to support transpilers, and assemblers.
2022-10-23Add cc.preprocess() method for c-like compilersXavier Claessens1-0/+2
This introduce a new type of BuildTarget: CompileTarget. From ninja backend POV it is the same thing as any other build target, except that it skips the final link step. It could be used in the future for transpilers too.
2022-10-09run wrapped-due-to-env commands on unix via the env programEli Schwartz1-1/+18
First, check if the env program exists. If it does, it is faster than doing it via a python script `basically-env.py` that maybe imports all of mesonbuild.* as a side effect of project structure. We do not, however, use env for setting up PATH additions, since env can override an environment variable but not extend it. So in that case we still need to wrap the command via python. By default, all run_targets (at least) are wrapped and now wrap via the `env` program as they export e.g. MESONINTROSPECT='/usr/bin/meson introspect'
2022-10-03pylint: enable unnecessary-lambdaDylan Baker1-1/+1
2022-09-28Move classes used by scripts to their own moduleXavier Claessens1-22/+2
Those classes are used by wrapper scripts and we should not have to import the rest of mesonlib, build.py, and all their dependencies for that. This renames mesonlib/ directory to utils/ and add a mesonlib.py module that imports everything from utils/ to not have to change `import mesonlib` everywhere. It allows to import utils.core without importing the rest of mesonlib.
2022-09-28Automatically tag systemtap filesXavier Claessens1-0/+2
2022-09-28Automaticall tag installed testsXavier Claessens1-0/+2
It is common, at least in GNOME projects, to install tests. Files goes into various locations, including: - /usr/lib/x86_64-linux-gnu/installed-tests - /usr/share/installed-tests - /usr/libexec/installed-tests It is safe to assume that everything that goes into a "installed-tests" subdir should be tagged as "tests" by default.
2022-09-27compilers: Cleanup a bit languages/suffixes listsXavier Claessens1-1/+1
Use set where order does not matter, fix is_source() to really mean only source suffixes.
2022-09-19pylint: enable consider-using-inDylan Baker1-1/+1
2022-09-11backends: limit maximum path of generated filenamesEli Schwartz1-1/+9
When calculating the output filename for a compiled object, we sanitize the whole input path, more or less. In cases where the input path is very long, this can overflow the max length of an individual filename component. At the same time, we do want unique names so people can recognize what these outputs actually are. Compromise: - for filepaths with >5 components (which are a lot more likely to cause problems, and simultanously less likely to have crucial information that far back in the filepath) - if an sha1 hash of the full path, replacing all *but* those last 5 components, produces a path that is *shorter* than the original path ... then use that modified path canonicalization via a hash. Due to the use of hashes, it's unique enough to guarantee correct builds. Because we keep the last 5 components intact, it's easy to tell what the output file is compiled from. Fixes building in ecosystems such as spack, where the build environment is a very long path containing repetitions of `__spack_path_placeholder__/` for... reasons of making the path long.
2022-09-06Fix install_subdirs not showing up in intro-install_plan.jsonThomas Li1-1/+3
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge1-1/+1
2022-08-24backend/ninja: properly track objects extracted from fortran sourcesDylan Baker1-9/+14
We need this to ensure that .mod files are created before we start compiling, and to ensure that the proper include directory arguments are generated.
2022-08-22introspection: untangle install_plan implemetation, fix a bunch of wrong onesEli Schwartz1-10/+12
Generally plumb through the values of get_option() passed to install_dir, and use this to establish the install plan name. Fixes several odd cases, such as: - {datadir} being prepended to "share" or "include" - dissociating custom install directories and writing them out as {prefix}/share/foo or {prefix}/lib/python3.10/site-packages This is the second half of #9478 Fixes #10601
2022-08-18build: Add a Union alias for all build targetsDylan Baker1-1/+1
2022-07-15backends: Remove /Zi arg if requested to use /Z7Christian Wendt1-5/+5
Change the order of testing flags and get_external_args() to handle flags set by get_external_args() correctly.
2022-06-14backend: always use the same code to compute the files in ExtractedObjectsPaolo Bonzini1-7/+7
Instead of asking the ExtractedObjects, but with a hook back into the backend, use the existing function in the backend itself. This fixes using the extract_objects(...) of a generated source file in a custom_target. It should also fix recursive extract_all_objects with the Xcode backend. Fixes: #10394
2022-06-14take override_option('unity=...') into account when allowing extract_objects()Paolo Bonzini1-5/+1
A single target could be picked for unity build, and in that case extract_objects() should not be allowed. Likewise for the opposite case, where extract_objects() should be allowed if unity build is disabled for a single target. A test that covers that case is added later.
2022-06-13ninja backend: generate additional meta-rules for test/benchmarks targetsEli Schwartz1-4/+7
'meson-test-prereq' now depends on any targets that were formerly added directly to 'all'. Behavior is not changed -- the all target still depends on this other meta-rule, and thus indirectly depends on all targets it used to depend on. It is now possible to build just the targets needed for the testsuite and then e.g. run `meson test --no-rebuild`.
2022-06-13flake8: fix various whitespace nitsEli Schwartz1-3/+3
2022-06-10flake8: remove no longer used importsEli Schwartz1-1/+0
2022-06-09intro-install_plan: fix destinations for build_targets with custom install_dirEli Schwartz1-13/+11
There are a couple issues that combine to make the current handling a bit confusing. - we call it "install_dir_name" but it is only ever the class default - CustomTarget always has it set to None, and then we check if it is None then create a different variable with a safe fallback. The if is useless -- it cannot fail, but if it did we'd get an undefined variable error when we tried to use `dir_name` Remove the special handling for CustomTarget. Instead, just always accept None as a possible value of outdir_name when constructing install data, and, if it is None, fall back to {prefix}/outdir regardless of what type it used to be.
2022-06-08build: Fix annotations for CustomTargetDylan Baker1-0/+4
and fix a bug in the backend that the correct annotations uncover
2022-06-01backends: work around some mypy limitations and fix spotted bugsDylan Baker1-15/+21
2022-05-06devenv: Set WINEPATH when cross compiling for WindowsXavier Claessens1-6/+12
2022-03-31allow RunTarget to skip wrapping due to envEli Schwartz1-5/+6
Forcing serialization on when writing out the build rule makes very little sense. It was always "forced" on because we mandated a couple of environment variables due to legacy reasons. Add an attribute to RunTarget to say that a given target doesn't *need* those environment variables, and let ninja optimize them away and run the command directly if set.
2022-03-29Target: Stop passing environment in method argsXavier Claessens1-3/+3
2022-03-29Replace backend.get_option_for_target() with target.get_option()Xavier Claessens1-24/+11
That method had nothing specific to the backend, it's purely a Target method. This allows to cache the OptionOverrideProxy object on the Target instance instead of creating a new one for each option lookup.
2022-03-22OptionOverrideProxy: Handle per-subproject optionsXavier Claessens1-8/+5
2022-03-22backends: Stop separating base and compiler optionsXavier Claessens1-11/+5
Since OptionKey is used we can mix all options together in a single dictionary. That's already what we do in coredata.options.
2022-03-14mtest: fix logic bug that broke tests where the cmd is a Windows found programEli Schwartz1-0/+2
In this case, the test fname might have an implicit extension and cannot be found by `os.path.isfile()`. We cannot use `shutil.which()` to handle platform differences, because not all test fnames are executable -- for example Java jars. The test representation does have an "is built" attribute which in theory should work here, because all built targets definitely have their full filename known to Meson, but it turns out to be misnamed. Rename it correctly and add an actual "is built" attribute to check. Tests which aren't built by Meson can be assumed to exist without consulting their existence on the filesystem. Fixes #10027
2022-03-09install: Add --strip optionXavier Claessens1-2/+4
2022-03-07treewide: string-quote the first argument to T.castEli Schwartz1-2/+2
Using future annotations, type annotations become strings at runtime and don't impact performance. This is not possible to do with T.cast though, because it is a function argument instead of an annotation. Quote the type argument everywhere in order to have the same effect as future annotations. This also allows linters to better detect in some cases that a given import is typing-only.
2022-03-07Fix default install tag for shared lib symlinksXavier Claessens1-7/+12
Versioned shared libraries should have .so file in devel, .so.1 and .so.1.2.3 in runtime. Fixes: #9811
2022-02-28devenv: Do not prepend empty list to PATH and LD_LIBRARY_PATHXavier Claessens1-7/+9
2022-02-28backends: Cache creation of install dataXavier Claessens1-0/+1
It is created twice for ninja and for introspection.
2022-02-16flake8: fix various whitespace errors with badly aligned codeEli Schwartz1-1/+1
2022-02-16flake8: fix typoed whitespace surrounding tokensEli Schwartz1-1/+1