dawn-cmake/generator/tint_gen_template.py
dan sinclair 6c5db2afa6 Scaffolding for generation of intrinsics files.
This CL sets up the basis for the intrinsic file generation. All of
the GN and CMake pieces are setup, but they aren't hooked into the
main build yet. That will be a followup which just enables the
generation in order to allow easy reverting.

Change-Id: Iccac59377076ed6ac66eeaf0be965be2f49bc738
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107981
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2022-11-01 13:15:36 +00:00

54 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright 2022 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import os
import subprocess
import sys
def run_generator():
parser = argparse.ArgumentParser(
description=
"Tint template generator for GN build. Use tools/run gen for non-GN build.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument('--output',
default='',
type=str,
help='Base output directory.')
parser.add_argument('--template',
default='',
type=str,
help='Template to generate.')
args = parser.parse_args()
root = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
go = os.path.join(root, "tools", "golang", "bin", "go")
if sys.platform == 'win32':
go += '.exe'
gen = os.path.join(root, "tools", "src", "cmd", "gen")
subprocess.check_call(
[go, "run", gen, "-o", args.output,
os.path.join(root, args.template)],
cwd=root)
return 0
if __name__ == '__main__':
sys.exit(run_generator())