doctest

FORK: The fastest feature-rich C++11/14/17/20 single-header testing framework
git clone https://git.neptards.moe/neptards/doctest.git
Log | Files | Refs | README

update_stuff.py (1559B)


      1 #!/usr/bin/python2.7
      2 
      3 import os
      4 import fileinput
      5 
      6 # the version of the release
      7 with open("version.txt") as f: version = f.read()
      8 
      9 def getVersionTuple(v):
     10     return tuple(map(int, (v.split("."))))
     11 
     12 version_major = str(getVersionTuple(version)[0])
     13 version_minor = str(getVersionTuple(version)[1])
     14 version_patch = str(getVersionTuple(version)[2])
     15 
     16 # update version in the header file
     17 print("updating the version in the header file")
     18 doctest_contents = ""
     19 for line in fileinput.input(["../doctest/parts/doctest_fwd.h"]):
     20     if line.startswith("#define DOCTEST_VERSION_MAJOR "):
     21         doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n"
     22     elif line.startswith("#define DOCTEST_VERSION_MINOR "):
     23         doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n"
     24     elif line.startswith("#define DOCTEST_VERSION_PATCH "):
     25         doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n"
     26     else:
     27         doctest_contents += line
     28 
     29 readme = open("../doctest/parts/doctest_fwd.h", "w")
     30 readme.write(doctest_contents)
     31 readme.close()
     32 
     33 # update meson file with version
     34 meson_contents = ""
     35 for line in fileinput.input(["../meson.build"]):
     36     if line.startswith("project('doctest'"):
     37         meson_contents += "project('doctest', ['cpp'], version: '" + version + "')\n"
     38     else:
     39         meson_contents += line
     40 
     41 meson = open("../meson.build", "w")
     42 meson.write(meson_contents)
     43 meson.close()
     44 
     45 # run generate_html.py
     46 print("generating html documentation from markdown")
     47 os.system("python generate_html.py")