collapse milepost/src to src/

This commit is contained in:
Martin Fouilleul 2023-08-09 17:49:22 +02:00
parent bfadcad7f3
commit 1c608aeda6
100 changed files with 54 additions and 55 deletions

View File

@ -14,7 +14,6 @@ fi
ORCA_DIR=../..
STDLIB_DIR=../../cstdlib
ORCA_SDK_DIR=../../sdk
MILEPOST_DIR=../../milepost
python3 ../../scripts/embed_text_files.py --prefix=glsl_ --output src/glsl_shaders.h src/shaders/*.glsl
@ -29,7 +28,8 @@ wasmFlags="--target=wasm32 \
-D__ORCA__ \
-I $STDLIB_DIR/include \
-I $ORCA_SDK_DIR \
-I $ORCA_DIR/ext -I $MILEPOST_DIR -I $MILEPOST_DIR/src"
-I $ORCA_DIR/ext \
-I $ORCA_DIR/src"
$CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c

View File

@ -14,7 +14,6 @@ fi
ORCA_DIR=../..
STDLIB_DIR=../../cstdlib
ORCA_SDK_DIR=../../sdk
MILEPOST_DIR=../../milepost
wasmFlags="--target=wasm32 \
--no-standard-libraries \
@ -28,7 +27,7 @@ wasmFlags="--target=wasm32 \
-I $STDLIB_DIR/include \
-I $ORCA_SDK_DIR \
-I $ORCA_DIR/ext \
-I $MILEPOST_DIR -I $MILEPOST_DIR/src"
-I $ORCA_DIR/src"
$CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c

View File

@ -14,7 +14,6 @@ fi
ORCA_DIR=../..
STDLIB_DIR=../../cstdlib
ORCA_SDK_DIR=../../sdk
MILEPOST_DIR=../../milepost
wasmFlags="--target=wasm32 \
--no-standard-libraries \
@ -28,7 +27,7 @@ wasmFlags="--target=wasm32 \
-I $STDLIB_DIR/include \
-I $ORCA_DIR/ext \
-I $ORCA_SDK_DIR \
-I $MILEPOST_DIR/ext -I $MILEPOST_DIR -I $MILEPOST_DIR/src"
-I $ORCA_DIR/src"
$CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c

View File

@ -12,6 +12,8 @@ else
fi
ORCA_DIR=../..
STDLIB_DIR=../../cstdlib
ORCA_SDK_DIR=../../sdk
wasmFlags="--target=wasm32 \
--no-standard-libraries \
@ -23,7 +25,10 @@ wasmFlags="--target=wasm32 \
-mbulk-memory \
-D__ORCA__ \
-I $ORCA_DIR/ext \
-isystem ../../cstdlib/include -I ../../sdk -I../../milepost/ext -I ../../milepost -I ../../milepost/src"
-I $STDLIB_DIR/include \
-I $ORCA_DIR/ext \
-I $ORCA_SDK_DIR \
-I $ORCA_DIR/src"
$CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c

View File

@ -67,7 +67,6 @@ def build_runtime(args):
def clean(args):
yeet("build")
yeet("milepost/build")
yeet("ext/angle")
yeet("scripts/files")
yeet("scripts/__pycache__")
@ -75,50 +74,47 @@ def clean(args):
def build_milepost(target, release):
print("Building milepost...")
with pushd("milepost"):
os.makedirs("../build/bin", exist_ok=True)
os.makedirs("../build/lib", exist_ok=True)
if target == "lib":
if platform.system() == "Windows":
build_milepost_lib_win(release)
elif platform.system() == "Darwin":
build_milepost_lib_mac(release)
else:
log_error(f"can't build milepost for unknown platform '{platform.system()}'")
exit(1)
elif target == "test":
with pushd("examples/test_app"):
# TODO?
subprocess.run(["./build.sh"])
elif target == "clean":
removeall("bin")
os.makedirs("build/bin", exist_ok=True)
os.makedirs("build/lib", exist_ok=True)
if target == "lib":
if platform.system() == "Windows":
build_milepost_lib_win(release)
elif platform.system() == "Darwin":
build_milepost_lib_mac(release)
else:
log_error(f"unrecognized milepost target '{target}'")
log_error(f"can't build milepost for unknown platform '{platform.system()}'")
exit(1)
elif target == "test":
with pushd("examples/test_app"):
# TODO?
subprocess.run(["./build.sh"])
elif target == "clean":
removeall("bin")
else:
log_error(f"unrecognized milepost target '{target}'")
exit(1)
def build_milepost_lib_win(release):
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",
"src\\glsl_shaders\\path_setup.glsl",
"src\\glsl_shaders\\segment_setup.glsl",
"src\\glsl_shaders\\backprop.glsl",
"src\\glsl_shaders\\merge.glsl",
"src\\glsl_shaders\\raster.glsl",
"src\\glsl_shaders\\balance_workgroups.glsl",
embed_text_files("src\\graphics\\glsl_shaders.h", "glsl_", [
"src\\graphics\\glsl_shaders\\common.glsl",
"src\\graphics\\glsl_shaders\\blit_vertex.glsl",
"src\\graphics\\glsl_shaders\\blit_fragment.glsl",
"src\\graphics\\glsl_shaders\\path_setup.glsl",
"src\\graphics\\glsl_shaders\\segment_setup.glsl",
"src\\graphics\\glsl_shaders\\backprop.glsl",
"src\\graphics\\glsl_shaders\\merge.glsl",
"src\\graphics\\glsl_shaders\\raster.glsl",
"src\\graphics\\glsl_shaders\\balance_workgroups.glsl",
])
includes = [
"/I", "src",
"/I", "src/util",
"/I", "src/platform",
"/I", "ext",
"/I", "../ext",
"/I", "../ext/angle/include",
"/I", "ext/angle/include",
]
libs = [
"user32.lib",
@ -131,7 +127,7 @@ def build_milepost_lib_win(release):
"ole32.lib",
"shell32.lib",
"shlwapi.lib",
"/LIBPATH:../ext/angle/bin",
"/LIBPATH:ext/angle/bin",
"libEGL.dll.lib",
"libGLESv2.dll.lib",
"/DELAYLOAD:libEGL.dll",
@ -148,8 +144,8 @@ def build_milepost_lib_win(release):
"/LD", "/link",
"/MANIFEST:EMBED", "/MANIFESTINPUT:src/win32_manifest.xml",
*libs,
"/OUT:../build/bin/milepost.dll",
"/IMPLIB:../build/bin/milepost.dll.lib",
"/OUT:build/bin/milepost.dll",
"/IMPLIB:build/bin/milepost.dll.lib",
], check=True)
@ -160,20 +156,20 @@ def build_milepost_lib_mac(release):
cflags = ["-std=c11"]
debug_flags = ["-O3"] if release else ["-g", "-DDEBUG", "-DLOG_COMPILE_DEBUG"]
ldflags = [f"-L{sdk_dir}/usr/lib", f"-F{sdk_dir}/System/Library/Frameworks/"]
includes = ["-Isrc", "-Isrc/util", "-Isrc/platform", "-Iext", "-I../ext", "-I../ext/angle/include"]
includes = ["-Isrc", "-Isrc/util", "-Isrc/platform", "-Iext", "-Iext/angle/include"]
# compile metal shader
subprocess.run([
"xcrun", "-sdk", "macosx", "metal",
# TODO: shaderFlagParam
"-fno-fast-math", "-c",
"-o", "../build/mtl_renderer.air",
"-o", "build/mtl_renderer.air",
"src/graphics/mtl_renderer.metal",
], check=True)
subprocess.run([
"xcrun", "-sdk", "macosx", "metallib",
"-o", "../build/bin/mtl_renderer.metallib",
"../build/mtl_renderer.air",
"-o", "build/bin/mtl_renderer.metallib",
"build/mtl_renderer.air",
], check=True)
# compile milepost. We use one compilation unit for all C code, and one
@ -181,14 +177,14 @@ def build_milepost_lib_mac(release):
subprocess.run([
"clang",
*debug_flags, "-c",
"-o", "../build/milepost_c.o",
"-o", "build/milepost_c.o",
*cflags, *flags, *includes,
"src/milepost.c"
], check=True)
subprocess.run([
"clang",
*debug_flags, "-c",
"-o", "../build/milepost_objc.o",
"-o", "build/milepost_objc.o",
*flags, *includes,
"src/milepost.m"
], check=True)
@ -197,9 +193,9 @@ def build_milepost_lib_mac(release):
subprocess.run([
"ld",
*ldflags, "-dylib",
"-o", "../build/bin/libmilepost.dylib",
"../build/milepost_c.o", "../build/milepost_objc.o",
"-L../ext/angle/bin", "-lc",
"-o", "build/bin/libmilepost.dylib",
"build/milepost_c.o", "build/milepost_objc.o",
"-Lext/angle/bin", "-lc",
"-framework", "Carbon", "-framework", "Cocoa", "-framework", "Metal", "-framework", "QuartzCore",
"-weak-lEGL", "-weak-lGLESv2",
], check=True)
@ -208,12 +204,12 @@ def build_milepost_lib_mac(release):
subprocess.run([
"install_name_tool",
"-change", "./libEGL.dylib", "@rpath/libEGL.dylib",
"../build/bin/libmilepost.dylib",
"build/bin/libmilepost.dylib",
], check=True)
subprocess.run([
"install_name_tool",
"-change", "./libGLESv2.dylib", "@rpath/libGLESv2.dylib",
"../build/bin/libmilepost.dylib",
"build/bin/libmilepost.dylib",
], check=True)
# add executable path to rpath. Client executable can still add its own
@ -221,7 +217,7 @@ def build_milepost_lib_mac(release):
subprocess.run([
"install_name_tool",
"-id", "@rpath/libmilepost.dylib",
"../build/bin/libmilepost.dylib",
"build/bin/libmilepost.dylib",
], check=True)