From bdb9843fd9d54e33fa2f9f691962e46a926fcf79 Mon Sep 17 00:00:00 2001
From: Lucas Briese <lucas.briese@iem.fraunhofer.de>
Date: Fri, 26 Jul 2024 14:02:14 +0200
Subject: [PATCH] build: venv for quick tasks

---
 .dockerignore |  1 +
 .gitignore    |  1 +
 venv          | 21 +++++++++++++++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 venv

diff --git a/.dockerignore b/.dockerignore
index 7a12d08c..1a759236 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -10,3 +10,4 @@ bin
 **/.DS_Store
 src/test/testResults/*
 app/backend/tools/db/cockroach-data
+opencode-venv
diff --git a/.gitignore b/.gitignore
index 68465b42..44b9e2b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ bin
 **/.DS_Store
 src/test/testResults/*
 app/backend/tools/db/cockroach-data
+opencode-venv
diff --git a/venv b/venv
new file mode 100644
index 00000000..0139e3df
--- /dev/null
+++ b/venv
@@ -0,0 +1,21 @@
+# this file is expected to be sourced!
+set -uo pipefail
+(
+  if [ ! -d "opencode-venv" ]; then
+    python3 -m venv opencode-venv
+  fi
+
+  # for each task install ln on ./gradlew
+  mapfile -t tasks < <(grep -Poe 'tasks\.register[^(]*\("\K[^"]*' build.gradle.kts || true)
+  (
+    repo_root=$(pwd)
+    cd opencode-venv/bin/ || exit 2
+    for task in "${tasks[@]}"; do
+      rm "$task" &>/dev/null || true
+      echo "cd $repo_root && ./gradlew $task \"\$@\"" > "$task"
+      chmod +x "$task"
+    done
+  )
+)
+
+source opencode-venv/bin/activate
-- 
GitLab