Skip to content

Rust module : Add support for cargo subprojects #8514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
86f8864
interpreter: Annotate Interpreter.subprojects
dcbaker Oct 29, 2020
2295e3d
Add a nodebuilder module
dcbaker Oct 29, 2020
1d788ed
wrap: handle cargo wraps
dcbaker Oct 29, 2020
8f992be
optinterpreter: Add support for using ast without a file
dcbaker Oct 29, 2020
e0e3d1e
cargo: Add a cargo manifest parser
dcbaker Oct 29, 2020
b7bb185
modules/rust: Add a subproject interface
dcbaker Oct 29, 2020
82aa33c
modules/rust: add cargo tests
dcbaker Oct 29, 2020
9d9edc4
interpreter: add support for cargo subprojects
dcbaker Oct 29, 2020
7dcfd19
fixup! cargo: Add a cargo manifest parser
dcbaker Jan 21, 2021
d3cdc15
mparser: Use an EmptyNode instead of None, which is invalid
dcbaker Jan 21, 2021
bc87c06
wip: split me
dcbaker Oct 30, 2020
2abebfd
remove override_dependency, which seems to break
dcbaker Feb 11, 2021
d91e47d
i screwed up on crate-types...
dcbaker Feb 12, 2021
3380620
cargo: update todos
dcbaker Mar 11, 2021
c197e7a
cargo: add a test for the `link` option
dcbaker Mar 11, 2021
8a88e9c
cargo: add support for [package]:links
dcbaker Mar 11, 2021
674c0ad
cargo: add a test for proc-macro crates
dcbaker Mar 11, 2021
4a2fdcf
build: Add proc-macro type for rust crates
dcbaker Apr 21, 2021
ce864e2
cargo: Add proc-macro support
dcbaker Apr 21, 2021
fc7e05e
pytests: add some tests for the cfg_builder
dcbaker Apr 21, 2021
2ed446a
cargo: remove unused imports
dcbaker Apr 21, 2021
c502b3b
cargo/cfg_parser: fix mypy warnings
dcbaker May 21, 2021
17f862b
cargo: more mypy fixes
dcbaker May 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Cargo to meson.build:
- Completed:
- dependencies
- binaries
- libraries
- proc-macro
- features
- target cfg() paring

- TODO:
- links
- targets
- no support for the triple style
- tests being triggered when they shouldn't?
- build-dependencies
- example
- bench
- profile
- patch
- test for default_options being set correctly
- binaries:
- test for auto bin and manual bin collision
- targets required features
- doctest?
- bench
- libraries
- targets required features
- doctest?
- bench
- Add test for invalid feature names
- extend test 15 to cover test, exampeles, and benches
- is the use of a disabler() for dev-dependencies smart?

Wrap
- TODO:
- workspaces
- fetching crates
- generating .wraps from crates

Overall:
- Figure out what to do about multiple versions of the same crate
- Add a mechanism to test.json to verify that the correct tests are being run
- Come up with a better solution for subprojects affecting each-others options
10 changes: 5 additions & 5 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1796,8 +1796,8 @@ def __init__(self, name, subdir, subproject, for_machine: MachineChoice, sources
mlog.debug('Defaulting Rust static library target crate type to rlib')
self.rust_crate_type = 'rlib'
# Don't let configuration proceed with a non-static crate type
elif self.rust_crate_type not in ['rlib', 'staticlib']:
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for static libraries; must be "rlib" or "staticlib"')
elif self.rust_crate_type not in ['rlib', 'staticlib', 'proc-macro']:
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for static libraries; must be "rlib", "staticlib", or "proc-macro"')
# By default a static library is named libfoo.a even on Windows because
# MSVC does not have a consistent convention for what static libraries
# are called. The MSVC CRT uses libfoo.lib syntax but nothing else uses
Expand All @@ -1809,7 +1809,7 @@ def __init__(self, name, subdir, subproject, for_machine: MachineChoice, sources
self.prefix = 'lib'
if not hasattr(self, 'suffix'):
if 'rust' in self.compilers:
if not hasattr(self, 'rust_crate_type') or self.rust_crate_type == 'rlib':
if not hasattr(self, 'rust_crate_type') or self.rust_crate_type in {'rlib', 'proc-macro'}:
# default Rust static library suffix
self.suffix = 'rlib'
elif self.rust_crate_type == 'staticlib':
Expand Down Expand Up @@ -1868,8 +1868,8 @@ def __init__(self, name, subdir, subproject, for_machine: MachineChoice, sources
mlog.debug('Defaulting Rust dynamic library target crate type to "dylib"')
self.rust_crate_type = 'dylib'
# Don't let configuration proceed with a non-dynamic crate type
elif self.rust_crate_type not in ['dylib', 'cdylib']:
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for dynamic libraries; must be "dylib" or "cdylib"')
elif self.rust_crate_type not in ['dylib', 'cdylib', 'proc-macro']:
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for dynamic libraries; must be "dylib", "cdylib", or "proc-macro"')
if not hasattr(self, 'prefix'):
self.prefix = None
if not hasattr(self, 'suffix'):
Expand Down
28 changes: 28 additions & 0 deletions mesonbuild/cargo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-license-identifier: Apache-2.0
# Copyright © 2020-2021 Intel Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__all__ = [
'HAS_TOML',
'ManifestInterpreter',
]

try:
import toml
del toml # so toml isn't exposed
HAS_TOML = True
except ImportError:
HAS_TOML = False
else:
from .cargo import ManifestInterpreter
Loading