From 68d800d4fa14ea4121b850cdb7c2eb224cbe6073 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 1 Feb 2024 20:33:14 +0530 Subject: [PATCH] make clean should clean generated asm as well --- .gitattributes | 5 +++++ setup.py | 11 ++++++++--- tools/simdstring/.gitignore | 3 --- tools/simdstring/generate.go | 12 ++++++------ 4 files changed, 19 insertions(+), 12 deletions(-) delete mode 100644 tools/simdstring/.gitignore diff --git a/.gitattributes b/.gitattributes index da21b2931..62122153c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/setup.py b/setup.py index 3b6a53b57..cd8db52c6 100755 --- a/setup.py +++ b/setup.py @@ -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) diff --git a/tools/simdstring/.gitignore b/tools/simdstring/.gitignore deleted file mode 100644 index 5f147192f..000000000 --- a/tools/simdstring/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -tags -simdstring.test -asm_* diff --git a/tools/simdstring/generate.go b/tools/simdstring/generate.go index d3199ea78..17b44aac8 100644 --- a/tools/simdstring/generate.go +++ b/tools/simdstring/generate.go @@ -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()) } }