Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ci/test/00_setup_env_mac_arm64_cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export GOAL="deploy"
export GRIDCOIN_CONFIG="--with-gui --enable-reduce-exports"

# Set the macOS deployment target for the depends build.
# This ensures that libraries compiled by 'depends' are compatible with the target macOS version.
# The value '10.14' matches the '-mmacos-version-min=10.14' used in CFLAGS/CXXFLAGS.
export DEP_OPTS="MACOSX_DEPLOYMENT_TARGET=10.14"
99 changes: 90 additions & 9 deletions ci/test/06_script_a.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@

export LC_ALL=C.UTF-8

# Define common configuration flags for Autotools.
# These set the installation prefixes for binaries and libraries to the depends output directory.
GRIDCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$DEPENDS_DIR/$HOST --bindir=$BASE_OUTDIR/bin --libdir=$BASE_OUTDIR/lib"

# Zero out ccache statistics and set its maximum size for the current build.
DOCKER_EXEC "ccache --zero-stats --max-size=$CCACHE_SIZE"

# --- Autogen Step ---
# Run the autogen.sh script to generate configure and other build system files.
# This step is conditional on whether CONFIG_SHELL is defined.
BEGIN_FOLD autogen
if [ -n "$CONFIG_SHELL" ]; then
DOCKER_EXEC "$CONFIG_SHELL" -c "./autogen.sh"
Expand All @@ -17,30 +24,104 @@ else
fi
END_FOLD

# Create the base build directory if it doesn't exist.
DOCKER_EXEC mkdir -p "${BASE_BUILD_DIR}"
# Set the current CI directory context.
export P_CI_DIR="${BASE_BUILD_DIR}"

BEGIN_FOLD configure
DOCKER_EXEC "${BASE_ROOT_DIR}/configure" --cache-file=config.cache $GRIDCOIN_CONFIG_ALL $GRIDCOIN_CONFIG || ( (DOCKER_EXEC cat config.log) && false)
END_FOLD
# --- First Configure Pass (in BASE_ROOT_DIR) ---
# This block handles the initial configure script execution.
# It ensures PKG_CONFIG_PATH is correctly set for depends-based builds
# and clears the config.cache to prevent "environment changed" errors.

# Clear the config.cache before running configure to ensure a clean state.
# This prevents errors if environment variables like PKG_CONFIG_PATH change between runs.
DOCKER_EXEC rm -f config.cache

if [ -z "$NO_DEPENDS" ]; then
# If NO_DEPENDS is NOT set (meaning depends are used, e.g., cross-compilation),
# we export PKG_CONFIG_PATH within the same DOCKER_EXEC subshell as configure.
DOCKER_EXEC bash -c "
export PKG_CONFIG_PATH=\"${DEPENDS_DIR}/${HOST}/lib/pkgconfig:\$PKG_CONFIG_PATH\"
echo \"PKG_CONFIG_PATH set for first configure: \$PKG_CONFIG_PATH\"
\"${BASE_ROOT_DIR}/configure\" --cache-file=config.cache ${GRIDCOIN_CONFIG_ALL} ${GRIDCOIN_CONFIG} || ( (cat config.log) && false)
"
else
# If NO_DEPENDS IS set (meaning system libs are used, e.g., native builds),
# run configure directly without modifying PKG_CONFIG_PATH.
DOCKER_EXEC "${BASE_ROOT_DIR}/configure" --cache-file=config.cache ${GRIDCOIN_CONFIG_ALL} ${GRIDCOIN_CONFIG} || ( (cat config.log) && false)
fi

# --- Make Distdir Step ---
# Create a distribution tarball of the source code.
BEGIN_FOLD distdir
DOCKER_EXEC make distdir VERSION=$HOST
END_FOLD

# Update the current CI directory context to the newly created distdir.
export P_CI_DIR="${BASE_BUILD_DIR}/gridcoin-$HOST"

BEGIN_FOLD configure
DOCKER_EXEC ./configure --cache-file=../config.cache $GRIDCOIN_CONFIG_ALL $GRIDCOIN_CONFIG || ( (DOCKER_EXEC cat config.log) && false)
END_FOLD
# --- Second Configure Pass (in distdir) ---
# This block handles the configure script execution within the distribution directory.
# It also ensures PKG_CONFIG_PATH is correctly set and clears config.cache,
# all within a single DOCKER_EXEC invocation.

