From fb1494fc81f7d3aafdaed79b342e1fe87e31a3d6 Mon Sep 17 00:00:00 2001 From: Jakub Date: Mon, 22 Aug 2022 11:11:17 +0200 Subject: [PATCH] GODT-1675: Build go bridge twice --- Makefile | 13 +++++++++++-- .../frontend/bridge-gui/bridge-gui/build.sh | 17 ++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 900b75d1..84c19fe8 100644 --- a/Makefile +++ b/Makefile @@ -80,14 +80,23 @@ build-gui: ${TGZ_TARGET} build-nogui: ${EXE_NAME} +go-build=go build $(1) -o $(2) $(3) +go-build-unify=${go-build} +ifeq "${GOOS}-$(shell uname -m)" "darwin-arm64" + go-build-unify= \ + CGO_ENABLED=1 GOARCH=arm64 $(call go-build,$(1),$(2)_arm,$(3)) && \ + CGO_ENABLED=1 GOARCH=amd64 $(call go-build,$(1),$(2)_amd,$(3)) && \ + lipo -create -output $(2) $(2)_arm $(2)_amd && rm -f $(2)_arm $(2)_amd +endif + ${EXE_NAME}: gofiles - go build ${BUILD_FLAGS} -o ${EXE_NAME} cmd/${TARGET_CMD}/main.go + $(call go-build-unify,${BUILD_FLAGS},"${EXE_NAME}","cmd/${TARGET_CMD}/main.go") build-launcher: ${RESOURCE_FILE} ifeq "${GOOS}" "windows" powershell Copy-Item ${ROOT_DIR}/${RESOURCE_FILE} ${ROOT_DIR}/${LAUNCHER_PATH}${RESOURCE_FILE} endif - go build ${BUILD_FLAGS_LAUNCHER} -o ${LAUNCHER_EXE} ${LAUNCHER_PATH} + $(call go-build-unify,${BUILD_FLAGS_LAUNCHER},"${LAUNCHER_EXE}","${LAUNCHER_PATH}") ifeq "${GOOS}" "windows" powershell Remove-Item ${ROOT_DIR}/${LAUNCHER_PATH}${RESOURCE_FILE} -Force endif diff --git a/internal/frontend/bridge-gui/bridge-gui/build.sh b/internal/frontend/bridge-gui/bridge-gui/build.sh index d5249a37..60702293 100755 --- a/internal/frontend/bridge-gui/bridge-gui/build.sh +++ b/internal/frontend/bridge-gui/bridge-gui/build.sh @@ -21,14 +21,7 @@ if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]] ; then exit $? fi - -BRIDGE_REPO_ROOT="../../../.." -BRIDGE_INSTALL_PATH=${BRIDGE_INSTALL_PATH:-deploy} -BRIDGE_APP_VERSION=${BRIDGE_APP_VERSION:-$("${BRIDGE_REPO_ROOT}/utils/bridge_app_version.sh")} -BRIDGE_APP_FULL_NAME=${BRIDGE_APP_FULL_NAME:-"Proton Bridge"} -BRIDGE_VENDOR=${BRIDGE_VENDOR:-"Proton AG"} -BUILD_CONFIG=${BRIDGE_GUI_BUILD_CONFIG:-Debug} -BUILD_DIR=$(echo "./cmake-build-${BUILD_CONFIG}" | tr '[:upper:]' '[:lower:]') +set -x realpath() { START_DIR=$PWD @@ -54,6 +47,13 @@ check_exit() { fi } +BRIDGE_REPO_ROOT=$(realpath "../../../..") +BRIDGE_INSTALL_PATH=${BRIDGE_INSTALL_PATH:-deploy} +BRIDGE_APP_VERSION=${BRIDGE_APP_VERSION:-$("${BRIDGE_REPO_ROOT}/utils/bridge_app_version.sh")} +BRIDGE_APP_FULL_NAME=${BRIDGE_APP_FULL_NAME:-"Proton Bridge"} +BRIDGE_VENDOR=${BRIDGE_VENDOR:-"Proton AG"} +BUILD_CONFIG=${BRIDGE_GUI_BUILD_CONFIG:-Debug} +BUILD_DIR=$(echo "./cmake-build-${BUILD_CONFIG}" | tr '[:upper:]' '[:lower:]') VCPKG_ROOT="${BRIDGE_REPO_ROOT}/extern/vcpkg" git submodule update --init --recursive ${VCPKG_ROOT} @@ -61,7 +61,6 @@ check_exit "Failed to initialize vcpkg as a submodule." echo submodule udpated -VCPKG_ROOT=$(realpath "$VCPKG_ROOT") VCPKG_EXE="${VCPKG_ROOT}/vcpkg" VCPKG_BOOTSTRAP="${VCPKG_ROOT}/bootstrap-vcpkg.sh"