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 all commits
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_features(self, features: List[str]):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think add implies that the features will be appended, here they are substituted, so I would use set_features

self.features = features

Comment on lines +42 to +44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we even need this method

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that ?


@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