@@ -40,6 +40,7 @@ set LATEST_P=26
4040rem ---- Accumulators for final rustc link flags ----
4141set " EXTERNS = "
4242set " LPATHS = "
43+ set " ALL_REVS = "
4344set " SOURCE_STAMP = .source-rev"
4445
4546rem ---- Build protocols MIN_P..MAX_P ----
@@ -52,6 +53,7 @@ for /l %%P in (%MIN_P%,1,%MAX_P%) do (
5253 rem -- Resolve current submodule rev --
5354 set " current_rev = "
5455 for /f %%R in ('git -C " !proto_dir! " rev-parse HEAD 2^ > nul ') do set " current_rev = %%R "
56+ set " ALL_REVS = !ALL_REVS! p%%P -!current_rev:~0 ,12 ! _"
5557
5658 rem -- Compare stamp to decide if cargo needs to run --
5759 set " stamp_ok = "
@@ -125,9 +127,25 @@ rem Clear RUSTFLAGS so that metadata from soroban-protocol builds above does
125127rem not leak into the stellar-core build and cause cargo to invalidate its
126128rem fingerprints on the next run (where the soroban builds may be skipped).
127129set " RUSTFLAGS = "
130+
131+ rem Write submodule revisions to a file that build.rs watches via
132+ rem cargo:rerun-if-changed. Only update the file when content actually
133+ rem changes so that the mtime (which cargo uses for freshness) stays
134+ rem stable across no-op builds.
135+ set " REVS_FILE = %project_dir% \src\rust\.soroban-revs"
136+ set " revs_changed = "
137+ if exist " !REVS_FILE! " (
138+ set " saved_revs = "
139+ set /p saved_revs = < " !REVS_FILE! "
140+ if not " !saved_revs! " == " !ALL_REVS! " set " revs_changed = 1"
141+ ) else (
142+ set " revs_changed = 1"
143+ )
144+ if defined revs_changed > " !REVS_FILE! " echo(!ALL_REVS!
145+
128146rem Always invoke cargo here: cargo's own incremental-build tracking will
129- rem no-op quickly when nothing changed, and the submodule-stamp mechanism
130- rem above does not detect changes to local Rust sources (src\rust\src\*.rs) .
147+ rem no-op quickly when nothing changed, and the .soroban-revs file
148+ rem (tracked via build.rs) forces a rebuild when submodules change .
131149echo Building stellar-core Rust library...
132150%set_linker_flags% & cd /d " %project_dir% " & cargo +%version% rustc %release_profile% --package stellar-core --locked %features% --target-dir " %out_dir% \target" -- %EXTERNS% %LPATHS%
133151
0 commit comments