diff options
-rw-r--r-- | docs/markdown/Release-notes-for-0.41.0.md | 3 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 1 | ||||
-rw-r--r-- | mesonbuild/build.py | 5 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 8 | ||||
-rw-r--r-- | test cases/rust/1 basic/meson.build | 5 |
5 files changed, 17 insertions, 5 deletions
diff --git a/docs/markdown/Release-notes-for-0.41.0.md b/docs/markdown/Release-notes-for-0.41.0.md index c93fee8..a96ded0 100644 --- a/docs/markdown/Release-notes-for-0.41.0.md +++ b/docs/markdown/Release-notes-for-0.41.0.md @@ -53,3 +53,6 @@ other build systems. Currently this only works for projects using Git and only with the Ninja backend. +## Support for passing arguments to Rust compiler + +Targets for building rust now take a `rust_args` keyword. diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index cad5096..4885f4b 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1150,6 +1150,7 @@ int dummy; args += rustc.get_buildtype_args(self.get_option_for_target('buildtype', target)) depfile = os.path.join(target.subdir, target.name + '.d') args += ['--emit', 'dep-info={}'.format(depfile), '--emit', 'link'] + args += target.get_extra_args('rust') args += ['-o', os.path.join(target.subdir, target.get_filename())] orderdeps = [os.path.join(t.subdir, t.get_filename()) for t in target.link_targets] linkdirs = OrderedDict() diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c2d4583..ce6405b 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -34,6 +34,7 @@ known_basic_kwargs = {'install': True, 'fortran_args': True, 'd_args': True, 'java_args': True, + 'rust_args': True, 'link_args': True, 'link_depends': True, 'link_with': True, @@ -632,6 +633,10 @@ class BuildTarget(Target): if not isinstance(fortranlist, list): fortranlist = [fortranlist] self.add_compiler_args('fortran', fortranlist) + rustlist = kwargs.get('rust_args', []) + if not isinstance(rustlist, list): + rustlist = [rustlist] + self.add_compiler_args('rust', rustlist) if not isinstance(self, Executable): self.vala_header = kwargs.get('vala_header', self.name + '.h') self.vala_vapi = kwargs.get('vala_vapi', self.name + '.vapi') diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index c30e8fb..199bbab 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -146,10 +146,10 @@ java_buildtype_args = {'plain': [], } rust_buildtype_args = {'plain': [], - 'debug': ['-g'], - 'debugoptimized': ['-g', '--opt-level', '2'], - 'release': ['--opt-level', '3'], - 'minsize': [], + 'debug': ['-C', 'debuginfo=2'], + 'debugoptimized': ['-C', 'debuginfo=2', '-C', 'opt-level=2'], + 'release': ['-C', 'opt-level=3'], + 'minsize': [], # In a future release: ['-C', 'opt-level=s'], } d_gdc_buildtype_args = {'plain': [], diff --git a/test cases/rust/1 basic/meson.build b/test cases/rust/1 basic/meson.build index 076d86b..3919279 100644 --- a/test cases/rust/1 basic/meson.build +++ b/test cases/rust/1 basic/meson.build @@ -1,6 +1,9 @@ project('rustprog', 'rust') -e = executable('program', 'prog.rs', install : true) +e = executable('program', 'prog.rs', + rust_args : ['-C', 'lto'], # Just a test + install : true +) test('rusttest', e) subdir('subdir') |