add new CMake macro generate_from_any and extend PythonToCPP script to create source file from any text file
This commit is contained in:
@@ -9,19 +9,24 @@ import os,sys,string
|
||||
|
||||
file = open(sys.argv[1])
|
||||
|
||||
if(len(sys.argv) > 3):
|
||||
sys.stderr.write("Wrong Parameter\n Usage:\n PythonToCPP Infile.py [Outfile]\n")
|
||||
if(len(sys.argv) > 4):
|
||||
sys.stderr.write("Wrong Parameter\n Usage:\n PythonToCPP Infile.py [Outfile][Variable]\n")
|
||||
|
||||
if(len(sys.argv) > 2):
|
||||
out = open(sys.argv[2],"w");
|
||||
else:
|
||||
out = sys.stdout
|
||||
|
||||
if(len(sys.argv) > 3):
|
||||
identifier = sys.argv[3]
|
||||
else:
|
||||
identifier = os.path.basename(sys.argv[1])
|
||||
identifier = identifier[:-3]
|
||||
|
||||
lines = file.readlines()
|
||||
|
||||
# We want to use this script for files in another directory, so we extract the actual file name
|
||||
fn = os.path.basename(sys.argv[1])
|
||||
out.write("const char " + fn[:-3] + "[] =")
|
||||
out.write("const char " + identifier + "[] =")
|
||||
|
||||
for line in lines:
|
||||
# remove new line
|
||||
|
||||
Reference in New Issue
Block a user