Skip to content
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

Add support to add features during cargo build #31

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
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
12 changes: 11 additions & 1 deletion rust_build_utils/rust_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import shutil
import importlib
from typing import Any, Dict, List, Optional, Tuple
from dataclasses import dataclass
from dataclasses import dataclass, field
from rust_build_utils.rust_utils_config import GLOBAL_CONFIG
from pathlib import Path
from rust_build_utils.msvc import activate_msvc, deactivate_msvc, is_msvc_active
Expand All @@ -26,6 +26,7 @@ class CargoConfig:
arch: str
debug: bool
rust_target: str = ""
features: list = field(default_factory=list)

def __post_init__(self):
if self.arch == "arm64":
Expand All @@ -38,6 +39,9 @@ def __post_init__(self):
def is_msvc(self):
return self.rust_target.endswith("-msvc")

def add_feature(self, features: List[str]):
lcruz99 marked this conversation as resolved.
Show resolved Hide resolved
self.features = features


@dataclass
class Project:
Expand Down Expand Up @@ -324,6 +328,12 @@ def _build_packages(
for p in packages:
args.append("--package")
args.append(p)

if config.features:
args.append("--features")
for f in config.features:
args.append(f)

args.extend(extra_args or [])

run_command(args)
Expand Down
Loading