From 59f87436ce5eafc9418d131d7d10d14acc903ce3 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 29 Jul 2023 14:03:44 -0500 Subject: [PATCH] Isolate dev commands to only run in Orca source --- .orcaroot | 3 +++ scripts/{runtime.py => dev.py} | 25 ++++++++++++++++++++----- scripts/{orca.py => orca} | 4 ++-- 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 .orcaroot rename scripts/{runtime.py => dev.py} (94%) rename scripts/{orca.py => orca} (76%) diff --git a/.orcaroot b/.orcaroot new file mode 100644 index 0000000..394e764 --- /dev/null +++ b/.orcaroot @@ -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. diff --git a/scripts/runtime.py b/scripts/dev.py similarity index 94% rename from scripts/runtime.py rename to scripts/dev.py index 4cb62d7..8b453b4 100644 --- a/scripts/runtime.py +++ b/scripts/dev.py @@ -18,18 +18,33 @@ from utils import pushd, removeall ANGLE_VERSION = "2023-07-05" -def attach_runtime_commands(subparsers): - runtime_cmd = subparsers.add_parser("runtime", help="Commands for building the Orca runtime") - runtime_sub = runtime_cmd.add_subparsers(required=True, title='commands') +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.") - 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.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)) +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): ensure_programs() ensure_angle() diff --git a/scripts/orca.py b/scripts/orca similarity index 76% rename from scripts/orca.py rename to scripts/orca index 104f5f0..f8b9750 100755 --- a/scripts/orca.py +++ b/scripts/orca @@ -3,13 +3,13 @@ import argparse from bundle import attach_bundle_commands -from runtime import attach_runtime_commands +from dev import attach_dev_commands parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(required=True, title='commands') attach_bundle_commands(subparsers) -attach_runtime_commands(subparsers) +attach_dev_commands(subparsers) args = parser.parse_args() args.func(args)