make clean should clean generated asm as well

This commit is contained in:
Kovid Goyal 2024-02-01 20:33:14 +05:30
parent 9fc3db1dd1
commit 68d800d4fa
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 19 additions and 12 deletions

5
.gitattributes vendored
View file

@ -22,6 +22,11 @@ tools/wcswidth/std.go linguist-generated=true
tools/unicode_names/names.txt linguist-generated=true
terminfo/kitty.term* linguist-generated=true
terminfo/x/* linguist-generated=true
*_generated.h linguist-generated=true
*_generated.go linguist-generated=true
*_generated_test.go linguist-generated=true
*_generated_test.s linguist-generated=true
*_generated.s linguist-generated=true
*.py text diff=python
*.m text diff=objc

View file

@ -1733,6 +1733,13 @@ def clean(for_cross_compile: bool = False) -> None:
q = os.path.relpath(os.path.join(root, d), src_base).replace(os.sep, '/')
return q in ('.git', 'bypy/b', 'dependencies')
def is_generated(f: str) -> bool:
e = f.endswith
return (
e('_generated.h') or e('_generated.go') or e('_generated.bin') or
e('_generated.s') or e('_generated_test.s') or e('_generated_test.go')
)
for root, dirs, files in os.walk(src_base, topdown=True):
dirs[:] = [d for d in dirs if not excluded(root, d)]
remove_dirs = {d for d in dirs if d == '__pycache__' or d.endswith('.dSYM')}
@ -1741,9 +1748,7 @@ def clean(for_cross_compile: bool = False) -> None:
dirs.remove(d)
for f in files:
ext = f.rpartition('.')[-1]
if ext in ('so', 'dylib', 'pyc', 'pyo') or (not for_cross_compile and (
f.endswith('_generated.h') or f.endswith('_generated.go') or f.endswith('_generated.bin'))
):
if ext in ('so', 'dylib', 'pyc', 'pyo') or (not for_cross_compile and is_generated(f)):
os.unlink(os.path.join(root, f))
for x in glob.glob('glfw/wayland-*-protocol.[ch]'):
os.unlink(x)

View file

@ -1,3 +0,0 @@
tags
simdstring.test
asm_*

View file

@ -1379,11 +1379,11 @@ func do_one(s *State) {
s.Generate()
if s.ISA.HasSIMD {
write_file(fmt.Sprintf("asm_%d_%s.s", s.ISA.Bits, s.ISA.Goarch), s.ASMOutput.String())
write_file(fmt.Sprintf("asm_%d_%s_test.s", s.ISA.Bits, s.ISA.Goarch), s.TestASMOutput.String())
write_file(fmt.Sprintf("asm_%d_%s_generated.s", s.ISA.Bits, s.ISA.Goarch), s.ASMOutput.String())
write_file(fmt.Sprintf("asm_%d_%s_generated_test.s", s.ISA.Bits, s.ISA.Goarch), s.TestASMOutput.String())
}
write_file(fmt.Sprintf("asm_%d_%s.go", s.ISA.Bits, s.ISA.Goarch), s.StubOutput.String())
write_file(fmt.Sprintf("asm_%d_%s_test.go", s.ISA.Bits, s.ISA.Goarch), s.TestStubOutput.String())
write_file(fmt.Sprintf("asm_%d_%s_generated.go", s.ISA.Bits, s.ISA.Goarch), s.StubOutput.String())
write_file(fmt.Sprintf("asm_%d_%s_generated_test.go", s.ISA.Bits, s.ISA.Goarch), s.TestStubOutput.String())
}
func create_isa(arch Arch, bits int) ISA {
@ -1430,8 +1430,8 @@ func main() {
s.ISA.HasSIMD = false
fmt.Fprintf(&s.StubOutput, "const HasSIMD%dCode = false\n", bits)
s.Generate()
write_file(fmt.Sprintf("asm_other_%d.go", bits), s.StubOutput.String())
write_file(fmt.Sprintf("asm_other_%d_test.go", bits), s.TestStubOutput.String())
write_file(fmt.Sprintf("asm_other_%d_generated.go", bits), s.StubOutput.String())
write_file(fmt.Sprintf("asm_other_%d_generated_test.go", bits), s.TestStubOutput.String())
}
}