Use a define rather than a generated file for wrapped kittens
This commit is contained in:
parent
00223c5bba
commit
5eb2142d70
@ -216,21 +216,14 @@ get_docs_ref_map(PyObject *self UNUSED, PyObject *args UNUSED) {
|
|||||||
return PyBytes_FromStringAndSize(docs_ref_map, sizeof(docs_ref_map));
|
return PyBytes_FromStringAndSize(docs_ref_map, sizeof(docs_ref_map));
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "wrapped_kitten_names_generated.h"
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
wrapped_kittens(PyObject *self UNUSED, PyObject *args UNUSED) {
|
wrapped_kittens(PyObject *self UNUSED, PyObject *args UNUSED) {
|
||||||
PyObject *ans = PyFrozenSet_New(NULL);
|
const char *wrapped_kitten_names = WRAPPED_KITTENS;
|
||||||
if (ans != NULL) {
|
PyObject *ans = PyUnicode_FromString(wrapped_kitten_names);
|
||||||
for (int i = 0; wrapped_kitten_names[i] != NULL; i++) {
|
if (ans == NULL) return NULL;
|
||||||
PyObject *n = PyUnicode_FromString(wrapped_kitten_names[i]);
|
PyObject *s = PyUnicode_Split(ans, NULL, -1);
|
||||||
if (n == NULL) break;
|
Py_DECREF(ans);
|
||||||
if (PySet_Add(ans, n) != 0) { Py_DECREF(n); break; }
|
return s;
|
||||||
Py_DECREF(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (PyErr_Occurred()) { Py_CLEAR(ans); }
|
|
||||||
return ans;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import termios
|
import termios
|
||||||
from ctypes import Array, c_ubyte
|
from ctypes import Array, c_ubyte
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, FrozenSet, Iterator, List, NewType, Optional, Tuple, TypedDict,
|
Any, Callable, Dict, Iterator, List, NewType, Optional, Tuple, TypedDict, Union,
|
||||||
Union,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from kitty.boss import Boss
|
from kitty.boss import Boss
|
||||||
@ -1493,5 +1492,5 @@ def get_clipboard_mime(ct: int, mime: Optional[str], callback: Callable[[bytes],
|
|||||||
def run_with_activation_token(func: Callable[[str], None]) -> None: ...
|
def run_with_activation_token(func: Callable[[str], None]) -> None: ...
|
||||||
def make_x11_window_a_dock_window(x11_window_id: int, strut: Tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> None: ...
|
def make_x11_window_a_dock_window(x11_window_id: int, strut: Tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> None: ...
|
||||||
def unicode_database_version() -> Tuple[int, int, int]: ...
|
def unicode_database_version() -> Tuple[int, int, int]: ...
|
||||||
def wrapped_kittens() -> FrozenSet[str]: ...
|
def wrapped_kittens() -> List[str]: ...
|
||||||
def expand_ansi_c_escapes(test: str) -> str: ...
|
def expand_ansi_c_escapes(test: str) -> str: ...
|
||||||
|
|||||||
24
setup.py
24
setup.py
@ -529,10 +529,12 @@ def get_source_specific_defines(env: Env, src: str) -> Tuple[str, Optional[List[
|
|||||||
if src == 'kitty/parser_dump.c':
|
if src == 'kitty/parser_dump.c':
|
||||||
return 'kitty/parser.c', ['DUMP_COMMANDS']
|
return 'kitty/parser.c', ['DUMP_COMMANDS']
|
||||||
if src == 'kitty/data-types.c':
|
if src == 'kitty/data-types.c':
|
||||||
return src, [f'KITTY_VCS_REV="{get_vcs_rev_define()}"']
|
wk = ' '.join(wrapped_kittens())
|
||||||
with suppress(KeyError):
|
return src, [f'KITTY_VCS_REV="{get_vcs_rev_define()}"', f'WRAPPED_KITTENS="{wk}"']
|
||||||
|
try:
|
||||||
return src, env.library_paths[src]
|
return src, env.library_paths[src]
|
||||||
return src, None
|
except KeyError:
|
||||||
|
return src, None
|
||||||
|
|
||||||
|
|
||||||
def newer(dest: str, *sources: str) -> bool:
|
def newer(dest: str, *sources: str) -> bool:
|
||||||
@ -870,27 +872,11 @@ def wrapped_kittens() -> Sequence[str]:
|
|||||||
raise Exception('Failed to read wrapped kittens from kitty wrapper script')
|
raise Exception('Failed to read wrapped kittens from kitty wrapper script')
|
||||||
|
|
||||||
|
|
||||||
def build_wrapped_kittens() -> str:
|
|
||||||
h = 'static const char* wrapped_kitten_names[] = {\n'
|
|
||||||
h += ', '.join(f'"{x}"' for x in wrapped_kittens())
|
|
||||||
h += ', NULL'
|
|
||||||
h += '\n};\n'
|
|
||||||
dest = 'kitty/wrapped_kitten_names_generated.h'
|
|
||||||
q = ''
|
|
||||||
with suppress(FileNotFoundError), open(dest) as f:
|
|
||||||
q = f.read()
|
|
||||||
if q != h:
|
|
||||||
with open(dest, 'w') as f:
|
|
||||||
f.write(h)
|
|
||||||
return dest
|
|
||||||
|
|
||||||
|
|
||||||
def build(args: Options, native_optimizations: bool = True, call_init: bool = True) -> None:
|
def build(args: Options, native_optimizations: bool = True, call_init: bool = True) -> None:
|
||||||
if call_init:
|
if call_init:
|
||||||
init_env_from_args(args, native_optimizations)
|
init_env_from_args(args, native_optimizations)
|
||||||
sources, headers = find_c_files()
|
sources, headers = find_c_files()
|
||||||
headers.append(build_ref_map())
|
headers.append(build_ref_map())
|
||||||
headers.append(build_wrapped_kittens())
|
|
||||||
compile_c_extension(
|
compile_c_extension(
|
||||||
kitty_env(), 'kitty/fast_data_types', args.compilation_database, sources, headers
|
kitty_env(), 'kitty/fast_data_types', args.compilation_database, sources, headers
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user