git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 13/13] rust/build-rust.sh: update dir_git_root variable instantiation

From
Ezekiel Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 27, 2025, 01:10 UTC
Message-ID
<0f797a238c3c102814a3402caca2539a518ecb74.1764205835.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2110.git.git.1764205835.gitgitgadget@gmail.com>
From: Ezekiel Newren <ezekielnewren@gmail.com>
Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
---
 Makefile            |  6 ++++--
 meson.build         |  1 +
 rust/build-crate.sh | 15 ++++++++++-----
 3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 6da9db7d83..848db03227 100644
--- a/Makefile
+++ b/Makefile
@@ -931,6 +931,8 @@ EXTLIBS =
 
 GIT_BUILD_DIR := $(CURDIR)
 export GIT_BUILD_DIR
+MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+export MAKEFILE_DIR
 
 RUST_CRATES := gitcore
 .PHONY: rust-compile rust-clean
@@ -949,7 +951,7 @@ RUST_LIBS := $(foreach c,$(RUST_CRATES),$(GIT_BUILD_DIR)/lib$(c).a)
 rust-compile:
 	@for c in $(RUST_CRATES); do \
 		echo "Building $$c..."; \
-		./rust/build-crate.sh $(GIT_BUILD_DIR) $(RUST_BUILD_MODE) $$c || exit $$?; \
+		./rust/build-crate.sh $(MAKEFILE_DIR) $(GIT_BUILD_DIR) $(RUST_BUILD_MODE) $$c || exit $$?; \
 	done
 
 rust-clean:
@@ -958,7 +960,7 @@ rust-clean:
 
 $(GIT_BUILD_DIR)/lib%.a:
 	echo $(RUST_LIBS)
-	./rust/build-crate.sh $(GIT_BUILD_DIR) $(RUST_BUILD_MODE) $*
+	./rust/build-crate.sh $(MAKEFILE_DIR) $(GIT_BUILD_DIR) $(RUST_BUILD_MODE) $*
 
 UNAME_S := $(shell uname -s)
 ifeq ($(UNAME_S),Linux)
diff --git a/meson.build b/meson.build
index 94ec5e4ac0..3154cd684a 100644
--- a/meson.build
+++ b/meson.build
@@ -305,6 +305,7 @@ if with_rust
       build_always_stale: true,
       command: [
         meson.project_source_root() / 'rust' / 'build-crate.sh',
+        meson.project_source_root(),
         meson.current_build_dir(), rust_build_profile, crate,
       ],
       install: false,
diff --git a/rust/build-crate.sh b/rust/build-crate.sh
index b3debf70e5..50f5b0058c 100755
--- a/rust/build-crate.sh
+++ b/rust/build-crate.sh
@@ -3,10 +3,12 @@
 rustc -vV || exit $?
 cargo --version || exit $?
 
-dir_git_root=${0%/*}
-dir_build=$1
-rust_build_profile=$2
-crate=$3
+dir_git_root=$1
+cd $dir_git_root || exit $?
+dir_git_root=$PWD
+dir_build=$2
+rust_build_profile=$3
+crate=$4
 
 if [ "$dir_git_root" = "" ]; then
   echo "did not specify the directory for the root of git"
@@ -38,9 +40,12 @@ libfile="lib${crate}.a"
 if rustc -vV | grep windows-msvc; then
   libfile="${crate}.lib"
   PATH="$(echo $PATH | tr ':' '\n' | grep -Ev "^(/mingw64/bin|/usr/bin)$" | paste -sd: -):/mingw64/bin:/usr/bin"
+  echo "PATH=$PATH"
 fi
 
-CARGO_TARGET_DIR=$dir_git_root/.build/rust/$crate
+echo "libfile=$libfile"
+
+CARGO_TARGET_DIR=$dir_build/.build/rust/$crate
 export CARGO_TARGET_DIR
 
 cargo clean && pwd && USE_LINKING="false" cargo build -p $crate $rust_args
-- 
gitgitgadget
Previous: Ezekiel Newren via GitGitGadget
Message 14 of 14 in “RFC: Convert to Cargo workspace”
  1. 00/13 RFC: Convert to Cargo workspaceEzekiel Newren via GitGitGadget, Nov 27, 2025
  2. 01/13 make: undo Patrick's changes concerning RustEzekiel Newren via GitGitGadget, Nov 27, 2025
  3. 02/13 meson: undo Patrick's changes concerning RustEzekiel Newren via GitGitGadget, Nov 27, 2025
  4. 03/13 cargo: convert from a crate to a workspaceEzekiel Newren via GitGitGadget, Nov 27, 2025
  5. 04/13 build: build Rust with Makefile and MesonEzekiel Newren via GitGitGadget, Nov 27, 2025
  6. 05/13 .gitignore: ignore /generated/Ezekiel Newren via GitGitGadget, Nov 27, 2025
  7. 06/13 cargo: create crate generate-headersEzekiel Newren via GitGitGadget, Nov 27, 2025
  8. 07/13 cargo: create crate link-with-cEzekiel Newren via GitGitGadget, Nov 27, 2025
  9. 08/13 rust/gitcore: link with cEzekiel Newren via GitGitGadget, Nov 27, 2025
  10. 09/13 varint.h: unsigned char -> uint8_tEzekiel Newren via GitGitGadget, Nov 27, 2025
  11. 10/13 make: delete files in generated/Ezekiel Newren via GitGitGadget, Nov 27, 2025
  12. 11/13 github-workflows: unify with rust parameters in make and mesonEzekiel Newren via GitGitGadget, Nov 27, 2025
  13. 12/13 github workflows: install RustEzekiel Newren via GitGitGadget, Nov 27, 2025
  14. 13/13 rust/build-rust.sh: update dir_git_root variable instantiationEzekiel Newren via GitGitGadget, Nov 27, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.