about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTheofilos Augoustis <theofilos.augoustis@tum.de>2025-08-28 13:31:51 +0000
committerTheofilos Augoustis <theofilos.augoustis@tum.de>2025-08-28 13:31:51 +0000
commit1ed51b9a902d7669c4dd26edf1a75d79c888bef4 (patch)
tree30ecfa2ce98474fd4447d2dcf1814d4c16661602
parentff3c9a0136b1b308a06d01108157146cc315274b (diff)
downloadfocaccia-1ed51b9a902d7669c4dd26edf1a75d79c888bef4.tar.gz
focaccia-1ed51b9a902d7669c4dd26edf1a75d79c888bef4.zip
Refactor tool handling to match flake system
-rw-r--r--flake.nix81
-rw-r--r--pyproject.toml5
-rw-r--r--src/focaccia/tools/__init__.py0
-rw-r--r--src/focaccia/tools/_qemu_tool.py (renamed from tools/_qemu_tool.py)0
-rwxr-xr-xsrc/focaccia/tools/capture_transforms.py (renamed from tools/capture_transforms.py)0
-rwxr-xr-xsrc/focaccia/tools/convert.py (renamed from tools/convert.py)0
-rwxr-xr-xsrc/focaccia/tools/validate_qemu.py (renamed from tools/verify_qemu.py)9
7 files changed, 73 insertions, 22 deletions
diff --git a/flake.nix b/flake.nix
index 63a1d90..b199e83 100644
--- a/flake.nix
+++ b/flake.nix
@@ -186,54 +186,97 @@
 
 		 # Create a Python venv with the default dependency group
 		 pythonDevEnv = pythonSetEditable.mkVirtualEnv "focaccia-env" workspace.deps.all;
-	in {
+
+		 uvEnv = {
+			UV_NO_SYNC = "1";
+			UV_PYTHON = python.interpreter;
+			UV_PYTHON_DOWNLOADS = "never";
+		};
+
+		uvShellHook = ''
+			unset PYTHONPATH
+
+			export REPO_ROOT=$(git rev-parse --show-toplevel)
+		'';
+	in rec {
 		# Default package just builds Focaccia
-		packages.default = pythonDevEnv;
+		packages = rec {
+			focaccia = pythonEnv;
+			dev = pythonDevEnv;
+
+			default = focaccia;
+		};
 
 		# Default app is just Focaccia
-		apps.default = {
-			type = "app";
-			program = "${self.packages.default}/bin/focaccia";
+		apps = {
+			default = {
+				type = "app";
+				program = "${packages.default}/bin/focaccia";
+			};
+
+			convert-log = {
+				type = "app";
+				program = "${packages.default}/bin/convert";
+			};
+
+			capture-transforms = {
+				type = "app";
+				program = "${packages.default}/bin/capture-transforms";
+			};
+
+			validate-qemu = {
+				type = "app";
+				program = "${packages.default}/bin/validate-qemu";
+			};
+
+			# Useful for synchronize the uv lockfile
+			uv-sync = {
+				type = "app";
+				program = "${pkgs.writeShellScriptBin "uv-sync" ''
+					set -euo pipefail
+					exec ${pkgs.uv}/bin/uv sync
+				''}/bin/uv-sync";
+			};
 		};
 
 		# Developer shell that includes Focaccia and QEMU
 		devShells = {
 			default = pkgs.mkShell {
 				packages = [
-					pythonDevEnv
+					packages.dev
+					pkgs.uv
 					pkgs.gdb
 					pkgs.git
 				];
 
-				env = {
-					UV_NO_SYNC = "1";
-					UV_PYTHON = python.interpreter;
-					UV_PYTHON_DOWNLOADS = "never";
-				};
-
-				shellHook = ''
-					unset PYTHONPATH
-
-					export REPO_ROOT=$(git rev-parse --show-toplevel)
-				'';
+				env = uvEnv;
+				shellHook = uvShellHook;
 			};
 
 			glibc = pkgs.mkShell {
 				packages = [
-					pythonEnv
+					packages.dev
+					pkgs.uv
 					pkgs.gdb
 					pkgs.gcc
 					pkgs.glibc.all
 				];
+
+				env = uvEnv;
+				shellHook = uvShellHook;
 			};
 
 			musl = pkgs.mkShell {
 				packages = [
-					pythonDevEnv
+					packages.dev
+					pkgs.uv
 					pkgs.gdb
 					musl-pkgs.gcc
 					musl-pkgs.pkg-config
 				];
+
+				env = uvEnv;
+				shellHook = uvShellHook;
 			};
 		};
 	});
diff --git a/pyproject.toml b/pyproject.toml
index 25cdcd6..4e323df 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -25,7 +25,10 @@ dev = [
 ]
 
 [project.scripts]
-focaccia = "focaccia:cli.main"
+focaccia = "focaccia.cli:main"
+convert = "focaccia.tools.convert:main"
+capture-transforms = "focaccia.tools.capture_transforms:main"
+validate-qemu = "focaccia.tools.validate_qemu:main"
 
 [build-system]
 requires = ["hatchling"]
diff --git a/src/focaccia/tools/__init__.py b/src/focaccia/tools/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/focaccia/tools/__init__.py
diff --git a/tools/_qemu_tool.py b/src/focaccia/tools/_qemu_tool.py
index b365d39..b365d39 100644
--- a/tools/_qemu_tool.py
+++ b/src/focaccia/tools/_qemu_tool.py
diff --git a/tools/capture_transforms.py b/src/focaccia/tools/capture_transforms.py
index 552b855..552b855 100755
--- a/tools/capture_transforms.py
+++ b/src/focaccia/tools/capture_transforms.py
diff --git a/tools/convert.py b/src/focaccia/tools/convert.py
index f21a2fa..f21a2fa 100755
--- a/tools/convert.py
+++ b/src/focaccia/tools/convert.py
diff --git a/tools/verify_qemu.py b/src/focaccia/tools/validate_qemu.py
index 7402852..f5d0bb2 100755
--- a/tools/verify_qemu.py
+++ b/src/focaccia/tools/validate_qemu.py
@@ -19,6 +19,7 @@ import os
 import subprocess
 import sys
 
+import focaccia
 from focaccia.compare import ErrorTypes
 
 verbosity = {
@@ -70,13 +71,13 @@ def try_remove(l: list, v):
     except ValueError:
         pass
 
-if __name__ == "__main__":
+def main():
     prog = make_argparser()
     prog.add_argument('--gdb', default='gdb',
                       help='GDB binary to invoke.')
     args = prog.parse_args()
 
-    filepath = os.path.realpath(__file__)
+    filepath = focaccia.__file__
     qemu_tool_path = os.path.join(os.path.dirname(filepath), '_qemu_tool.py')
 
     # We have to remove all arguments we don't want to pass to the qemu tool
@@ -104,3 +105,7 @@ if __name__ == "__main__":
 
     ret = proc.wait()
     exit(ret)
+
+if __name__ == "__main__":
+    main()
+