Skip to content
Open
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ endfunction()
# enable json support
if(ENABLE_RAPIDJSON)
find_package(RapidJSON CONFIG REQUIRED)
if(NOT TARGET RapidJSON)
message(
FATAL_ERROR
"RapidJSON was found, but target RapidJSON is missing. Check if your RapidJSON installation provides a complete exported CMake configuration."
)
endif()
abacus_add_feature_definitions(__RAPIDJSON)
target_link_libraries(abacus_external_deps INTERFACE RapidJSON)
endif()
Comment on lines 162 to 172

This comment was marked as resolved.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed. The fallback path was dropped; ENABLE_RAPIDJSON now requires the exported RapidJSON target and links it through abacus_external_deps.

Expand Down
2 changes: 0 additions & 2 deletions toolchain/build_abacus_aocc-aocl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ rm -rf $BUILD_DIR
PREFIX=$ABACUS_DIR
ELPA=${ELPA_ROOT}
CEREAL=${CEREAL_ROOT}/include
RAPIDJSON=${RAPIDJSON_ROOT}
LAPACK=$AOCLhome/lib
SCALAPACK=$AOCLhome/lib
FFTW3=$AOCLhome
Expand Down Expand Up @@ -75,7 +74,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
-DUSE_OPENMP=ON \
-DUSE_ELPA=ON \
-DENABLE_RAPIDJSON=ON \
-DRapidJSON_DIR=$RAPIDJSON \
-DENABLE_LIBRI=ON \
-DLIBRI_DIR=$LIBRI \
-DLIBCOMM_DIR=$LIBCOMM \
Expand Down
2 changes: 1 addition & 1 deletion toolchain/install_abacus_toolchain_new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ main() {
# Initialize configuration with command line arguments
if ! config_init "${args[@]}"; then
show_help
exit 0
exit 1
fi

# Handle special version-related requests
Expand Down
42 changes: 27 additions & 15 deletions toolchain/scripts/lib/config_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ config_validate() {
if [[ -n "${CONFIG_CACHE[NPROCS_OVERWRITE]}" ]]; then
if ! [[ "${CONFIG_CACHE[NPROCS_OVERWRITE]}" =~ ^[0-9]+$ ]]; then
report_error ${LINENO} "Invalid number of processes: ${CONFIG_CACHE[NPROCS_OVERWRITE]}"
exit 1
return 1
fi
fi

if ! [[ "${CONFIG_CACHE[LOG_LINES]}" =~ ^[0-9]+$ ]]; then
report_error ${LINENO} "Invalid log lines value: ${CONFIG_CACHE[LOG_LINES]}"
exit 1
return 1
fi

# Validate GPU version - support only numeric formats
Expand All @@ -476,7 +476,7 @@ config_validate() {
CONFIG_CACHE["ARCH_NUM"]="$arch_num"
else
report_error ${LINENO} "Invalid GPU version: $gpu_ver. Supported formats: numeric with decimal (6.0, 7.0, 8.0, 8.9, etc.) or numeric without decimal (60, 70, 80, 89, etc.)"
exit 1
return 1
fi
else
CONFIG_CACHE["ARCH_NUM"]="no"
Expand Down Expand Up @@ -1166,27 +1166,37 @@ config_parse_arguments() {
config_init() {
# Set defaults first
config_set_defaults

# Initialize version helper to ensure VERSION_STRATEGY defaults are set
if command -v version_helper_init > /dev/null 2>&1; then
version_helper_init
fi

# Load configuration from file (if available) - this will override defaults
config_load_from_file

if ! config_load_from_file; then
return 1
fi

# Apply mode-based configurations from file - this will override defaults
config_apply_modes_from_file

if ! config_apply_modes_from_file; then
return 1
fi

# Parse command line arguments - this will override file settings
config_parse_arguments "$@"

if ! config_parse_arguments "$@"; then
return 1
fi

# Apply mode-based configurations from command line
config_apply_modes

if ! config_apply_modes; then
return 1
fi

# Validate configuration
config_validate

if ! config_validate; then
return 1
fi

return 0
}

Expand Down Expand Up @@ -1262,4 +1272,6 @@ config_apply_modes() {
;;
esac
fi

return 0
}
11 changes: 11 additions & 0 deletions toolchain/scripts/lib/wrapper_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

run_toolchain_with_log() {
local log_file="$1"
shift

"$@" | tee "$log_file"
local installer_status=${PIPESTATUS[0]}

return "$installer_status"
}
128 changes: 128 additions & 0 deletions toolchain/tests/test_installer_argument_failures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env bash
set -u

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
TOOLCHAIN_DIR="${REPO_ROOT}/toolchain"
FAILURES=0

fail() {
printf 'FAIL: %s\n' "$*" >&2
FAILURES=$((FAILURES + 1))
}

copy_toolchain() {
local tmpdir="$1"
local entry name
mkdir -p "${tmpdir}/toolchain"
while IFS= read -r -d '' entry; do
name="${entry##*/}"
case "$name" in
build|install) continue ;;
esac
cp -a "$entry" "${tmpdir}/toolchain/"
done < <(find "${TOOLCHAIN_DIR}" -mindepth 1 -maxdepth 1 -print0)
}

run_installer_in_copy() {
local tmpdir="$1"
shift
(cd "${tmpdir}/toolchain" && ./install_abacus_toolchain_new.sh "$@") >"${tmpdir}/output.log" 2>&1
}

assert_invalid_input_fails() {
local name="$1"
local expected_text="$2"
shift 2

local tmpdir status
tmpdir="$(mktemp -d)"
copy_toolchain "$tmpdir"

run_installer_in_copy "$tmpdir" "$@"
status=$?

if [[ "$status" -eq 0 ]]; then
cat "${tmpdir}/output.log" >&2
fail "${name} exited 0; expected nonzero"
fi

if ! grep -Fq -- "$expected_text" "${tmpdir}/output.log"; then
cat "${tmpdir}/output.log" >&2
fail "${name} did not report expected error: ${expected_text}"
fi

if ! grep -Fq "install_abacus_toolchain_new.sh [OPTIONS]" "${tmpdir}/output.log"; then
cat "${tmpdir}/output.log" >&2
fail "${name} output did not contain usage text"
fi

if [[ -e "${tmpdir}/toolchain/install/setup" ]]; then
fail "${name} wrote install/setup even though argument parsing failed"
fi

rm -rf "$tmpdir"
}

assert_valid_dry_run_succeeds() {
local name="$1"
shift

local tmpdir status
tmpdir="$(mktemp -d)"
copy_toolchain "$tmpdir"

run_installer_in_copy "$tmpdir" "$@"
status=$?

if [[ "$status" -ne 0 ]]; then
cat "${tmpdir}/output.log" >&2
fail "${name} exited ${status}; expected 0"
fi

if ! grep -Fq "Configuration files generated successfully (dry-run mode)" "${tmpdir}/output.log"; then
cat "${tmpdir}/output.log" >&2
fail "${name} output did not contain dry-run success text"
fi

if grep -Fq "Attempting secure download" "${tmpdir}/output.log"; then
cat "${tmpdir}/output.log" >&2
fail "${name} attempted a package download during dry-run"
fi

rm -rf "$tmpdir"
}

assert_valid_help_succeeds() {
local tmpdir status
tmpdir="$(mktemp -d)"
copy_toolchain "$tmpdir"

run_installer_in_copy "$tmpdir" --help
status=$?

if [[ "$status" -ne 0 ]]; then
cat "${tmpdir}/output.log" >&2
fail "--help exited ${status}; expected 0"
fi

if ! grep -Fq "install_abacus_toolchain_new.sh [OPTIONS]" "${tmpdir}/output.log"; then
cat "${tmpdir}/output.log" >&2
fail "--help output did not contain usage text"
fi

rm -rf "$tmpdir"
}

assert_invalid_input_fails "invalid package version" "Invalid package version format" --dry-run --package-version bad:wrong
assert_invalid_input_fails "missing package version value" "--package-version requires at least one package:version argument" --dry-run --package-version
assert_invalid_input_fails "invalid mpi mode" "Invalid MPI mode: invalid" --dry-run --mpi-mode invalid
assert_invalid_input_fails "invalid gpu version" "Invalid GPU version" --dry-run --gpu-ver bad
assert_valid_dry_run_succeeds "explicit system openblas dry-run" --dry-run --with-openblas=system
assert_valid_help_succeeds

if [[ "$FAILURES" -ne 0 ]]; then
printf '%s installer argument failure test(s) failed\n' "$FAILURES" >&2
exit 1
fi

printf 'installer argument failure tests passed\n'
Loading
Loading