Let kitty-tool know if it was built for a frozen kitty

This commit is contained in:
Kovid Goyal 2022-08-17 10:59:55 +05:30
parent 82410c58ed
commit a0bff4abab
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 2 deletions

View File

@ -70,6 +70,7 @@ var Version VersionType = VersionType{{Major: {kc.version.major}, Minor: {kc.ver
var DefaultPager []string = []string{{ {dp} }} var DefaultPager []string = []string{{ {dp} }}
var VCSRevision string = "" var VCSRevision string = ""
var RC_ENCRYPTION_PROTOCOL_VERSION string = "{kc.RC_ENCRYPTION_PROTOCOL_VERSION}" var RC_ENCRYPTION_PROTOCOL_VERSION string = "{kc.RC_ENCRYPTION_PROTOCOL_VERSION}"
var IsFrozenBuild bool = false
''') ''')
with open('tools/cmd/at/template.go') as f: with open('tools/cmd/at/template.go') as f:
template = f.read() template = f.read()

View File

@ -894,7 +894,7 @@ def update_go_generated_files(args: Options, kitty_exe: str) -> None:
subprocess.check_call([kitty_exe, '+launch', os.path.join(base, 'gen-rc-go.py')]) subprocess.check_call([kitty_exe, '+launch', os.path.join(base, 'gen-rc-go.py')])
def build_kitty_tool(args: Options, launcher_dir: str) -> None: def build_kitty_tool(args: Options, launcher_dir: str, for_freeze: bool = False) -> None:
go = shutil.which('go') go = shutil.which('go')
if not go: if not go:
raise SystemExit('The go tool was not found on this system. Install Go') raise SystemExit('The go tool was not found on this system. Install Go')
@ -903,6 +903,8 @@ def build_kitty_tool(args: Options, launcher_dir: str) -> None:
if args.verbose: if args.verbose:
cmd.append('-v') cmd.append('-v')
ld_flags = [f"-X 'kitty.VCSRevision={get_vcs_rev_define()}'"] ld_flags = [f"-X 'kitty.VCSRevision={get_vcs_rev_define()}'"]
if for_freeze:
ld_flags.append("-X 'kitty.IsFrozenBuild=true")
if not args.debug: if not args.debug:
ld_flags.append('-s') ld_flags.append('-s')
ld_flags.append('-w') ld_flags.append('-w')
@ -1709,7 +1711,7 @@ def main() -> None:
bundle_type = ('macos' if is_macos else 'linux') + '-freeze' bundle_type = ('macos' if is_macos else 'linux') + '-freeze'
build_launcher(args, launcher_dir=os.path.join(args.prefix, 'bin'), bundle_type=bundle_type) build_launcher(args, launcher_dir=os.path.join(args.prefix, 'bin'), bundle_type=bundle_type)
elif args.action == 'build-frozen-tools': elif args.action == 'build-frozen-tools':
build_kitty_tool(args, launcher_dir=args.prefix) build_kitty_tool(args, launcher_dir=args.prefix, for_freeze=True)
elif args.action == 'linux-package': elif args.action == 'linux-package':
build(args, native_optimizations=False) build(args, native_optimizations=False)
package(args, bundle_type='linux-package') package(args, bundle_type='linux-package')