Add more type annotations

This commit is contained in:
Kovid Goyal
2021-10-27 08:45:45 +05:30
parent 4494ddd8ff
commit 9c2f96f7eb
4 changed files with 36 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ import json
import os
import re
import sys
from typing import Callable, Dict, List, Optional, Tuple
from typing import Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple
_plat = sys.platform.lower()
is_linux = 'linux' in _plat
@@ -14,6 +14,21 @@ is_openbsd = 'openbsd' in _plat
base = os.path.dirname(os.path.abspath(__file__))
class CompileKey(NamedTuple):
src: str
dest: str
class Command(NamedTuple):
desc: str
cmd: Sequence[str]
is_newer_func: Callable[[], bool]
on_success: Callable[[], None]
key: Optional[CompileKey]
keyfile: Optional[str]
class Env:
cc: List[str] = []
@@ -56,7 +71,14 @@ def wayland_protocol_file_name(base: str, ext: str = 'c') -> str:
return 'wayland-{}-client-protocol.{}'.format(base, ext)
def init_env(env: Env, pkg_config: Callable, pkg_version: Callable, at_least_version: Callable, test_compile: Callable, module: str = 'x11') -> Env:
def init_env(
env: Env,
pkg_config: Callable[..., List[str]],
pkg_version: Callable[[str], Tuple[int, int]],
at_least_version: Callable[..., None],
test_compile: Callable[..., bool],
module: str = 'x11'
) -> Env:
ans = env.copy()
ans.cflags.append('-fPIC')
ans.cppflags.append('-D_GLFW_' + module.upper())