From a5f5f5a1aafa781d40fd00ad31f608738e8d68b7 Mon Sep 17 00:00:00 2001 From: Fumitoshi Ukai Date: Tue, 12 Apr 2022 16:18:01 +0000 Subject: [PATCH] use stamp file for tint_generate_wgsl_corpus using directory for actions output causes issue like crbug.com/1315457 ninja explain: output obj/third_party/dawn/src/tint/fuzzers/tint_generate_wgsl_corpus.stamp older than most recent input gen/third_party/dawn/src/tint/fuzzers/fuzzer_corpus_wgsl (1649712735 vs 1649712999) Use stamp file instead of directory. Bug: chromium:1315457, chromium:1314527 Change-Id: Ifdf0493e23dbab000513e8f2c0ae4aa8cd76444f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86482 Auto-Submit: Fumitoshi Ukai Reviewed-by: Ryan Harrison Commit-Queue: Ryan Harrison Reviewed-by: Ben Clayton Commit-Queue: Ben Clayton --- src/tint/fuzzers/BUILD.gn | 4 +++- src/tint/fuzzers/generate_wgsl_corpus.py | 16 +++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/tint/fuzzers/BUILD.gn b/src/tint/fuzzers/BUILD.gn index 3253e94ce8..afd1e3a881 100644 --- a/src/tint/fuzzers/BUILD.gn +++ b/src/tint/fuzzers/BUILD.gn @@ -22,14 +22,16 @@ if (build_with_chromium) { import("//testing/libfuzzer/fuzzer_test.gni") fuzzer_corpus_wgsl_dir = "${target_gen_dir}/fuzzer_corpus_wgsl" + fuzzer_corpus_wgsl_stamp = "${fuzzer_corpus_wgsl_dir}.stamp" action("tint_generate_wgsl_corpus") { script = "generate_wgsl_corpus.py" sources = [ "generate_wgsl_corpus.py" ] args = [ + "--stamp=${fuzzer_corpus_wgsl_stamp}", rebase_path("${tint_root_dir}/test", root_build_dir), rebase_path(fuzzer_corpus_wgsl_dir, root_build_dir), ] - outputs = [ fuzzer_corpus_wgsl_dir ] + outputs = [ fuzzer_corpus_wgsl_stamp ] } tint_fuzzer_common_libfuzzer_options = [ diff --git a/src/tint/fuzzers/generate_wgsl_corpus.py b/src/tint/fuzzers/generate_wgsl_corpus.py index 65c564f904..983acd97b5 100644 --- a/src/tint/fuzzers/generate_wgsl_corpus.py +++ b/src/tint/fuzzers/generate_wgsl_corpus.py @@ -26,6 +26,7 @@ # Usage: # generate_wgsl_corpus.py +import optparse import os import pathlib import shutil @@ -40,11 +41,14 @@ def list_wgsl_files(root_search_dir): def main(): - if len(sys.argv) != 3: - print("Usage: " + sys.argv[0] + " ") - return 1 - input_dir: str = os.path.abspath(sys.argv[1].rstrip(os.sep)) - corpus_dir: str = os.path.abspath(sys.argv[2]) + parser = optparse.OptionParser( + usage="usage: %prog [option] input-dir output-dir") + parser.add_option('--stamp', dest='stamp', help='stamp file') + options, args = parser.parse_args(sys.argv[1:]) + if len(args) != 2: + parser.error("incorrect number of arguments") + input_dir: str = os.path.abspath(args[0].rstrip(os.sep)) + corpus_dir: str = os.path.abspath(args[1]) if os.path.exists(corpus_dir): shutil.rmtree(corpus_dir) os.makedirs(corpus_dir) @@ -53,6 +57,8 @@ def main(): continue out_file = in_file[len(input_dir) + 1:].replace(os.sep, '_') shutil.copy(in_file, corpus_dir + os.sep + out_file) + if options.stamp: + pathlib.Path(options.stamp).touch(mode=0o644, exist_ok=True) if __name__ == "__main__":