From bf8374ef0148bde4ffe4434eb2395a01521819bf Mon Sep 17 00:00:00 2001 From: Martin Fouilleul Date: Wed, 9 Aug 2023 15:02:15 +0200 Subject: [PATCH] Collapse milepost/scripts into scripts/ --- milepost/scripts/embed_text.py | 44 ---------------------- milepost/src/graphics_common.c | 4 +- milepost/src/platform/orca_strings.c | 2 +- milepost/src/platform/platform_strings.h | 2 +- samples/fluid/build.bat | 6 +-- samples/fluid/build.sh | 5 ++- samples/fluid/src/glsl_shaders.h | 4 +- samples/glesTriangle/build.bat | 2 +- samples/glesTriangle/build.sh | 2 +- scripts/dev.py | 44 ++-------------------- scripts/embed_text_files.py | 48 ++++++++++++++++++++++++ {milepost/scripts => scripts}/glapi.py | 0 12 files changed, 66 insertions(+), 97 deletions(-) delete mode 100644 milepost/scripts/embed_text.py create mode 100644 scripts/embed_text_files.py rename {milepost/scripts => scripts}/glapi.py (100%) diff --git a/milepost/scripts/embed_text.py b/milepost/scripts/embed_text.py deleted file mode 100644 index a8fa369..0000000 --- a/milepost/scripts/embed_text.py +++ /dev/null @@ -1,44 +0,0 @@ -import os -from datetime import datetime -from argparse import ArgumentParser - -parser = ArgumentParser() -parser.add_argument("inputFiles", nargs="+") -parser.add_argument("-o", "--output") -parser.add_argument("-p", "--prefix") - -args = parser.parse_args() - -output = open(args.output, "w") -output.write("/*********************************************************************\n") -output.write("*\n") -output.write("*\tfile: %s\n" % os.path.basename(args.output)) -output.write("*\tnote: string literals auto-generated by embed_text.py\n") -output.write("*\tdate: %s\n" % datetime.now().strftime("%d/%m%Y")) -output.write("*\n") -output.write("**********************************************************************/\n") - -outSymbol = (os.path.splitext(os.path.basename(args.output))[0]).upper() - -output.write("#ifndef __%s_H__\n" % outSymbol) -output.write("#define __%s_H__\n" % outSymbol) -output.write("\n\n") - -for fileName in args.inputFiles: - f = open(fileName, "r") - lines = f.read().splitlines() - - output.write("//NOTE: string imported from %s\n" % fileName) - - stringName = os.path.splitext(os.path.basename(fileName))[0] - output.write(f"const char* {args.prefix}{stringName} = ") - - for line in lines: - output.write("\n\"%s\\n\"" % line) - - output.write(";\n\n") - f.close() - -output.write("#endif // __%s_H__\n" % outSymbol) - -output.close() diff --git a/milepost/src/graphics_common.c b/milepost/src/graphics_common.c index e308750..10b3cb8 100644 --- a/milepost/src/graphics_common.c +++ b/milepost/src/graphics_common.c @@ -15,10 +15,10 @@ #define STBI_NO_STDIO #define STBI_NO_HDR #endif -#include"ext/stb_image.h" +#include"stb_image.h" #define STB_TRUETYPE_IMPLEMENTATION -#include"ext/stb_truetype.h" +#include"stb_truetype.h" #include"platform/platform_log.h" #include"platform/platform_assert.h" diff --git a/milepost/src/platform/orca_strings.c b/milepost/src/platform/orca_strings.c index ac89942..a20bd0e 100644 --- a/milepost/src/platform/orca_strings.c +++ b/milepost/src/platform/orca_strings.c @@ -8,7 +8,7 @@ #include"platform_strings.h" #define STB_SPRINTF_IMPLEMENTATION -#include"ext/stb_sprintf.h" +#include"stb_sprintf.h" size_t strlen(const char *s) { diff --git a/milepost/src/platform/platform_strings.h b/milepost/src/platform/platform_strings.h index 90b203b..46a561a 100644 --- a/milepost/src/platform/platform_strings.h +++ b/milepost/src/platform/platform_strings.h @@ -12,7 +12,7 @@ #include"platform_varg.h" #if PLATFORM_ORCA - #include"ext/stb_sprintf.h" + #include"stb_sprintf.h" size_t strlen(const char *s); int strcmp(const char *s1, const char *s2); diff --git a/samples/fluid/build.bat b/samples/fluid/build.bat index c01c970..1652fc9 100644 --- a/samples/fluid/build.bat +++ b/samples/fluid/build.bat @@ -10,7 +10,7 @@ set wasmFlags=--target=wasm32^ -O2 ^ -mbulk-memory ^ -D__ORCA__ ^ - -isystem ..\..\cstdlib\include -I ..\..\sdk -I..\..\milepost\ext -I ..\..\milepost -I ..\..\milepost\src + -isystem ..\..\cstdlib\include -I ..\..\sdk -I..\..\ext -I ..\..\milepost -I ..\..\milepost\src set shaders=src/shaders/advect.glsl^ src/shaders/blit_div_fragment.glsl^ @@ -26,8 +26,8 @@ set shaders=src/shaders/advect.glsl^ src/shaders/splat.glsl^ src/shaders/subtract_pressure.glsl -call python3 ../../milepost/scripts/embed_text.py --prefix=glsl_ --output src/glsl_shaders.h %shaders% +call python3 ../../scripts/embed_text_files.py --prefix=glsl_ --output src/glsl_shaders.h %shaders% clang %wasmFlags% -o .\module.wasm ..\..\sdk\orca.c ..\..\cstdlib\src\*.c src\main.c -python3 ..\..\scripts\mkapp.py --orca-dir ..\.. --icon icon.png --name Fluid module.wasm +orca bundle --orca-dir ..\.. --icon icon.png --name Fluid module.wasm diff --git a/samples/fluid/build.sh b/samples/fluid/build.sh index c2439c3..513a2e0 100755 --- a/samples/fluid/build.sh +++ b/samples/fluid/build.sh @@ -11,11 +11,12 @@ else CLANG=clang fi +ORCA_DIR=../.. STDLIB_DIR=../../cstdlib ORCA_SDK_DIR=../../sdk MILEPOST_DIR=../../milepost -python3 ../../milepost/scripts/embed_text.py --prefix=glsl_ --output src/glsl_shaders.h src/shaders/*.glsl +python3 ../../scripts/embed_text_files.py --prefix=glsl_ --output src/glsl_shaders.h src/shaders/*.glsl wasmFlags="--target=wasm32 \ --no-standard-libraries \ @@ -28,7 +29,7 @@ wasmFlags="--target=wasm32 \ -D__ORCA__ \ -I $STDLIB_DIR/include \ -I $ORCA_SDK_DIR \ - -I $MILEPOST_DIR/ext -I $MILEPOST_DIR -I $MILEPOST_DIR/src" + -I $ORCA_DIR/ext -I $MILEPOST_DIR -I $MILEPOST_DIR/src" $CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c diff --git a/samples/fluid/src/glsl_shaders.h b/samples/fluid/src/glsl_shaders.h index a15bb11..df10253 100644 --- a/samples/fluid/src/glsl_shaders.h +++ b/samples/fluid/src/glsl_shaders.h @@ -1,8 +1,8 @@ /********************************************************************* * * file: glsl_shaders.h -* note: string literals auto-generated by embed_text.py -* date: 08/082023 +* note: string literals auto-generated by build_runtime.py +* date: 09/082023 * **********************************************************************/ #ifndef __GLSL_SHADERS_H__ diff --git a/samples/glesTriangle/build.bat b/samples/glesTriangle/build.bat index add38e3..2e71d98 100644 --- a/samples/glesTriangle/build.bat +++ b/samples/glesTriangle/build.bat @@ -10,7 +10,7 @@ set wasmFlags=--target=wasm32^ -O2 ^ -mbulk-memory ^ -D__ORCA__ ^ - -isystem ..\..\cstdlib\include -I ..\..\sdk -I..\..\milepost\ext -I ..\..\milepost -I ..\..\milepost\src + -isystem ..\..\cstdlib\include -I ..\..\sdk -I..\..\ext -I ..\..\milepost -I ..\..\milepost\src clang %wasmFlags% -o .\module.wasm ..\..\sdk\orca.c ..\..\cstdlib\src\*.c src\main.c diff --git a/samples/glesTriangle/build.sh b/samples/glesTriangle/build.sh index 5349f68..b39157d 100755 --- a/samples/glesTriangle/build.sh +++ b/samples/glesTriangle/build.sh @@ -27,7 +27,7 @@ wasmFlags="--target=wasm32 \ -D__ORCA__ \ -I $STDLIB_DIR/include \ -I $ORCA_SDK_DIR \ - -I $ORCA_DIR \ + -I $ORCA_DIR/ext \ -I $MILEPOST_DIR -I $MILEPOST_DIR/src" $CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c diff --git a/scripts/dev.py b/scripts/dev.py index 99c964e..da36093 100644 --- a/scripts/dev.py +++ b/scripts/dev.py @@ -13,7 +13,7 @@ from .bindgen import bindgen from .gles_gen import gles_gen from .log import * from .utils import pushd, removeall - +from .embed_text_files import * ANGLE_VERSION = "2023-07-05" @@ -100,8 +100,8 @@ def build_milepost(target, release): def build_milepost_lib_win(release): - # TODO(ben): delete embed_text.py - embed_text_glsl("src\\glsl_shaders.h", "glsl_", [ + + embed_text_files("src\\glsl_shaders.h", "glsl_", [ "src\\glsl_shaders\\common.glsl", "src\\glsl_shaders\\blit_vertex.glsl", "src\\glsl_shaders\\blit_fragment.glsl", @@ -118,7 +118,7 @@ def build_milepost_lib_win(release): "/I", "src/util", "/I", "src/platform", "/I", "ext", - "/I", "../ext" + "/I", "../ext", "/I", "../ext/angle/include", ] libs = [ @@ -504,42 +504,6 @@ def download_angle(): shutil.copytree(f"scripts/files/angle/", "ext/angle", dirs_exist_ok=True) -def embed_text_glsl(outputpath, prefix, shaders): - output = open(outputpath, "w") - output.write("/*********************************************************************\n") - output.write("*\n") - output.write("*\tfile: %s\n" % os.path.basename(outputpath)) - output.write("*\tnote: string literals auto-generated by build_runtime.py\n") - output.write("*\tdate: %s\n" % datetime.now().strftime("%d/%m%Y")) - output.write("*\n") - output.write("**********************************************************************/\n") - - outSymbol = (os.path.splitext(os.path.basename(outputpath))[0]).upper() - - output.write("#ifndef __%s_H__\n" % outSymbol) - output.write("#define __%s_H__\n" % outSymbol) - output.write("\n\n") - - for fileName in shaders: - f = open(fileName, "r") - lines = f.read().splitlines() - - output.write("//NOTE: string imported from %s\n" % fileName) - - stringName = os.path.splitext(os.path.basename(fileName))[0] - output.write(f"const char* {prefix}{stringName} = ") - - for line in lines: - output.write("\n\"%s\\n\"" % line) - - output.write(";\n\n") - f.close() - - output.write("#endif // __%s_H__\n" % outSymbol) - - output.close() - - def yeet(path): os.makedirs(path, exist_ok=True) shutil.rmtree(path) diff --git a/scripts/embed_text_files.py b/scripts/embed_text_files.py new file mode 100644 index 0000000..25a0234 --- /dev/null +++ b/scripts/embed_text_files.py @@ -0,0 +1,48 @@ +import os +from datetime import datetime +from argparse import ArgumentParser + + +def embed_text_files(outputpath, prefix, files): + output = open(outputpath, "w") + output.write("/*********************************************************************\n") + output.write("*\n") + output.write("*\tfile: %s\n" % os.path.basename(outputpath)) + output.write("*\tnote: string literals auto-generated by build_runtime.py\n") + output.write("*\tdate: %s\n" % datetime.now().strftime("%d/%m%Y")) + output.write("*\n") + output.write("**********************************************************************/\n") + + outSymbol = (os.path.splitext(os.path.basename(outputpath))[0]).upper() + + output.write("#ifndef __%s_H__\n" % outSymbol) + output.write("#define __%s_H__\n" % outSymbol) + output.write("\n\n") + + for fileName in files: + f = open(fileName, "r") + lines = f.read().splitlines() + + output.write("//NOTE: string imported from %s\n" % fileName) + + stringName = os.path.splitext(os.path.basename(fileName))[0] + output.write(f"const char* {prefix}{stringName} = ") + + for line in lines: + output.write("\n\"%s\\n\"" % line) + + output.write(";\n\n") + f.close() + + output.write("#endif // __%s_H__\n" % outSymbol) + output.close() + +if __name__ == "__main__": + parser = ArgumentParser() + parser.add_argument("inputFiles", nargs="+") + parser.add_argument("-o", "--output") + parser.add_argument("-p", "--prefix") + + args = parser.parse_args() + + embed_text_files(args.output, args.prefix, args.inputFiles) diff --git a/milepost/scripts/glapi.py b/scripts/glapi.py similarity index 100% rename from milepost/scripts/glapi.py rename to scripts/glapi.py