Add --environment/-e flag to select PlatformIO build environment

This commit is contained in:
justin committed 2026-04-01 19:01:55 -07:00
1 parent e760fdc653
commit 781a291cd0
2 files changed
+49 -7

No files matched your search

+13
View File
@@ -53,6 +53,19 @@ From the root of this repository, run:
python3 install.py
```
By default this uses the `default` build environment. To use a different environment pass `-e`:
```bash
python3 install.py -e slim
python3 install.py -e gh_release
```
| Environment | Description |
|-------------|-------------|
| `default` | Debug logging enabled, version from current git branch (recommended) |
| `gh_release` | Info logging only, version hardcoded to release tag |
| `slim` | No serial logging, smallest binary size |
The installer will:
1. Clone the CrossPoint Reader source repository
+36 -7
View File
@@ -6,11 +6,18 @@ import shutil
import subprocess
import glob
import importlib.util
import argparse
REPO_URL = "https://github.com/crosspoint-reader/crosspoint-reader.git"
REPO_DIR = "crosspoint-reader"
REPO_URL = "https://github.com/crosspoint-reader/crosspoint-reader.git"
REPO_DIR = "crosspoint-reader"
PLUGINS_DIR = "plugins"
ENVIRONMENTS = {
"default": "Debug logging enabled, version from current git branch (recommended)",
"gh_release": "Info logging only, version hardcoded to release tag",
"slim": "No serial logging, smallest binary size",
}
def run(cmd, cwd=None, check=True):
print(f" $ {cmd}")
@@ -176,20 +183,38 @@ def prompt_for_upload_port():
print(" Please enter a valid port name.")
def build_and_flash():
print("\nBuilding firmware with PlatformIO...")
run("pio run --environment default", cwd=REPO_DIR)
def build_and_flash(environment: str):
print(f"\nBuilding firmware with PlatformIO (environment: {environment})...")
run(f"pio run --environment {environment}", cwd=REPO_DIR)
port = prompt_for_upload_port()
print(f"\n Flashing to {port}...")
run(
f"pio run --target upload --environment default --upload-port {port}",
f"pio run --target upload --environment {environment} --upload-port {port}",
cwd=REPO_DIR,
)
def parse_args():
parser = argparse.ArgumentParser(
description="xteink Plugin Installer",
formatter_class=argparse.RawTextHelpFormatter,
)
env_help = "\n".join(f" {name}: {desc}" for name, desc in ENVIRONMENTS.items())
parser.add_argument(
"-e", "--environment",
default="default",
choices=ENVIRONMENTS.keys(),
metavar="ENV",
help=f"PlatformIO build environment (default: default)\n{env_help}",
)
return parser.parse_args()
def main():
args = parse_args()
print("=" * 60)
print(" xteink Plugin Installer")
print("=" * 60)
@@ -199,6 +224,9 @@ def main():
print(" no responsibility for any damage that may occur to your")
print(" device as a result of using this installer.")
print()
print(f" Environment : {args.environment}")
print(f" {ENVIRONMENTS[args.environment]}")
print()
answer = input(" Do you wish to proceed? [Y/n]: ").strip().lower()
if answer not in ("", "y", "yes"):
print(" Aborted.")
@@ -206,8 +234,9 @@ def main():
print()
clone_repo()
apply_plugins()
build_and_flash()
build_and_flash(args.environment)
print("\nDone.")
if __name__ == "__main__":
main()