From 61fdcb975ab928dc2b56269e0602f3d8a66e726d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 15 Jun 2010 10:50:04 +0000 Subject: [PATCH] Add a flavor system to allow addition of other OpenGL versions --- Makefile | 15 ++++++++++++--- enum.spec => flavors/gl/enum.spec | 0 flavors/gl/flavor.mk | 3 +++ gl.api => flavors/gl/gl.api | 0 gl.io => flavors/gl/gl.io | 0 gl.spec => flavors/gl/gl.spec | 0 gl.tm => flavors/gl/gl.tm | 0 glx.api => flavors/gl/glx.api | 0 glx.io => flavors/gl/glx.io | 0 glx.spec => flavors/gl/glx.spec | 0 glx.tm => flavors/gl/glx.tm | 0 glxenum.spec => flavors/gl/glxenum.spec | 0 glxext.spec => flavors/gl/glxext.spec | 0 {source => flavors/gl/source}/arraysize.c | 2 +- {source => flavors/gl/source}/glwrap_funcs.c | 4 +--- flavors/gl/source/opengl.h | 10 ++++++++++ generate.py | 10 ++++++---- source/arraysize.h | 4 ++-- source/enums.h | 4 ++-- source/gldecoder.h | 5 ++--- 20 files changed, 39 insertions(+), 18 deletions(-) rename enum.spec => flavors/gl/enum.spec (100%) create mode 100644 flavors/gl/flavor.mk rename gl.api => flavors/gl/gl.api (100%) rename gl.io => flavors/gl/gl.io (100%) rename gl.spec => flavors/gl/gl.spec (100%) rename gl.tm => flavors/gl/gl.tm (100%) rename glx.api => flavors/gl/glx.api (100%) rename glx.io => flavors/gl/glx.io (100%) rename glx.spec => flavors/gl/glx.spec (100%) rename glx.tm => flavors/gl/glx.tm (100%) rename glxenum.spec => flavors/gl/glxenum.spec (100%) rename glxext.spec => flavors/gl/glxext.spec (100%) rename {source => flavors/gl/source}/arraysize.c (97%) rename {source => flavors/gl/source}/glwrap_funcs.c (96%) create mode 100644 flavors/gl/source/opengl.h diff --git a/Makefile b/Makefile index 3fda9ec..119aef3 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,18 @@ # $Id$ -CPPFLAGS := -I. +ifeq ($(FLAVOR),) +FLAVOR := gl +endif + +CPPFLAGS := -I. -Isource -Iflavors/$(FLAVOR)/source CFLAGS := -ggdb -Wall -Wextra CXXFLAGS := $(CFLAGS) PACKAGES_gldbg := mspcore mspstrings mspio mspfs +FLAVOR_ROOT := flavors/$(FLAVOR) +VPATH := $(FLAVOR_ROOT) + SOURCES_libgldbg := source/gldecoder.c \ source/glprint.c \ source/enums.c \ @@ -50,6 +57,8 @@ DEPS_all := $(call deps,$(SOURCES_all) $(TEMPLATES)) .PHONY: all all: glwrap.so gldump gldbg +include flavors/$(FLAVOR)/flavor.mk + $(OBJECTS_gldbg): CXXFLAGS += $(shell pkg-config --cflags $(PACKAGES_gldbg)) gldbg: LIBS += $(shell pkg-config --libs $(PACKAGES_gldbg)) -lreadline gldump gldbg: LIBS += ./libgldbg.a @@ -77,7 +86,7 @@ temp/.created: touch $@ gensrc/%: source/%.t gensrc/.created generate.py - python ./generate.py $< gl.api glx.api >$@ + python ./generate.py $< $(APIS) >$@ gensrc/.created: mkdir -p gensrc @@ -92,7 +101,7 @@ temp/%.d: source/%.cpp temp/.created $(CXX) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $< temp/%.d: source/%.t temp/.created - python ./generate.py --depends=$(call rename,gensrc,,$<) $< gl.api glx.api >$@ + python ./generate.py --depends=$(call rename,gensrc,,$<) $< $(APIS) >$@ .PHONY: clean clean: diff --git a/enum.spec b/flavors/gl/enum.spec similarity index 100% rename from enum.spec rename to flavors/gl/enum.spec diff --git a/flavors/gl/flavor.mk b/flavors/gl/flavor.mk new file mode 100644 index 0000000..e326b8c --- /dev/null +++ b/flavors/gl/flavor.mk @@ -0,0 +1,3 @@ +# $Id$ + +APIS := $(FLAVOR_ROOT)/gl.api $(FLAVOR_ROOT)/glx.api diff --git a/gl.api b/flavors/gl/gl.api similarity index 100% rename from gl.api rename to flavors/gl/gl.api diff --git a/gl.io b/flavors/gl/gl.io similarity index 100% rename from gl.io rename to flavors/gl/gl.io diff --git a/gl.spec b/flavors/gl/gl.spec similarity index 100% rename from gl.spec rename to flavors/gl/gl.spec diff --git a/gl.tm b/flavors/gl/gl.tm similarity index 100% rename from gl.tm rename to flavors/gl/gl.tm diff --git a/glx.api b/flavors/gl/glx.api similarity index 100% rename from glx.api rename to flavors/gl/glx.api diff --git a/glx.io b/flavors/gl/glx.io similarity index 100% rename from glx.io rename to flavors/gl/glx.io diff --git a/glx.spec b/flavors/gl/glx.spec similarity index 100% rename from glx.spec rename to flavors/gl/glx.spec diff --git a/glx.tm b/flavors/gl/glx.tm similarity index 100% rename from glx.tm rename to flavors/gl/glx.tm diff --git a/glxenum.spec b/flavors/gl/glxenum.spec similarity index 100% rename from glxenum.spec rename to flavors/gl/glxenum.spec diff --git a/glxext.spec b/flavors/gl/glxext.spec similarity index 100% rename from glxext.spec rename to flavors/gl/glxext.spec diff --git a/source/arraysize.c b/flavors/gl/source/arraysize.c similarity index 97% rename from source/arraysize.c rename to flavors/gl/source/arraysize.c index 779fbea..00d6a79 100644 --- a/source/arraysize.c +++ b/flavors/gl/source/arraysize.c @@ -1,7 +1,7 @@ /* $Id$ This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions Distributed under the GPL */ diff --git a/source/glwrap_funcs.c b/flavors/gl/source/glwrap_funcs.c similarity index 96% rename from source/glwrap_funcs.c rename to flavors/gl/source/glwrap_funcs.c index b6bc4d8..7fc5adf 100644 --- a/source/glwrap_funcs.c +++ b/flavors/gl/source/glwrap_funcs.c @@ -6,12 +6,10 @@ Distributed under the GPL */ #include -#include -#include -#include #include "arraysize.h" #include "functions.h" #include "glwrap.h" +#include "opengl.h" int in_begin_block = 0; GLenum cur_error = GL_NO_ERROR; diff --git a/flavors/gl/source/opengl.h b/flavors/gl/source/opengl.h new file mode 100644 index 0000000..72bfa59 --- /dev/null +++ b/flavors/gl/source/opengl.h @@ -0,0 +1,10 @@ +/* $Id$ + +This file is part of gldbg +Copyright © 2010 Mikko Rasa, Mikkosoft Productions +Distributed under the GPL +*/ + +#include +#include +#include diff --git a/generate.py b/generate.py index 0f9c569..229ecc3 100755 --- a/generate.py +++ b/generate.py @@ -334,18 +334,20 @@ class Api: self.ignore_categs = [] self.ignore_funcs = [] + path = os.path.split(fn)[0] + for line in InputFile(fn): parts = line.split() if parts[0]=="typemap": - self.typemap = parts[1] + self.typemap = os.path.join(path, parts[1]) elif parts[0]=="iomap": - self.iomap = parts[1] + self.iomap = os.path.join(path, parts[1]) elif parts[0]=="spec": - self.specs.append(parts[1]) + self.specs.append(os.path.join(path, parts[1])) elif parts[0]=="prefix": self.prefix = parts[1] elif parts[0]=="enumspec": - self.enumspecs.append(parts[1]) + self.enumspecs.append(os.path.join(path, parts[1])) elif parts[0]=="enumprefix": self.enumprefix = parts[1] elif parts[0]=="ignore": diff --git a/source/arraysize.h b/source/arraysize.h index 1ab0ae7..56f0826 100644 --- a/source/arraysize.h +++ b/source/arraysize.h @@ -1,14 +1,14 @@ /* $Id$ This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions Distributed under the GPL */ #ifndef ARRAYSIZE_H_ #define ARRAYSIZE_H_ -#include +#include "opengl.h" extern int typesize(GLenum); extern int formatsize(GLenum); diff --git a/source/enums.h b/source/enums.h index a3ae8d8..f3c82a5 100644 --- a/source/enums.h +++ b/source/enums.h @@ -1,14 +1,14 @@ /* $Id$ This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions Distributed under the GPL */ #ifndef ENUMS_H_ #define ENUMS_H_ -#include +#include "opengl.h" #ifdef __cplusplus extern "C" { diff --git a/source/gldecoder.h b/source/gldecoder.h index b13bc21..39d4f6a 100644 --- a/source/gldecoder.h +++ b/source/gldecoder.h @@ -1,15 +1,14 @@ /* $Id$ This file is part of gldbg -Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions Distributed under the GPL */ #ifndef GLDECODER_H_ #define GLDECODER_H_ -#include -#include +#include "opengl.h" #ifdef __cplusplus extern "C" { -- 2.45.2