Commits

Virgil Dupras committed a6e2ca6

Add a comment to generated units indicating xibless version and generation timestamp.

  • Participants
  • Parent commits 3b46313

Comments (0)

Files changed (3)

 from setuptools import setup
+from xibless import __version__
 
 CLASSIFIERS = [
     'Development Status :: 3 - Alpha',
 ]
 
 LONG_DESC = open('README', 'rt').read() + '\n\n' + open('CHANGES', 'rt').read()
-VERSION = '0.4.1'
 
 setup(
     name='xibless',
-    version=VERSION,
+    version=__version__,
     author='Virgil Dupras',
     author_email='hsoft@hardcoded.net',
     packages=['xibless'],
     },
     command_options={
        'build_sphinx': {
-           'version': ('setup.py', VERSION),
-           'release': ('setup.py', VERSION)}
+           'version': ('setup.py', __version__),
+           'release': ('setup.py', __version__)}
     },
 )

File xibless/__init__.py

 
 from .gen import generate, runUI
 
+__version__ = '0.4.1'
+
 def main():
     parser = ArgumentParser()
     parser.add_argument('command', choices=['compile', 'run'],

File xibless/gen.py

 import tempfile
 import shutil
 from subprocess import Popen
+from datetime import datetime
 
 from . import globalvars
 from .base import CodeTemplate, GeneratedItem, owner, NSApp, const, defaults
         with open(file, "r") as fh:
             exec(fh.read()+"\n", globals, locals)
 
+AUTOGEN_COMMENT = "/* This unit was automatically generated by xibless v{version} on {timestamp}. */\n\n" 
+
 HEADER_TMPL = """
 #import "XiblessSupport.h"
 $ownerimport$
     funcsig = "{}* create{}({})".format(result.OBJC_CLASS, dest_basename, ownerdecl)
     tmpl.funcsig = funcsig
     tmpl.contents = '\n'.join(codePieces)
+    from xibless import __version__ # We have to import it here to avoid circular references
+    autogen_comment = AUTOGEN_COMMENT.format(version=__version__, timestamp=datetime.now().strftime('%c'))
     with open(dest, 'wt') as fp:
+        fp.write(autogen_comment)
         fp.write(tidyCode(tmpl.render()))
     if dest_header:
         tmpl = CodeTemplate(HEADER_TMPL)
         tmpl.funcsig = funcsig
         tmpl.ownerimport = ownerimport
         with open(dest_header, 'wt') as fp:
+            fp.write(autogen_comment)
             fp.write(tidyCode(tmpl.render()))
     copy_support_unit(op.dirname(dest))