fixed a bug related to parsing multiple platforms when '-t all' is specified

This commit is contained in:
Swarup Sengupta
2025-09-14 02:45:14 +05:30
parent 4266d9124d
commit 8bd953079c
2 changed files with 21 additions and 17 deletions
+16 -15
View File
@@ -61,7 +61,8 @@ CURRENT_TARGET="$(go env GOOS)/$(go env GOARCH)"
TARGETS=${TARGETS:-"current"}
TARGETS=$(decipher_targets "${TARGETS}")
TARGETS=${TARGETS//,/ }
TARGETS=${TARGETS%$'\n'}
IFS=' ' TARGETS=(${TARGETS//,/ })
BUILD_DIR=$(pwd)/tmp_build_$$
rm -rf "${BUILD_DIR}"
@@ -77,21 +78,21 @@ pushd "${BUILD_DIR}/ConsoleClient" > /dev/null
export CGO_ENABLED=0
for PLATFORM in ${TARGETS}
for PLATFORM in "${TARGETS[@]}"
do
IFS='/' read -r OS ARCH VARIANT <<< "${PLATFORM}"
export GOOS=${OS}
export GOARCH=${ARCH}
if [[ -n "${VARIANT}" ]]; then
export GOARM=${VARIANT#v}
fi
GOEXT=""
if [[ "${OS}" == "windows" ]]; then
GOEXT=".exe"
fi
${GO} build -a -tags netgo -ldflags "-s -w -extldflags '-static'" -o "${BIN_DIR}/psiphon_${PLATFORM//\//_}${GOEXT}"
unset GOOS GOARCH GOARM
echo "Building for ${PLATFORM}..."
IFS='/' read -r OS ARCH VARIANT <<< "${PLATFORM}"
export GOOS=${OS}
export GOARCH=${ARCH}
if [[ -n "${VARIANT}" ]]; then
export GOARM=${VARIANT#v}
fi
GOEXT=""
if [[ "${OS}" == "windows" ]]; then
GOEXT=".exe"
fi
${GO} build -a -tags netgo -ldflags "-s -w -extldflags '-static'" -o "${BIN_DIR}/psiphon_${PLATFORM//\//_}${GOEXT}"
unset GOOS GOARCH GOARM
done
popd > /dev/null
+5 -2
View File
@@ -7,10 +7,13 @@ function help_message() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --targets, -t <targets> Comma-separated list of target platforms (default: current, use 'all' for all supported targets)"
echo " --version, -v <version> Psiphon version to build (default: 2.0.32)"
echo " --version, -v <version> Psiphon version to build (default: latest available)"
echo " --go, -g <version> Go version to use (default: 1.22.7)"
echo " --help, -h Show this help message and exit"
echo " --load Load the built image into local Docker (cannot be used with --push)"
echo " --push Push the built image to Docker Hub (cannot be used with --load)"
echo " --supported-targets Show supported targets and exit"
echo " --current-target Show current target platform and exit"
echo " --help, -h Show this help message and exit"
exit ${1:-1}
}