-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved tooling, and getting started on the binaries
- Loading branch information
1 parent
c2171c2
commit e6a3c65
Showing
14 changed files
with
123 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# IDE Files | ||
*.code-workspace | ||
.vscode | ||
.idea | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,7 @@ license.workspace = true | |
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[[bin]] | ||
name = "arc" | ||
path = "bin/main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Callable | ||
|
||
class Gamepad(object): | ||
_id: str | ||
def __repr__(self) -> str: | ||
return f"<Gamepad {self._id}>" | ||
|
||
class Op(object): | ||
gamepad: Gamepad | ||
name: str | ||
def __init__(self, name: str) -> None: | ||
self.name = name | ||
def __repr__(self) -> str: | ||
return f"<Op {self.name}>" | ||
|
||
def _stub_op(op: Op) -> None: print("!!!OP IS NOT DEFINED!!!") | ||
|
||
_op: Callable[[Op], bool | int | str | None] | None = _stub_op | ||
|
||
OK = True | ||
def OP(func: Callable[[Op], bool | int | str | None]) -> None: | ||
_op = func | ||
|
||
def run_op() -> None: | ||
op = Op("auto") | ||
result = _op(op) | ||
if result == OK: return | ||
if result is None: return | ||
|
||
print(f"Program exited unsucessfully: {result}!") | ||
|
||
run_op() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
from typing import Callable | ||
|
||
type RunResult = bool | ||
type RunResult = bool | int | str | None | ||
class Gamepad(object): | ||
pass | ||
|
||
class Op(object): | ||
gamepad: Gamepad | ||
name: str | ||
def __init__(self, name: str) -> None: ... | ||
def __repr__(self) -> str: ... | ||
OK: RunResult = True | ||
FAIL: RunResult = False | ||
def MAIN(func: Callable[[], RunResult]) -> None: ... | ||
def OP(func: Callable[[Op], RunResult]) -> None: """ | ||
Run the given function as the main function of the program. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("ARC"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from arc import * | ||
|
||
def main() -> RunResult: | ||
print("Hello, world!") | ||
def auto(op: Op) -> RunResult: | ||
op.gamepad | ||
|
||
return OK | ||
|
||
MAIN(main) | ||
OP(auto) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("ARC Robot"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "arc-robot-hardware" | ||
description = "ARC Robot hardware" | ||
repository.workspace = true | ||
version.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
|
||
[lib] | ||
path = "lib.rs" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,42 @@ | ||
from libs.scripts.build import build | ||
from libs.scripts.clean import clean | ||
from libs.scripts.doc import doc | ||
from libs.scripts.test import test | ||
from libs.scripts.fmt import fmt | ||
from libs.scripts.run import run | ||
from libs.scripts.test import test | ||
|
||
def run_cmd(cmd: str, cwd: str, args: list[str]) -> str | int | None: | ||
if cmd == "help" or cmd == "--help" or cmd == "-h": return hlp() | ||
if cmd == "build": return build(cwd, args) | ||
if cmd == "clean": return clean(cwd, args) | ||
if cmd == "doc": return doc(cwd, args) | ||
if cmd == "test": return test(cwd, args) | ||
if cmd == "fmt": return fmt(cwd, args) | ||
if cmd == "run": return run(cwd, args) | ||
if cmd == "test": return test(cwd, args) | ||
|
||
return f"Unknown command: {cmd}" | ||
|
||
def hlp() -> str | int | None: | ||
print("""\033[35mUsage: \033[36m./epearl \033[32m<command> \033[96m[args]\033[0m | ||
\033[35mCommands: | ||
\033[32mbuild \033[0mBuild the project | ||
\033[96m--release\033[0m Build in release mode | ||
\033[32mrun \033[0mRun an OpMode | ||
\033[32m<file> \033[0mThe file to run | ||
\033[32mtest \033[0mRun the tests | ||
\033[96m--tarpaulin\033[0m Run the tests with tarpaulin | ||
\033[96m--llvm \033[0m Run the tests with llvm coverage | ||
\033[96m--all \033[0m Run the tests with both tarpaulin and llvm coverage | ||
\033[32mclean \033[0mClean the project | ||
\033[96m--deep \033[0mRemoves all generated files and folders | ||
\033[32mdoc \033[0mGenerate the documentation | ||
\033[32mtest \033[0mRun the tests | ||
\033[32mfmt \033[0mFormat the code | ||
\033[32mhelp \033[0mDisplay this message""") | ||
\033[96m--open \033[0mOpen the documentation in the browser | ||
\033[32mfmt \033[0mFix formatting issues in the code | ||
\033[96m--check \033[0mCheck if the code is formatted correctly | ||
\033[32mhelp \033[0mDisplay this message | ||
\033[35mExamples: | ||
\033[0mRun the example OpMode: \033[36m./epearl \033[32mrun \033[32m./examples/auto.py | ||
\033[0mBuild the project: \033[36m./epearl \033[32mbuild \033[96m--release | ||
\033[0mRun the tests: \033[36m./epearl \033[32mtest \033[96m--all | ||
\033[0m""") | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def run(cd: str, args: list[str]) -> str | int | None: | ||
import subprocess | ||
|
||
binary = "arc" | ||
if len(args) > 0: | ||
if '--bin=' in args[0]: | ||
binary = args[0].split('=')[1] | ||
args = args[1:] | ||
|
||
cmd = ["cargo", "run", "--bin", binary] | ||
res = subprocess.run(cmd, cwd=cd) | ||
if res.returncode != 0: return res.returncode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[project] | ||
name = "arc" | ||
version = "0.0.1-dev" | ||
description = "Advanced Robot Controller" | ||
requires-python = ">=3.11" |