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

Replace Makefiles with build.py in specs/*. #3679

Merged
merged 1 commit into from
Aug 8, 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
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.

Loading