Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.py in specs/latest/2.0 as an alternative to Makefile. #3627

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions specs/latest/2.0/build.py
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 1 addition & 1 deletion specs/latest/2.0/webgl2.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading