Skip to content

Commit ca9aa12

Browse files
committed
try to adapt to namespace cache structure
1 parent 9c8fbd3 commit ca9aa12

File tree

8 files changed

+43
-26
lines changed

8 files changed

+43
-26
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ jobs:
5555

5656
build:
5757
runs-on: namespace-profile-jammy-32-stellar-core
58-
env:
59-
CACHED_PATHS: |
60-
~/.ccache
61-
~/.cargo
62-
target
6358
strategy:
6459
fail-fast: false
6560
matrix:
@@ -82,7 +77,9 @@ jobs:
8277
- name: Configure Namespace cache volume
8378
uses: namespacelabs/nscloud-cache-action@v1
8479
with:
85-
path: ${{ env.CACHED_PATHS }}
80+
path: |
81+
~/.cargo
82+
build-${{matrix.toolchain}}-${{matrix.protocol}}
8683
8784
- name: install rustup
8885
run: ./install-rust.sh

ci-build.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ NPROCS=$(getconf _NPROCESSORS_ONLN)
6868
echo "Found $NPROCS processors"
6969
date
7070

71+
mkdir -p "build-${CC}-${PROTOCOL}"
72+
cd "build-${CC}-${PROTOCOL}"
73+
7174
# Try to ensure we're using the real g++ and clang++ versions we want
7275
mkdir bin
7376

@@ -111,7 +114,7 @@ export ASAN_OPTIONS="quarantine_size_mb=100:malloc_context_size=4:detect_leaks=0
111114
echo "config_flags = $config_flags"
112115

113116
#### ccache config
114-
export CCACHE_DIR=$HOME/.ccache
117+
export CCACHE_DIR=$(pwd)/.ccache
115118
export CCACHE_COMPRESS=true
116119
export CCACHE_COMPRESSLEVEL=9
117120
# cache size should be large enough for a full build
@@ -130,8 +133,8 @@ ccache -p
130133

131134
ccache -s
132135
date
133-
time ./autogen.sh
134-
time ./configure $config_flags
136+
time (cd .. && ./autogen.sh)
137+
time ../configure $config_flags
135138
if [ -z "${SKIP_FORMAT_CHECK}" ]; then
136139
make format
137140
d=`git diff | wc -l`

src/Makefile.am

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ endif # !BUILD_TESTS
6565
if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
6666
CARGO_FEATURE_NEXT = --features next
6767
main/XDRFilesSha256.cpp: $(SRC_X_FILES) Makefile $(top_srcdir)/hash-xdrs.sh
68-
$(top_srcdir)/hash-xdrs.sh protocol-next >$@
68+
$(top_srcdir)/hash-xdrs.sh $(top_srcdir)/src/protocol-next >$@
6969
else
7070
CARGO_FEATURE_NEXT =
7171
main/XDRFilesSha256.cpp: $(SRC_X_FILES) Makefile $(top_srcdir)/hash-xdrs.sh
72-
$(top_srcdir)/hash-xdrs.sh protocol-curr >$@
72+
$(top_srcdir)/hash-xdrs.sh $(top_srcdir)/src/protocol-curr >$@
7373
endif
7474

7575
stellar_core_LDADD = $(soci_LIBS) $(libmedida_LIBS) \
@@ -89,6 +89,7 @@ BUILT_SOURCES = $(SRC_X_FILES:.x=.h) main/StellarCoreVersion.cpp main/XDRFilesSh
8989
$(SRC_X_FILES:.x=.h): $(XDRC)
9090
SUFFIXES = .x .h .rs
9191
.x.h:
92+
mkdir -p $(@D)
9293
$(XDRC) -hh -pedantic -o $@ $<
9394