# Perform the operations in the distdir within a single DOCKER_EXEC call.
if [ -z "$NO_DEPENDS" ]; then
DOCKER_EXEC bash -c "
pushd \"${BASE_BUILD_DIR}/gridcoin-${HOST}\" >/dev/null && \
rm -f config.cache && \
export PKG_CONFIG_PATH=\"${DEPENDS_DIR}/${HOST}/lib/pkgconfig:\$PKG_CONFIG_PATH\" && \
echo \"PKG_CONFIG_PATH set for second configure: \$PKG_CONFIG_PATH\" && \
./configure --cache-file=../config.cache ${GRIDCOIN_CONFIG_ALL} ${GRIDCOIN_CONFIG} || ( (cat config.log) && false) && \
popd >/dev/null
"
else
DOCKER_EXEC bash -c "
pushd \"${BASE_BUILD_DIR}/gridcoin-${HOST}\" >/dev/null && \
rm -f config.cache && \
./configure --cache-file=../config.cache ${GRIDCOIN_CONFIG_ALL} ${GRIDCOIN_CONFIG} || ( (cat config.log) && false) && \
popd >/dev/null
"
fi

# --- Error Trace Trap (for Sanitizer Output) ---
# Set up a trap to output sanitizer logs if the build fails.
set -o errtrace
trap 'DOCKER_EXEC "cat ${BASE_SCRATCH_DIR}/sanitizer-output/* 2> /dev/null"' ERR

BEGIN_FOLD build
DOCKER_EXEC make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false )
END_FOLD
# --- Build Step ---
# Compile the project using make. If it fails, rerun with verbose output for debugging.
# --- Adjust LDFLAGS and CPPFLAGS for linking and compilation issues ---
# This ensures that zlib is linked after Boost libraries that depend on it.
# This also suppresses 'sprintf' deprecation warnings from Boost headers.
# This should happen within the DOCKER_EXEC context for the build.
if [ -z "$NO_DEPENDS" ]; then
# For depends builds, prepend depends-built zlib path and library,
# and add warning suppression for Boost/system headers.
DOCKER_EXEC bash -c "
export LDFLAGS=\"\$LDFLAGS -L${DEPENDS_DIR}/${HOST}/lib -lz\"
# Suppress -Wdeprecated-declarations warnings, especially from Boost and system headers.
export CPPFLAGS=\"\$CPPFLAGS -Wno-deprecated-declarations\"
echo \"Adjusted LDFLAGS for build: \$LDFLAGS\"
echo \"Adjusted CPPFLAGS for build: \$CPPFLAGS\"
make \$MAKEJOBS \$GOAL || ( echo \"Build failure. Verbose build follows.\" && make \$GOAL V=1 ; false )
"
else
# For non-depends builds, use system zlib and add warning suppression.
DOCKER_EXEC bash -c "
export LDFLAGS=\"\$LDFLAGS -lz\"
# Suppress -Wdeprecated-declarations warnings, especially from Boost and system headers.
export CPPFLAGS=\"\$CPPFLAGS -Wno-deprecated-declarations\"
echo \"Adjusted LDFLAGS for build: \$LDFLAGS\"
echo \"Adjusted CPPFLAGS for build: \$CPPFLAGS\"
make \$MAKEJOBS \$GOAL || ( echo \"Build failure. Verbose build follows.\" && make \$GOAL V=1 ; false )
"
fi
# --- END ADJUSTMENT ---

# --- Cache Statistics ---
# Display ccache statistics and disk usage of depends and previous releases directories.
BEGIN_FOLD cache_stats
DOCKER_EXEC "ccache --version | head -n 1 && ccache --show-stats"
DOCKER_EXEC du -sh "${DEPENDS_DIR}"/*/
Expand Down
11 changes: 10 additions & 1 deletion ci/test/wrap-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@

export LC_ALL=C.UTF-8

for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/univalue/{no_nul,test_json,unitester,object}}; do
# Loop through a list of binaries (by name) that need to be wrapped with QEMU.
# This allows binaries compiled for a different architecture (e.g., ARM) to run
# on the x86_64 CI host via QEMU emulation.
# Added 'src/test/test_gridcoin' to wrap the main unit test executable.
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/univalue/{no_nul,test_json,unitester,object},src/test/test_gridcoin}; do
# Use 'find' to locate the actual executable file(s) corresponding to the binary name.
# shellcheck disable=SC2044
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name $(basename $b_name)); do
echo "Wrap $b ..."
# Rename the original binary by appending '_orig'.
mv "$b" "${b}_orig"
# Create a new wrapper script with the original binary's name.
echo '#!/usr/bin/env bash' > "$b"
# The wrapper script executes QEMU with the original binary and passes all arguments.
echo "$QEMU_USER_CMD \"${b}_orig\" \"\$@\"" >> "$b"
# Make the wrapper script executable.
chmod +x "$b"
done
done
Loading
Loading