Skip to content

Commit

Permalink
build.py in specs/latest/2.0 as an alternative to Makefile. (#3627)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdashg authored Mar 7, 2024
1 parent e2ac29b commit 050af3f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
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

0 comments on commit 050af3f

Please sign in to comment.