summaryrefslogtreecommitdiff
path: root/cpp/managementgen
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2009-04-23 22:59:12 +0000
committerStephen D. Huston <shuston@apache.org>2009-04-23 22:59:12 +0000
commit3c95f9a289fee6a3b43608ec2ac95f841c43e3ff (patch)
tree5860c778c3e2b2c6c23b49887ae870cb5d4558ff /cpp/managementgen
parent7db52d95099fb7ae237277f12e4e368cf643f174 (diff)
downloadqpid-python-3c95f9a289fee6a3b43608ec2ac95f841c43e3ff.tar.gz
Merge in initial changes to allow building with CMake; rubygen and managementgen can now generate either .mk files or .cmake files as needed; CONF_FILE and MODULE_DIR macros now have broker/client counterparts QPIDD_CONF_FILE, QPIDD_MODULE_DIR, QPIDC_CONF_FILE, QPIDC_MODULE_DIR configurable by cmake
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@768085 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/managementgen')
-rw-r--r--cpp/managementgen/CMakeLists.txt37
-rwxr-xr-xcpp/managementgen/qmf-gen8
-rwxr-xr-xcpp/managementgen/qmfgen/generate.py95
-rw-r--r--cpp/managementgen/qmfgen/templates/CMakeLists.cmake39
4 files changed, 175 insertions, 4 deletions
diff --git a/cpp/managementgen/CMakeLists.txt b/cpp/managementgen/CMakeLists.txt
new file mode 100644
index 0000000000..fa0c3f2909
--- /dev/null
+++ b/cpp/managementgen/CMakeLists.txt
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+project(qpidc-qmfgen)
+cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
+
+install(PROGRAMS qmf-gen DESTINATION managementgen
+ COMPONENT all-source)
+install(FILES qmfgen/__init__.py
+ qmfgen/generate.py
+ qmfgen/schema.py
+ qmfgen/templates/Args.h
+ qmfgen/templates/Class.cpp
+ qmfgen/templates/Class.h
+ qmfgen/templates/Event.cpp
+ qmfgen/templates/Event.h
+ qmfgen/templates/Makefile.mk
+ qmfgen/templates/Package.cpp
+ qmfgen/templates/Package.h
+ qmfgen/management-types.xml
+ DESTINATION managementgen
+ COMPONENT all-source)
diff --git a/cpp/managementgen/qmf-gen b/cpp/managementgen/qmf-gen
index f2efa109f3..c6cfca5f83 100755
--- a/cpp/managementgen/qmf-gen
+++ b/cpp/managementgen/qmf-gen
@@ -33,6 +33,8 @@ usage = "usage: %prog [options] schema-document..."
parser = OptionParser(usage=usage)
parser.add_option("-o", "--outputdir", dest="outputdir", metavar="DIR", default="./",
help="Output directory")
+parser.add_option("-c", "--cmakelists", dest="cmakelists", metavar="FILE",
+ help="CMakeLists fragment")
parser.add_option("-m", "--makefile", dest="makefile", metavar="FILE",
help="Makefile fragment")
parser.add_option("-t", "--typefile", dest="typefile", metavar="FILE", default=defaultTypeFile,
@@ -72,3 +74,9 @@ if opts.makefile != None:
args["qpidbroker"] = opts.qpidbroker
args["genprefix"] = opts.genprefix
gen.makeSingleFile("Makefile.mk", opts.makefile, force=True, vars=args)
+
+if opts.cmakelists != None:
+ args = {}
+ args["qpidbroker"] = opts.qpidbroker
+ args["genprefix"] = opts.genprefix
+ gen.makeSingleFile("CMakeLists.cmake", opts.cmakelists, force=True, vars=args)
diff --git a/cpp/managementgen/qmfgen/generate.py b/cpp/managementgen/qmfgen/generate.py
index 35e222ebad..255d41ea0e 100755
--- a/cpp/managementgen/qmfgen/generate.py
+++ b/cpp/managementgen/qmfgen/generate.py
@@ -24,6 +24,7 @@ from errno import *
import os
import os.path
import filecmp
+import re
class Template:
"""
@@ -175,6 +176,81 @@ class Makefile:
return variables["qpidbroker"]
return False
+class CMakeLists(Makefile):
+ """ Object representing a makefile fragment """
+
+ # Regardless of what normalize() did, switch all the dir separators back
+ # to '/' - cmake expects that regardless of platform.
+ def unNormCase (self, path):
+ return re.sub("\\\\", "/", path)
+
+ def genGenSources (self, stream, variables):
+ mdir = self.unNormCase(variables["mgenDir"])
+ sdir = self.unNormCase(variables["specDir"])
+ stream.write (mdir + "/qmf-gen \n")
+ stream.write (" " + mdir + "/qmfgen/generate.py\n")
+ stream.write (" " + mdir + "/qmfgen/schema.py\n")
+ stream.write (" " + mdir + "/qmfgen/management-types.xml\n")
+ stream.write (" " + sdir + "/management-schema.xml\n")
+ first = True
+ for template in self.templateFiles:
+ if first:
+ first = False
+ stream.write (" ")
+ else:
+ stream.write ("\n ")
+ stream.write (mdir + "/qmfgen/templates/" + template)
+
+ def genGenCppFiles (self, stream, variables):
+ first = True
+ for file in self.filelists["cpp"]:
+ if first:
+ first = False
+ else:
+ stream.write (" \n ")
+ stream.write (self.unNormCase(file))
+
+ def genGenHFiles (self, stream, variables):
+ first = True
+ for file in self.filelists["h"]:
+ if first:
+ first = False
+ else:
+ stream.write (" \n ")
+ stream.write (self.unNormCase(file))
+
+ def genGeneratedFiles(self, stream, variables):
+ first = True
+ extensions = ("h", "cpp")
+ for ext in extensions:
+ for file in self.filelists[ext]:
+ if first:
+ first = False
+ else:
+ stream.write(" \n ")
+ if "genprefix" in variables:
+ prefix = variables["genprefix"]
+ if prefix != "":
+ stream.write(prefix + "/")
+ stream.write(self.unNormCase(file))
+
+ def genHeaderInstalls (self, stream, variables):
+ for package in self.packagelist:
+ stream.write("#Come back to this later...\n")
+ name = "_".join(package.split("/"))
+ stream.write("#" + name + "dir = $(includedir)/qmf/" + package + "\n")
+ stream.write("#dist_" + name + "_HEADERS = ")
+ first = True
+ for file in self.filelists["h"]:
+ file = self.unNormCase(file)
+ if file.find("gen/qmf/" + package) == 0:
+ if first:
+ first = False
+ else:
+ stream.write ("\n ")
+ stream.write("#" + file)
+ stream.write("\n\n")
+
class Generator:
"""
@@ -208,9 +284,10 @@ class Generator:
self.input = self.normalize (templateDir)
self.packagePath = self.dest
self.filelists = {}
- self.filelists["h"] = []
- self.filelists["cpp"] = []
- self.filelists["mk"] = []
+ self.filelists["h"] = []
+ self.filelists["cpp"] = []
+ self.filelists["mk"] = []
+ self.filelists["cmake"] = []
self.packagelist = []
self.templateFiles = []
self.variables = {}
@@ -354,7 +431,17 @@ class Generator:
def makeSingleFile (self, templateFile, target, force=False, vars=None):
""" Generate a single expanded template """
- makefile = Makefile (self.filelists, self.templateFiles, self.packagelist)
+ dot = templateFile.find(".")
+ if dot == -1:
+ raise ValueError ("Invalid template file name %s" % templateFile)
+ className = templateFile[0:dot]
+ if className == "Makefile":
+ classType = Makefile
+ elif className == "CMakeLists":
+ classType = CMakeLists
+ else:
+ raise ValueError ("Invalid class name %s" % className)
+ makefile = classType (self.filelists, self.templateFiles, self.packagelist)
template = Template (self.input + templateFile, self)
if vars:
for arg in vars:
diff --git a/cpp/managementgen/qmfgen/templates/CMakeLists.cmake b/cpp/managementgen/qmfgen/templates/CMakeLists.cmake
new file mode 100644
index 0000000000..a7268ad206
--- /dev/null
+++ b/cpp/managementgen/qmfgen/templates/CMakeLists.cmake
@@ -0,0 +1,39 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+/*MGEN:commentPrefix=#*/
+/*MGEN:Root.Disclaimer*/
+/*MGEN:IF(CMakeLists.QpidBroker)*/
+/*MGEN:mgenDir=${mgen_dir}*/
+/*MGEN:specDir=${qpidc_SOURCE_DIR}/../specs*/
+
+set(mgen_generator /*MGEN:CMakeLists.GenSources*/)
+
+set(mgen_broker_cpp /*MGEN:CMakeLists.GenCppFiles*/)
+
+# Header file install rules.
+#/*MGEN:CMakeLists.HeaderInstalls*/
+#if GENERATE
+#$(srcdir)/managementgen.mk: $(mgen_generator)
+# $(mgen_cmd)
+#
+#$(mgen_generator):
+#endif
+#/*MGEN:ENDIF*/
+
+set(qmfgen_sources /*MGEN:CMakeLists.GeneratedFiles*/)