blob: 41a1f6296f576368c1a8be7de0830a5c19f2d6a3 [file] [log] [blame]
hardlyb1e7e142014-08-06 00:43:51 +03001#!/usr/bin/python2.7
2
3import os
hardlyb1e7e142014-08-06 00:43:51 +03004import fileinput
hardlyb1e7e142014-08-06 00:43:51 +03005
onqtame6d0d512016-04-27 23:23:16 +03006# the version of the release
onqtame8bdda42016-06-01 15:12:36 +03007with open("version.txt") as f: version = f.read()
onqtame6d0d512016-04-27 23:23:16 +03008
onqtame8bdda42016-06-01 15:12:36 +03009def getVersionTuple(v):
10 return tuple(map(int, (v.split("."))))
11
12version_major = str(getVersionTuple(version)[0])
13version_minor = str(getVersionTuple(version)[1])
14version_patch = str(getVersionTuple(version)[2])
onqtame6d0d512016-04-27 23:23:16 +030015
16# update version in the header file
onqtame8bdda42016-06-01 15:12:36 +030017print("updating the version in the header file")
onqtame6d0d512016-04-27 23:23:16 +030018doctest_contents = ""
onqtame8bdda42016-06-01 15:12:36 +030019for line in fileinput.input(["../doctest/parts/doctest_fwd.h"]):
onqtamf3a680f2016-04-30 03:15:07 +030020 if line.startswith("#define DOCTEST_VERSION_MAJOR "):
onqtame6d0d512016-04-27 23:23:16 +030021 doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030022 elif line.startswith("#define DOCTEST_VERSION_MINOR "):
onqtame6d0d512016-04-27 23:23:16 +030023 doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030024 elif line.startswith("#define DOCTEST_VERSION_PATCH "):
onqtame6d0d512016-04-27 23:23:16 +030025 doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n"
onqtamd1737e42016-08-01 19:05:07 +030026 elif line.startswith("#define DOCTEST_VERSION_STR "):
27 doctest_contents += "#define DOCTEST_VERSION_STR \"" + version + "\"\n"
onqtame6d0d512016-04-27 23:23:16 +030028 else:
29 doctest_contents += line
30
onqtame8bdda42016-06-01 15:12:36 +030031readme = open("../doctest/parts/doctest_fwd.h", "w")
onqtame6d0d512016-04-27 23:23:16 +030032readme.write(doctest_contents)
33readme.close()
34
onqtam43271a62019-05-06 11:29:37 +030035# update meson file with version
36meson_contents = ""
37for line in fileinput.input(["../meson.build"]):
38 if line.startswith("project('doctest'"):
39 meson_contents += "project('doctest', ['cpp'], version: '" + version + "', meson_version:'>=0.50')\n"
40 else:
41 meson_contents += line
42
43meson = open("../meson.build", "w")
44meson.write(meson_contents)
45meson.close()
46
hardlyb1e7e142014-08-06 00:43:51 +030047# run generate_html.py
onqtam8126b562016-05-27 17:01:15 +030048print("generating html documentation from markdown")
49os.system("python generate_html.py")