From ae9729b6df885eb04c63501b33399d401829a76a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 1 Sep 2016 22:10:20 +0200 Subject: Move various scripts to the "scripts" folder Thus cleaning up the "tools" folder a bit. --- tools/addheader/addheader.py | 72 ---------------- tools/addheader/files | 158 ---------------------------------- tools/addheader/header.txt | 12 --- tools/bmfhdr/makehdr.py | 70 --------------- tools/glwrapper/makewrapper.py | 183 ---------------------------------------- tools/memsort.py | 35 -------- tools/scripts/addheader.py | 72 ++++++++++++++++ tools/scripts/make_bmfhdr.py | 70 +++++++++++++++ tools/scripts/make_glwrapper.py | 183 ++++++++++++++++++++++++++++++++++++++++ tools/scripts/make_icons.sh | 5 ++ tools/scripts/memsort.py | 35 ++++++++ tools/steam/make_icons.sh | 5 -- 12 files changed, 365 insertions(+), 535 deletions(-) delete mode 100644 tools/addheader/addheader.py delete mode 100644 tools/addheader/files delete mode 100644 tools/addheader/header.txt delete mode 100644 tools/bmfhdr/makehdr.py delete mode 100644 tools/glwrapper/makewrapper.py delete mode 100644 tools/memsort.py create mode 100644 tools/scripts/addheader.py create mode 100644 tools/scripts/make_bmfhdr.py create mode 100644 tools/scripts/make_glwrapper.py create mode 100644 tools/scripts/make_icons.sh create mode 100644 tools/scripts/memsort.py delete mode 100644 tools/steam/make_icons.sh diff --git a/tools/addheader/addheader.py b/tools/addheader/addheader.py deleted file mode 100644 index d040d8b5d6..0000000000 --- a/tools/addheader/addheader.py +++ /dev/null @@ -1,72 +0,0 @@ -header="""\ -/*************************************************************************/ -/* $filename */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -""" - -f = open("files","rb") - -fname = f.readline() -while (fname!=""): - - fr = open(fname.strip(),"rb") - l = fr.readline() - bc=False - fsingle = fname.strip() - - if (fsingle.find("/")!=-1): - fsingle=fsingle[fsingle.rfind("/")+1:] - rep_fl="$filename" - rep_fi=fsingle - len_fl=len(rep_fl) - len_fi=len(rep_fi) - if (len_fi0): - cstr+=", " - cstr+=c - -cstr+=("};") - -print(cstr) \ No newline at end of file diff --git a/tools/glwrapper/makewrapper.py b/tools/glwrapper/makewrapper.py deleted file mode 100644 index 2e5f06be12..0000000000 --- a/tools/glwrapper/makewrapper.py +++ /dev/null @@ -1,183 +0,0 @@ -#! /usr/bin/python -import sys - -if (len(sys.argv)<2): - print("usage: makewrapper.py ") - sys.exit(255) - - -functions=[] -types=[] -constants=[] - -READ_FUNCTIONS=0 -READ_TYPES=1 -READ_CONSTANTS=2 - -read_what=READ_TYPES - -for x in (range(len(sys.argv)-1)): - f=open(sys.argv[x+1],"r") - - while(True): - - line=f.readline() - if (line==""): - break - - line=line.replace("\n","").strip() - """ - if (line.find("[types]")!=-1): - read_what=READ_TYPES - continue - elif (line.find("[constants]")!=-1): - read=READ_TYPES - continue - elif (line.find("[functions]")!=-1): - read_what=READ_FUNCTIONS - continue - """ - - if (line.find("#define")!=-1): - if (line.find("0x")==-1 and line.find("GL_VERSION")==-1): - continue - constants.append(line) - elif (line.find("typedef")!=-1): - if (line.find("(")!=-1 or line.find(")")!=-1 or line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("GL")==-1): - continue - types.append(line) - elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-1): - - if (line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("NV")!=-1): - continue - - line=line.replace("APIENTRY","") - line=line.replace("GLAPI","") - - glpos=line.find(" gl") - if (glpos==-1): - - glpos=line.find("\tgl") - if (glpos==-1): - continue - - ret=line[:glpos].strip(); - - line=line[glpos:].strip() - namepos=line.find("(") - - if (namepos==-1): - continue - - name=line[:namepos].strip() - line=line[namepos:] - - argpos=line.rfind(")") - if (argpos==-1): - continue - - args=line[1:argpos] - - funcdata={} - funcdata["ret"]=ret - funcdata["name"]=name - funcdata["args"]=args - - functions.append(funcdata) - print(funcdata) - - - -#print(types) -#print(constants) -#print(functions) - - -f=open("glwrapper.h","w") - -f.write("#ifndef GL_WRAPPER\n") -f.write("#define GL_WRAPPER\n\n\n") - -header_code="""\ -#if defined(__gl_h_) || defined(__GL_H__) -#error gl.h included before glwrapper.h -#endif -#if defined(__glext_h_) || defined(__GLEXT_H_) -#error glext.h included before glwrapper.h -#endif -#if defined(__gl_ATI_h_) -#error glATI.h included before glwrapper.h -#endif - -#define __gl_h_ -#define __GL_H__ -#define __glext_h_ -#define __GLEXT_H_ -#define __gl_ATI_h_ - -#define GL_TRUE 1 -#define GL_FALSE 0 - -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_NONE 0 -#define GL_NO_ERROR 0 - -\n\n -""" - -f.write("#include \n\n\n") - -f.write(header_code); - -f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n") -f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n") -f.write("#define GLWRP_APIENTRY __stdcall\n") -f.write("#else\n"); -f.write("#define GLWRP_APIENTRY \n") -f.write("#endif\n\n"); -for x in types: - f.write(x+"\n") - -f.write("\n\n") - -for x in constants: - f.write(x+"\n") - -f.write("\n\n") - -for x in functions: - f.write("extern "+x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+");\n") - f.write("#define "+x["name"]+" __wrapper_"+x["name"]+"\n") - -f.write("\n\n") -f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n"); -f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n") - -f.write("#ifdef __cplusplus\n}\n#endif\n") - -f.write("#endif\n\n") - -f=open("glwrapper.c","w") - -f.write("\n\n") -f.write("#include \"glwrapper.h\"\n") -f.write("\n\n") - -for x in functions: - f.write(x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+")=NULL;\n") - -f.write("\n\n") -f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) ) {\n") -f.write("\n") - -for x in functions: - f.write("\t__wrapper_"+x["name"]+"=("+x["ret"]+" GLWRP_APIENTRY (*)("+x["args"]+"))wrapperFunc(\""+x["name"]+"\");\n") - -f.write("\n\n") -f.write("}\n") -f.write("\n\n") - - - - diff --git a/tools/memsort.py b/tools/memsort.py deleted file mode 100644 index d2e4fe0226..0000000000 --- a/tools/memsort.py +++ /dev/null @@ -1,35 +0,0 @@ - -import sys - -arg="memdump.txt" - -if (len(sys.argv)>1): - arg=sys.argv[1] - -f = open(arg,"rb") - - -l=f.readline() - - -sum = {} -cnt={} - - -while(l!=""): - - s=l.split("-") - amount = int(s[1]) - what=s[2] - if (what in sum): - sum[what]+=amount - cnt[what]+=1 - else: - sum[what]=amount - cnt[what]=1 - - l=f.readline() - - -for x in sum: - print(x.strip()+"("+str(cnt[x])+"):\n: "+str(sum[x])) diff --git a/tools/scripts/addheader.py b/tools/scripts/addheader.py new file mode 100644 index 0000000000..d040d8b5d6 --- /dev/null +++ b/tools/scripts/addheader.py @@ -0,0 +1,72 @@ +header="""\ +/*************************************************************************/ +/* $filename */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +""" + +f = open("files","rb") + +fname = f.readline() +while (fname!=""): + + fr = open(fname.strip(),"rb") + l = fr.readline() + bc=False + fsingle = fname.strip() + + if (fsingle.find("/")!=-1): + fsingle=fsingle[fsingle.rfind("/")+1:] + rep_fl="$filename" + rep_fi=fsingle + len_fl=len(rep_fl) + len_fi=len(rep_fi) + if (len_fi0): + cstr+=", " + cstr+=c + +cstr+=("};") + +print(cstr) \ No newline at end of file diff --git a/tools/scripts/make_glwrapper.py b/tools/scripts/make_glwrapper.py new file mode 100644 index 0000000000..f3f8d39837 --- /dev/null +++ b/tools/scripts/make_glwrapper.py @@ -0,0 +1,183 @@ +#! /usr/bin/python +import sys + +if (len(sys.argv)<2): + print("usage: make_glwrapper.py ") + sys.exit(255) + + +functions=[] +types=[] +constants=[] + +READ_FUNCTIONS=0 +READ_TYPES=1 +READ_CONSTANTS=2 + +read_what=READ_TYPES + +for x in (range(len(sys.argv)-1)): + f=open(sys.argv[x+1],"r") + + while(True): + + line=f.readline() + if (line==""): + break + + line=line.replace("\n","").strip() + """ + if (line.find("[types]")!=-1): + read_what=READ_TYPES + continue + elif (line.find("[constants]")!=-1): + read=READ_TYPES + continue + elif (line.find("[functions]")!=-1): + read_what=READ_FUNCTIONS + continue + """ + + if (line.find("#define")!=-1): + if (line.find("0x")==-1 and line.find("GL_VERSION")==-1): + continue + constants.append(line) + elif (line.find("typedef")!=-1): + if (line.find("(")!=-1 or line.find(")")!=-1 or line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("GL")==-1): + continue + types.append(line) + elif (line.find("APIENTRY")!=-1 and line.find("GLAPI")!=-1): + + if (line.find("ARB")!=-1 or line.find("EXT")!=-1 or line.find("NV")!=-1): + continue + + line=line.replace("APIENTRY","") + line=line.replace("GLAPI","") + + glpos=line.find(" gl") + if (glpos==-1): + + glpos=line.find("\tgl") + if (glpos==-1): + continue + + ret=line[:glpos].strip(); + + line=line[glpos:].strip() + namepos=line.find("(") + + if (namepos==-1): + continue + + name=line[:namepos].strip() + line=line[namepos:] + + argpos=line.rfind(")") + if (argpos==-1): + continue + + args=line[1:argpos] + + funcdata={} + funcdata["ret"]=ret + funcdata["name"]=name + funcdata["args"]=args + + functions.append(funcdata) + print(funcdata) + + + +#print(types) +#print(constants) +#print(functions) + + +f=open("glwrapper.h","w") + +f.write("#ifndef GL_WRAPPER\n") +f.write("#define GL_WRAPPER\n\n\n") + +header_code="""\ +#if defined(__gl_h_) || defined(__GL_H__) +#error gl.h included before glwrapper.h +#endif +#if defined(__glext_h_) || defined(__GLEXT_H_) +#error glext.h included before glwrapper.h +#endif +#if defined(__gl_ATI_h_) +#error glATI.h included before glwrapper.h +#endif + +#define __gl_h_ +#define __GL_H__ +#define __glext_h_ +#define __GLEXT_H_ +#define __gl_ATI_h_ + +#define GL_TRUE 1 +#define GL_FALSE 0 + +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_NONE 0 +#define GL_NO_ERROR 0 + +\n\n +""" + +f.write("#include \n\n\n") + +f.write(header_code); + +f.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n") +f.write("#if defined(_WIN32) && !defined(__CYGWIN__)\n") +f.write("#define GLWRP_APIENTRY __stdcall\n") +f.write("#else\n"); +f.write("#define GLWRP_APIENTRY \n") +f.write("#endif\n\n"); +for x in types: + f.write(x+"\n") + +f.write("\n\n") + +for x in constants: + f.write(x+"\n") + +f.write("\n\n") + +for x in functions: + f.write("extern "+x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+");\n") + f.write("#define "+x["name"]+" __wrapper_"+x["name"]+"\n") + +f.write("\n\n") +f.write("typedef void (*GLWrapperFuncPtr)(void);\n\n"); +f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n") + +f.write("#ifdef __cplusplus\n}\n#endif\n") + +f.write("#endif\n\n") + +f=open("glwrapper.c","w") + +f.write("\n\n") +f.write("#include \"glwrapper.h\"\n") +f.write("\n\n") + +for x in functions: + f.write(x["ret"]+" GLWRP_APIENTRY (*__wrapper_"+x["name"]+")("+x["args"]+")=NULL;\n") + +f.write("\n\n") +f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) ) {\n") +f.write("\n") + +for x in functions: + f.write("\t__wrapper_"+x["name"]+"=("+x["ret"]+" GLWRP_APIENTRY (*)("+x["args"]+"))wrapperFunc(\""+x["name"]+"\");\n") + +f.write("\n\n") +f.write("}\n") +f.write("\n\n") + + + + diff --git a/tools/scripts/make_icons.sh b/tools/scripts/make_icons.sh new file mode 100644 index 0000000000..71037cd1c3 --- /dev/null +++ b/tools/scripts/make_icons.sh @@ -0,0 +1,5 @@ +convert -resize 32x32 ../../icon.svg icon32.ico +convert -resize 32x32 ../../icon.svg icon32.icns +for s in 16 24 32 64 96 128 256; do convert -resize ${s}x$s ../../icon.svg icon$s.png; done +zip icons.zip icon*.png +rm icon*.png diff --git a/tools/scripts/memsort.py b/tools/scripts/memsort.py new file mode 100644 index 0000000000..d2e4fe0226 --- /dev/null +++ b/tools/scripts/memsort.py @@ -0,0 +1,35 @@ + +import sys + +arg="memdump.txt" + +if (len(sys.argv)>1): + arg=sys.argv[1] + +f = open(arg,"rb") + + +l=f.readline() + + +sum = {} +cnt={} + + +while(l!=""): + + s=l.split("-") + amount = int(s[1]) + what=s[2] + if (what in sum): + sum[what]+=amount + cnt[what]+=1 + else: + sum[what]=amount + cnt[what]=1 + + l=f.readline() + + +for x in sum: + print(x.strip()+"("+str(cnt[x])+"):\n: "+str(sum[x])) diff --git a/tools/steam/make_icons.sh b/tools/steam/make_icons.sh deleted file mode 100644 index 71037cd1c3..0000000000 --- a/tools/steam/make_icons.sh +++ /dev/null @@ -1,5 +0,0 @@ -convert -resize 32x32 ../../icon.svg icon32.ico -convert -resize 32x32 ../../icon.svg icon32.icns -for s in 16 24 32 64 96 128 256; do convert -resize ${s}x$s ../../icon.svg icon$s.png; done -zip icons.zip icon*.png -rm icon*.png -- cgit v1.2.3