Go to the documentation of this file.00001
00002
00003 """
00004
00005 Copyright (c) 2016, Meissner Pascal, Schleicher Ralf
00006 All rights reserved.
00007
00008 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00009
00010 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00011
00012 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
00013
00014 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
00015
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00017
00018 """
00019
00020 import os
00021 import shutil
00022
00023 def main():
00024 '''
00025 creates the cpp object from xmlschema
00026 '''
00027 ros_env = os.environ['ROS_DISTRO'].lower()
00028
00029 basepath = os.path.abspath(os.path.curdir)
00030 projectName = os.path.basename(basepath)
00031 xmlschemapath = os.path.join(basepath, "xsd")
00032 xmlschemagenpath = os.path.join(basepath, "xsd_gen")
00033 xmlschemagenprojectnamepath = os.path.join(xmlschemagenpath, projectName)
00034
00035 if not os.path.exists(xmlschemapath):
00036 return
00037
00038 if os.path.exists(xmlschemagenpath):
00039 shutil.rmtree(xmlschemagenpath)
00040 os.mkdir(xmlschemagenpath)
00041 os.mkdir(xmlschemagenprojectnamepath)
00042
00043 os.chdir(xmlschemagenprojectnamepath)
00044 for root, dirs, files in os.walk(xmlschemapath):
00045 for file in files:
00046 f = os.path.splitext(file)
00047 if f[1] == ".xsd":
00048 if ros_env == "indigo":
00049 os.system("xsd cxx-tree --std c++11 --guard-prefix %s --cxx-suffix .cpp --hxx-suffix .h --polymorphic-type-all %s" % (f[0], os.path.join(root, file)))
00050 else:
00051 os.system("xsdcxx cxx-tree --std c++11 --guard-prefix %s --cxx-suffix .cpp --hxx-suffix .h --polymorphic-type-all %s" % (f[0], os.path.join(root, file)))
00052
00053 if __name__ == "__main__":
00054 main()