Simplify cleanup and ignoring of generated go files
This commit is contained in:
parent
780b5ca8bd
commit
c85af36116
2
.github/workflows/ci.py
vendored
2
.github/workflows/ci.py
vendored
@ -131,7 +131,7 @@ def main():
|
|||||||
elif action == 'test':
|
elif action == 'test':
|
||||||
test_kitty()
|
test_kitty()
|
||||||
elif action == 'gofmt':
|
elif action == 'gofmt':
|
||||||
q = subprocess.check_output('gofmt -s -l tools version.go'.split())
|
q = subprocess.check_output('gofmt -s -l tools'.split())
|
||||||
if q.strip():
|
if q.strip():
|
||||||
print(q.decode())
|
print(q.decode())
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,7 +14,7 @@
|
|||||||
/glad/out/
|
/glad/out/
|
||||||
/kitty/launcher/kitty*
|
/kitty/launcher/kitty*
|
||||||
/tools/cmd/at/*_generated.go
|
/tools/cmd/at/*_generated.go
|
||||||
/constants.go
|
*_generated.go
|
||||||
/*.dSYM/
|
/*.dSYM/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
/glfw/wayland-*-client-protocol.[ch]
|
/glfw/wayland-*-client-protocol.[ch]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
to_vm_excludes '/build /dist /kitty/launcher/kitty /.build-cache /tags __pycache__ /*_commands.json *.so *.pyd *.pyc'
|
to_vm_excludes '/build /dist /kitty/launcher/kitty /.build-cache /tags __pycache__ /*_commands.json *.so *.pyd *.pyc *_generated.go'
|
||||||
|
|||||||
@ -27,7 +27,7 @@ def main() -> None:
|
|||||||
if 'prewarmed' in getattr(sys, 'kitty_run_data'):
|
if 'prewarmed' in getattr(sys, 'kitty_run_data'):
|
||||||
os.environ.pop('KITTY_PREWARM_SOCKET')
|
os.environ.pop('KITTY_PREWARM_SOCKET')
|
||||||
os.execlp(sys.executable, sys.executable, '+launch', __file__, *sys.argv[1:])
|
os.execlp(sys.executable, sys.executable, '+launch', __file__, *sys.argv[1:])
|
||||||
with open('constants.go', 'w') as f:
|
with open('constants_generated.go', 'w') as f:
|
||||||
dp = ", ".join(map(lambda x: f'"{serialize_as_go_string(x)}"', kc.default_pager_for_help))
|
dp = ", ".join(map(lambda x: f'"{serialize_as_go_string(x)}"', kc.default_pager_for_help))
|
||||||
f.write(f'''\
|
f.write(f'''\
|
||||||
// auto-generated by {__file__} do no edit
|
// auto-generated by {__file__} do no edit
|
||||||
|
|||||||
10
setup.py
10
setup.py
@ -880,15 +880,15 @@ def update_go_generated_files() -> None:
|
|||||||
# update all the various auto-generated go files, if needed
|
# update all the various auto-generated go files, if needed
|
||||||
rc_sources = [x for x in glob.glob('kitty/rc/*.py') if os.path.basename(x) not in ('base.py', '__init__.py')]
|
rc_sources = [x for x in glob.glob('kitty/rc/*.py') if os.path.basename(x) not in ('base.py', '__init__.py')]
|
||||||
rc_objects = glob.glob('tools/cmd/at/*_generated.go')
|
rc_objects = glob.glob('tools/cmd/at/*_generated.go')
|
||||||
generated = rc_objects + glob.glob('constants.go')
|
generated = rc_objects + glob.glob('constants_generated.go')
|
||||||
sources = ['gen-rc-go.py', 'kitty/constants.py', 'setup.py', 'tools/cmd/at/template.go'] + rc_sources
|
sources = ['gen-rc-go.py', 'kitty/constants.py', 'setup.py', 'tools/cmd/at/template.go'] + rc_sources
|
||||||
if generated:
|
if generated:
|
||||||
oldest_generated = min(map(os.path.getmtime, generated))
|
oldest_generated = min(map(os.path.getmtime, generated))
|
||||||
newest_source = max(map(os.path.getmtime, sources))
|
newest_source = max(map(os.path.getmtime, sources))
|
||||||
if oldest_generated > newest_source and len(rc_sources) == len(rc_objects) and 'constants.go' in generated:
|
if oldest_generated > newest_source and len(rc_sources) == len(rc_objects) and 'constants_generated.go' in generated:
|
||||||
return
|
return
|
||||||
print('Updating Go generated files...')
|
print('Updating Go generated files...')
|
||||||
subprocess.check_call(['./gen-rc-go.py'])
|
subprocess.check_call([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 = '.') -> None:
|
||||||
@ -1443,7 +1443,7 @@ def clean() -> None:
|
|||||||
safe_remove(
|
safe_remove(
|
||||||
'build', 'compile_commands.json', 'link_commands.json',
|
'build', 'compile_commands.json', 'link_commands.json',
|
||||||
'linux-package', 'kitty.app', 'asan-launcher',
|
'linux-package', 'kitty.app', 'asan-launcher',
|
||||||
'kitty-profile', 'docs/generated')
|
'kitty-profile', 'docs/generated', 'constants.go')
|
||||||
clean_launcher_dir('kitty/launcher')
|
clean_launcher_dir('kitty/launcher')
|
||||||
|
|
||||||
def excluded(root: str, d: str) -> bool:
|
def excluded(root: str, d: str) -> bool:
|
||||||
@ -1458,7 +1458,7 @@ def clean() -> None:
|
|||||||
dirs.remove(d)
|
dirs.remove(d)
|
||||||
for f in files:
|
for f in files:
|
||||||
ext = f.rpartition('.')[-1]
|
ext = f.rpartition('.')[-1]
|
||||||
if ext in ('so', 'dylib', 'pyc', 'pyo') or f.endswith('_generated.h'):
|
if ext in ('so', 'dylib', 'pyc', 'pyo') or f.endswith('_generated.h') or f.endswith('_generated.go'):
|
||||||
os.unlink(os.path.join(root, f))
|
os.unlink(os.path.join(root, f))
|
||||||
for x in glob.glob('glfw/wayland-*-protocol.[ch]'):
|
for x in glob.glob('glfw/wayland-*-protocol.[ch]'):
|
||||||
os.unlink(x)
|
os.unlink(x)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user