File: ci_single_header_check.py

package info (click to toggle)
tomlplusplus 3.3.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,184 kB
  • sloc: cpp: 35,145; ansic: 2,220; python: 983; makefile: 25; sh: 17
file content (31 lines) | stat: -rwxr-xr-x 965 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
# This file is a part of toml++ and is subject to the the terms of the MIT license.
# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
# SPDX-License-Identifier: MIT

import sys
import utils
from pathlib import Path


def main():
	hpp_path = Path(Path(__file__).resolve().parents[1], 'toml.hpp').resolve()
	hash1 = utils.sha1(utils.read_all_text_from_file(hpp_path, logger=True))
	print(rf'Hash 1: {hash1}')
	utils.run_python_script(r'generate_single_header.py')
	hash2 = utils.sha1(utils.read_all_text_from_file(hpp_path, logger=True))
	print(rf'Hash 2: {hash2}')
	if (hash1 != hash2):
		print(
			"toml.hpp wasn't up-to-date!\nRun generate_single_header.py before your commit to prevent this error.",
			file=sys.stderr
		)
		return 1
	print("toml.hpp was up-to-date")
	return 0



if __name__ == '__main__':
	utils.run(main, verbose=True)