aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/snippets/swift-module-name.md9
-rw-r--r--docs/yaml/functions/configure_file.yaml2
-rw-r--r--docs/yaml/functions/custom_target.yaml2
-rw-r--r--docs/yaml/functions/install_data.yaml3
-rw-r--r--docs/yaml/functions/install_headers.yaml4
-rw-r--r--mesonbuild/backend/ninjabackend.py7
-rw-r--r--mesonbuild/build.py8
-rw-r--r--mesonbuild/compilers/mixins/clike.py17
-rw-r--r--mesonbuild/interpreter/kwargs.py1
-rw-r--r--mesonbuild/interpreter/type_checking.py1
-rw-r--r--test cases/common/104 has arg/meson.build19
11 files changed, 60 insertions, 13 deletions
diff --git a/docs/markdown/snippets/swift-module-name.md b/docs/markdown/snippets/swift-module-name.md
new file mode 100644
index 0000000..689dd84
--- /dev/null
+++ b/docs/markdown/snippets/swift-module-name.md
@@ -0,0 +1,9 @@
+## Explicitly setting Swift module name is now supported
+
+It is now possible to set the Swift module name for a target via the
+*swift_module_name* target kwarg, overriding the default inferred from the
+target name.
+
+```meson
+lib = library('foo', 'foo.swift', swift_module_name: 'Foo')
+```
diff --git a/docs/yaml/functions/configure_file.yaml b/docs/yaml/functions/configure_file.yaml
index 943ad22..2deeff4 100644
--- a/docs/yaml/functions/configure_file.yaml
+++ b/docs/yaml/functions/configure_file.yaml
@@ -16,6 +16,8 @@ description: |
it takes any source or configured file as the `input:` and assumes
that the `output:` is produced when the specified command is run.
+ You can install the outputted file with the `install_dir:` kwarg, see below.
+
*(since 0.47.0)* When the `copy:` keyword argument is set to `true`,
this function will copy the file provided in `input:` to a file in the
build directory with the name `output:` in the current directory.
diff --git a/docs/yaml/functions/custom_target.yaml b/docs/yaml/functions/custom_target.yaml
index 4920407..094787b 100644
--- a/docs/yaml/functions/custom_target.yaml
+++ b/docs/yaml/functions/custom_target.yaml
@@ -12,6 +12,8 @@ description: |
custom_target('foo', output: 'file.txt', ...)
```
+ You can install the outputted files with the `install_dir:` kwarg, see below.
+
*Since 0.60.0* the name argument is optional and defaults to the basename of the first
output (`file.txt` in the example above).
diff --git a/docs/yaml/functions/install_data.yaml b/docs/yaml/functions/install_data.yaml
index fdedf7e..b9aedca 100644
--- a/docs/yaml/functions/install_data.yaml
+++ b/docs/yaml/functions/install_data.yaml
@@ -2,6 +2,9 @@ name: install_data
returns: void
description: |
Installs files from the source tree that are listed as positional arguments.
+ Please note that this can only install static files from the source tree.
+ Generated files are installed via the `install_dir:` kwarg on the respective
+ generators, such as `custom_target()` or `configure_file().
See [Installing](Installing.md) for more examples.
diff --git a/docs/yaml/functions/install_headers.yaml b/docs/yaml/functions/install_headers.yaml
index da304bc..42f6462 100644
--- a/docs/yaml/functions/install_headers.yaml
+++ b/docs/yaml/functions/install_headers.yaml
@@ -9,6 +9,10 @@ description: |
argument. As an example if this has the value `myproj` then the
headers would be installed to `/{prefix}/include/myproj`.
+ Please note that this can only install static files from the source tree.
+ Generated files are installed via the `install_dir:` kwarg on the respective
+ generators, such as `custom_target()` or `configure_file().
+
example: |
For example, this will install `common.h` and `kola.h` into
`/{prefix}/include`:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 82411b0..eebdd05 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2232,10 +2232,7 @@ class NinjaBackend(backends.Backend):
def swift_module_file_name(self, target):
return os.path.join(self.get_target_private_dir(target),
- self.target_swift_modulename(target) + '.swiftmodule')
-
- def target_swift_modulename(self, target):
- return target.name
+ target.swift_module_name + '.swiftmodule')
def determine_swift_dep_modules(self, target):
result = []
@@ -2262,7 +2259,7 @@ class NinjaBackend(backends.Backend):
return srcs, others
def generate_swift_target(self, target) -> None:
- module_name = self.target_swift_modulename(target)
+ module_name = target.swift_module_name
swiftc = target.compilers['swift']
abssrc = []
relsrc = []
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index fa8d214..1745b9e 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -75,6 +75,7 @@ lang_arg_kwargs |= {
vala_kwargs = {'vala_header', 'vala_gir', 'vala_vapi'}
rust_kwargs = {'rust_crate_type', 'rust_dependency_map'}
cs_kwargs = {'resources', 'cs_args'}
+swift_kwargs = {'swift_module_name'}
buildtarget_kwargs = {
'build_by_default',
@@ -110,7 +111,8 @@ known_build_target_kwargs = (
pch_kwargs |
vala_kwargs |
rust_kwargs |
- cs_kwargs)
+ cs_kwargs |
+ swift_kwargs)
known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic', 'pie', 'vs_module_defs', 'android_exe_type'}
known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs', 'darwin_versions', 'rust_abi'}
@@ -1260,6 +1262,10 @@ class BuildTarget(Target):
raise InvalidArguments(f'Invalid rust_dependency_map "{rust_dependency_map}": must be a dictionary with string values.')
self.rust_dependency_map = rust_dependency_map
+ self.swift_module_name = kwargs.get('swift_module_name')
+ if self.swift_module_name == '':
+ self.swift_module_name = self.name
+
def _extract_pic_pie(self, kwargs: T.Dict[str, T.Any], arg: str, option: str) -> bool:
# Check if we have -fPIC, -fpic, -fPIE, or -fpie in cflags
all_flags = self.extra_args['c'] + self.extra_args['cpp']
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 1c875a3..e2daaa1 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -1272,12 +1272,21 @@ class CLikeCompiler(Compiler):
# check the equivalent enable flag too "-Wforgotten-towel".
if arg.startswith('-Wno-'):
# Make an exception for -Wno-attributes=x as -Wattributes=x is invalid
- # for GCC at least. Also, the opposite of -Wno-vla-larger-than is
- # -Wvla-larger-than=N
+ # for GCC at least. Also, the positive form of some flags require a
+ # value to be specified, i.e. we need to pass -Wfoo=N rather than just
+ # -Wfoo.
if arg.startswith('-Wno-attributes='):
pass
- elif arg == '-Wno-vla-larger-than':
- new_args.append('-Wvla-larger-than=1000')
+ elif arg in {
+ '-Wno-alloc-size-larger-than',
+ '-Wno-alloca-larger-than',
+ '-Wno-frame-larger-than',
+ '-Wno-stack-usage',
+ '-Wno-vla-larger-than',
+ }:
+ # Pass an arbitrary value to the enabling flag; since the test program
+ # is trivial, it is unlikely to provoke any of these warnings.
+ new_args.append('-W' + arg[5:] + '=1000')
else:
new_args.append('-W' + arg[5:])
if arg.startswith('-Wl,'):
diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py
index d741aab..62d855d 100644
--- a/mesonbuild/interpreter/kwargs.py
+++ b/mesonbuild/interpreter/kwargs.py
@@ -363,6 +363,7 @@ class _BuildTarget(_BaseBuildTarget):
d_module_versions: T.List[T.Union[str, int]]
d_unittest: bool
rust_dependency_map: T.Dict[str, str]
+ swift_module_name: str
sources: SourcesVarargsType
c_args: T.List[str]
cpp_args: T.List[str]
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index fbe3e3e..a94e26b 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -633,6 +633,7 @@ _BUILD_TARGET_KWS: T.List[KwargInfo] = [
default={},
since='1.2.0',
),
+ KwargInfo('swift_module_name', str, default='', since='1.9.0'),
KwargInfo('build_rpath', str, default='', since='0.42.0'),
KwargInfo(
'gnu_symbol_visibility',
diff --git a/test cases/common/104 has arg/meson.build b/test cases/common/104 has arg/meson.build
index 466bed9..500b8a9 100644
--- a/test cases/common/104 has arg/meson.build
+++ b/test cases/common/104 has arg/meson.build
@@ -56,9 +56,22 @@ if cpp.get_id() == 'gcc' and cpp.version().version_compare('>=12.1.0')
# Handle special -Wno-attributes=foo where -Wattributes=foo is invalid
# i.e. our usual -Wno-foo -Wfoo hack doesn't work for -Wattributes=foo.
assert(cpp.has_argument('-Wno-attributes=meson::i_do_not_exist'))
- # Likewise, the positive counterpart to -Wno-vla-larger-than is
- # -Wvla-larger-than=N
- assert(cpp.has_argument('-Wno-vla-larger-than'))
+endif
+
+if cpp.get_id() == 'gcc'
+ # Handle negative flags whose positive counterparts require a value to be
+ # specified.
+ if cpp.version().version_compare('>=4.4.0')
+ assert(cpp.has_argument('-Wno-frame-larger-than'))
+ endif
+ if cpp.version().version_compare('>=4.7.0')
+ assert(cpp.has_argument('-Wno-stack-usage'))
+ endif
+ if cpp.version().version_compare('>=7.1.0')
+ assert(cpp.has_argument('-Wno-alloc-size-larger-than'))
+ assert(cpp.has_argument('-Wno-alloca-larger-than'))
+ assert(cpp.has_argument('-Wno-vla-larger-than'))
+ endif
endif
if cc.get_id() == 'clang' and cc.version().version_compare('<=4.0.0')