this repo has no description

revert k prefix naming #2

merged opened by jonaskruckenberg.de targeting main from push-mxypkzmpquky
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:wur5mmsnhlocanyqtus3oex5/sh.tangled.repo.pull/3mgottuu24v22
-154
Interdiff #0 โ†’ #1
build/defs.bzl

This file has not been changed.

lib/BUCK

This file has not been changed.

lib/_kmem/Cargo.toml

This file has not been changed.

lib/_kmem/src/address_space.rs

This file has not been changed.

lib/_kmem/src/address_space/region.rs

This file has not been changed.

lib/abort/Cargo.toml

This file has not been changed.

lib/abort/src/lib.rs

This file has not been changed.

lib/addr2line/Cargo.toml

This file has not been changed.

lib/addr2line/src/lib.rs

This file has not been changed.

lib/arrayvec/Cargo.toml

This file has not been changed.

lib/backtrace/Cargo.toml

This file has not been changed.

lib/backtrace/src/lib.rs

This file has not been changed.

lib/backtrace/src/symbolize.rs

This file has not been changed.

lib/cpu-local/Cargo.toml

This file has not been changed.

lib/cpu-local/src/collection.rs

This file has not been changed.

lib/fastrand/Cargo.toml

This file has not been changed.

lib/fdt/Cargo.toml

This file has not been changed.

lib/mem-core/Cargo.toml

This file has not been changed.

lib/mem-core/src/arch/riscv64.rs

This file has not been changed.

lib/mem-core/src/flush.rs

This file has not been changed.

lib/mem-core/src/frame_allocator/bump.rs

This file has not been changed.

lib/mem-core/src/table.rs

This file has not been changed.

lib/mem-core/src/test_utils/machine.rs

This file has not been changed.

lib/panic-unwind/Cargo.toml

This file has not been changed.

lib/panic-unwind/src/hook.rs

This file has not been changed.

lib/panic-unwind/src/lib.rs

This file has not been changed.

lib/panic-unwind/src/panic_count.rs

This file has not been changed.

lib/range-tree/benches/comparisons.rs

This file has not been changed.

lib/range-tree/tests/gaps.rs

This file has not been changed.

lib/range-tree/tests/insertion.rs

This file has not been changed.

lib/range-tree/tests/lookup.rs

This file has not been changed.

lib/range-tree/tests/proptest.rs

This file has not been changed.

lib/riscv/Cargo.toml

This file has not been changed.

lib/riscv/src/hio.rs

This file has not been changed.

lib/riscv/src/trap.rs

This file has not been changed.

lib/sharded-slab/Cargo.toml

This file has not been changed.

lib/sharded-slab/src/clear.rs

This file has not been changed.

lib/sharded-slab/src/lib.rs

This file has not been changed.

lib/sharded-slab/src/page/slot.rs

This file has not been changed.

lib/sharded-slab/src/pool.rs

This file has not been changed.

lib/sharded-slab/src/tid.rs

This file has not been changed.

lib/spin/Cargo.toml

This file has not been changed.

lib/spin/src/barrier.rs

This file has not been changed.

lib/spin/src/lazy_lock.rs

This file has not been changed.

lib/spin/src/once.rs

This file has not been changed.

lib/spin/src/once_lock.rs

This file has not been changed.

lib/test/Cargo.toml

This file has not been changed.

lib/test/macros/Cargo.toml

This file has not been changed.

lib/test/macros/src/lib.rs

This file has not been changed.

lib/test/src/lib.rs

This file has not been changed.

lib/uart-16550/Cargo.toml

This file has not been changed.

lib/uart-16550/src/lib.rs

This file has not been changed.

lib/unwind/Cargo.toml

This file has not been changed.

lib/unwind/src/eh_info.rs

This file has not been changed.

lib/unwind/src/exception.rs

This file has not been changed.

lib/unwind/src/frame.rs

This file has not been changed.

lib/unwind/src/lang_items.rs

