mirror of
https://github.com/OpenVPN/openvpn.git
synced 2025-05-09 13:41:06 +08:00

Change-Id: Ic377958d303b1dcfa9d877d3a63ecf39bdff7aef Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20240315170054.2368254-1-frank@lichtenheld.com> URL: https://sourceforge.net/p/openvpn/mailman/message/58749316/ Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit b25c6d7e861d446b7a2e03cbcfb892d554c1ef73)
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
#
|
|
# OpenVPN -- An application to securely tunnel IP networks
|
|
# over a single UDP port, with support for SSL/TLS-based
|
|
# session authentication and key exchange,
|
|
# packet encryption, packet authentication, and
|
|
# packet compression.
|
|
#
|
|
# Copyright (C) 2022-2024 OpenVPN Inc <sales@openvpn.net>
|
|
# Copyright (C) 2022-2022 Lev Stipakov <lev@lestisoftware.fi>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License version 2
|
|
# as published by the Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
#
|
|
|
|
# Usage: ./parse-version.m4.py m4file [directory]
|
|
# Read <m4file>, extract all lines looking like M4 define(), and translate
|
|
# them into CMake style set(). Those are then written out to file
|
|
# <directory>/version.cmake.
|
|
# Intended to be used on top-level version.m4 file.
|
|
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
def main():
|
|
assert len(sys.argv) > 1
|
|
version_path = sys.argv[1]
|
|
output = []
|
|
with open(version_path, 'r') as version_file:
|
|
for line in version_file:
|
|
match = re.match(r'[ \t]*define\(\[(.*)\],[ \t]*\[(.*)\]\)[ \t]*', line)
|
|
if match is not None:
|
|
output.append(match.expand(r'set(\1 \2)'))
|
|
out_path = os.path.join("%s" % (sys.argv[2] if len(sys.argv) > 2 else "."), "version.cmake")
|
|
|
|
prev_content = ""
|
|
try:
|
|
with open(out_path, "r") as out_file:
|
|
prev_content = out_file.read()
|
|
except:
|
|
# file doesn't exist
|
|
pass
|
|
|
|
content = "\n".join(output) + "\n"
|
|
if prev_content != content:
|
|
print("Writing %s" % out_path)
|
|
with open(out_path, "w") as out_file:
|
|
out_file.write(content)
|
|
else:
|
|
print("Content of %s hasn't changed" % out_path)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|