From ce56be6bb97ad2699b9d5d20cb8339407d17065e Mon Sep 17 00:00:00 2001 From: Pavlo Penenko Date: Fri, 14 Feb 2025 20:07:21 -0500 Subject: [PATCH] Clean the output directory and prevent keeping stale output files (#57) * Delete the output directory * Sort attributes in vertex data IDs to make them stable * Update references --- src/_impl/vertex_data.py | 2 +- src/generate.py | 7 +++++-- tests/ref | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/_impl/vertex_data.py b/src/_impl/vertex_data.py index c6ebfc9..426b41c 100644 --- a/src/_impl/vertex_data.py +++ b/src/_impl/vertex_data.py @@ -49,7 +49,7 @@ def __init__(self, primitive): self._optional_attributes.add(attr.sl_name) def get_id(self) -> str: - return '_'.join(self._optional_attributes) + return '_'.join(sorted(self._optional_attributes)) def _generate_vs_in(self, sh): with sh.vs_input('VsIn') as VsIn: diff --git a/src/generate.py b/src/generate.py index 34ad22b..f0f0412 100644 --- a/src/generate.py +++ b/src/generate.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argparse, functools, io, json, os, sys +import argparse, functools, io, json, os, shutil, sys from pathlib import Path import multiprocessing as mp from typing import List, NamedTuple @@ -121,7 +121,10 @@ def generate( if not gltf_dir_path.is_dir(): raise NotADirectoryError(gltf_dir_path) - os.makedirs(out_dir_path, exist_ok = True) + # Delete the output directory in order to delete any stale files + if os.path.exists(out_dir_path): + shutil.rmtree(out_dir_path) + os.makedirs(out_dir_path) shader_dict = dict() diff --git a/tests/ref b/tests/ref index c2227ae..663c298 160000 --- a/tests/ref +++ b/tests/ref @@ -1 +1 @@ -Subproject commit c2227ae720c1e050feb787b38e3f76b12ff83eed +Subproject commit 663c298311e29a4dafad24f034dca8ede9152140