mirror of
https://github.com/bkthomps/Containers.git
synced 2026-05-15 22:05:46 +00:00
Improve header script (#65)
Improve the header script by rewriting it so that it is fully automated with a single command. It now updates the included version file as well as the header.
This commit is contained in:
3
Makefile
3
Makefile
@@ -22,3 +22,6 @@ dynamic_gcc:
|
||||
clean:
|
||||
rm -f containers.a
|
||||
rm -f containers.so
|
||||
|
||||
header:
|
||||
python3 compile_headers.py $(version)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
header_name="./containers.h"
|
||||
IFS=''
|
||||
first="1"
|
||||
|
||||
find ./src -type f -name "*.h" | while read header;
|
||||
do
|
||||
ignore="1"
|
||||
if [[ $first == "1" ]];
|
||||
then
|
||||
first="0"
|
||||
cp "./src/include/VERSION" "$header_name"
|
||||
fi
|
||||
while read line;
|
||||
do
|
||||
if [[ $ignore == "0" ]];
|
||||
then
|
||||
echo "$line" >> "$header_name"
|
||||
elif [[ $line == *"*/"* ]];
|
||||
then
|
||||
ignore="0"
|
||||
echo "" >> "$header_name"
|
||||
fi
|
||||
done < "$header"
|
||||
done
|
||||
57
compile_headers.py
Normal file
57
compile_headers.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
github_location = "github.com/bkthomps/Containers"
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
exit("Format: python3 compile_headers.py <version_number>")
|
||||
version = str(sys.argv[1])
|
||||
if not re.match(r"v[0-9]+\.[0-9]+\.[0-9]+", version):
|
||||
exit("Error: version format must be: vi.j.k")
|
||||
|
||||
license_list = []
|
||||
license_file = open("LICENSE", "r")
|
||||
i = 0
|
||||
for line in license_file:
|
||||
if i >= 2:
|
||||
license_list.append(line)
|
||||
i += 1
|
||||
license_file.close()
|
||||
|
||||
first_line = license_list[0].split(" ")
|
||||
name = ""
|
||||
i = 0
|
||||
for part in first_line:
|
||||
if i >= 3:
|
||||
name += part
|
||||
name += " "
|
||||
i += 1
|
||||
|
||||
header = "/*\n"
|
||||
for line in license_list:
|
||||
if line == "\n":
|
||||
header += " *" + line
|
||||
else:
|
||||
header += " * " + line
|
||||
header += " */\n\n"
|
||||
header += "/*\n"
|
||||
header += " * The Containers library is hosted at: " + github_location + "\n"
|
||||
header += " * The author is: " + name
|
||||
header += "* This local version is: " + version + "\n"
|
||||
header += " */\n"
|
||||
|
||||
version_file = open("src/include/VERSION", "w+")
|
||||
version_file.write(header)
|
||||
version_file.close()
|
||||
|
||||
folder_path = 'src/include'
|
||||
for filename in glob.glob(os.path.join(folder_path, '*.h')):
|
||||
with open(filename, 'r') as file:
|
||||
text = file.read()
|
||||
header += text.split("*/", 1)[1]
|
||||
|
||||
containers_header_file = open("containers.h", "w+")
|
||||
containers_header_file.write(header)
|
||||
containers_header_file.close()
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017-2019 Bailey Thompson
|
||||
* Copyright (c) 2017-2020 Bailey Thompson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,7 @@
|
||||
/*
|
||||
* The Containers library is hosted at: github.com/bkthomps/Containers
|
||||
* The author is: Bailey Thompson
|
||||
* This local version is: v1.1.1
|
||||
* This local version is: v1.1.2
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017-2019 Bailey Thompson
|
||||
* Copyright (c) 2017-2020 Bailey Thompson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,5 +23,5 @@
|
||||
/*
|
||||
* The Containers library is hosted at: github.com/bkthomps/Containers
|
||||
* The author is: Bailey Thompson
|
||||
* This local version is: v1.1.1
|
||||
* This local version is: v1.1.2
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user