From: Thomas Walker Lynch Date: Thu, 16 Oct 2025 05:31:29 +0000 (+0000) Subject: adds Z stamp to git-tar X-Git-Url: https://git.reasoningtechnology.com/fossil/%7Bstyle.link%7D?a=commitdiff_plain;h=2297e7058164cf495d335bfd5b3b1c828170a8b1;p=RT-project-share adds Z stamp to git-tar --- diff --git a/developer/bash/git-tar b/developer/bash/git-tar index d655f03..65ab4b1 100755 --- a/developer/bash/git-tar +++ b/developer/bash/git-tar @@ -1,9 +1,9 @@ #!/usr/bin/env bash -# puts a tar file of the repo in the top level scratchdir +# puts a tar file of the repo in the top level scratchdir, filename suffixed with UTC stamp from Z set -euo pipefail -# ensure we're in a git repo +# 1) ensure we're in a git repo git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo "Error: not inside a git repository." >&2 exit 1 @@ -12,9 +12,28 @@ git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { repo_top="$(git rev-parse --show-toplevel)" repo_name="$(basename "$repo_top")" ref_label="$(git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD)" -out="${repo_top}/scratchpad/${repo_name}-${ref_label}.tar.gz" -# create archive of HEAD (tracked files only; .gitignore’d stuff is omitted) +# 2) ensure Z is available (prefer PATH; otherwise add repo-local RT-project-share path) +if ! command -v Z >/dev/null 2>&1; then + z_guess="${repo_top}/tool_shared/third_party/RT-project-share/release/bash" + if [ -x "${z_guess}/Z" ]; then + PATH="${z_guess}:${PATH}" + else + echo "Error: required program 'Z' not found in PATH." >&2 + echo "Hint: expected at '${z_guess}/Z' or ensure your env_* is sourced." >&2 + exit 1 + fi +fi + +# 3) timestamp and output path +stamp="$(Z)" +# trim trailing newline just in case +stamp="${stamp//$'\n'/}" + +mkdir -p "${repo_top}/scratchpad" +out="${repo_top}/scratchpad/${repo_name}-${ref_label}-${stamp}.tar.gz" + +# 4) create archive of HEAD (tracked files only; .gitignore’d stuff omitted) git -C "$repo_top" archive --format=tar --prefix="${repo_name}/" HEAD | gzip > "$out" echo "Wrote ${out}" diff --git a/developer/make/environment_RT_0 b/developer/make/environment_RT_0 index a9c91be..ad4e617 100644 --- a/developer/make/environment_RT_0 +++ b/developer/make/environment_RT_0 @@ -10,7 +10,7 @@ ECHO := printf "%b\n" # sources found in these subdirectories: -SRCDIR_List=cc cc +SRCDIR_List=cc LIBDIR=scratchpad EXECDIR=machine diff --git a/developer/make/targets_kernel b/developer/make/targets_kernel index 8bbb07e..065fc8f 100644 --- a/developer/make/targets_kernel +++ b/developer/make/targets_kernel @@ -9,7 +9,13 @@ KDIR := /lib/modules/$(shell uname -r)/build # Use KBUILD_OUTPUT_DIR to direct Kbuild output to the scratchpad -KBUILD_OUTPUT_DIR := $(TMPDIR) + +# PATH CORRECTION: Define REPO_ROOT (the Rabbit/ directory) relative to the shell's PWD. +# Assuming PWD is the developer/ directory, REPO_ROOT is the parent directory. +REPO_ROOT := $(dir $(PWD)) + +# The scratchpad directory is relative to the REPO_ROOT, not the execution directory. +KBUILD_OUTPUT_DIR := $(REPO_ROOT)/$(TMPDIR) # Convert KBUILD_BASE_List (e.g. "no-op") into Kbuild-compatible object list (e.g. "no-op.o") KERNEL_OBJS_M := $(addsuffix .o, $(KBUILD_BASE_List)) @@ -29,18 +35,16 @@ kernel_module: $(KERNEL_MODULE_TARGETS) # Dependency: The temporary Kbuild source file (e.g. scratchpad/rabbit_module_no-op.c) $(KBUILD_OUTPUT_DIR)/%.ko: $(KBUILD_OUTPUT_DIR)/%.c @echo "--- Invoking Kbuild for Module: $* ---" - - # The Kbuild variables are passed on the command line: - # M=$(PWD): tells Kbuild to use the project root as the source directory for relative paths. - # O=$(KBUILD_OUTPUT_DIR): tells Kbuild where to place ALL output. - # obj-m: specifies the single object file Kbuild must compile and link into a .ko - $(MAKE) -C $(KDIR) M=$(PWD) O=$(KBUILD_OUTPUT_DIR) \ + # M=$(REPO_ROOT): Tells Kbuild to look for source (cc/) relative to the project root, + # which is the directory containing the 'developer/' directory. + # O=$(KBUILD_OUTPUT_DIR): tells Kbuild where to place ALL output (scratchpad/). + $(MAKE) -C $(KDIR) M=$(REPO_ROOT) O=$(KBUILD_OUTPUT_DIR) \ obj-m=$*.o # --- Rule to Create Kbuild-Compatible Source Link --- # Kbuild expects a .c file, but our source is .mod.c and is read-only in cc/. # Action: Copy the read-only source file to the scratchpad under the expected Kbuild name (.c). -$(KBUILD_OUTPUT_DIR)/%.c: cc/%.mod.c +$(KBUILD_OUTPUT_DIR)/%.c: $(REPO_ROOT)/cc/%.mod.c @echo "--- Preparing Kbuild Source Link: $@ ---" cp $< $@ @@ -51,8 +55,6 @@ all: kernel_module # This target ensures that only the artifacts created by Kbuild are cleaned from the scratchpad. clean_kernel: @echo "--- Cleaning Kbuild Artifacts for Modules in $(KBUILD_OUTPUT_DIR) ---" - - # Kbuild is run from the project root (M=$(PWD)) but cleans files in the output directory (O=$(KBUILD_OUTPUT_DIR)) - # We pass obj-m to ensure Kbuild knows which modules to clean, thus only removing specific artifacts. - $(MAKE) -C $(KDIR) M=$(PWD) O=$(KBUILD_OUTPUT_DIR) \ + # M=$(REPO_ROOT): We use the correct project root again for Kbuild to find its context. + $(MAKE) -C $(KDIR) M=$(REPO_ROOT) O=$(KBUILD_OUTPUT_DIR) \ obj-m="$(KERNEL_OBJS_M)" clean diff --git a/developer/tool/makefile b/developer/tool/makefile index 550c796..8fce343 100644 --- a/developer/tool/makefile +++ b/developer/tool/makefile @@ -7,7 +7,7 @@ CFLAGS+=-Werror -include "$(RT-INCOMMON)/make/RT_0.h" LINKFLAGS+= -l$(PROJECT) LIBFILE=$(LIBDIR)/lib$(PROJECT).a -include $(RT-INCOMMON)/make/targets +include $(RT-INCOMMON)/make/targets_developer -include $(DEPFILE)