devel-versioning.rst
changeset 1115 abbbaffa9c9f
parent 1114 9131b58f51c4
child 1334 9bf0d5a1f0cf
equal deleted inserted replaced
1114:9131b58f51c4 1115:abbbaffa9c9f
   398 It is essential to make file format or protocol extensible. This can be achieved
   398 It is essential to make file format or protocol extensible. This can be achieved
   399 by:
   399 by:
   400 
   400 
   401  * Reserving some possible names/prefixes for future use.
   401  * Reserving some possible names/prefixes for future use.
   402  * Generalising file format or protocol to envelop more cases.
   402  * Generalising file format or protocol to envelop more cases.
       
   403 
       
   404 Extracting version from VCS.
       
   405 ============================
       
   406 
       
   407 Including version in sources.
       
   408 =============================
       
   409 
       
   410 Don't use any ``$REVISION`` like keywords (usual practice in CVS, SVN)!
       
   411 
       
   412 Use sed, awk, M4 or any other preprocessor for non-compiled or non-preprocessed
       
   413 files (like .lisp, .py, .java files)::
       
   414 
       
   415   $ cat my-version.el.in
       
   416   (defvar my-major-version @VMAJOR@
       
   417     "Major version.")
       
   418   (defvar my-major-version @VMAJOR@
       
   419     "Major version.")
       
   420   (provide 'my-version)
       
   421 
       
   422   $ cat Makefile
       
   423   %: %.in
       
   424       sed -e 's|@VMAJOR@|$(VMAJOR)|' -e 's|@VMINOR@|$(VMINOR)|' <$< >$@
       
   425 
       
   426 Pass version component to preprocessed file (like .c, .cxx files) through
       
   427 preprocessor::
       
   428 
       
   429   $ cat my-version.c
       
   430   int get_major_version() { return VMAJOR; }
       
   431   int get_minor_version() { return VMINOR; }
       
   432 
       
   433   $ cat Makefile
       
   434   %.o: %.c
       
   435       $(CC) -DVMAJOR=$(VMAJOR) -DVMINOR=$(VMINOR) -o $@ $<
   403 
   436 
   404 Reference.
   437 Reference.
   405 ==========
   438 ==========
   406 
   439 
   407   http://semver.org/
   440   http://semver.org/