55set " project_dir = %~dp0 ..\.."
66set " toolchain_file = %project_dir% \rust-toolchain.toml"
77set " out_dir = %1 \rust"
8- set features =
8+ set " host_features = "
9+ set " core_features = "
910set release_profile =
1011set " set_linker_flags = cd ."
1112if " %2 " == " debug" set " set_linker_flags = (set CFLAGS=-MDd) & (set CXXFLAGS=-MDd)"
1213if " %2 " == " release" set " release_profile = --release"
13- if " %3 " == " next" set " features = --features next"
1414
1515if not exist " %toolchain_file% " (
1616 echo Error: " %toolchain_file% " not found.
@@ -35,7 +35,15 @@ rem -- range to use for stable host envs
3535set MIN_P = 21
3636set MAX_P = 26
3737rem -- version of the latest WIP protocol
38- set LATEST_P = 26
38+ set LATEST_P = 27
39+ rem -- source host used to build the latest protocol. When this differs from
40+ rem -- LATEST_P, the latest build reuses an older host with --features next.
41+ set LATEST_HOST_P = 27
42+
43+ if " %3 " == " next" (
44+ set " core_features = --features next"
45+ if not " %LATEST_HOST_P% " == " %LATEST_P% " set " host_features = --features next"
46+ )
3947
4048rem ---- Accumulators for final rustc link flags ----
4149set " EXTERNS = "
@@ -67,7 +75,7 @@ for /l %%P in (%MIN_P%,1,%MAX_P%) do (
6775
6876 rem -- Decide whether to skip building this protocol in the loop --
6977 set " skip_build = "
70- if defined features if %%P == %LATEST_P% set " skip_build = 1"
78+ if " %3 " == " next " if %%P == %LATEST_P% set " skip_build = 1"
7179
7280 if not defined skip_build (
7381 if defined stamp_ok (
@@ -83,15 +91,16 @@ for /l %%P in (%MIN_P%,1,%MAX_P%) do (
8391 )
8492 )
8593
86- if not defined skip_build (
87- set " EXTERNS = !EXTERNS! --extern soroban_env_host_p%%P =%out_dir% \soroban-p%%P -target\%2 \libsoroban_env_host.rlib"
88- set " LPATHS = !LPATHS! -L dependency=%out_dir% \soroban-p%%P -target\%2 \deps"
89- )
94+ if not defined skip_build (
95+ set " EXTERNS = !EXTERNS! --extern soroban_env_host_p%%P =%out_dir% \soroban-p%%P -target\%2 \libsoroban_env_host.rlib"
96+ set " LPATHS = !LPATHS! -L dependency=%out_dir% \soroban-p%%P -target\%2 \deps"
97+ )
9098)
9199
92- rem ---- Build LATEST_P with features (only when "next" is passed) ----
93- if defined features (
94- set " latest_proto_dir = %project_dir% \src\rust\soroban\p%LATEST_P% "
100+ rem ---- Build LATEST_P for next builds. If LATEST_HOST_P differs from LATEST_P,
101+ rem ---- the latest build reuses that host source with --features next. ----
102+ if " %3 " == " next" (
103+ set " latest_proto_dir = %project_dir% \src\rust\soroban\p%LATEST_HOST_P% "
95104 set " latest_proto_target = %out_dir% \soroban-p%LATEST_P% -target"
96105
97106 set " latest_rev = "
@@ -109,8 +118,8 @@ if defined features (
109118 if defined latest_stamp_ok (
110119 echo p%LATEST_P% ^ (latest^ ): up to date, skipping.
111120 ) else (
112- echo p%LATEST_P% ^ (latest^ ): building soroban-env-host with %features % ...
113- %set_linker_flags% & pushd " !latest_proto_dir! " & (set RUSTFLAGS=-Cmetadata=p%LATEST_P% -!latest_rev:~0 ,12 ! ) & cargo +%version% build %release_profile% --package soroban-env-host --locked %features % --target-dir " !latest_proto_target! " & popd
121+ echo p%LATEST_P% ^ (latest^ ): building soroban-env-host with %host_features % ...
122+ %set_linker_flags% & pushd " !latest_proto_dir! " & (set RUSTFLAGS=-Cmetadata=p%LATEST_P% -!latest_rev:~0 ,12 ! ) & cargo +%version% build %release_profile% --package soroban-env-host --locked %host_features % --target-dir " !latest_proto_target! " & popd
114123 if errorlevel 1 exit /b 1
115124 if not " !latest_rev! " == " " (
116125 if not exist " !latest_proto_target! " mkdir " !latest_proto_target! "
@@ -147,7 +156,8 @@ rem Always invoke cargo here: cargo's own incremental-build tracking will
147156rem no-op quickly when nothing changed, and the .soroban-revs file
148157rem (tracked via build.rs) forces a rebuild when submodules change.
149158echo Building stellar-core Rust library...
150- %set_linker_flags% & cd /d " %project_dir% " & cargo +%version% rustc %release_profile% --package stellar-core --locked %features% --target-dir " %out_dir% \target" -- %EXTERNS% %LPATHS%
159+ echo Build command: cargo +%version% rustc %release_profile% --package stellar-core --locked %core_features% --target-dir " %out_dir% \target" -- %EXTERNS% %LPATHS%
160+ %set_linker_flags% & cd /d " %project_dir% " & cargo +%version% rustc %release_profile% --package stellar-core --locked %core_features% --target-dir " %out_dir% \target" -- %EXTERNS% %LPATHS%
151161
152162endlocal
153163
0 commit comments