159 lines
3.7 KiB
Markdown
159 lines
3.7 KiB
Markdown
# gbuild
|
|
|
|
A C rewrite of the original [gbuild](https://spdlab.hu/gbuild) bash tool.
|
|
Clone, pull, pick a target, build — all from one command.
|
|
|
|
---
|
|
|
|
## Features
|
|
|
|
- **Clone or pull** — automatically clones a fresh repo on first run; pulls on subsequent runs
|
|
- **Interactive target picker** — reads your `Makefile` and presents an ncurses TUI to select the build target; pass `--target` to skip it
|
|
- **Timestamped log files** — every run writes a log to `~/.local/log/gbuild/` named `<timestamp>_<project>.log`
|
|
- **Log browser** — built-in two-pane TUI: file list on the left, live preview on the right; open in `less`, delete, or quit
|
|
- **Configurable** — reads `~/.gconfig`; override with `--url` and `--user` at runtime
|
|
- **`gconfig` companion** — manages `~/.gconfig` with `init`, `show`, and `help` commands
|
|
|
|
---
|
|
|
|
## Dependencies
|
|
|
|
| Library | Purpose |
|
|
|----------|------------------------------|
|
|
| ncurses | TUI for picker & log browser |
|
|
| git | Clone / pull |
|
|
| make | Build projects |
|
|
| less | Open logs from browser |
|
|
|
|
---
|
|
|
|
## Build
|
|
|
|
### Linux
|
|
|
|
```sh
|
|
# Install these packages with your package manager
|
|
libncurses-dev make
|
|
|
|
# Clone this repository
|
|
git clone https://github.com/jokerz/gbuild.git
|
|
|
|
# Build both binaries into bin/
|
|
make
|
|
|
|
# Optionally install system-wide
|
|
sudo make install
|
|
```
|
|
|
|
---
|
|
|
|
## Quick setup
|
|
|
|
```sh
|
|
# 1. Initialise ~/.gconfig with defaults
|
|
gconfig init
|
|
|
|
# 2. Fill in your values
|
|
$EDITOR ~/.gconfig
|
|
|
|
# 3. Verify
|
|
gconfig show
|
|
|
|
# 4. Build a project
|
|
gbuild myproject
|
|
```
|
|
|
|
### `~/.gconfig` format
|
|
|
|
```ini
|
|
# ~/.gconfig — managed by gconfig
|
|
|
|
[git]
|
|
GIT_URL = http://localhost:3000
|
|
GIT_USER = Username
|
|
|
|
[auth]
|
|
# Use token-based OR password-based auth; leave the other blank
|
|
GIT_TOKEN =
|
|
GIT_PASSWORD =
|
|
|
|
[build]
|
|
DEFAULT_TARGET =
|
|
CLONE_DIR = ~/projects
|
|
|
|
[log]
|
|
LOG_ENABLED = true
|
|
LOG_DIR = ~/.local/log/gbuild
|
|
```
|
|
|
|
---
|
|
|
|
## Usage
|
|
|
|
```
|
|
gbuild [options] <project>
|
|
gbuild --logs
|
|
|
|
Options:
|
|
--url <url> Override Git base URL (default: ~/.gconfig)
|
|
--user <name> Override Git username (default: ~/.gconfig)
|
|
--target <tgt> Run target directly, skip interactive picker
|
|
--logs Open the interactive log browser
|
|
-h, --help Print this help and exit
|
|
```
|
|
|
|
### Examples
|
|
|
|
```sh
|
|
# Build with defaults
|
|
gbuild myproject
|
|
|
|
# Skip the target picker
|
|
gbuild --target clean myproject
|
|
|
|
# Different server and user for this run
|
|
gbuild --url http://10.0.0.5:3000 --user alice myproject
|
|
|
|
# Browse past build logs
|
|
gbuild --logs
|
|
```
|
|
|
|
---
|
|
|
|
## `gconfig` commands
|
|
|
|
| Command | Description |
|
|
|---------------------|-------------------------------------------------------------|
|
|
| `gconfig init` | Create `~/.gconfig` with defaults (skips if already exists) |
|
|
| `gconfig init --force` | Overwrite; backs up old file as `~/.gconfig.bak.<ts>` |
|
|
| `gconfig show` | Print current config (auth fields masked) |
|
|
| `gconfig help` | Print usage |
|
|
|
|
---
|
|
|
|
## Project layout
|
|
|
|
```
|
|
gbuild/
|
|
├── Makefile
|
|
├── README.md
|
|
├── include/
|
|
│ ├── config.h — GConfig struct, INI load/save/init/show
|
|
│ ├── git_ops.h — clone / pull
|
|
│ ├── logger.h — timestamped coloured logging
|
|
│ ├── make_ops.h — Makefile target parser + build runner
|
|
│ └── tui.h — ncurses target picker + log browser
|
|
└── src/
|
|
├── config.c
|
|
├── gbuild.c — gbuild main()
|
|
├── gconfig.c — gconfig main()
|
|
├── git_ops.c
|
|
├── logger.c
|
|
├── make_ops.c
|
|
└── tui.c
|
|
```
|
|
|
|
---
|
|
|
|
MIT License — maintained by jokerz / spdlab.hu
|