Collapse milepost/scripts into scripts/
This commit is contained in:
		
							parent
							
								
									60a2237269
								
							
						
					
					
						commit
						bf8374ef01
					
				|  | @ -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() | ||||
|  | @ -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" | ||||
|  |  | |||
|  | @ -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) | ||||
| { | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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__ | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
|  | @ -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) | ||||
		Loading…
	
		Reference in New Issue