Isolate dev commands to only run in Orca source

This commit is contained in:
Ben Visness 2023-07-29 14:03:44 -05:00
parent bbe34a3b58
commit 59f87436ce
3 changed files with 25 additions and 7 deletions

3
.orcaroot Normal file
View File

@ -0,0 +1,3 @@
You are currently at the root of the Orca source. Welcome.
This file exists to signal to the Orca CLI that you are in the Orca source and can do Orca source things. When the CLI detects this file, it will ignore the system Orca installation and use only the contents of this current source checkout.

View File

@ -18,18 +18,33 @@ from utils import pushd, removeall
ANGLE_VERSION = "2023-07-05" ANGLE_VERSION = "2023-07-05"
def attach_runtime_commands(subparsers): def attach_dev_commands(subparsers):
runtime_cmd = subparsers.add_parser("runtime", help="Commands for building the Orca runtime") dev_cmd = subparsers.add_parser("dev", help="Commands for building Orca itself. Must be run from the root of an Orca source checkout.")
runtime_sub = runtime_cmd.add_subparsers(required=True, title='commands')
build_cmd = runtime_sub.add_parser("build", help="Build the Orca runtime from source.") try:
os.stat(".orcaroot")
except FileNotFoundError:
dev_cmd.set_defaults(func=orca_root_only)
return
dev_sub = dev_cmd.add_subparsers(required=True, title='commands')
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=shellish(build_runtime))
clean_cmd = runtime_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=shellish(clean))
def orca_root_only(args):
print("The Orca dev commands can only be run from an Orca source checkout.")
print()
print("If you want to build Orca yourself, download the source here:")
print("https://git.handmade.network/hmn/orca")
exit(1)
def build_runtime(args): def build_runtime(args):
ensure_programs() ensure_programs()
ensure_angle() ensure_angle()

View File

@ -3,13 +3,13 @@
import argparse import argparse
from bundle import attach_bundle_commands from bundle import attach_bundle_commands
from runtime import attach_runtime_commands from dev import attach_dev_commands
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(required=True, title='commands') subparsers = parser.add_subparsers(required=True, title='commands')
attach_bundle_commands(subparsers) attach_bundle_commands(subparsers)
attach_runtime_commands(subparsers) attach_dev_commands(subparsers)
args = parser.parse_args() args = parser.parse_args()
args.func(args) args.func(args)