aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--cross/iphone.txt2
-rw-r--r--docs/markdown/Getting-meson.md2
-rw-r--r--docs/markdown/Overview.md2
-rw-r--r--docs/markdown/Reference-manual.md51
-rw-r--r--docs/markdown/Unit-tests.md2
-rw-r--r--docs/markdown/Users.md2
-rw-r--r--docs/markdown/tmp.json29
-rwxr-xr-xmanual tests/4 standalone binaries/build_osx_package.sh7
-rw-r--r--mesonbuild/backend/backends.py7
-rw-r--r--mesonbuild/backend/ninjabackend.py7
-rw-r--r--mesonbuild/backend/vs2010backend.py18
-rw-r--r--mesonbuild/build.py9
-rw-r--r--mesonbuild/compilers.py19
-rw-r--r--mesonbuild/dependencies/misc.py2
-rw-r--r--mesonbuild/mesonlib.py17
-rw-r--r--mesonbuild/scripts/dist.py3
-rwxr-xr-xrun_project_tests.py23
-rwxr-xr-xrun_tests.py7
-rwxr-xr-xrun_unittests.py21
-rw-r--r--test cases/common/152 link depends custom target/foo.c15
-rwxr-xr-xtest cases/common/152 link depends custom target/make_file.py5
-rw-r--r--test cases/common/152 link depends custom target/meson.build19
-rw-r--r--test cases/windows/11 vs module defs generated custom target/meson.build10
-rw-r--r--test cases/windows/11 vs module defs generated custom target/prog.c5
-rwxr-xr-xtest cases/windows/11 vs module defs generated custom target/subdir/make_def.py6
-rw-r--r--test cases/windows/11 vs module defs generated custom target/subdir/meson.build7
-rw-r--r--test cases/windows/11 vs module defs generated custom target/subdir/somedll.c3
28 files changed, 197 insertions, 106 deletions
diff --git a/.gitignore b/.gitignore
index 8914def..b350689 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,5 @@ packagecache
/dist
/meson.egg-info
-hotdoc-private*
+/docs/built_docs
+/docs/hotdoc-private*
diff --git a/cross/iphone.txt b/cross/iphone.txt
index b2fe3c9..e714da5 100644
--- a/cross/iphone.txt
+++ b/cross/iphone.txt
@@ -20,7 +20,7 @@ has_function_printf = true
has_function_hfkerhisadf = false
[host_machine]
-system = 'ios'
+system = 'darwin'
cpu_family = 'arm'
cpu = 'armv7'
endian = 'little'
diff --git a/docs/markdown/Getting-meson.md b/docs/markdown/Getting-meson.md
index c01a947..d654ff3 100644
--- a/docs/markdown/Getting-meson.md
+++ b/docs/markdown/Getting-meson.md
@@ -12,7 +12,7 @@ The newest development code can be obtained directly from [Git]
## Dependencies
Meson is implemented in Python 3. If your operating system provides a
-package manager, use should install it with that. For platforms that
+package manager, you should install it with that. For platforms that
don't have a package manager, you need to download it from [Python's
home page].
diff --git a/docs/markdown/Overview.md b/docs/markdown/Overview.md
index 537aa8f..c9acda5 100644
--- a/docs/markdown/Overview.md
+++ b/docs/markdown/Overview.md
@@ -6,7 +6,7 @@ short-description: Overview of the Meson build system
Meson is a build system that is designed to be as user-friendly as possible without sacrificing performance. The main tool for this is a custom language that the user uses to describe the structure of his build. The main design goals of this language has been simplicity, clarity and conciseness. Much inspiration was drawn from the Python programming language, which is considered very readable, even to people who have not programmed in Python before.
-Another main idea has been to provide first class support for modern programming tools and best practices. These include features as varied as unit testing, code coverage reporting, precompiled headers and the like. All of these features should be immediately available to any project using Meson. The user should not need to hunt for third party macros or write shell scripts to get these features. They just just work out of the box.
+Another main idea has been to provide first class support for modern programming tools and best practices. These include features as varied as unit testing, code coverage reporting, precompiled headers and the like. All of these features should be immediately available to any project using Meson. The user should not need to hunt for third party macros or write shell scripts to get these features. They should just work out of the box.
This power should not come at the expense of limited usability. Many software builds require unorthodox steps. A common example is that you first need to build a custom tool and then use that tool to generate more source code to build. This functionality needs to be supported and be as easy to use as other parts of the system.
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 62c0fb3..c835f6f 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -132,7 +132,7 @@ These are all the supported keyword arguments:
### custom_target()
``` meson
- ctarget custom_target(*name*, ...)
+ customtarget custom_target(*name*, ...)
```
Create a custom top level build target. The only positional argument is the name of this target and the keyword arguments are the following.
@@ -158,6 +158,8 @@ The list of strings passed to the `command` keyword argument accept the followin
- `@OUTDIR@` the full path to the directory where the output(s) must be written
- `@DEPFILE@` the full path to the dependency file passed to `depfile`
+The returned object also has methods that are documented in the [object methods section](#custom-target-object) below.
+
### declare_dependency()
``` meson
@@ -212,7 +214,7 @@ Returns an empty [environment variable object](#environment-object).
### executable()
``` meson
- exe executable(*exe_name*, *sources*, ...)
+ buildtarget executable(*exe_name*, *sources*, ...)
```
Creates a new executable. The first argument specifies its name and the remaining positional arguments define the input files to use. They can be of the following types:
@@ -582,7 +584,7 @@ Builds a shared library with the given sources. Positional and keyword arguments
- `version` a string specifying the version of this shared library, such as `1.1.0`. On Linux and OS X, this is used to set the shared library version in the filename, such as `libfoo.so.1.1.0` and `libfoo.1.1.0.dylib`. If this is not specified, `soversion` is used instead (see below).
- `soversion` a string specifying the soversion of this shared library, such as `0`. On Linux and Windows this is used to set the soversion (or equivalent) in the filename. For example, if `soversion` is `4`, a Windows DLL will be called `foo-4.dll` and one of the aliases of the Linux shared library would be `libfoo.so.4`. If this is not specified, the first part of `version` is used instead. For example, if `version` is `3.6.0` and `soversion` is not defined, it is set to `3`.
-- `vs_module_defs` a string pointing to a file or a File object that is a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).
+- `vs_module_defs` a string, a File object, or Custom Target for a Microsoft module definition file for controlling symbol exports, etc., on platforms where that is possible (e.g. Windows).
### shared_module()
@@ -647,7 +649,7 @@ Defined tests can be run in a backend-agnostic way by calling `mesontest` inside
### vcs_tag()
``` meson
- ctarget vcs_tag(...)
+ customtarget vcs_tag(...)
```
This command detects revision control commit information at build time and places it in the specified output file. This file is guaranteed to be up to date on every build. Keywords are similar to `custom_target`.
@@ -737,18 +739,6 @@ When all compilation is 'native', all the methods return the same values as `bui
Note that while cross-compiling, it simply returns the values defined in the cross-info file. If `target_machine` values are not defined in the cross-info file, `host_machine` values are returned instead.
-### `build target` object
-
-A build target is either an [executable](#executable), [shared](#shared_library) or [static library](#static_library).
-
-- `extract_objects()` returns an opaque value representing the generated object files of arguments, usually used to take single object files and link them to unit tests or to compile some source files with custom flags. To use the object file(s) in another build target, use the `objects:` keyword argument.
-
-- `extract_all_objects()` is same as above but returns all object files generated by this target
-
-- `private_dir_include()` returns a opaque value that works like `include_directories` but points to the private directory of this target, usually only needed if an another target needs to access some generated internal headers of this target
-
-- `full_path()` returns a full path pointing to the result target file
-
### `compiler` object
This object is returned by [`meson.get_compiler(lang)`](#meson-object). It represents a compiler for a given language and allows you to query its properties. It has the following methods:
@@ -833,14 +823,17 @@ You can also iterate over arrays with the [`foreach` statement](https://github.c
These are objects returned by the [functions listed above](#functions).
-### `run result` object
+### `build target` object
-This object encapsulates the result of trying to compile and run a sample piece of code with [`compiler.run()`](#compiler-object) or [`run_command()`](#run_command). It has the following methods:
+A build target is either an [executable](#executable), [shared](#shared_library), [static library](#static_library) or [shared module](#shared_module).
-- `compiled()` if true, the compilation succeeded, if false it did not and the other methods return unspecified data
-- `returncode()` the return code of executing the compiled binary
-- `stdout()` the standard out produced when the binary was run
-- `stderr()` the standard error produced when the binary was run
+- `extract_objects()` returns an opaque value representing the generated object files of arguments, usually used to take single object files and link them to unit tests or to compile some source files with custom flags. To use the object file(s) in another build target, use the `objects:` keyword argument.
+
+- `extract_all_objects()` is same as above but returns all object files generated by this target
+
+- `private_dir_include()` returns a opaque value that works like `include_directories` but points to the private directory of this target, usually only needed if an another target needs to access some generated internal headers of this target
+
+- `full_path()` returns a full path pointing to the result target file
### `configuration` data object
@@ -854,6 +847,12 @@ This object is returned by [`configuration_data()`](#configuration_data) and enc
They all take the `description` keyword that will be written in the result file. The replacement assumes a file with C syntax. If your generated file is source code in some other language, you probably don't want to add a description field because it most likely will cause a syntax error.
+### `custom target` object
+
+This object is returned by [`custom_target`](#custom_target) and contains a target with the following methods:
+
+- `full_path()` returns a full path pointing to the result target file
+
### `dependency` object
This object is returned by [`dependency()`](#dependency) and contains an external dependency with the following methods:
@@ -906,3 +905,11 @@ This object is returned by [`subproject()`](#subproject) and is an opaque object
subproject. This is useful to, for instance, get a [declared
dependency](#declare_dependency) from the subproject.
+### `run result` object
+
+This object encapsulates the result of trying to compile and run a sample piece of code with [`compiler.run()`](#compiler-object) or [`run_command()`](#run_command). It has the following methods:
+
+- `compiled()` if true, the compilation succeeded, if false it did not and the other methods return unspecified data
+- `returncode()` the return code of executing the compiled binary
+- `stdout()` the standard out produced when the binary was run
+- `stderr()` the standard error produced when the binary was run
diff --git a/docs/markdown/Unit-tests.md b/docs/markdown/Unit-tests.md
index 1aa7806..13d66f7 100644
--- a/docs/markdown/Unit-tests.md
+++ b/docs/markdown/Unit-tests.md
@@ -30,7 +30,7 @@ Note how you need to specify multiple values as an array.
Coverage
--
-If you enable coverage measurements by giving Meson the command line flag `-Db_coverage=true`, you can generate coverage reports. Meson will autodetect what coverage generator tools you have installed and will generate the corresponding targets. These targets are `coverage-xml` and `coverage-text` which are both provided by [Gcovr](https://software.sandia.gov/trac/fast/wiki/gcovr) and `coverage-html`, which requires [Lcov](https://ltp.sourceforge.io/coverage/lcov.php) and [GenHTML](https://linux.die.net/man/1/genhtml).
+If you enable coverage measurements by giving Meson the command line flag `-Db_coverage=true`, you can generate coverage reports. Meson will autodetect what coverage generator tools you have installed and will generate the corresponding targets. These targets are `coverage-xml` and `coverage-text` which are both provided by [Gcovr](http://gcovr.com) and `coverage-html`, which requires [Lcov](https://ltp.sourceforge.io/coverage/lcov.php) and [GenHTML](https://linux.die.net/man/1/genhtml).
The the output of these commands is written to the log directory `meson-logs` in your build directory.
diff --git a/docs/markdown/Users.md b/docs/markdown/Users.md
index 0d24d6b..8cfaf94 100644
--- a/docs/markdown/Users.md
+++ b/docs/markdown/Users.md
@@ -9,7 +9,7 @@ If you have a project that uses Meson that you want to add to this list, let us
- [AQEMU](https://github.com/tobimensch/aqemu), a Qt GUI for QEMU virtual machines, since version 0.9.3
- [Arduino sample project](https://github.com/jpakkane/mesonarduino)
- [Emeus](https://github.com/ebassi/emeus), Constraint based layout manager for GTK+
- - [Frida.re](https://github.com/frida/frida-core), a code tracing framework
+ - [Frida](https://www.frida.re/), a dynamic binary instrumentation toolkit
- [GLib](https://github.com/centricular/glib/), cross-platform C library used by GTK+ (not merged yet)
- [Gnome Builder](https://git.gnome.org/browse/gnome-builder/), an IDE for the Gnome platform
- [Gnome MPV](https://github.com/gnome-mpv/gnome-mpv), Gnome frontend to the mpv video player
diff --git a/docs/markdown/tmp.json b/docs/markdown/tmp.json
deleted file mode 100644
index 190d12f..0000000
--- a/docs/markdown/tmp.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "functions": {
- "add_global_arguments": {
- "doc": ["Adds the positional arguments to the compiler command line for the language specified in `language` keyword argument. Note that there is no way to remove an argument set in this way.",
- "If you have an argument that is only used in a subset of targets, you have to specify it in per-target flags.",
- "The arguments are used in all compiler invocations with the exception of compile tests, because you might need to run a compile test with and without the argument in question. For this reason only the arguments explicitly specified are used during compile tests.",
- "**Note:** Usually you should use `add_project_arguments` instead, because that works even when you project is used as a subproject.",
- "**Note:** You must pass always arguments individually `arg1, arg2, ...` rather than as a string `'arg1 arg2', ...`"]
- "arguments": [
- {"name": "args1", "doc": "Some argument"}
- ]
- }
- }
- "objects": [
- "meson": {
- "doc": ["The `meson` object allows you to introspect various properties of the system. This object is always mapped in the `meson` variable. It has the following methods."]
- "methods": [
- "get_compiler": {
- "arguments": [
- {"name": "language", "doc": "returns [an object describing a compiler](#compiler-object), takes one positional argument which is the language to use. ",
- "It also accepts one keyword argument, `native` which when set to true makes Meson return the compiler for the build machine (the \"native\" compiler)",
- "and when false it returns the host compiler (the \"cross\" compiler). If `native` is omitted, Meson returns the \"cross\" compiler if we're currently",
- " cross-compiling and the \"native\" compiler if we're not."}
- ]
- }
- ]
- }
- ]
-}
diff --git a/manual tests/4 standalone binaries/build_osx_package.sh b/manual tests/4 standalone binaries/build_osx_package.sh
index eca11c6..eb4ec38 100755
--- a/manual tests/4 standalone binaries/build_osx_package.sh
+++ b/manual tests/4 standalone binaries/build_osx_package.sh
@@ -9,12 +9,11 @@ mkdir -p mnttmp
rm -f working.dmg
gunzip < template.dmg.gz > working.dmg
hdiutil attach working.dmg -noautoopen -quiet -mountpoint mnttmp
-# NOTE: output of hdiutil changes every now and then.
-# Verify that this is still working.
-DEV=`hdiutil info|tail -1|awk '{print $1}'`
rm -rf mnttmp/myapp.app
mv /tmp/myapp.app mnttmp
-hdiutil detach ${DEV}
+# NOTE: output of hdiutil changes every now and then.
+# Verify that this is still working.
+hdiutil detach $(hdiutil info|grep "mnttmp"|awk '{print $1}')
rm -rf mnttmp
rm -f myapp.dmg
hdiutil convert working.dmg -quiet -format UDZO -imagekey zlib-level=9 -o myapp.dmg
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index a95294b..75974a5 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -405,9 +405,10 @@ class Backend:
# Add compile args added using add_global_arguments()
# These override per-project arguments
commands += self.build.get_global_args(compiler)
- # Compile args added from the env: CFLAGS/CXXFLAGS, etc. We want these
- # to override all the defaults, but not the per-target compile args.
- commands += self.environment.coredata.external_args[compiler.get_language()]
+ if not target.is_cross:
+ # Compile args added from the env: CFLAGS/CXXFLAGS, etc. We want these
+ # to override all the defaults, but not the per-target compile args.
+ commands += self.environment.coredata.external_args[compiler.get_language()]
# Always set -fPIC for shared libraries
if isinstance(target, build.SharedLibrary):
commands += compiler.get_pic_args()
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 4b12da6..e12678d 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2267,9 +2267,10 @@ rule FORTRAN_DEP_HACK
# Add link args added using add_global_link_arguments()
# These override per-project link arguments
commands += self.build.get_global_link_args(linker)
- # Link args added from the env: LDFLAGS. We want these to
- # override all the defaults but not the per-target link args.
- commands += self.environment.coredata.external_link_args[linker.get_language()]
+ if not target.is_cross:
+ # Link args added from the env: LDFLAGS. We want these to
+ # override all the defaults but not the per-target link args.
+ commands += self.environment.coredata.external_link_args[linker.get_language()]
# Now we will add libraries and library paths from various sources
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index f97ab87..082f3c5 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -759,11 +759,12 @@ class Vs2010Backend(backends.Backend):
for l, args in self.build.global_args.items():
if l in file_args:
file_args[l] += args
- # Compile args added from the env: CFLAGS/CXXFLAGS, etc. We want these
- # to override all the defaults, but not the per-target compile args.
- for l, args in self.environment.coredata.external_args.items():
- if l in file_args:
- file_args[l] += args
+ if not target.is_cross:
+ # Compile args added from the env: CFLAGS/CXXFLAGS, etc. We want these
+ # to override all the defaults, but not the per-target compile args.
+ for l, args in self.environment.coredata.external_args.items():
+ if l in file_args:
+ file_args[l] += args
for args in file_args.values():
# This is where Visual Studio will insert target_args, target_defines,
# etc, which are added later from external deps (see below).
@@ -901,9 +902,10 @@ class Vs2010Backend(backends.Backend):
# Add link args added using add_global_link_arguments()
# These override per-project link arguments
extra_link_args += self.build.get_global_link_args(compiler)
- # Link args added from the env: LDFLAGS. We want these to
- # override all the defaults but not the per-target link args.
- extra_link_args += self.environment.coredata.external_link_args[compiler.get_language()]
+ if not target.is_cross:
+ # Link args added from the env: LDFLAGS. We want these to
+ # override all the defaults but not the per-target link args.
+ extra_link_args += self.environment.coredata.external_link_args[compiler.get_language()]
# Only non-static built targets need link args and link dependencies
extra_link_args += target.link_args
# External deps must be last because target link libraries may depend on them.
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 242ce6f..855c0bd 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1279,6 +1279,8 @@ class SharedLibrary(BuildTarget):
# Visual Studio module-definitions file
if 'vs_module_defs' in kwargs:
path = kwargs['vs_module_defs']
+ if hasattr(path, 'held_object'):
+ path = path.held_object
if isinstance(path, str):
if os.path.isabs(path):
self.vs_module_defs = File.from_absolute_file(path)
@@ -1289,10 +1291,15 @@ class SharedLibrary(BuildTarget):
# When passing a generated file.
self.vs_module_defs = path
self.link_depends.append(path)
+ elif hasattr(path, 'get_filename'):
+ # When passing output of a Custom Target
+ path = File.from_built_file(path.subdir, path.get_filename())
+ self.vs_module_defs = path
+ self.link_depends.append(path)
else:
raise InvalidArguments(
'Shared library vs_module_defs must be either a string, '
- 'or a file object')
+ 'a file object or a Custom Target')
def check_unknown_kwargs(self, kwargs):
self.check_unknown_kwargs_int(kwargs, known_lib_kwargs)
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 171aa5c..e7c02b2 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -956,15 +956,16 @@ class CCompiler(Compiler):
args += self.get_linker_debug_crt_args()
# Read c_args/cpp_args/etc from the cross-info file (if needed)
args += self.get_cross_extra_flags(env, link=(mode == 'link'))
- if mode == 'preprocess':
- # Add CPPFLAGS from the env.
- args += env.coredata.external_preprocess_args[self.language]
- elif mode == 'compile':
- # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
- args += env.coredata.external_args[self.language]
- elif mode == 'link':
- # Add LDFLAGS from the env
- args += env.coredata.external_link_args[self.language]
+ if not self.is_cross:
+ if mode == 'preprocess':
+ # Add CPPFLAGS from the env.
+ args += env.coredata.external_preprocess_args[self.language]
+ elif mode == 'compile':
+ # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env
+ args += env.coredata.external_args[self.language]
+ elif mode == 'link':
+ # Add LDFLAGS from the env
+ args += env.coredata.external_link_args[self.language]
args += self.get_compiler_check_args()
# extra_args must override all other arguments, so we add them last
args += extra_args
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index e997807..3e0b558 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -202,7 +202,7 @@ class BoostDependency(Dependency):
self.lib_modules_mt[modname] = fname
def detect_lib_modules_nix(self):
- if mesonlib.is_osx():
+ if mesonlib.is_osx() and not self.want_cross:
libsuffix = 'dylib'
else:
libsuffix = 'so'
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 6937502..415bc50 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -15,6 +15,7 @@
"""A library of random helper functionality."""
import stat
+import time
import platform, subprocess, operator, os, shutil, re
import collections
@@ -687,6 +688,22 @@ def get_filenames_templates_dict(inputs, outputs):
values['@OUTDIR@'] = '.'
return values
+
+def windows_proof_rmtree(f):
+ # On Windows if anyone is holding a file open you can't
+ # delete it. As an example an anti virus scanner might
+ # be scanning files you are trying to delete. The only
+ # way to fix this is to try again and again.
+ delays = [0.1, 0.1, 0.2, 0.2, 0.2, 0.5, 0.5, 1, 1, 1, 1, 2]
+ for d in delays:
+ try:
+ shutil.rmtree(f)
+ return
+ except (OSError, PermissionError):
+ time.sleep(d)
+ # Try one last time and throw if it fails.
+ shutil.rmtree(f)
+
class OrderedSet(collections.MutableSet):
"""A set that preserves the order in which items are added, by first
insertion.
diff --git a/mesonbuild/scripts/dist.py b/mesonbuild/scripts/dist.py
index f17b296..064708e 100644
--- a/mesonbuild/scripts/dist.py
+++ b/mesonbuild/scripts/dist.py
@@ -22,6 +22,7 @@ import tarfile, zipfile
import tempfile
from glob import glob
from mesonbuild.environment import detect_ninja
+from mesonbuild.mesonlib import windows_proof_rmtree
def create_hash(fname):
hashname = fname + '.sha256sum'
@@ -49,7 +50,7 @@ def create_zip(zipfilename, packaging_dir):
def del_gitfiles(dirname):
for f in glob(os.path.join(dirname, '.git*')):
if os.path.isdir(f) and not os.path.islink(f):
- shutil.rmtree(f)
+ windows_proof_rmtree(f)
else:
os.unlink(f)
diff --git a/run_project_tests.py b/run_project_tests.py
index 7f7cfdc..822286b 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -114,24 +114,11 @@ class AutoDeletedDir:
return self.dir
def __exit__(self, _type, value, traceback):
- # On Windows, shutil.rmtree fails sometimes, because 'the directory is not empty'.
- # Retrying fixes this.
- # That's why we don't use tempfile.TemporaryDirectory, but wrap the deletion in the AutoDeletedDir class.
- retries = 5
- for i in range(0, retries):
- try:
- shutil.rmtree(self.dir)
- return
- # Sometimes we get: ValueError: I/O operation on closed file.
- except ValueError:
- return
- # Deleting can raise OSError or PermissionError on Windows
- # (most likely because of anti-virus locking the file)
- except (OSError, PermissionError):
- if i == retries - 1:
- mlog.warning('Could not delete temporary directory.')
- return
- time.sleep(0.1 * (2**i))
+ # We don't use tempfile.TemporaryDirectory, but wrap the
+ # deletion in the AutoDeletedDir class because
+ # it fails on Windows due antivirus programs
+ # holding files open.
+ mesonlib.windows_proof_rmtree(self.dir)
failing_logs = []
print_debug = 'MESON_PRINT_TEST_OUTPUT' in os.environ
diff --git a/run_tests.py b/run_tests.py
index a374839..7ef9cf4 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -114,6 +114,9 @@ def get_fake_options(prefix):
opts.prefix = prefix
return opts
+def should_run_linux_cross_tests():
+ return shutil.which('arm-linux-gnueabihf-gcc-6') and not platform.machine().startswith('arm')
+
class FakeEnvironment(object):
def __init__(self):
self.cross_info = None
@@ -154,6 +157,8 @@ if __name__ == '__main__':
units = ['InternalTests', 'AllPlatformTests']
if mesonlib.is_linux():
units += ['LinuxlikeTests']
+ if should_run_linux_cross_tests():
+ units += ['LinuxArmCrossCompileTests']
elif mesonlib.is_windows():
units += ['WindowsTests']
# Can't pass arguments to unit tests, so set the backend to use in the environment
@@ -161,7 +166,7 @@ if __name__ == '__main__':
env['MESON_UNIT_TEST_BACKEND'] = backend.name
returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'] + units, env=env)
# Ubuntu packages do not have a binary without -6 suffix.
- if shutil.which('arm-linux-gnueabihf-gcc-6') and not platform.machine().startswith('arm'):
+ if should_run_linux_cross_tests():
print('Running cross compilation tests.\n')
returncode += subprocess.call([sys.executable, 'run_cross_test.py', 'cross/ubuntu-armhf.txt'])
returncode += subprocess.call([sys.executable, 'run_project_tests.py'] + sys.argv[1:])
diff --git a/run_unittests.py b/run_unittests.py
index 85474e8..e3b7c5c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1540,6 +1540,27 @@ class LinuxlikeTests(BasePlatformTests):
env['LD_LIBRARY_PATH'] = installed_libdir
self.assertEqual(subprocess.call(installed_exe, env=env), 0)
+class LinuxArmCrossCompileTests(BasePlatformTests):
+ '''
+ Tests that verify cross-compilation to Linux/ARM
+ '''
+ def setUp(self):
+ super().setUp()
+ src_root = os.path.dirname(__file__)
+ self.meson_command += ['--cross=' + os.path.join(src_root, 'cross', 'ubuntu-armhf.txt')]
+
+ def test_cflags_cross_environment_pollution(self):
+ '''
+ Test that the CFLAGS environment variable does not pollute the cross
+ environment. This can't be an ordinary test case because we need to
+ inspect the compiler database.
+ '''
+ testdir = os.path.join(self.common_test_dir, '3 static')
+ os.environ['CFLAGS'] = '-DBUILD_ENVIRONMENT_ONLY'
+ self.init(testdir)
+ compdb = self.get_compdb()
+ self.assertNotIn('-DBUILD_ENVIRONMENT_ONLY', compdb[0]['command'])
+
class RewriterTests(unittest.TestCase):
def setUp(self):
diff --git a/test cases/common/152 link depends custom target/foo.c b/test cases/common/152 link depends custom target/foo.c
new file mode 100644
index 0000000..8700a9e
--- /dev/null
+++ b/test cases/common/152 link depends custom target/foo.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main() {
+ const char *fn = DEPFILE;
+ FILE *f = fopen(fn, "r");
+ if (!f) {
+ printf("could not open %s", fn);
+ return 1;
+ }
+ else {
+ printf("successfully opened %s", fn);
+ }
+
+ return 0;
+}
diff --git a/test cases/common/152 link depends custom target/make_file.py b/test cases/common/152 link depends custom target/make_file.py
new file mode 100755
index 0000000..ceb6e19
--- /dev/null
+++ b/test cases/common/152 link depends custom target/make_file.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python3
+import sys
+
+with open(sys.argv[1], 'w') as f:
+ print('# this file does nothing', file=f)
diff --git a/test cases/common/152 link depends custom target/meson.build b/test cases/common/152 link depends custom target/meson.build
new file mode 100644
index 0000000..ee7a865
--- /dev/null
+++ b/test cases/common/152 link depends custom target/meson.build
@@ -0,0 +1,19 @@
+project('link_depends_custom_target', 'c')
+
+if meson.backend().startswith('vs')
+ # FIXME: Broken on the VS backends
+ error('MESON_SKIP_TEST see https://github.com/mesonbuild/meson/issues/1799')
+endif
+
+cmd = find_program('make_file.py')
+
+dep_file = custom_target('gen_dep',
+ command: [cmd, '@OUTPUT@'],
+ output: 'dep_file')
+
+exe = executable('foo', 'foo.c',
+ link_depends: dep_file,
+ c_args: ['-DDEPFILE="' + dep_file.full_path()+ '"'])
+
+# check that dep_file exists, which means that link_depends target ran
+test('runtest', exe)
diff --git a/test cases/windows/11 vs module defs generated custom target/meson.build b/test cases/windows/11 vs module defs generated custom target/meson.build
new file mode 100644
index 0000000..fe594c8
--- /dev/null
+++ b/test cases/windows/11 vs module defs generated custom target/meson.build
@@ -0,0 +1,10 @@
+project('generated_dll_module_defs', 'c')
+
+if meson.backend().startswith('vs')
+ # FIXME: Broken on the VS backends
+ error('MESON_SKIP_TEST see https://github.com/mesonbuild/meson/issues/1799')
+endif
+
+subdir('subdir')
+exe = executable('prog', 'prog.c', link_with : shlib)
+test('runtest', exe)
diff --git a/test cases/windows/11 vs module defs generated custom target/prog.c b/test cases/windows/11 vs module defs generated custom target/prog.c
new file mode 100644
index 0000000..f35f4a0
--- /dev/null
+++ b/test cases/windows/11 vs module defs generated custom target/prog.c
@@ -0,0 +1,5 @@
+int somedllfunc();
+
+int main(int argc, char **argv) {
+ return somedllfunc() == 42 ? 0 : 1;
+}
diff --git a/test cases/windows/11 vs module defs generated custom target/subdir/make_def.py b/test cases/windows/11 vs module defs generated custom target/subdir/make_def.py
new file mode 100755
index 0000000..50acfb5
--- /dev/null
+++ b/test cases/windows/11 vs module defs generated custom target/subdir/make_def.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+import sys
+
+with open(sys.argv[1], 'w') as f:
+ print('EXPORTS', file=f)
+ print(' somedllfunc', file=f)
diff --git a/test cases/windows/11 vs module defs generated custom target/subdir/meson.build b/test cases/windows/11 vs module defs generated custom target/subdir/meson.build
new file mode 100644
index 0000000..c4ae33a
--- /dev/null
+++ b/test cases/windows/11 vs module defs generated custom target/subdir/meson.build
@@ -0,0 +1,7 @@
+make_def = find_program('make_def.py')
+
+def_file = custom_target('gen_def',
+ command: [make_def, '@OUTPUT@'],
+ output: 'somedll.def')
+
+shlib = shared_library('somedll', 'somedll.c', vs_module_defs: def_file)
diff --git a/test cases/windows/11 vs module defs generated custom target/subdir/somedll.c b/test cases/windows/11 vs module defs generated custom target/subdir/somedll.c
new file mode 100644
index 0000000..b23d8fe
--- /dev/null
+++ b/test cases/windows/11 vs module defs generated custom target/subdir/somedll.c
@@ -0,0 +1,3 @@
+int somedllfunc() {
+ return 42;
+}