diff options
| author | Stephen D. Huston <shuston@apache.org> | 2009-04-23 22:59:12 +0000 |
|---|---|---|
| committer | Stephen D. Huston <shuston@apache.org> | 2009-04-23 22:59:12 +0000 |
| commit | 3c95f9a289fee6a3b43608ec2ac95f841c43e3ff (patch) | |
| tree | 5860c778c3e2b2c6c23b49887ae870cb5d4558ff /cpp/managementgen/qmfgen | |
| parent | 7db52d95099fb7ae237277f12e4e368cf643f174 (diff) | |
| download | qpid-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/qmfgen')
| -rwxr-xr-x | cpp/managementgen/qmfgen/generate.py | 95 | ||||
| -rw-r--r-- | cpp/managementgen/qmfgen/templates/CMakeLists.cmake | 39 |
2 files changed, 130 insertions, 4 deletions
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*/)
|
