This commit is contained in:
TalBarYakar 2026-05-26 16:15:12 +03:00
parent 208f4ff33d
commit a348615dfa
4 changed files with 83 additions and 20 deletions

View file

@ -28,6 +28,7 @@ GOALS_WITH_ARGS := \
modules-update:MODULES_ARGS \
modules-shallow:SHALLOW_ARGS \
run:RUN_ARGS \
all:BUILD_ARGS \
build:BUILD_ARGS \
bootstrap:BOOTSTRAP_ARGS \
setup:SETUP_ARGS \
@ -89,10 +90,14 @@ install:
# usage. All scripts respect $(MAKE) and run from the repo root.
# ----------------------------------------------------------------------------
# build [<name> ...|all|.|'*'|redis|none] — Redis core + selected modules.
build:
# all / build [<name> ...|all|.|'*'|redis|none] — Redis core + selected modules.
# `all` is the canonical entry point (also `make`'s default goal at line 11);
# `make build` is kept as a discoverable alias and routes here.
all:
@scripts/build.sh $(BUILD_ARGS)
build: all
# bootstrap [<name> ...|all|.|'*'] — install per-module build/test prereqs.
bootstrap:
@scripts/bootstrap.sh $(BOOTSTRAP_ARGS)
@ -133,6 +138,7 @@ sync-redis-conf:
@REDIS_CONF='$(REDIS_CONF)' REDIS_GEN_CONF='$(REDIS_GEN_CONF)' \
MODULES='$(strip $(MODULES))' ASSUME_BUILT='$(strip $(ASSUME_BUILT))' \
MODULES_MANIFEST_FILE='$(MODULES_MANIFEST_FILE)' \
PREFIX='$(PREFIX)' \
scripts/sync-redis-conf.sh
# promote-redis-conf [<name> ...] [MODULES="<names>"] [ASSUME_BUILT=1|yes|true]
@ -144,6 +150,7 @@ promote-redis-conf:
@REDIS_CONF='$(REDIS_CONF)' REDIS_GEN_CONF='$(REDIS_GEN_CONF)' \
MODULES='$(strip $(MODULES))' ASSUME_BUILT='$(strip $(ASSUME_BUILT))' \
MODULES_MANIFEST_FILE='$(MODULES_MANIFEST_FILE)' \
PREFIX='$(PREFIX)' \
scripts/promote-redis-conf.sh
.PHONY: install build run test setup bootstrap modules-update modules-shallow sync-redis-conf promote-redis-conf tarball
.PHONY: all install build run test setup bootstrap modules-update modules-shallow sync-redis-conf promote-redis-conf tarball

View file

