This commit will not hard-lock your Mac
This commit is contained in:
parent
731b5a6bba
commit
8bd12bdd1f
|
@ -1,6 +1,7 @@
|
|||
.DS_Store
|
||||
*.dSYM
|
||||
bin/*
|
||||
build
|
||||
*.metallib
|
||||
*.pdb
|
||||
*.exe
|
||||
|
|
|
@ -19,9 +19,12 @@ ANGLE_VERSION = "2023-07-05"
|
|||
|
||||
|
||||
def attach_build_runtime(subparsers):
|
||||
build = subparsers.add_parser("build-runtime", help="TODO")
|
||||
build.add_argument("--release", action="store_true", help="compile Orca in release mode (default is debug)")
|
||||
build.set_defaults(func=shellish(build_runtime))
|
||||
build_cmd = subparsers.add_parser("build-runtime", help="TODO")
|
||||
build_cmd.add_argument("--release", action="store_true", help="compile Orca in release mode (default is debug)")
|
||||
build_cmd.set_defaults(func=shellish(build_runtime))
|
||||
|
||||
clean_cmd = subparsers.add_parser("clean", help="Delete all build artifacts and start fresh")
|
||||
clean_cmd.set_defaults(func=shellish(clean))
|
||||
|
||||
|
||||
def build_runtime(args):
|
||||
|
@ -33,11 +36,21 @@ def build_runtime(args):
|
|||
build_orca(args.release)
|
||||
|
||||
|
||||
def clean(args):
|
||||
def yeet(path):
|
||||
os.makedirs(path, exist_ok=True)
|
||||
shutil.rmtree(path)
|
||||
yeet("build")
|
||||
yeet("milepost/build")
|
||||
yeet("scripts/files")
|
||||
yeet("scripts/__pycache__")
|
||||
|
||||
|
||||
def build_milepost(target, release):
|
||||
print("Building milepost...")
|
||||
with pushd("milepost"):
|
||||
os.makedirs("bin", exist_ok=True)
|
||||
os.makedirs("lib", exist_ok=True)
|
||||
os.makedirs("build/bin", exist_ok=True)
|
||||
os.makedirs("build/lib", exist_ok=True)
|
||||
os.makedirs("resources", exist_ok=True)
|
||||
|
||||
if target == "lib":
|
||||
|
@ -126,13 +139,13 @@ def build_milepost_lib_mac(release):
|
|||
"xcrun", "-sdk", "macosx", "metal",
|
||||
# TODO: shaderFlagParam
|
||||
"-fno-fast-math", "-c",
|
||||
"-o", "lib/mtl_renderer.air",
|
||||
"-o", "build/mtl_renderer.air",
|
||||
"src/mtl_renderer.metal",
|
||||
], check=True)
|
||||
subprocess.run([
|
||||
"xcrun", "-sdk", "macosx", "metallib",
|
||||
"-o", "lib/mtl_renderer.metallib",
|
||||
"lib/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
|
||||
|
@ -140,14 +153,14 @@ def build_milepost_lib_mac(release):
|
|||
subprocess.run([
|
||||
"clang",
|
||||
*debug_flags, "-c",
|
||||
"-o", "bin/milepost_c.o",
|
||||
"-o", "build/milepost_c.o",
|
||||
*cflags, *flags, *includes,
|
||||
"src/milepost.c"
|
||||
], check=True)
|
||||
subprocess.run([
|
||||
"clang",
|
||||
*debug_flags, "-c",
|
||||
"-o", "bin/milepost_objc.o",
|
||||
"-o", "build/milepost_objc.o",
|
||||
*flags, *includes,
|
||||
"src/milepost.m"
|
||||
], check=True)
|
||||
|
@ -156,9 +169,9 @@ def build_milepost_lib_mac(release):
|
|||
subprocess.run([
|
||||
"ld",
|
||||
*ldflags, "-dylib",
|
||||
"-o", "bin/libmilepost.dylib",
|
||||
"bin/milepost_c.o", "bin/milepost_objc.o",
|
||||
"-Llib", "-lc",
|
||||
"-o", "build/bin/libmilepost.dylib",
|
||||
"build/milepost_c.o", "build/milepost_objc.o",
|
||||
"-Lbuild/bin", "-lc",
|
||||
"-framework", "Carbon", "-framework", "Cocoa", "-framework", "Metal", "-framework", "QuartzCore",
|
||||
"-weak-lEGL", "-weak-lGLESv2",
|
||||
], check=True)
|
||||
|
@ -167,12 +180,12 @@ def build_milepost_lib_mac(release):
|
|||
subprocess.run([
|
||||
"install_name_tool",
|
||||
"-change", "./libEGL.dylib", "@rpath/libEGL.dylib",
|
||||
"bin/libmilepost.dylib",
|
||||
"build/bin/libmilepost.dylib",
|
||||
], check=True)
|
||||
subprocess.run([
|
||||
"install_name_tool",
|
||||
"-change", "./libGLESv2.dylib", "@rpath/libGLESv2.dylib",
|
||||
"bin/libmilepost.dylib",
|
||||
"build/bin/libmilepost.dylib",
|
||||
], check=True)
|
||||
|
||||
# add executable path to rpath. Client executable can still add its own
|
||||
|
@ -180,15 +193,16 @@ def build_milepost_lib_mac(release):
|
|||
subprocess.run([
|
||||
"install_name_tool",
|
||||
"-id", "@rpath/libmilepost.dylib",
|
||||
"bin/libmilepost.dylib",
|
||||
"build/bin/libmilepost.dylib",
|
||||
], check=True)
|
||||
|
||||
|
||||
def build_wasm3(release):
|
||||
print("Building wasm3...")
|
||||
|
||||
os.makedirs("bin", exist_ok=True)
|
||||
os.makedirs("bin/obj", exist_ok=True)
|
||||
os.makedirs("build/bin", exist_ok=True)
|
||||
os.makedirs("build/lib", exist_ok=True)
|
||||
os.makedirs("build/obj", exist_ok=True)
|
||||
|
||||
if platform.system() == "Windows":
|
||||
build_wasm3_lib_win(release)
|
||||
|
@ -217,8 +231,8 @@ def build_wasm3_lib_win(release):
|
|||
|
||||
|
||||
def build_wasm3_lib_mac(release):
|
||||
includes = ["-I./ext/wasm3/source"]
|
||||
debug_flags = ["-O2"] if release else ["-g"]
|
||||
includes = ["-Iext/wasm3/source"]
|
||||
debug_flags = ["-g", "-O2"]
|
||||
flags = [
|
||||
*debug_flags,
|
||||
"-foptimize-sibling-calls",
|
||||
|
@ -226,21 +240,22 @@ def build_wasm3_lib_mac(release):
|
|||
"-Dd_m3VerboseErrorMessages",
|
||||
]
|
||||
|
||||
for f in glob.iglob("./ext/wasm3/source/*.c"):
|
||||
for f in glob.iglob("ext/wasm3/source/*.c"):
|
||||
name = os.path.splitext(os.path.basename(f))[0] + ".o"
|
||||
subprocess.run([
|
||||
"clang", "-c", *flags, *includes,
|
||||
"-o", f"./bin/obj/{name}",
|
||||
"-o", f"build/obj/{name}",
|
||||
f,
|
||||
], check=True)
|
||||
subprocess.run(["ar", "-rcs", "./bin/libwasm3.a", *glob.glob("./bin/obj/*.o")], check=True)
|
||||
subprocess.run(["rm", "-rf", "./bin/obj"], check=True)
|
||||
subprocess.run(["ar", "-rcs", "build/lib/libwasm3.a", *glob.glob("build/obj/*.o")], check=True)
|
||||
subprocess.run(["rm", "-rf", "build/obj"], check=True)
|
||||
|
||||
|
||||
def build_orca(release):
|
||||
print("Building Orca...")
|
||||
|
||||
os.makedirs("bin", exist_ok=True)
|
||||
os.makedirs("build/bin", exist_ok=True)
|
||||
os.makedirs("build/lib", exist_ok=True)
|
||||
|
||||
if platform.system() == "Windows":
|
||||
build_orca_win(release)
|
||||
|
@ -292,10 +307,10 @@ def build_orca_win(release):
|
|||
|
||||
def build_orca_mac(release):
|
||||
# copy libraries
|
||||
shutil.copy("milepost/bin/mtl_renderer.metallib", "bin/")
|
||||
shutil.copy("milepost/bin/libmilepost.dylib", "bin/")
|
||||
shutil.copy("milepost/bin/libGLESv2.dylib", "bin/")
|
||||
shutil.copy("milepost/bin/libEGL.dylib", "bin/")
|
||||
shutil.copy("milepost/build/bin/mtl_renderer.metallib", "build/bin/")
|
||||
shutil.copy("milepost/build/bin/libmilepost.dylib", "build/bin/")
|
||||
shutil.copy("milepost/build/bin/libGLESv2.dylib", "build/bin/")
|
||||
shutil.copy("milepost/build/bin/libEGL.dylib", "build/bin/")
|
||||
|
||||
includes = [
|
||||
"-Isrc",
|
||||
|
@ -306,7 +321,7 @@ def build_orca_mac(release):
|
|||
"-Iext/wasm3/source",
|
||||
"-Imilepost/ext/",
|
||||
]
|
||||
libs = ["-Lbin", "-lmilepost", "-lwasm3"]
|
||||
libs = ["-Lbuild/bin", "-Lbuild/lib", "-lmilepost", "-lwasm3"]
|
||||
debug_flags = ["-O2"] if release else ["-g", "-DLOG_COMPILE_DEBUG"]
|
||||
flags = [
|
||||
*debug_flags,
|
||||
|
@ -319,18 +334,20 @@ def build_orca_mac(release):
|
|||
# compile orca
|
||||
subprocess.run([
|
||||
"clang", *flags, *includes, *libs,
|
||||
"-o", "bin/orca",
|
||||
"-o", "build/bin/orca",
|
||||
"src/main.c",
|
||||
], check=True)
|
||||
|
||||
# fix libs imports
|
||||
subprocess.run([
|
||||
"install_name_tool", "-change",
|
||||
"./bin/libmilepost.dylib", "@rpath/libmilepost.dylib", "bin/orca",
|
||||
"install_name_tool",
|
||||
"-change", "build/bin/libmilepost.dylib", "@rpath/libmilepost.dylib",
|
||||
"build/bin/orca",
|
||||
], check=True)
|
||||
subprocess.run([
|
||||
"install_name_tool", "-add_rpath",
|
||||
"@executable_path/", "bin/orca",
|
||||
"install_name_tool",
|
||||
"-add_rpath", "@executable_path/",
|
||||
"build/bin/orca",
|
||||
], check=True)
|
||||
|
||||
|
||||
|
@ -400,8 +417,8 @@ def verify_angle():
|
|||
]
|
||||
elif platform.system() == "Darwin":
|
||||
checkfiles = [
|
||||
"milepost/lib/libEGL.dylib",
|
||||
"milepost/lib/libGLESv2.dylib",
|
||||
"milepost/build/bin/libEGL.dylib",
|
||||
"milepost/build/bin/libGLESv2.dylib",
|
||||
]
|
||||
|
||||
if checkfiles is None:
|
||||
|
@ -424,10 +441,15 @@ def download_angle():
|
|||
print("Downloading ANGLE...")
|
||||
if platform.system() == "Windows":
|
||||
build = "windows-2019"
|
||||
extensions = ["dll", "lib"]
|
||||
extensions = [
|
||||
("dll", "milepost/build/bin/"),
|
||||
("lib", "milepost/build/lib/"),
|
||||
]
|
||||
elif platform.system() == "Darwin":
|
||||
build = "macos-jank"
|
||||
extensions = ["dylib"]
|
||||
extensions = [
|
||||
("dylib", "milepost/build/bin/"),
|
||||
]
|
||||
else:
|
||||
log_error(f"could not automatically download ANGLE for unknown platform {platform.system()}")
|
||||
return
|
||||
|
@ -448,11 +470,12 @@ def download_angle():
|
|||
with ZipFile(filepath, "r") as anglezip:
|
||||
anglezip.extractall(path="scripts/files")
|
||||
|
||||
os.makedirs("milepost/lib", exist_ok=True)
|
||||
os.makedirs("milepost/build/bin", exist_ok=True)
|
||||
os.makedirs("milepost/build/lib", exist_ok=True)
|
||||
for angleDir in ["bin", "lib"]:
|
||||
for ext in extensions:
|
||||
for (ext, dest) in extensions:
|
||||
for filepath in glob.glob(f"scripts/files/angle/{angleDir}/*.{ext}"):
|
||||
shutil.copy(filepath, "milepost/lib")
|
||||
shutil.copy(filepath, dest)
|
||||
|
||||
|
||||
def embed_text_glsl(outputpath, prefix, shaders):
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"milepost/lib/libEGL.dll.lib": "4cec54c534136da413dea86bd271ccb9c5ae88e40aa91d1de7a01e701be8e1d7",
|
||||
"milepost/lib/libGLESv2.dll": "193b53b0a16b702eaa28a73e84527acf7aecfd665e3e3f54a8d9db9ae73111e1",
|
||||
"milepost/lib/libGLESv2.dll.lib": "ee87aac129efe8fe871825d181b85da1b1ea6626cb48be52c2e689f2804b953f",
|
||||
"milepost/lib/libEGL.dylib": "96baea4b1c8578d30738764784d07b509d1153df694c094faba2ee8ccbfde2a9",
|
||||
"milepost/lib/libGLESv2.dylib": "98ce9f6248a6447ba9199e96b8f6d87df9548d43ce583a2615717aab168ecb71"
|
||||
"milepost/build/bin/libEGL.dylib": "96baea4b1c8578d30738764784d07b509d1153df694c094faba2ee8ccbfde2a9",
|
||||
"milepost/build/bin/libGLESv2.dylib": "98ce9f6248a6447ba9199e96b8f6d87df9548d43ce583a2615717aab168ecb71"
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ def macos_make_app(args):
|
|||
#-----------------------------------------------------------
|
||||
#NOTE: copy orca runtime executable and libraries
|
||||
#-----------------------------------------------------------
|
||||
orca_exe = args.orca_dir + '/bin/orca'
|
||||
milepost_lib = args.orca_dir + '/bin/libmilepost.dylib'
|
||||
gles_lib = args.orca_dir + '/bin/libGLESv2.dylib'
|
||||
egl_lib = args.orca_dir + '/bin/libEGL.dylib'
|
||||
renderer_lib = args.orca_dir + '/bin/mtl_renderer.metallib'
|
||||
orca_exe = args.orca_dir + '/build/bin/orca'
|
||||
milepost_lib = args.orca_dir + '/build/bin/libmilepost.dylib'
|
||||
gles_lib = args.orca_dir + '/build/bin/libGLESv2.dylib'
|
||||
egl_lib = args.orca_dir + '/build/bin/libEGL.dylib'
|
||||
renderer_lib = args.orca_dir + '/build/bin/mtl_renderer.metallib'
|
||||
|
||||
shutil.copy(orca_exe, exe_dir)
|
||||
shutil.copy(milepost_lib, exe_dir)
|
||||
|
@ -169,11 +169,11 @@ def windows_make_app(args):
|
|||
#-----------------------------------------------------------
|
||||
#NOTE: copy orca runtime executable and libraries
|
||||
#-----------------------------------------------------------
|
||||
orca_exe = args.orca_dir + '/bin/orca.exe'
|
||||
milepost_lib = args.orca_dir + '/bin/milepost.dll'
|
||||
gles_lib = args.orca_dir + '/milepost/bin/libGLESv2.dll'
|
||||
egl_lib = args.orca_dir + '/milepost/bin/libEGL.dll'
|
||||
pthread_lib = args.orca_dir + '/bin/pthreadVC3.dll'
|
||||
orca_exe = args.orca_dir + '/build/bin/orca.exe'
|
||||
milepost_lib = args.orca_dir + '/build/bin/milepost.dll'
|
||||
gles_lib = args.orca_dir + '/milepost/build/bin/libGLESv2.dll'
|
||||
egl_lib = args.orca_dir + '/milepost/build/bin/libEGL.dll'
|
||||
pthread_lib = args.orca_dir + '/build/bin/pthreadVC3.dll'
|
||||
|
||||
shutil.copy(orca_exe, exe_dir)
|
||||
shutil.copy(milepost_lib, exe_dir)
|
||||
|
|
Loading…
Reference in New Issue