This file has not been changed.

lib/unwind/src/lib.rs

This file has not been changed.

lib/util/Cargo.toml

This file has not been changed.

lib/wast/Cargo.toml

This file has not been changed.

lib/wast/src/gensym.rs

This file has not been changed.

lib/wavltree/benches/insertions_deletions.rs

This file has not been changed.

lib/wavltree/fuzz/fuzz_targets/inserts.rs

This file has not been changed.

lib/wavltree/fuzz/fuzz_targets/inserts_deletes.rs

This file has not been changed.

lib/wavltree/src/lib.rs

This file has not been changed.

-154
scripts/remove_k_prefix.py
··· 1 - #!/usr/bin/env python3 2 - """Remove 'k' prefix from crate names across the project.""" 3 - 4 - import os 5 - import re 6 - import sys 7 - 8 - PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 9 - 10 - # Directories to skip 11 - SKIP_DIRS = {"buck-out", "third-party", ".git", ".jj", "target", "scripts"} 12 - 13 - # File extensions/names to process 14 - EXTENSIONS = {".rs", ".toml", ".bzl", ".md"} 15 - EXACT_NAMES = {"BUCK", "TARGETS"} 16 - 17 - # Explicit mapping: old hyphenated name -> new hyphenated name 18 - # These are the Cargo.toml package names 19 - HYPHENATED_RENAMES = { 20 - "ktest-macros": "test-macros", # must come before ktest 21 - "kpanic-unwind": "panic-unwind", 22 - "ksharded-slab": "sharded-slab", 23 - "kcpu-local": "cpu-local", 24 - "kmem-core": "mem-core", 25 - "kuart-16550": "uart-16550", 26 - "kaddr2line": "addr2line", 27 - "kbacktrace": "backtrace", 28 - "karrayvec": "arrayvec", 29 - "kfastrand": "fastrand", 30 - "kabort": "abort", 31 - "kspin": "spin", 32 - "kutil": "util", 33 - "kwast": "wast", 34 - "kunwind": "unwind", 35 - "ktest": "test", 36 - "kfdt": "fdt", 37 - } 38 - 39 - # Underscore form mapping (for Rust identifiers and BUCK crate names) 40 - # Includes crates that are only k-prefixed in BUCK files 41 - UNDERSCORE_RENAMES = { 42 - "ktest_macros": "test_macros", # must come before ktest 43 - "kpanic_unwind": "panic_unwind", 44 - "ksharded_slab": "sharded_slab", 45 - "kcpu_local": "cpu_local", 46 - "kmem_core": "mem_core", 47 - "kuart_16550": "uart_16550", 48 - "kaddr2line": "addr2line", 49 - "kbacktrace": "backtrace", 50 - "karrayvec": "arrayvec", 51 - "kfastrand": "fastrand", 52 - "krange_tree": "range_tree", 53 - "kwavltree": "wavltree", 54 - "kabort": "abort", 55 - "kriscv": "riscv", 56 - "ktrap": "trap", 57 - "kspin": "spin", 58 - "kutil": "util", 59 - "kwast": "wast", 60 - "kunwind": "unwind", 61 - "ktest": "test", 62 - "kfdt": "fdt", 63 - } 64 - 65 - 66 - def to_underscore(name: str) -> str: 67 - """Convert a hyphenated crate name to underscore form.""" 68 - return name.replace("-", "_") 69 - 70 - 71 - def should_process(path: str) -> bool: 72 - """Check if a file should be processed.""" 73 - parts = path.split(os.sep) 74 - if any(skip in parts for skip in SKIP_DIRS): 75 - return False 76 - basename = os.path.basename(path) 77 - if basename in EXACT_NAMES: 78 - return True 79 - _, ext = os.path.splitext(basename) 80 - return ext in EXTENSIONS 81 - 82 - 83 - def apply_replacements(content: str, filepath: str) -> str: 84 - """Apply all replacements to file content.""" 85 - original = content 86 - basename = os.path.basename(filepath) 87 - _, ext = os.path.splitext(filepath) 88 - is_toml = ext == ".toml" 89 - is_rust = ext == ".rs" 90 - is_buck = basename in ("BUCK", "TARGETS") or ext == ".bzl" 91 - is_md = ext == ".md" 92 - 93 - if is_toml: 94 - # In TOML files, replace both hyphenated forms (package names, dep keys) 95 - # and underscore forms (feature references etc.) 96 - # Sort by length descending to avoid partial matches 97 - for old, new in sorted(HYPHENATED_RENAMES.items(), key=lambda x: -len(x[0])): 98 - content = content.replace(old, new) 99 - 100 - if is_rust or is_md: 101 - # In Rust/markdown files, replace underscore forms used as identifiers 102 - # Use word-boundary-aware replacement to avoid partial matches 103 - for old, new in sorted(UNDERSCORE_RENAMES.items(), key=lambda x: -len(x[0])): 104 - content = re.sub(r"\b" + re.escape(old) + r"\b", new, content) 105 - 106 - if is_buck: 107 - # In BUCK files, replace underscore forms in crate = "..." fields 108 - for old, new in sorted(UNDERSCORE_RENAMES.items(), key=lambda x: -len(x[0])): 109 - content = re.sub(r"\b" + re.escape(old) + r"\b", new, content) 110 - 111 - if content != original: 112 - return content 113 - return None 114 - 115 - 116 - def main(): 117 - changed_files = [] 118 - dry_run = "--dry-run" in sys.argv 119 - 120 - for dirpath, dirnames, filenames in os.walk(PROJECT_ROOT): 121 - # Prune skipped directories 122 - dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS] 123 - 124 - for filename in filenames: 125 - filepath = os.path.join(dirpath, filename) 126 - if not should_process(filepath): 127 - continue 128 - 129 - try: 130 - with open(filepath, "r", encoding="utf-8") as f: 131 - content = f.read() 132 - except (UnicodeDecodeError, PermissionError): 133 - continue 134 - 135 - new_content = apply_replacements(content, filepath) 136 - if new_content is not None: 137 - rel_path = os.path.relpath(filepath, PROJECT_ROOT) 138 - changed_files.append(rel_path) 139 - if not dry_run: 140 - with open(filepath, "w", encoding="utf-8") as f: 141 - f.write(new_content) 142 - 143 - # Print summary 144 - mode = "Would change" if dry_run else "Changed" 145 - print(f"\n{mode} {len(changed_files)} files:") 146 - for f in sorted(changed_files): 147 - print(f" {f}") 148 - 149 - if dry_run: 150 - print("\nRun without --dry-run to apply changes.") 151 - 152 - 153 - if __name__ == "__main__": 154 - main()
sys/async/Cargo.toml

This file has not been changed.

sys/async/src/executor.rs

This file has not been changed.

sys/async/src/sync/wait_cell.rs

This file has not been changed.

sys/async/src/sync/wait_queue.rs

This file has not been changed.

sys/async/src/sync/wake_batch.rs

This file has not been changed.

sys/async/src/task.rs

This file has not been changed.

sys/async/src/task/state.rs

This file has not been changed.

sys/async/src/test_util.rs

This file has not been changed.

sys/async/src/time/sleep.rs

This file has not been changed.

sys/async/src/time/timer.rs

This file has not been changed.

sys/async/src/time/timer/entry.rs

This file has not been changed.

sys/kernel/main.rs

This file has not been changed.

History

3 rounds 2 comments
sign up or login to add to the discussion
1 commit
expand
revert k prefix naming
expand 0 comments
pull request successfully merged
1 commit
expand
revert k prefix naming
expand 2 comments

the ktest renaming might become problematic in the future ๐Ÿค” but I guess we'll need to rebuild the testing infra anyways

lets revert this for now though

1 commit
expand
revert k prefix naming
expand 0 comments