@ -185,12 +185,21 @@ the dependency install (e.g. after a Python version change).
---
## 4. Build: `make build`
## 4. Build: `make` / `make all` / `make build`
```bash
make build [<name> ...|all|.|'*'|redis|none] [VAR=value ...]
make [<name> ...|all|.|'*'|redis|none] [VAR=value ...]
make all [<name> ...] [VAR=value ...]
make build [<name> ...] [VAR=value ...]
```
All three are equivalent — they route through `scripts/build.sh`. `all` is
the canonical target (also Make's default goal), and `build` is a
discoverable alias declared as `build: all`. Positional names work on
either form (`make all redisbloom` ≡ `make build redisbloom`); positional
args after a bare `make` aren't supported (Make has no goal to attach
them to).
Selection:
| Argument | Selects |
@ -208,15 +217,16 @@ Order (deliberate):
1. Validate selection.
2. Build Redis (`$(MAKE) -C src all`). If this fails, nothing else runs.
3. For each selected cloned module, invoke `$(MAKE) -C modules/<name>`
with:
using `modules/common.mk` with:
```make
RM_INCLUDE_DIR=<repo>/src # point at our redismodule.h
RS_INCLUDE_DIR=<repo>/src # redisearch SDK variant
REDIS_SERVER=<repo>/src/redis-server
```
Modules that honor these variables will compile against our freshly
built `redismodule.h` and can use our `redis-server` for test
harnesses. Modules that ignore them are unaffected.
So module test harnesses use the Redis we just built. The include-path
vars (`RM_INCLUDE_DIR`, `RS_INCLUDE_DIR`) are **not** overridden — each
module resolves `redismodule.h` via its own upstream defaults, the
same way it would build standalone in its own repo. Override them on
the command line — `make build VAR=…` — if you need to compile a
module against this tree's `redismodule.h`.
4. Build stops on the first failing module (fail-fast).
5. Refresh `redis-gen.conf` via `make sync-redis-conf MODULES="<selected>"`
so the file reflects which modules were actually built this run.
@ -318,6 +328,16 @@ Rewrites the untracked `redis-gen.conf` file at the repo root from:
the module isn't loaded).
- Modules with no `loadmodule:` field show up as `Bad manifest: <name>`
in the file header so misconfigurations surface loudly.
- **Path rewriting**: the manifest's `loadmodule:` value (e.g.
`./modules/redisbloom/redisbloom.so`) is absolutized against
`PREFIX` before being written — the leading `.` is replaced by
`$PREFIX`, yielding `$PREFIX/modules/redisbloom/redisbloom.so`.
`PREFIX` defaults to `$PWD` (the repo root, since the script
`cd`s there), so out of the box the generated conf carries
absolute paths and `redis-server <conf>` works from any cwd.
Already-absolute manifest values are left untouched.
File existence is still tested against the on-disk path (where
the build actually drops .so files — REPO_ROOT-relative).
The write is atomic (tmpfile + `mv`), so a mid-run failure leaves the
previous `redis-gen.conf` intact.
@ -326,6 +346,7 @@ previous `redis-gen.conf` intact.
|---|---|---|
| `MODULES` | every module in `modules.yaml` | Subset of modules to include. Unrequested modules are omitted entirely (not even commented out). |
| `ASSUME_BUILT` | unset | When `1` / `true` / `yes`, emit active `loadmodule` lines regardless of whether the `.so` is on disk. Used by `make tarball`. |
| `PREFIX` | `$PWD` (= repo root) | Install root prepended to every emitted `loadmodule` path. `./modules/foo/foo.so``$PREFIX/modules/foo/foo.so`. Pass on the make line: `make build PREFIX=/opt/redis-deploy`. |
| `REDIS_CONF` | `redis.conf` | Source Redis-core config |
| `REDIS_GEN_CONF` | `redis-gen.conf` | Destination |
@ -586,7 +607,8 @@ make sync-redis-conf [<name> ...] \ # rewrite redis-gen.conf from redis
make promote-redis-conf [<name> ...] \ # sync-redis-conf, then overwrite redis.conf
[MODULES="<names>"] [ASSUME_BUILT=1] # (destructive on redis.conf; refuses to run twice)
make build [<name> ...|all|.|'*'|redis|none] [VAR=value ...]
make [<name> ...|all|.|'*'|redis|none] [VAR=value ...]
make all|build [<name> ...|all|.|'*'|redis|none] [VAR=value ...]
make run [<name> ...] [ARGS="<redis-server args>"]

View file

@ -8,8 +8,12 @@
# redis | none build Redis only
# <name> [<name> ...] build Redis + the listed modules
#
# Each selected module is built via `make -C modules/<name>` with
# RM_INCLUDE_DIR/RS_INCLUDE_DIR/REDIS_SERVER pointing at our just-built tree.
# Each selected module is built via `make -C modules/<name>` using its
# upstream defaults — RM_INCLUDE_DIR / RS_INCLUDE_DIR are intentionally
# NOT overridden here, so a bundled build resolves `redismodule.h` the
# same way the module would when built standalone in its own repo.
# REDIS_SERVER is overridden so module test harnesses run against the
# Redis we just built.
# Failures are collected and reported at the end.
set -euo pipefail
@ -41,15 +45,13 @@ if [ -z "$modules" ]; then
fi
else
echo
echo "==> Building modules against $PWD/src (RM_INCLUDE_DIR) and $PWD/src/redis-server:"
echo "==> Building modules (REDIS_SERVER=$REPO_ROOT/src/redis-server):"
echo " $modules"
for name in $modules; do
echo
echo "==> [module] $name (modules/$name)"
mkdir -p "modules/$name"
if ! "$MAKE_BIN" -C "modules/$name" -f "$REPO_ROOT/modules/common.mk" \
RM_INCLUDE_DIR="$REPO_ROOT/src" \
RS_INCLUDE_DIR="$REPO_ROOT/src" \
REDIS_SERVER="$REPO_ROOT/src/redis-server"; then
failed="$failed $name"
echo "==> [module] $name: FAILED (continuing with remaining modules)"

