Ensure extract_rt_targets is run only once per build

This commit is contained in:
Kovid Goyal 2022-08-24 14:00:44 +05:30
parent 77fbdfbb53
commit 9e9aa52553
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 4 deletions

View File

@ -20,7 +20,7 @@ def find_page_title(text: str) -> str:
return ''
def main() -> Dict[str, str]:
def main() -> Dict[str, Dict[str, str]]:
refs = {}
docs = {}
base = os.path.dirname(os.path.abspath(__file__))

View File

@ -21,7 +21,7 @@ from functools import lru_cache, partial
from pathlib import Path
from typing import (
Callable, Dict, FrozenSet, Iterable, List, Optional, Sequence, Set, Tuple,
Union
Union, cast
)
from glfw import glfw
@ -840,9 +840,14 @@ def init_env_from_args(args: Options, native_optimizations: bool = False) -> Non
)
def build_ref_map() -> str:
@lru_cache
def extract_rst_targets() -> Dict[str, Dict[str, str]]:
m = runpy.run_path('docs/extract-rst-targets.py')
d = m['main']()
return cast(Dict[str, Dict[str, str]], m['main']())
def build_ref_map() -> str:
d = extract_rst_targets()
h = 'static const char docs_ref_map[] = {\n' + textwrap.fill(', '.join(map(str, bytearray(json.dumps(d).encode('utf-8'))))) + '\n};\n'
dest = 'kitty/docs_ref_map_generated.h'
q = ''