File indexing completed on 2024-12-01 13:02:58

0001 #!/usr/bin/env python3
0002 # -*- coding: utf-8 -*-
0003 #     Copyright 2009-2014 Simon Edwards <simon@simonzone.com>
0004 #     Copyright 2015 Scott Kitterman <scott@kitterman.com>
0005 #
0006 # This program is free software; you can redistribute it and/or modify
0007 # it under the terms of the GNU General Public License as published by
0008 # the Free Software Foundation; either version 2 of the License, or
0009 # (at your option) any later version.
0010 #
0011 # This program is distributed in the hope that it will be useful,
0012 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 # GNU General Public License for more details.
0015 #
0016 # You should have received a copy of the GNU General Public License
0017 # along with this program; if not, write to the
0018 # Free Software Foundation, Inc.,
0019 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0020 
0021 import argparse
0022 import configparser
0023 import inspect
0024 import kbindinggenerator.toolkit as toolkit
0025 import kbindinggenerator.qtkde5macros as qtkde5macros
0026 import kbindinggenerator.sipsymboldata as sipsymboldata
0027 import os
0028 import re
0029 
0030 kauth = None
0031 kitemmodels = None
0032 kitemviews = None
0033 karchive = None
0034 kplotting = None
0035 solid = None
0036 kcoreaddons = None
0037 sonnet = None
0038 kguiaddons = None
0039 kwidgetsaddons = None
0040 
0041 def _readConfiguration(configfile):
0042 
0043     settings = configparser.ConfigParser()
0044     settings._interpolation = configparser.ExtendedInterpolation()
0045     settings.read(configfile)
0046     
0047     return(settings)
0048 
0049 def _writeConfiguration(settings, configfile):
0050     cfgfile = open(configfile,'w')
0051     settings.write(cfgfile)
0052     cfgfile.close()
0053 
0054 def _setSettings(source_dir, build_dir, settings):
0055     outputBaseDirectory = os.path.join(source_dir,
0056                                        settings.get('kf5.config', 'outputBaseDirectory'))
0057     cmakelistBaseDirectory = os.path.join(source_dir,
0058                                           settings.get('kf5.config', 'cmakelistBaseDirectory'))
0059     kdelibsBuildDirectory = os.path.join(build_dir,
0060                                          settings.get('kf5.config', 'kdelibsBuildDirectory'))
0061     sipImportDir = os.path.join(source_dir,
0062                                 settings.get('kf5.config', 'sipImportDir'))
0063     sipImportDirs = [ str(sipImportDir), str(outputBaseDirectory) + '/sip']
0064     return(outputBaseDirectory, cmakelistBaseDirectory, kdelibsBuildDirectory,
0065            sipImportDir, sipImportDirs)
0066 
0067 def _getConfiguration(configfile):
0068     settings = _readConfiguration(configfile)
0069     outputBaseDirectory, cmakelistBaseDirectory, kdelibsBuildDirectory, \
0070         sipImportDir, sipImportDirs =_setSettings(settings)
0071     return(outputBaseDirectory, cmakelistBaseDirectory, kdelibsBuildDirectory,
0072         sipImportDir, sipImportDirs)
0073 
0074 def _printConfiguration(outputBaseDirectory, cmakelistBaseDirectory,
0075                         kdelibsBuildDirectory, sipImportDir, sipImportDirs):
0076     print('Current values for configuration options:')
0077     print('outputBaseDirectory = {0}'.format(outputBaseDirectory))
0078     print('cmakelistBaseDirectory = {0}'.format(cmakelistBaseDirectory))
0079     print('kdelibsBuildDirectory = {0}'.format(kdelibsBuildDirectory))
0080     print('sipImportDir = {0}'.format(sipImportDir))
0081     print('sipImportDirs = {0}'.format(sipImportDirs))
0082 
0083 def _setupAll(outputBaseDirectory, cmakelistBaseDirectory, kdelibsBuildDirectory,
0084               sipImportDir, sipImportDirs):
0085 
0086     global kauth
0087     global kitemmodels
0088     global kitemviews
0089     global karchive
0090     global kplotting
0091     global solid
0092     global kcoreaddons
0093     global sonnet
0094     global kguiaddons
0095     global kwidgetsaddons
0096     ###########################################################################
0097     kauth = toolkit.ModuleGenerator(
0098         module="PyKDE5.kauth",
0099         outputDirectory=os.path.join(outputBaseDirectory, "sip/kauth"),
0100         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/kauth"),
0101         mainDocs=os.path.join(cmakelistBaseDirectory,"kauth/Mainpage.dox"),
0102         
0103         # .h file extraction
0104         cmakelists=os.path.join(cmakelistBaseDirectory,"kauth/CMakeLists.txt"),
0105         
0106         ignoreHeaders="""kauth_export.h kauth_version.h kauth.h""".split(" "),
0107         
0108         #noUpdateSip=["typedefs.sip"],
0109         
0110         # Cpp parsing    
0111         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0112         macros=qtkde5macros.QtMacros(),
0113         bareMacros=qtkde5macros.QtBareMacros(["KAUTH_EXPORT"]),
0114         
0115         # Sip generation
0116         sipImportDirs=[sipImportDir],
0117         sipImports=["QtCore/QtCoremod.sip","QtGui/QtGuimod.sip","QtNetwork/QtNetworkmod.sip"],
0118         copyrightNotice=qtkde5macros.copyrightNotice(),
0119         exportMacros=["KAUTH_EXPORT"],
0120         ignoreBases=[],
0121         
0122         annotationRules=qtkde5macros.annotationRules()
0123         )
0124 
0125     ###########################################################################
0126     kitemmodels = toolkit.ModuleGenerator(
0127         module="PyKDE5.kitemmodels",
0128         outputDirectory=os.path.join(outputBaseDirectory, "sip/kitemmodels"),
0129         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/kitemmodels"),
0130         # mainDocs=os.path.join(cmakelistBaseDirectory,"kitemmodels/Mainpage.dox"),
0131 
0132         # .h file extraction
0133         cmakelists=os.path.join(cmakelistBaseDirectory,"kitemmodels/CMakeLists.txt"),
0134 
0135         ignoreHeaders="""kitemmodels_export.h kitemmodels_version.h kitemmodels.h""".split(" "),
0136 
0137         #noUpdateSip=["typedefs.sip"],
0138 
0139         # Cpp parsing
0140         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0141         macros=qtkde5macros.QtMacros(),
0142         bareMacros=qtkde5macros.QtBareMacros(["KITEMMODELS_EXPORT"]),
0143 
0144         # Sip generation
0145         sipImportDirs=[sipImportDir],
0146         sipImports=["QtCore/QtCoremod.sip"],
0147         copyrightNotice=qtkde5macros.copyrightNotice(),
0148         exportMacros=["KITEMMODELS_EXPORT"],
0149         ignoreBases=[],
0150 
0151         annotationRules=qtkde5macros.annotationRules()
0152         )
0153 
0154     ###########################################################################
0155     kitemviews = toolkit.ModuleGenerator(
0156         module="PyKDE5.kitemviews",
0157         outputDirectory=os.path.join(outputBaseDirectory, "sip/kitemviews"),
0158         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/kitemviews"),
0159         # mainDocs=os.path.join(cmakelistBaseDirectory,"kitemviews/Mainpage.dox"),
0160 
0161         # .h file extraction
0162         cmakelists=os.path.join(cmakelistBaseDirectory,"kitemviews/CMakeLists.txt"),
0163 
0164         ignoreHeaders="""kitemviews_export.h kitemviews_version.h kitemviews.h""".split(" "),
0165 
0166         #noUpdateSip=["typedefs.sip"],
0167 
0168         preprocessorValues={"KDE_NO_DEPRECATED": "1", "KITEMVIEWS_NO_DEPRECATED": "1"},
0169 
0170         # Cpp parsing
0171         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0172         macros=qtkde5macros.QtMacros(),
0173         bareMacros=qtkde5macros.QtBareMacros(["KITEMVIEWS_EXPORT"]),
0174 
0175         # Sip generation
0176         sipImportDirs=[sipImportDir],
0177         sipImports=["QtCore/QtCoremod.sip","QtGui/QtGuimod.sip","QtWidgets/QtWidgetsmod.sip"],
0178         copyrightNotice=qtkde5macros.copyrightNotice(),
0179         exportMacros=["KITEMVIEWS_EXPORT"],
0180         ignoreBases=[],
0181 
0182         annotationRules=qtkde5macros.annotationRules()
0183         )
0184 
0185     ###########################################################################
0186     karchive = toolkit.ModuleGenerator(
0187         module="PyKDE5.karchive",
0188         outputDirectory=os.path.join(outputBaseDirectory, "sip/karchive"),
0189         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/karchive"),
0190         # mainDocs=os.path.join(cmakelistBaseDirectory,"karchive/Mainpage.dox"),
0191 
0192         # .h file extraction
0193         cmakelists=os.path.join(cmakelistBaseDirectory,"karchive/CMakeLists.txt"),
0194 
0195         ignoreHeaders="""karchive_export.h karchive_version.h""".split(" "),
0196 
0197         #noUpdateSip=["typedefs.sip"],
0198 
0199         preprocessorValues={"KDE_NO_DEPRECATED": "1", "KARCHIVE_NO_DEPRECATED": "1"},
0200 
0201         # Cpp parsing
0202         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0203         macros=qtkde5macros.QtMacros(),
0204         bareMacros=qtkde5macros.QtBareMacros(["KARCHIVE_EXPORT"]),
0205 
0206         # Sip generation
0207         sipImportDirs=sipImportDirs,
0208         sipImports=["typedefs.sip", "QtCore/QtCoremod.sip"],
0209         copyrightNotice=qtkde5macros.copyrightNotice(),
0210         exportMacros=["KARCHIVE_EXPORT"],
0211         ignoreBases=[],
0212 
0213         annotationRules=qtkde5macros.annotationRules()
0214         )
0215 
0216     ###########################################################################
0217     kplotting = toolkit.ModuleGenerator(
0218         module="PyKDE5.kplotting",
0219         outputDirectory=os.path.join(outputBaseDirectory, "sip/kplotting"),
0220         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/kplotting"),
0221         # mainDocs=os.path.join(cmakelistBaseDirectory,"kplotting/Mainpage.dox"),
0222 
0223         # .h file extraction
0224         cmakelists=os.path.join(cmakelistBaseDirectory,"kplotting/CMakeLists.txt"),
0225 
0226         ignoreHeaders="""kplotting_export.h kplotting_version.h""".split(" "),
0227 
0228         #noUpdateSip=["typedefs.sip"],
0229 
0230         preprocessorValues={"KDE_NO_DEPRECATED": "1"},
0231 
0232         # Cpp parsing
0233         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0234         macros=qtkde5macros.QtMacros(),
0235         bareMacros=qtkde5macros.QtBareMacros(["KPLOTTING_EXPORT"]),
0236 
0237         # Sip generation
0238         sipImportDirs=sipImportDirs,
0239         sipImports=["typedefs.sip", "QtCore/QtCoremod.sip", "QtGui/QtGuimod.sip", "QtWidgets/QtWidgetsmod.sip"],
0240         copyrightNotice=qtkde5macros.copyrightNotice(),
0241         exportMacros=["KPLOTTING_EXPORT"],
0242         ignoreBases=[],
0243 
0244         annotationRules=qtkde5macros.annotationRules()
0245         )
0246 
0247     ###########################################################################
0248     solid = toolkit.ModuleGenerator(
0249         module="PyKDE5.solid",
0250         outputDirectory=os.path.join(outputBaseDirectory, "sip/solid"),
0251         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/solid"),
0252         # mainDocs=os.path.join(cmakelistBaseDirectory,"solid/Mainpage.dox"),
0253 
0254         # .h file extraction
0255         cmakelists=os.path.join(cmakelistBaseDirectory,"solid/CMakeLists.txt"),
0256 
0257         ignoreHeaders="""solid_export.h solid_version.h kuser.h acpluggedjob.h inhibition.h inhibitionjob.h job.h power.h requeststatejob.h statesjob.h""".split(" "),
0258 
0259         #noUpdateSip=["typedefs.sip"],
0260 
0261         preprocessorValues={"KDE_NO_DEPRECATED": "1"},
0262 
0263         # Cpp parsing
0264         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0265         macros=qtkde5macros.QtMacros(),
0266         bareMacros=qtkde5macros.QtBareMacros(["SOLID_EXPORT", "SOLID_DEPRECATED"]),
0267 
0268         # Sip generation
0269         sipImportDirs=sipImportDirs,
0270         sipImports=["typedefs.sip", "QtCore/QtCoremod.sip"],
0271         copyrightNotice=qtkde5macros.copyrightNotice(),
0272         exportMacros=["SOLID_EXPORT"],
0273         ignoreBases=[],
0274 
0275         annotationRules=qtkde5macros.annotationRules()
0276         )
0277 
0278     ###########################################################################
0279     kcoreaddons = toolkit.ModuleGenerator(
0280         module="PyKDE5.kcoreaddons",
0281         outputDirectory=os.path.join(outputBaseDirectory, "sip/kcoreaddons"),
0282         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/kcoreaddons"),
0283         # mainDocs=os.path.join(cmakelistBaseDirectory,"kcoreaddons/Mainpage.dox"),
0284 
0285         # .h file extraction
0286         cmakelists=os.path.join(cmakelistBaseDirectory,"kcoreaddons/CMakeLists.txt"),
0287         cmakeVariables = {"cmake_current_binary_dir": [kdelibsBuildDirectory + "/kcoreaddons"]},
0288 
0289         ignoreHeaders="""kcoreaddons_export.h kcoreaddons_version.h""".split(" "),
0290 
0291         #noUpdateSip=["typedefs.sip"],
0292 
0293         preprocessorValues={"KDE_NO_DEPRECATED": "1", "KCOREADDONS_NO_DEPRECATED": "1"},
0294 
0295         # Cpp parsing
0296         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0297         macros=qtkde5macros.QtMacros(),
0298         bareMacros=qtkde5macros.QtBareMacros(["KCOREADDONS_EXPORT"]),
0299 
0300         # Sip generation
0301         sipImportDirs=sipImportDirs,
0302         sipImports=["typedefs.sip", "QtCore/QtCoremod.sip"],
0303         copyrightNotice=qtkde5macros.copyrightNotice(),
0304         exportMacros=["KCOREADDONS_EXPORT"],
0305         ignoreBases=[],
0306 
0307         annotationRules=qtkde5macros.annotationRules()
0308         )
0309 
0310     ###########################################################################
0311     sonnet = toolkit.ModuleGenerator(
0312         module="PyKDE5.sonnet",
0313         outputDirectory=os.path.join(outputBaseDirectory, "sip/sonnet"),
0314         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/sonnet"),
0315         # mainDocs=os.path.join(cmakelistBaseDirectory,"sonnet/Mainpage.dox"),
0316 
0317         # .h file extraction
0318         cmakelists=os.path.join(cmakelistBaseDirectory,"sonnet/CMakeLists.txt"),
0319 
0320         ignoreHeaders="""sonnetui_export.h sonnet_export.h sonnet_version.h""".split(" "),
0321 
0322         #noUpdateSip=["typedefs.sip"],
0323 
0324         preprocessorValues={"KDE_NO_DEPRECATED": "1"},
0325 
0326         # Cpp parsing
0327         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0328         macros=qtkde5macros.QtMacros(),
0329         bareMacros=qtkde5macros.QtBareMacros(["SONNETCORE_EXPORT","SONNETUI_EXPORT"]),
0330 
0331         # Sip generation
0332         sipImportDirs=sipImportDirs,
0333         sipImports=["typedefs.sip", "QtCore/QtCoremod.sip", "QtGui/QtGuimod.sip", "QtWidgets/QtWidgetsmod.sip"],
0334         copyrightNotice=qtkde5macros.copyrightNotice(),
0335         exportMacros=["SONNET_EXPORT","SONNETUI_EXPORT","SONNETCORE_EXPORT"],
0336         ignoreBases=[],
0337 
0338         annotationRules=qtkde5macros.annotationRules()
0339         )
0340 
0341     ###########################################################################
0342     kguiaddons = toolkit.ModuleGenerator(
0343         module="PyKDE5.kguiaddons",
0344         outputDirectory=os.path.join(outputBaseDirectory, "sip/kguiaddons"),
0345         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/kguiaddons"),
0346         # mainDocs=os.path.join(cmakelistBaseDirectory,"kguiaddons/Mainpage.dox"),
0347 
0348         # .h file extraction
0349         cmakelists=os.path.join(cmakelistBaseDirectory,"kguiaddons/CMakeLists.txt"),
0350         cmakeVariables = {"cmake_current_binary_dir": [kdelibsBuildDirectory + "/kguiaddons"]},
0351 
0352         ignoreHeaders="""kguiaddons_export.h kguiaddons_version.h""".split(" "),
0353 
0354         #noUpdateSip=["typedefs.sip"],
0355 
0356         preprocessorValues={"KDE_NO_DEPRECATED": "1"},
0357 
0358         # Cpp parsing
0359         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0360         macros=qtkde5macros.QtMacros(),
0361         bareMacros=qtkde5macros.QtBareMacros(["KGUIADDONS_EXPORT"]),
0362 
0363         # Sip generation
0364         sipImportDirs=sipImportDirs,
0365         sipImports=["typedefs.sip", "QtCore/QtCoremod.sip", "QtGui/QtGuimod.sip"],
0366         copyrightNotice=qtkde5macros.copyrightNotice(),
0367         exportMacros=["KGUIADDONS_EXPORT"],
0368         ignoreBases=[],
0369 
0370         annotationRules=qtkde5macros.annotationRules()
0371         )
0372 
0373     ###########################################################################
0374     kwidgetsaddons = toolkit.ModuleGenerator(
0375         module="PyKDE5.kwidgetsaddons",
0376         outputDirectory=os.path.join(outputBaseDirectory, "sip/kwidgetsaddons"),
0377         docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/html/kwidgetsaddons"),
0378         # mainDocs=os.path.join(cmakelistBaseDirectory,"kwidgetsaddons/Mainpage.dox"),
0379 
0380         # .h file extraction
0381         cmakelists=os.path.join(cmakelistBaseDirectory,"kwidgetsaddons/CMakeLists.txt"),
0382         cmakeVariables = {"cmake_current_binary_dir": [kdelibsBuildDirectory + "/kwidgetsaddons"]},
0383 
0384         ignoreHeaders="""kwidgetsaddons_export.h kwidgetsaddons_version.h""".split(" "),
0385 
0386         #noUpdateSip=["typedefs.sip"],
0387 
0388         preprocessorValues={"KDE_NO_DEPRECATED": "1", "KWIDGETSADDONS_NO_DEPRECATED": "1"},
0389 
0390         # Cpp parsing
0391         preprocessSubstitutionMacros=qtkde5macros.QtPreprocessSubstitutionMacros(),
0392         macros=qtkde5macros.QtMacros(),
0393         bareMacros=qtkde5macros.QtBareMacros(["KWIDGETSADDONS_EXPORT"]),
0394 
0395         # Sip generation
0396         sipImportDirs=sipImportDirs,
0397         sipImports=["typedefs.sip", "QtCore/QtCoremod.sip", "QtWidgets/QtWidgetsmod.sip"],
0398         copyrightNotice=qtkde5macros.copyrightNotice(),
0399         exportMacros=["KWIDGETSADDONS_EXPORT"],
0400         ignoreBases=[],
0401 
0402         annotationRules=qtkde5macros.annotationRules()
0403         )
0404 
0405 def updateSIP():
0406     global kauth
0407     global kitemmodels
0408     global kitemviews
0409     global karchive
0410     global kplotting
0411     global solid
0412     global kcoreaddons
0413     global sonnet
0414     global kguiaddons
0415     global kwidgetsaddons
0416     kauth.run()
0417     kitemmodels.run()
0418     kitemviews.run()
0419     karchive.run()
0420     kplotting.run()
0421     solid.run()
0422     kcoreaddons.run()
0423     sonnet.run()
0424 
0425     # kcodecs N/A - use Python's libraries for this functionality.
0426     # kwindowsystem N/A
0427 
0428     kguiaddons.run()
0429     kwidgetsaddons.run()
0430 
0431     # TODO
0432     # kconfig
0433     # kjs
0434 
0435 def updateDocs():
0436     global kauth
0437     global kitemmodels
0438     global kitemviews
0439     global karchive
0440     global kplotting
0441     global solid
0442     global kcoreaddons
0443     global sonnet
0444     global kguiaddons
0445     global kwidgetsaddons
0446     classNames = []
0447     nsNames = []
0448 
0449     def UpdateClassNamespaceList(moduleName,sipScopes):
0450         nsNames.append( (moduleName,'global', 'global') )
0451         def ExtractClassNamespace(scope):
0452             for item in scope:
0453                 if isinstance(item,sipsymboldata.SymbolData.SipClass):
0454                     classNames.append( (moduleName, item.fqPythonName(), item.fqPythonName()) )
0455                     ExtractClassNamespace(item)
0456                 elif isinstance(item,sipsymboldata.SymbolData.Namespace):
0457                     nsTuple = (moduleName,item.fqPythonName(),item.fqPythonName())
0458                     if nsTuple not in nsNames:
0459                         nsNames.append( nsTuple )
0460                     ExtractClassNamespace(item)
0461         for scope in sipScopes:
0462             ExtractClassNamespace(scope)
0463 
0464     # UpdateClassNamespaceList('kauth',kauth.docs())
0465     UpdateClassNamespaceList('kitemmodels',kitemmodels.docs())
0466     UpdateClassNamespaceList('kitemviews',kitemviews.docs())
0467     UpdateClassNamespaceList('karchive',karchive.docs())
0468     UpdateClassNamespaceList('kplotting',kplotting.docs())
0469     UpdateClassNamespaceList('solid',solid.docs())
0470     UpdateClassNamespaceList('kcoreaddons',kcoreaddons.docs())
0471     UpdateClassNamespaceList('sonnet',sonnet.docs())
0472     UpdateClassNamespaceList('kguiaddons',kguiaddons.docs())
0473     UpdateClassNamespaceList('kwidgetsaddons',kwidgetsaddons.docs())
0474 
0475     print("Writing all classes index:")
0476     toolkit.ModuleGenerator.WriteAllClasses(os.path.join(outputBaseDirectory,"docs/html"),nsNames,classNames)
0477     print("Done")
0478     
0479 ###########################################################################
0480 def main():
0481     """
0482     Process kf5 source to generate Python bindings.
0483 
0484     The current CONFIGFILE defaults are:
0485 
0486         [kf5.config]
0487         source = /source
0488         build = /build
0489         ...
0490         outputbasedirectory = ${kf5.config:source}/pykde5
0491             
0492     The output is a set of files in the outputbasedirectory directory.
0493     """
0494     configfile = os.path.join(os.path.dirname(__file__), 'config')
0495     parser = argparse.ArgumentParser(epilog = inspect.getdoc(main),
0496                                      formatter_class=argparse.RawDescriptionHelpFormatter)
0497     parser.add_argument('-l', '--listopts', default=False, action='store_true', help='list stored configuration option values and exit')
0498     parser.add_argument('-f', '--configfile', default=configfile, action='store', help='path to alternate configuration file to use')
0499     parser.add_argument('-w', '--writeopt', default=[], action='append', help='change config file value using item=value syntax - add multiple times to change multiple values')
0500     args = parser.parse_args()
0501     #
0502     # The source directory is located relative to the specified configfile,
0503     # and the build directory is "here".
0504     #
0505     source_dir = os.path.dirname(os.path.dirname(os.path.realpath(args.configfile)))
0506     build_dir = os.getcwd()
0507     #
0508     # Read the default settings.
0509     #
0510     settings = _readConfiguration(args.configfile)
0511     outputBaseDirectory, cmakelistBaseDirectory, kdelibsBuildDirectory, sipImportDir, \
0512         sipImportDirs =_setSettings(source_dir, build_dir, settings)
0513     if args.listopts:
0514         _printConfiguration(outputBaseDirectory, cmakelistBaseDirectory,
0515                             kdelibsBuildDirectory, sipImportDir, sipImportDirs)
0516         exit(0)
0517     if args.writeopt:
0518         for arg in args.writeopt:
0519             try:
0520                 item, value = arg.split('=')
0521             except ValueError as e:
0522                 print("Error: item and value must be separated by '='. {0}".format(e))
0523                 exit(1)
0524             item = item.strip()
0525             value = value.strip()
0526             oldvalue = settings.get('kf5.config', item)
0527             print("Changing {0} from {1} to {2}".format(item, oldvalue, value))
0528             settings.set('kf5.config', item, value)
0529             _setSettings(source_dir, build_dir, settings)
0530             _writeConfiguration(settings, configfile)
0531         exit(0)
0532         
0533     _setupAll(outputBaseDirectory, cmakelistBaseDirectory, kdelibsBuildDirectory,
0534               sipImportDir, sipImportDirs)
0535     #print(repr(kitemmodels.extractCmakeListsHeaders()))
0536     updateSIP()
0537     updateDocs()
0538 
0539 if __name__=="__main__":
0540     main()