View file

@ -18,6 +18,13 @@
# regardless of whether the .so is present on disk
# (used by `make tarball`)
# MODULES_MANIFEST_FILE manifest path (default: modules/modules.yaml)
# PREFIX install root prepended to every emitted loadmodule
# path. The manifest's `loadmodule:` value
# `./modules/foo/foo.so` is rewritten as
# `$PREFIX/modules/foo/foo.so`. Defaults to $PWD (i.e.
# the repo root, since this script `cd`s there) when
# unset — yielding absolute paths that work regardless
# of where `redis-server` is launched from.
#
# Output is always rewritten in full and is atomic (write to sibling tmpfile,
# then rename). On any failure the temp file is cleaned up and the existing
@ -33,6 +40,27 @@ cd "$REPO_ROOT"
REDIS_CONF="${REDIS_CONF:-redis.conf}"
REDIS_GEN_CONF="${REDIS_GEN_CONF:-redis-gen.conf}"
# Install prefix used to absolutize every emitted `loadmodule` path. Default
# is the current working directory (which is REPO_ROOT after the `cd` above),
# so by default the generated conf carries absolute paths rooted at the build
# tree — `redis-server <conf>` works from any cwd. Trailing slash stripped so
# concatenation never produces `//`.
PREFIX="${PREFIX:-$PWD}"
PREFIX="${PREFIX%/}"
# Translate a manifest `loadmodule:` value into the path written to the
# generated conf:
# ./modules/foo/foo.so → $PREFIX/modules/foo/foo.so (leading '.' → PREFIX)
# modules/foo/foo.so → $PREFIX/modules/foo/foo.so (no leading '.': prepend)
# /abs/path/foo.so → /abs/path/foo.so (already absolute)
resolve_so_path() {
case "$1" in
/*) printf '%s\n' "$1" ;;
./*) printf '%s\n' "$PREFIX${1#.}" ;;
*) printf '%s\n' "$PREFIX/$1" ;;
esac
}
# Mirror DOCKER_STRICT semantics from
# modules/docker-install-bundled-module-deps.sh so all boolean-ish env vars
# in this codebase accept the same forms.
@ -197,19 +225,23 @@ EOF
EOF
# `loadmodule` lines (or commented placeholders) come first so the rest of
# the section is just per-module config blocks.
# the section is just per-module config blocks. File existence is tested
# against the on-disk path (where the build actually drops .so files —
# REPO_ROOT-relative), while the emitted path is absolutized via $PREFIX
# so the conf is portable across cwds at `redis-server` launch time.
for name in $requested; do
so="$(lookup_so "$name")"
if [ -z "$so" ]; then
printf "# %s: 'loadmodule' field missing in modules.yaml\n" "$name"
continue
fi
so_full="$(resolve_so_path "$so")"
if [ -f "$so" ] || [ "$ASSUME_BUILT_FLAG" = "1" ]; then
printf "loadmodule %s\n" "$so"
printf "loadmodule %s\n" "$so_full"
else
printf "# %s: not built (%s absent — run 'make build %s')\n" \
"$name" "$so" "$name"
printf "# loadmodule %s\n" "$so"
printf "# loadmodule %s\n" "$so_full"
fi
done
echo