Finish move of prewarm launcher into its own compilation unit

This commit is contained in:
Kovid Goyal 2022-07-05 19:18:36 +05:30
parent 4195c239c8
commit 09ddbbf600
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 15 additions and 11 deletions

View File

@ -5,8 +5,6 @@
* Distributed under terms of the GPL3 license.
*/
#include "prewarm-launcher.h"
#include <libgen.h>
#ifdef __APPLE__
#include <mach-o/dyld.h>
@ -15,6 +13,8 @@
#else
#include <limits.h>
#endif
#include <stdbool.h>
#include <stdint.h>
#include <wchar.h>
#include <Python.h>
@ -268,6 +268,8 @@ read_exe_path(char *exe, size_t buf_sz) {
}
#endif // }}}
extern void use_prewarmed_process(int argc, char *argv[]);
int main(int argc, char *argv[]) {
if (argc < 1 || !argv) { fprintf(stderr, "Invalid argc/argv\n"); return 1; }
use_prewarmed_process(argc, argv);

View File

@ -4,8 +4,6 @@
* Distributed under terms of the GPL3 license.
*/
#pragma once
// for SA_RESTART
#define _XOPEN_SOURCE 700
// for cfmakeraw
@ -510,7 +508,7 @@ check_socket_addr(char *addr) {
return p + 1;
}
static void
void
use_prewarmed_process(int argc, char *argv[]) {
char *env_addr = getenv("KITTY_PREWARM_SOCKET");
if (!env_addr || !*env_addr || !is_prewarmable(argc, argv)) return;

View File

@ -864,13 +864,17 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
# RUNPATH locations for transitive dependencies, unlike RPATH.
ldflags += ['-Wl,--disable-new-dtags', '-Wl,-rpath,$ORIGIN/../lib']
os.makedirs(launcher_dir, exist_ok=True)
objects = []
for src in ('launcher.c', 'prewarm-launcher.c'):
obj = os.path.join(build_dir, src.replace('.c', '.o'))
objects.append(obj)
cmd = env.cc + cppflags + cflags + ['-c', src, '-o', obj]
key = CompileKey('launcher.c', os.path.basename(obj))
args.compilation_database.add_command(f'Compiling {emphasis(src)} ...', cmd, partial(newer, obj, src), key=key, keyfile=src)
dest = os.path.join(launcher_dir, 'kitty')
src = 'launcher.c'
cmd = env.cc + cppflags + cflags + [
src, '-o', dest] + ldflags + libs + pylib
key = CompileKey('launcher.c', 'kitty')
desc = f'Building {emphasis("launcher")} ...'
args.compilation_database.add_command(desc, cmd, partial(newer, dest, src, "prewarm-launcher.h"), key=key, keyfile=src)
desc = f'Linking {emphasis("launcher")} ...'
cmd = env.cc + ldflags + objects + libs + pylib + ['-o', dest]
args.compilation_database.add_command(desc, cmd, partial(newer, dest, *objects), key=CompileKey('', 'kitty'))
args.compilation_database.build_all()