# Sourced by wasm32 scripts to set up RUSTFLAGS
CARGO_CONFIG_RUSTFLAGS=$(cargo +nightly -Z unstable-options config get 'target.cfg(target_arch="wasm32").rustflags' --format json 2>/dev/null | python3 -c "import json,sys; d=sys.stdin.read(); print(' '.join(json.loads(d)['target']['cfg(target_arch=\"wasm32\")']['rustflags']) if d.strip() else '')" 2>/dev/null)
if [ -z "$CARGO_CONFIG_RUSTFLAGS" ]; then
echo "Warning: Could not read rustflags from cargo config" >&2
fi
# Add -D warnings unless RELAXED_WARNINGS is set
WARN_FLAGS=""
if [ -z "$RELAXED_WARNINGS" ]; then
WARN_FLAGS="-D warnings"
fi
export WASM32_RUSTFLAGS="$WARN_FLAGS $CARGO_CONFIG_RUSTFLAGS"
export WASM32_RUSTDOCFLAGS="$WARN_FLAGS $CARGO_CONFIG_RUSTFLAGS"