mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-105481: opcode.h is no longer generated during the build (#108080)
This commit is contained in:
parent
4cb08188e8
commit
0b243c2f66
7 changed files with 99 additions and 72 deletions
|
@ -1,4 +1,4 @@
|
|||
# This script generates the opcode.h header file.
|
||||
# This script generates the pycore_opcode.h header file.
|
||||
|
||||
import sys
|
||||
import tokenize
|
||||
|
@ -6,27 +6,6 @@ import tokenize
|
|||
SCRIPT_NAME = "Tools/build/generate_opcode_h.py"
|
||||
PYTHON_OPCODE = "Lib/opcode.py"
|
||||
|
||||
opcode_h_header = f"""
|
||||
// Auto-generated by {SCRIPT_NAME} from {PYTHON_OPCODE}
|
||||
|
||||
#ifndef Py_OPCODE_H
|
||||
#define Py_OPCODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {{
|
||||
#endif
|
||||
|
||||
#include "opcode_ids.h"
|
||||
|
||||
""".lstrip()
|
||||
|
||||
opcode_h_footer = """
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OPCODE_H */
|
||||
"""
|
||||
|
||||
internal_header = f"""
|
||||
// Auto-generated by {SCRIPT_NAME} from {PYTHON_OPCODE}
|
||||
|
||||
|
@ -62,20 +41,10 @@ def get_python_module_dict(filename):
|
|||
return mod
|
||||
|
||||
def main(opcode_py,
|
||||
opcode_h='Include/opcode.h',
|
||||
internal_opcode_h='Include/internal/pycore_opcode.h'):
|
||||
|
||||
opcode = get_python_module_dict(opcode_py)
|
||||
|
||||
with open(opcode_h, 'w') as fobj:
|
||||
fobj.write(opcode_h_header)
|
||||
|
||||
fobj.write("\n")
|
||||
for i, (op, _) in enumerate(opcode["_nb_ops"]):
|
||||
fobj.write(DEFINE.format(op, i))
|
||||
|
||||
fobj.write(opcode_h_footer)
|
||||
|
||||
with open(internal_opcode_h, 'w') as iobj:
|
||||
iobj.write(internal_header)
|
||||
|
||||
|
@ -91,8 +60,8 @@ def main(opcode_py,
|
|||
|
||||
iobj.write(internal_footer)
|
||||
|
||||
print(f"{opcode_h} regenerated from {opcode_py}")
|
||||
print(f"{internal_opcode_h} regenerated from {opcode_py}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||
main(sys.argv[1], sys.argv[2])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue