blob: 0918c37c984e49aef18f8b2e47038d18876b6a75 [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"
26 else:
27 doctest_contents += line
28
onqtame8bdda42016-06-01 15:12:36 +030029readme = open("../doctest/parts/doctest_fwd.h", "w")
onqtame6d0d512016-04-27 23:23:16 +030030readme.write(doctest_contents)
31readme.close()
32
onqtam43271a62019-05-06 11:29:37 +030033# update meson file with version
34meson_contents = ""
35for line in fileinput.input(["../meson.build"]):
36 if line.startswith("project('doctest'"):
Eli Schwartz0b79b492022-04-20 09:23:23 -040037 meson_contents += "project('doctest', ['cpp'], version: '" + version + "')\n"
onqtam43271a62019-05-06 11:29:37 +030038 else:
39 meson_contents += line
40
41meson = open("../meson.build", "w")
42meson.write(meson_contents)
43meson.close()
44
hardlyb1e7e142014-08-06 00:43:51 +030045# run generate_html.py
onqtam8126b562016-05-27 17:01:15 +030046print("generating html documentation from markdown")
47os.system("python generate_html.py")