build: Split arguments for dispatch generator

The gen_dispatch.py script relies on the source and include directories
to exist before dumping the files in there, split by type, in order to
sustain the split of the headers existing in a separate root from the
source files. This causes a spooky-action-at-a-distance scenario where
headers are generated by rules inside the source directory but influence
the contents of a separate directory — and require a separate set of
rules to install those headers.

Different build systems would require either splitting the generation in
to two separate passes (which is more expensive and time consuming), or
generate the header and source files in the same directory, and just
tweak the inclusion paths accordingly.

Since we want to maintain this fiction for the autotools build, but
ignore it for different build systems, let's add a separate set of
arguments for gen_dispatch.py that make the rules inside Makefile.am
work appropriately.
macos/v1.5.9
Emmanuele Bassi 8 years ago
parent 4fe238e023
commit e2e2fedbdb
  1. 20
      src/Makefile.am
  2. 22
      src/gen_dispatch.py

@ -153,19 +153,31 @@ $(GENERATED_WGL_INCLUDES): $(GENERATED_WGL_SOURCE)
$(GENERATED_GL_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/gl.xml $(GENERATED_GL_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/gl.xml
@$(MKDIR_P) $(top_builddir)/include/epoxy @$(MKDIR_P) $(top_builddir)/include/epoxy
$(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py --dir $(top_builddir) $(top_srcdir)/registry/gl.xml $(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py \
--srcdir $(top_builddir)/src \
--includedir $(top_builddir)/include/epoxy \
$(top_srcdir)/registry/gl.xml
$(GENERATED_GLX_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/glx.xml $(GENERATED_GLX_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/glx.xml
@$(MKDIR_P) $(top_builddir)/include/epoxy @$(MKDIR_P) $(top_builddir)/include/epoxy
$(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py --dir $(top_builddir) $(top_srcdir)/registry/glx.xml $(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py \
--srcdir $(top_builddir)/src \
--includedir $(top_builddir)/include/epoxy \
$(top_srcdir)/registry/glx.xml
$(GENERATED_EGL_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/egl.xml $(GENERATED_EGL_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/egl.xml
@$(MKDIR_P) $(top_builddir)/include/epoxy @$(MKDIR_P) $(top_builddir)/include/epoxy
$(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py --dir $(top_builddir) $(top_srcdir)/registry/egl.xml $(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py \
--srcdir $(top_builddir)/src \
--includedir $(top_builddir)/include/epoxy \
$(top_srcdir)/registry/egl.xml
$(GENERATED_WGL_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/wgl.xml $(GENERATED_WGL_SOURCE): $(srcdir)/gen_dispatch.py $(top_srcdir)/registry/wgl.xml
@$(MKDIR_P) $(top_builddir)/include/epoxy @$(MKDIR_P) $(top_builddir)/include/epoxy
$(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py --dir $(top_builddir) $(top_srcdir)/registry/wgl.xml $(AM_V_GEN)$(PYTHON) $(srcdir)/gen_dispatch.py \
--srcdir $(top_builddir)/src \
--includedir $(top_builddir)/include/epoxy \
$(top_srcdir)/registry/wgl.xml
EXTRA_DIST = \ EXTRA_DIST = \
gen_dispatch.py \ gen_dispatch.py \

@ -836,11 +836,23 @@ class Generator(object):
argparser = argparse.ArgumentParser(description='Generate GL dispatch wrappers.') argparser = argparse.ArgumentParser(description='Generate GL dispatch wrappers.')
argparser.add_argument('files', metavar='file.xml', nargs='+', help='GL API XML files to be parsed') argparser.add_argument('files', metavar='file.xml', nargs='+', help='GL API XML files to be parsed')
argparser.add_argument('--dir', metavar='dir', required=True, help='Destination directory') argparser.add_argument('--srcdir', metavar='srcdir', required=False, help='Destination directory for source files')
argparser.add_argument('--includedir', metavar='incdir', required=False, help='Destination director for header files')
argparser.add_argument('--dir', metavar='dir', required=False, help='Destination directory')
args = argparser.parse_args() args = argparser.parse_args()
srcdir = args.dir + '/src/' if args.dir:
incdir = args.dir + '/include/epoxy/' srcdir = args.dir
incdir = args.dir
else:
srcdir = args.srcdir
incdir = args.includedir
if not srcdir:
srcdir = os.getcwd()
if not incdir:
incdir = os.getcwd()
for file in args.files: for file in args.files:
name = os.path.basename(file).split('.xml')[0] name = os.path.basename(file).split('.xml')[0]
@ -869,5 +881,5 @@ for file in args.files:
generator.prepare_provider_enum() generator.prepare_provider_enum()
generator.write_header(incdir + name + '_generated.h') generator.write_header(os.path.join(incdir, name + '_generated.h'))
generator.write_source(srcdir + name + '_generated_dispatch.c') generator.write_source(os.path.join(srcdir, name + '_generated_dispatch.c'))

Loading…
Cancel
Save