From 050af3ff7182956b33825d42c39536c5b5c834c8 Mon Sep 17 00:00:00 2001 From: Kelsey Gilbert Date: Wed, 6 Mar 2024 21:43:11 -0800 Subject: [PATCH] build.py in specs/latest/2.0 as an alternative to Makefile. (#3627) --- specs/latest/2.0/build.py | 41 +++++++++++++++++++++++++++++++++++++ specs/latest/2.0/webgl2.idl | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 specs/latest/2.0/build.py diff --git a/specs/latest/2.0/build.py b/specs/latest/2.0/build.py new file mode 100644 index 000000000..5b1622688 --- /dev/null +++ b/specs/latest/2.0/build.py @@ -0,0 +1,41 @@ +#! /usr/bin/env python3 +import os +import pathlib +import subprocess +import sys + +DIR = pathlib.Path(__file__).parent + +# - +# Extract the idl from index.html. + +RESOURCES = DIR.parent.parent.parent / 'resources' +assert RESOURCES.exists(), RESOURCES +PYTHONPATH_LIBS = [ + RESOURCES / 'html5lib-1.1/src/html5lib', + RESOURCES / 'webencodings-0.5.1/src/webencodings', +] +for lib in PYTHONPATH_LIBS: + assert lib.exists(), lib +PYTHONPATH = os.pathsep.join([str(lib.parent) for lib in PYTHONPATH_LIBS]) + +ENV = os.environ +ENV['PYTHONPATH'] = PYTHONPATH + +args = [sys.executable, 'extract-idl.py', 'index.html'] +print(f'Running {args}...') +p = subprocess.run([sys.executable, 'extract-idl.py', 'index.html'], cwd=DIR, env=ENV, stdout=subprocess.PIPE, text=True) +p.check_returncode() +idl = p.stdout +assert '\r' not in idl + +idl_file_data = '''\ +// AUTOGENERATED FILE -- DO NOT EDIT -- SEE Makefile +// +// WebGL IDL definitions scraped from the Khronos specification: +// https://www.khronos.org/registry/webgl/specs/latest/ +''' + idl + +out_file = DIR / 'webgl2.idl' +print(f'Writing "{out_file}"...') +out_file.write_bytes(idl_file_data.encode()) diff --git a/specs/latest/2.0/webgl2.idl b/specs/latest/2.0/webgl2.idl index 70a514837..c810cbf62 100644 --- a/specs/latest/2.0/webgl2.idl +++ b/specs/latest/2.0/webgl2.idl @@ -3,7 +3,7 @@ // WebGL IDL definitions scraped from the Khronos specification: // https://www.khronos.org/registry/webgl/specs/latest/ -// Copyright (c) 2023 The Khronos Group Inc. +// Copyright (c) 2024 The Khronos Group Inc. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and/or associated documentation files (the