Skip to content

Commit

Permalink
Replace Makefiles with build.py in specs/*. (KhronosGroup#3679)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdashg authored Aug 8, 2024
1 parent 7c70574 commit eeeb020
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 252 deletions.
14 changes: 0 additions & 14 deletions specs/1.0.2/Makefile

This file was deleted.

37 changes: 0 additions & 37 deletions specs/1.0.2/extract-idl.py

This file was deleted.

14 changes: 0 additions & 14 deletions specs/1.0.3/Makefile

This file was deleted.

37 changes: 0 additions & 37 deletions specs/1.0.3/extract-idl.py

This file was deleted.

14 changes: 0 additions & 14 deletions specs/2.0.0/Makefile

This file was deleted.

37 changes: 0 additions & 37 deletions specs/2.0.0/extract-idl.py

This file was deleted.

45 changes: 45 additions & 0 deletions specs/build-idl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#! /usr/bin/env python3
# Usage:
# build-idl.py latest/2.0/webgl2.idl
import os
import pathlib
import subprocess
import sys

OUT_IDL = pathlib.Path(sys.argv[1])
INDEX_HTML = OUT_IDL.parent / 'index.html'
assert INDEX_HTML.exists(), INDEX_HTML

BASE_DIR = pathlib.Path(__file__).parent.parent
assert (BASE_DIR / '.git').exists(), BASE_DIR / '.git'

# -
# Extract the idl from index.html.

PYTHONPATH_LIBS = [
BASE_DIR / 'resources/html5lib-1.1/src/html5lib',
BASE_DIR / '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, BASE_DIR / 'specs/extract-idl.py', INDEX_HTML]
print(f'Running {args}...')
p = subprocess.run(args, 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

print(f'Writing "{OUT_IDL}"...')
OUT_IDL.write_bytes(idl_file_data.encode())
File renamed without changes.
11 changes: 11 additions & 0 deletions specs/latest/1.0/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env python3
# Usage: build.py (no args)
import pathlib
import subprocess
import sys

THIS_DIR = pathlib.Path(__file__).parent
BASE_DIR = THIS_DIR.parent.parent.parent
assert (BASE_DIR / '.git').exists(), BASE_DIR / '.git'

subprocess.run([sys.executable, BASE_DIR / 'specs/build-idl.py', THIS_DIR / 'webgl.idl'], check=True)
40 changes: 5 additions & 35 deletions specs/latest/2.0/build.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
#! /usr/bin/env python3
import os
# Usage: build.py (no args)
import pathlib
import subprocess
import sys

DIR = pathlib.Path(__file__).parent
THIS_DIR = pathlib.Path(__file__).parent
BASE_DIR = THIS_DIR.parent.parent.parent
assert (BASE_DIR / '.git').exists(), BASE_DIR / '.git'

# -
# 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())
subprocess.run([sys.executable, BASE_DIR / 'specs/build-idl.py', THIS_DIR / 'webgl2.idl'], check=True)
64 changes: 0 additions & 64 deletions specs/latest/2.0/extract-idl.py

This file was deleted.

0 comments on commit eeeb020

Please sign in to comment.