Add Orca install workflow
This commit is contained in:
parent
59f87436ce
commit
956ad51072
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# This file is copied into the user's home directory on install,
|
||||||
|
# but also can be run from the root of an Orca source checkout.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
root = True
|
||||||
|
try:
|
||||||
|
os.stat(".orcaroot")
|
||||||
|
except FileNotFoundError:
|
||||||
|
root = False
|
||||||
|
|
||||||
|
if root:
|
||||||
|
# Running from Orca source checkout; use local source's scripts.
|
||||||
|
|
||||||
|
scriptdir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
if scriptdir != os.getcwd():
|
||||||
|
# Only print this warning if running the system-installed Orca.
|
||||||
|
# It's annoying to see this if you run ./orca from the source.
|
||||||
|
print("The Orca tool is running from a local source checkout and will")
|
||||||
|
print("use that instead of the system Orca installation.")
|
||||||
|
print()
|
||||||
|
|
||||||
|
sys.path.append(os.getcwd())
|
||||||
|
import scripts.orca
|
||||||
|
else:
|
||||||
|
# Running from outside Orca source checkout; use system Orca install.
|
||||||
|
import sys_scripts.orca
|
|
@ -6,7 +6,7 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
from log import *
|
from .log import *
|
||||||
|
|
||||||
|
|
||||||
def attach_bundle_commands(subparsers):
|
def attach_bundle_commands(subparsers):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from log import *
|
from .log import *
|
||||||
|
|
||||||
|
|
||||||
def checkfile(filepath):
|
def checkfile(filepath):
|
||||||
|
|
|
@ -8,11 +8,11 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
import checksum
|
from . import checksum
|
||||||
from bindgen import bindgen
|
from .bindgen import bindgen
|
||||||
from bindgen2 import bindgen2
|
from .bindgen2 import bindgen2
|
||||||
from log import *
|
from .log import *
|
||||||
from utils import pushd, removeall
|
from .utils import pushd, removeall
|
||||||
|
|
||||||
|
|
||||||
ANGLE_VERSION = "2023-07-05"
|
ANGLE_VERSION = "2023-07-05"
|
||||||
|
@ -20,21 +20,28 @@ ANGLE_VERSION = "2023-07-05"
|
||||||
|
|
||||||
def attach_dev_commands(subparsers):
|
def attach_dev_commands(subparsers):
|
||||||
dev_cmd = subparsers.add_parser("dev", help="Commands for building Orca itself. Must be run from the root of an Orca source checkout.")
|
dev_cmd = subparsers.add_parser("dev", help="Commands for building Orca itself. Must be run from the root of an Orca source checkout.")
|
||||||
|
|
||||||
try:
|
|
||||||
os.stat(".orcaroot")
|
|
||||||
except FileNotFoundError:
|
|
||||||
dev_cmd.set_defaults(func=orca_root_only)
|
dev_cmd.set_defaults(func=orca_root_only)
|
||||||
return
|
|
||||||
|
|
||||||
dev_sub = dev_cmd.add_subparsers(required=True, title='commands')
|
dev_sub = dev_cmd.add_subparsers(required=is_orca_root(), title='commands')
|
||||||
|
|
||||||
build_cmd = dev_sub.add_parser("build-runtime", help="Build the Orca runtime from source.")
|
build_cmd = dev_sub.add_parser("build-runtime", help="Build the Orca runtime from source.")
|
||||||
build_cmd.add_argument("--release", action="store_true", help="compile Orca in release mode (default is debug)")
|
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))
|
build_cmd.set_defaults(func=dev_shellish(build_runtime))
|
||||||
|
|
||||||
clean_cmd = dev_sub.add_parser("clean", help="Delete all build artifacts and start fresh.")
|
clean_cmd = dev_sub.add_parser("clean", help="Delete all build artifacts and start fresh.")
|
||||||
clean_cmd.set_defaults(func=shellish(clean))
|
clean_cmd.set_defaults(func=dev_shellish(clean))
|
||||||
|
|
||||||
|
install_cmd = dev_sub.add_parser("install", help="Install the Orca tools into a system folder.")
|
||||||
|
install_cmd.add_argument("--no-confirm", action="store_true", help="don't ask the user for confirmation before installing")
|
||||||
|
install_cmd.set_defaults(func=dev_shellish(install))
|
||||||
|
|
||||||
|
|
||||||
|
def is_orca_root():
|
||||||
|
try:
|
||||||
|
os.stat(".orcaroot")
|
||||||
|
return True
|
||||||
|
except FileNotFoundError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def orca_root_only(args):
|
def orca_root_only(args):
|
||||||
|
@ -45,6 +52,10 @@ def orca_root_only(args):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def dev_shellish(func):
|
||||||
|
return shellish(func) if is_orca_root() else orca_root_only
|
||||||
|
|
||||||
|
|
||||||
def build_runtime(args):
|
def build_runtime(args):
|
||||||
ensure_programs()
|
ensure_programs()
|
||||||
ensure_angle()
|
ensure_angle()
|
||||||
|
@ -55,9 +66,6 @@ def build_runtime(args):
|
||||||
|
|
||||||
|
|
||||||
def clean(args):
|
def clean(args):
|
||||||
def yeet(path):
|
|
||||||
os.makedirs(path, exist_ok=True)
|
|
||||||
shutil.rmtree(path)
|
|
||||||
yeet("build")
|
yeet("build")
|
||||||
yeet("milepost/build")
|
yeet("milepost/build")
|
||||||
yeet("scripts/files")
|
yeet("scripts/files")
|
||||||
|
@ -530,3 +538,38 @@ def embed_text_glsl(outputpath, prefix, shaders):
|
||||||
output.write("#endif // __%s_H__\n" % outSymbol)
|
output.write("#endif // __%s_H__\n" % outSymbol)
|
||||||
|
|
||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
|
|
||||||
|
def yeet(path):
|
||||||
|
os.makedirs(path, exist_ok=True)
|
||||||
|
shutil.rmtree(path)
|
||||||
|
|
||||||
|
|
||||||
|
def install(args):
|
||||||
|
if not args.no_confirm:
|
||||||
|
dest = os.path.expanduser(os.path.join("~", ".orca"))
|
||||||
|
|
||||||
|
print("The Orca command-line tools will be installed to your home directory in:")
|
||||||
|
print(dest)
|
||||||
|
print()
|
||||||
|
while True:
|
||||||
|
answer = input("Proceed with the installation? (y/n) >")
|
||||||
|
if answer.lower() in ["y", "yes"]:
|
||||||
|
break
|
||||||
|
elif answer.lower() in ["n", "no"]:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
print("Please enter \"yes\" or \"no\" and press return.")
|
||||||
|
|
||||||
|
bin_dir = os.path.join(dest, "bin")
|
||||||
|
yeet(bin_dir)
|
||||||
|
shutil.copytree("scripts", os.path.join(bin_dir, "sys_scripts"))
|
||||||
|
shutil.copy("orca", bin_dir)
|
||||||
|
|
||||||
|
# TODO: Customize these instructions for Windows
|
||||||
|
print()
|
||||||
|
print("Orca has been installed. Make sure the Orca tools are on your PATH by adding the")
|
||||||
|
print("following to your shell config:")
|
||||||
|
print()
|
||||||
|
print(f"export PATH=\"{bin_dir}:$PATH\"")
|
||||||
|
print()
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from bundle import attach_bundle_commands
|
from .bundle import attach_bundle_commands
|
||||||
from dev import attach_dev_commands
|
from .dev import attach_dev_commands
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
Loading…
Reference in New Issue