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 <ukai@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Fumitoshi Ukai 2022-04-12 16:18:01 +00:00 committed by Dawn LUCI CQ
parent 4c9a6b0951
commit a5f5f5a1aa
2 changed files with 14 additions and 6 deletions

View File

@ -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 = [

View File

@ -26,6 +26,7 @@
# Usage:
# generate_wgsl_corpus.py <input_dir> <corpus_dir>
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] + " <input dir> <output dir>")
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__":