Get a predefined cache configuration by name. Args: name: Cache name (e.g., "cpp_lint", "python_test", "examples") cache_dir: Base cache directory (defaults to .cache/) build_mode: Build mode string ("quick", "debug", "release") Returns: CacheConfig ins
(
name: str,
cache_dir: Optional[Path] = None,
build_mode: Optional[str] = None,
)
| 103 | |
| 104 | |
| 105 | def get_cache_config( |
| 106 | name: str, |
| 107 | cache_dir: Optional[Path] = None, |
| 108 | build_mode: Optional[str] = None, |
| 109 | ) -> CacheConfig: |
| 110 | """ |
| 111 | Get a predefined cache configuration by name. |
| 112 | |
| 113 | Args: |
| 114 | name: Cache name (e.g., "cpp_lint", "python_test", "examples") |
| 115 | cache_dir: Base cache directory (defaults to .cache/) |
| 116 | build_mode: Build mode string ("quick", "debug", "release") |
| 117 | |
| 118 | Returns: |
| 119 | CacheConfig instance for the specified cache |
| 120 | |
| 121 | Raises: |
| 122 | ValueError: If cache name is unknown |
| 123 | """ |
| 124 | if cache_dir is None: |
| 125 | cache_dir = Path(".cache") |
| 126 | |
| 127 | # Parse build mode if provided |
| 128 | build_mode_enum: Optional[BuildMode] = None |
| 129 | if build_mode is not None: |
| 130 | try: |
| 131 | build_mode_enum = BuildMode(build_mode.lower()) |
| 132 | except ValueError: |
| 133 | raise ValueError( |
| 134 | f"Unknown build mode: {build_mode}. " |
| 135 | f"Valid modes: {[m.value for m in BuildMode]}" |
| 136 | ) |
| 137 | |
| 138 | # Predefined configurations |
| 139 | configs = { |
| 140 | # Linting caches (two-layer recommended for fast iteration) |
| 141 | "cpp_lint": CacheConfig( |
| 142 | name="cpp_lint", |
| 143 | cache_type=CacheType.TWO_LAYER, |
| 144 | cache_dir=cache_dir, |
| 145 | description="C++ source file linting (clang-format + custom linters)", |
| 146 | ), |
| 147 | "python_lint": CacheConfig( |
| 148 | name="python_lint", |
| 149 | cache_type=CacheType.TWO_LAYER, |
| 150 | cache_dir=cache_dir, |
| 151 | description="Python source file linting (pyright type checking)", |
| 152 | ), |
| 153 | "js_lint": CacheConfig( |
| 154 | name="js_lint", |
| 155 | cache_type=CacheType.TWO_LAYER, |
| 156 | cache_dir=cache_dir, |
| 157 | description="JavaScript/TypeScript linting", |
| 158 | ), |
| 159 | # Test caches (support build modes) |
| 160 | "cpp_test": CacheConfig( |
| 161 | name="cpp_test", |
| 162 | cache_type=CacheType.HASH, |
nothing calls this directly
no test coverage detected