Skip to content

Commit 0a454dc

Browse files
committed
Fix _related_source_files for examples
1 parent 068c87e commit 0a454dc

File tree

1 file changed

+6
-2
lines changed
  • onlinejudge_verify/languages

1 file changed

+6
-2
lines changed

onlinejudge_verify/languages/rust.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def _related_source_files(basedir: pathlib.Path, metadata: Dict[str, Any]) -> Di
169169
# - https://github.com/rust-lang/cargo/blob/rust-1.49.0/src/cargo/core/compiler/fingerprint.rs#L1979-L1997
170170
# - https://github.com/rust-lang/cargo/blob/rust-1.49.0/src/cargo/core/compiler/fingerprint.rs#L1824-L1830
171171
dep_info_paths = sorted(
172-
pathlib.Path(metadata['target_directory'], 'debug', 'deps').glob(f'{target["name"].replace("-", "_")}-*.d'),
172+
pathlib.Path(metadata['target_directory'], 'debug', 'examples' if _is_example(target) else 'deps').glob(f'{target["name"].replace("-", "_")}-*.d'),
173173
key=lambda p: p.stat().st_mtime_ns,
174174
reverse=True,
175175
)
@@ -362,8 +362,12 @@ def _is_bin(target: Dict[str, Any]) -> bool:
362362
return target['kind'] == ['bin']
363363

364364

365+
def _is_example(target: Dict[str, Any]) -> bool:
366+
return target['kind'] == ['example']
367+
368+
365369
def _is_bin_or_example_bin(target: Dict[str, Any]) -> bool:
366-
return _is_bin(target) or target['kind'] == ['example'] and target['crate_types'] == ['bin']
370+
return _is_bin(target) or _is_example(target) and target['crate_types'] == ['bin']
367371

368372

369373
def _need_dev_deps(target: Dict[str, Any]) -> bool:

0 commit comments

Comments
 (0)