Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.

Commit 882da33

Browse files
committed
chore: add scripts
1 parent 6b9b05e commit 882da33

6 files changed

Lines changed: 129 additions & 10 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea/
2-
cmake-build-debug/
2+
cmake-build-debug/
3+
venv/

‎README.md‎

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
11
## Getting Started
22

3+
### Prerequisites
4+
5+
- **CMake** (version 3.16+ recommended)
6+
- **Python 3.8+** (for development environment and tooling)
7+
- A C++17 capable compiler (e.g. `g++`, `clang++`, or MSVC on Windows)
8+
9+
### Setup
10+
11+
#### GNU/Linux
12+
313
```bash
4-
mkdir build
5-
cd build
6-
cmake ..
7-
make
14+
bash ./scripts/setup.sh
15+
```
16+
17+
#### Windows (PowerShell)
18+
19+
```powershell
20+
. .\scripts\setup.ps1
821
```
922

23+
---
24+
1025
## Usage
1126

27+
After building, you can run the interpreter with:
28+
1229
```bash
13-
usage: lbd [options]
30+
lbd [options]
31+
```
1432

15-
options:
33+
### Options
34+
35+
```
1636
-f, --file <filename> Specify input source file to run
1737
-h, --help Show this help message and exit
1838
-d, --debug Enable debug mode
19-
-r, --repl Run in interactive REPL node
39+
-r, --repl Run in interactive REPL mode
2040
```
2141

22-
> TODO: Add build instructions for Windows as well.
42+
---
43+
44+
### TODO
2345

24-
> TODO: Add small script to print all TODOs and there Loc.
46+
- TODO: Add build instructions for Windows (MSVC toolchain).
47+
- TODO: Provide better examples (e.g., Advent of Code snippets).

‎requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pathspec # used in scripts/dump_todo.py

‎scripts/dump_todo.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
This script recursively scans the current directory for lines containing "TOD0:" and
3+
prints them in the format relative_filepath:line_number: TOD0: tod0 text.
4+
It skips scanning itself, respects .gitignore rules using the pathspec library, and
5+
ignores files that cannot be read due to encoding or permission issues.
6+
P.S. TOD0 is intentionally misspelled here, and in above description.
7+
"""
8+
9+
import os
10+
import pathspec
11+
12+
BASE_DIR = "."
13+
SCRIPT_PATH = os.path.abspath(__file__) # Absolute path of this script
14+
15+
EXCLUDE_PATHS = {
16+
os.path.relpath(SCRIPT_PATH, BASE_DIR),
17+
".git",
18+
}
19+
20+
GITIGNORE_PATH = os.path.join(BASE_DIR, ".gitignore")
21+
spec = None
22+
if os.path.exists(GITIGNORE_PATH):
23+
with open(GITIGNORE_PATH, "r", encoding="utf-8") as f:
24+
spec = pathspec.PathSpec.from_lines("gitwildmatch", f)
25+
26+
for root, _, files in os.walk(BASE_DIR):
27+
for filename in files:
28+
filepath: str = os.path.join(root, filename)
29+
rel_path: str = os.path.relpath(filepath, BASE_DIR)
30+
if any(rel_path == p or rel_path.startswith(p + os.sep) for p in EXCLUDE_PATHS):
31+
continue
32+
if spec and spec.match_file(rel_path):
33+
continue
34+
try:
35+
with open(filepath, "r", encoding="utf-8") as f:
36+
for lineno, line in enumerate(f, start=1):
37+
if "TODO:" in line:
38+
todo_index = line.index("TODO:")
39+
todo_text = line[todo_index:].strip()
40+
print(f"{rel_path}:{lineno}: {todo_text}")
41+
except (UnicodeDecodeError, PermissionError):
42+
# Skip files that can’t be read as text
43+
continue

‎scripts/setup.ps1‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This script sets up the project which includes building the CMake project, and
2+
# creating python environment for development.
3+
# Should be run from within the PROJECT ROOT.
4+
5+
# --- CMake Project Setup ---
6+
$BuildDir = "cmake-build-debug"
7+
if (!(Test-Path $BuildDir))
8+
{
9+
New-Item -ItemType Directory -Path $BuildDir | Out-Null
10+
}
11+
Set-Location $BuildDir
12+
cmake ..
13+
cmake --build .
14+
Set-Location ..
15+
16+
# --- Python Environment Setup ---
17+
$VenvDir = "venv"
18+
if (!(Test-Path $VenvDir))
19+
{
20+
python -m venv $VenvDir
21+
}
22+
. .\$VenvDir\Scripts\Activate.ps1
23+
python -m pip install --upgrade pip
24+
pip install -r requirements.txt

‎scripts/setup.sh‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
# This script sets up the project which includes building the CMake project,
3+
# and creating a Python environment for development.
4+
# Should be run from within the PROJECT ROOT.
5+
6+
set -e
7+
8+
# --- CMake Project Setup ---
9+
BuildDir="cmake-build-debug"
10+
if [[ ! -d "$BuildDir" ]]; then
11+
mkdir "$BuildDir"
12+
fi
13+
cd "$BuildDir"
14+
cmake ..
15+
cmake --build .
16+
cd ..
17+
18+
# --- Python Environment Setup ---
19+
VenvDir="venv"
20+
if [[ ! -d "$VenvDir" ]]; then
21+
python3 -m venv "$VenvDir"
22+
fi
23+
source "$VenvDir/bin/activate"
24+
python -m pip install --upgrade pip
25+
if [[ -f "requirements.txt" ]]; then
26+
pip install -r requirements.txt
27+
fi

0 commit comments

Comments
 (0)