9495
BISON=bison
@@ -124,9 +125,10 @@ RUST_TOOLCHAIN_CHANNEL=$(shell sed -n 's/channel *= *"\([^"]*\)"/\1/p' $(RUST_TO
124125
endif
125126
CARGO=cargo +$(RUST_TOOLCHAIN_CHANNEL)
126127

127-
# we pass RUST_TOOLCHAIN_CHANNEL by environment variable
128+
# we pass some configuration by environment variable
128129
# to tests since they can't take command-line arguments.
129130
export RUST_TOOLCHAIN_CHANNEL
131+
export top_srcdir
130132

131133
RUST_BUILD_DIR=$(top_builddir)/src/rust
132134
RUST_BIN_DIR=$(RUST_BUILD_DIR)/bin
@@ -233,11 +235,12 @@ rust/RustBridge.cpp: rust/src/bridge.rs $(SRC_RUST_FILES) Makefile $(RUST_CXXBRI
233235

234236
$(RUST_DEP_TREE_STAMP): $(wildcard rust/soroban/*/Cargo.*) Makefile $(RUST_TOOLCHAIN_FILE)
235237
rm -f $@
238+
mkdir -p $(RUST_BUILD_DIR)/src/dep-trees
236239
for proto in $(ALL_SOROBAN_PROTOCOLS); \
237240
do \
238-
$(CARGO) tree --manifest-path rust/soroban/$${proto}/Cargo.toml --locked --package soroban-env-host --edges no-dev --target all \
241+
$(CARGO) tree --manifest-path $(top_srcdir)/src/rust/soroban/$${proto}/Cargo.toml --locked --package soroban-env-host --edges no-dev --target all \
239242
| sed -e "s@$(abspath $(top_srcdir))/@@g" > $(RUST_BUILD_DIR)/src/dep-trees/$${proto}-actual.txt ; \
240-
if ! diff -u rust/src/dep-trees/$${proto}-expect.txt $(RUST_BUILD_DIR)/src/dep-trees/$${proto}-actual.txt; \
243+
if ! diff -u $(top_srcdir)/src/rust/src/dep-trees/$${proto}-expect.txt $(RUST_BUILD_DIR)/src/dep-trees/$${proto}-actual.txt; \
241244
then \
242245
echo "dep trees differ, please update $${proto}-expect.txt or roll back submodule"; \
243246
exit 1; \
@@ -346,9 +349,11 @@ $(SOROBAN_LIBS_STAMP): $(wildcard rust/soroban/p*/Cargo.lock) Makefile $(RUST_DE
346349
FEATURE_FLAGS="$(CARGO_FEATURE_TRACY)" \
347350
;; \
348351
esac ; \
349-
cd $(abspath $(RUST_BUILD_DIR))/soroban/$$proto && \
352+
mkdir -p $(SOROBAN_BUILD_DIR)/$$proto/target && \
353+
cd $(abspath $(top_srcdir))/src/rust/soroban/$$proto && \
350354
CC="$(CC)" CXX="$(CXX)" LD="$(LD)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXXSTDLIB="$(CXXSTDLIB)" LDFLAGS="$(LDFLAGS)" \
351355
RUSTFLAGS="-Cmetadata=$$proto" \
356+
CARGO_TARGET_DIR=$(SOROBAN_BUILD_DIR)/$$proto/target \
352357
CARGO_NET_GIT_FETCH_WITH_CLI=true \
353358
$(CARGO) build \
354359
--package soroban-env-host \

src/herder/test/TxSetTests.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,9 +2262,14 @@ TEST_CASE("txset nomination", "[txset]")
22622262
}
22632263
namespace fs = std::filesystem;
22642264
fs::path resultsPath = "testdata/txset/" + testName;
2265-
fs::create_directories(resultsPath.parent_path());
2265+
char* srcdir = getenv("top_srcdir");
2266+
if (srcdir)
2267+
{
2268+
resultsPath = fs::path(srcdir) / "src" / resultsPath;
2269+
}
22662270
if (getenv("GENERATE_TEST_TXSETS"))
22672271
{
2272+
fs::create_directories(resultsPath.parent_path());
22682273
std::ofstream resultsStream(resultsPath);
22692274
for (auto const& result : testResults)
22702275
{

src/main/test/ApplicationUtilsTests.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,24 @@ TEST_CASE("application major version numbers", "[applicationutils]")
173173
TEST_CASE("standalone quorum intersection check", "[applicationutils]")
174174
{
175175
Config cfg = getTestConfig();
176-
const std::string JSON_ROOT = "testdata/check-quorum-intersection-json/";
176+
namespace fs = std::filesystem;
177+
fs::path JSON_ROOT = "testdata/check-quorum-intersection-json";
178+
char* srcdir = getenv("top_srcdir");
179+
if (srcdir)
180+
{
181+
JSON_ROOT = fs::path(srcdir) / "src" / JSON_ROOT;
182+
}
177183

178184
SECTION("enjoys quorum intersection")
179185
{
180186
REQUIRE(checkQuorumIntersectionFromJson(
181-
JSON_ROOT + "enjoys-intersection.json", cfg));
187+
JSON_ROOT / "enjoys-intersection.json", cfg));
182188
}
183189

184190
SECTION("does not enjoy quorum intersection")
185191
{
186192
REQUIRE(!checkQuorumIntersectionFromJson(
187-
JSON_ROOT + "no-intersection.json", cfg));
193+
JSON_ROOT / "no-intersection.json", cfg));
188194
}
189195

190196
SECTION("malformed JSON")
@@ -193,17 +199,17 @@ TEST_CASE("standalone quorum intersection check", "[applicationutils]")
193199

194200
// Malformed key
195201
REQUIRE_THROWS_AS(
196-
checkQuorumIntersectionFromJson(JSON_ROOT + "bad-key.json", cfg),
202+
checkQuorumIntersectionFromJson(JSON_ROOT / "bad-key.json", cfg),
197203
KeyUtils::InvalidStrKey);
198204

199205
// Wrong datatype
200206
REQUIRE_THROWS_AS(checkQuorumIntersectionFromJson(
201-
JSON_ROOT + "bad-threshold-type.json", cfg),
207+
JSON_ROOT / "bad-threshold-type.json", cfg),
202208
std::runtime_error);
203209

204210
// No such file
205211
REQUIRE_THROWS_AS(
206-
checkQuorumIntersectionFromJson(JSON_ROOT + "no-file.json", cfg),
212+
checkQuorumIntersectionFromJson(JSON_ROOT / "no-file.json", cfg),
207213
std::runtime_error);
208214
}
209-
}
215+
}

src/test/check-sorobans

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ SKIP_TESTS="host::declared_size::test::test_expected_size"
2828
set -e
2929
set -x
3030

31-
cd rust/soroban
31+
cd "${top_srcdir}/src/rust/soroban"
3232
for i in p??; do
3333
cd $i
34+
CARGO_TARGET_DIR="${top_builddir}/src/rust/soroban/${i}/target" \
3435
RUSTFLAGS="-Cmetadata=${i}" cargo +${RUST_TOOLCHAIN_CHANNEL} \
3536
test \
3637
--locked \

src/test/selftest-nopg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# under the Apache License, Version 2.0. See the COPYING file at the root
55
# of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
66

7-
exec ./test/selftest-parallel ./test/run-selftest-nopg
7+
exec "${top_srcdir}/src/test/selftest-parallel" "${top_srcdir}/src/test/run-selftest-nopg"

src/test/selftest-pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# under the Apache License, Version 2.0. See the COPYING file at the root
55
# of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
66

7-
exec ./test/selftest-parallel ./test/run-selftest-pg
7+
exec "${top_srcdir}/src/test/selftest-parallel" "${top_srcdir}/src/test/run-selftest-pg"

0 commit comments

Comments
 (0)