1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

python: Concat generated files in generator.py

This commit is contained in:
Dan Yeaw
2025-03-31 22:18:14 -04:00
committed by Nick Wellnhofer
parent fc4adba90e
commit ffef921be3
6 changed files with 16 additions and 38 deletions

1
python/.gitignore vendored
View File

@@ -3,7 +3,6 @@
/libxml2-py.c
/libxml2-py.h
/libxml2.py
/libxml2class.py
/libxml2class.txt
/setup.py
/tests/tmp.xml

View File

@@ -32,8 +32,8 @@ python_PYTHON = drv_libxml2.py
nodist_python_PYTHON = libxml2.py
API_DESC = $(top_srcdir)/doc/libxml2-api.xml $(srcdir)/libxml2-python-api.xml
GENERATED = libxml2class.py libxml2class.txt $(BUILT_SOURCES)
CLEANFILES = libxml2.py $(GENERATED)
GENERATED = libxml2.py libxml2class.txt $(BUILT_SOURCES)
CLEANFILES = $(GENERATED)
all-local: libxml2.py
@@ -43,9 +43,6 @@ $(GENERATED): $(srcdir)/generator.py $(API_DESC)
# libxml.c #includes libxml2-export.c
libxml.$(OBJEXT): libxml2-export.c
libxml2.py: $(srcdir)/libxml.py libxml2class.py
cat $(srcdir)/libxml.py `test -f libxml2class.py || echo $(srcdir)/`libxml2class.py > $@
clean-local:
rm -rf __pycache__ *.pyc

View File

@@ -1091,9 +1091,20 @@ def buildWrappers():
func = nameFixup(name, "None", file, file)
info = (0, func, name, ret, args, file)
function_classes['None'].append(info)
classes = open(os.path.join(dstPref, "libxml2class.py"), "w")
libxml_content = ""
try:
with open(os.path.join(srcPref, "libxml.py"), "r") as libxml_file:
libxml_content = libxml_file.read()
except IOError as msg:
print("Error reading libxml.py:", msg)
sys.exit(1)
classes = open(os.path.join(dstPref, "libxml2.py"), "w")
txt = open(os.path.join(dstPref, "libxml2class.txt"), "w")
classes.write(libxml_content)
txt.write(" Generated Classes for libxml2-python\n\n")
txt.write("#\n# Global functions of the module\n#\n\n")

View File

@@ -16,7 +16,7 @@ if py.found() == true
'libxml2-py.h',
'libxml2-export.c',
'libxml2-py.c',
'libxml2class.py',
'libxml2.py',
'libxml2class.txt',
],
command: [py, '@INPUT@', meson.current_build_dir()],
@@ -25,16 +25,6 @@ if py.found() == true
sources : [pygenerated[0]],
)
libxml2_py = custom_target(
'libxml2.py',
input: [files('libxml.py'), pygenerated[3]],
output: 'libxml2.py',
command: [find_program('cat'), '@INPUT@'],
capture: true,
install: true,
install_dir: py.get_install_dir(),
)
libxml2mod_src = [
files('libxml.c', 'types.c'),
pygenerated[2],

View File

@@ -116,20 +116,6 @@ if missing("libxml2-py.c") or missing("libxml2.py"):
print(sys.exc_info()[0], sys.exc_info()[1])
sys.exit(1)
head = open("libxml.py", "r")
generated = open("libxml2class.py", "r")
result = open("libxml2.py", "w")
for line in head.readlines():
if WITHDLLS:
result.write(altImport(line))
else:
result.write(line)
for line in generated.readlines():
result.write(line)
head.close()
generated.close()
result.close()
with_xslt=0
if missing("libxslt-py.c") or missing("libxslt.py"):
if missing("xsltgenerator.py") or missing("libxslt-api.xml"):