Skip to content

Commit

Permalink
First work for Windows multi-arch support
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisameling committed Feb 10, 2021
1 parent 830779b commit 5e05c38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ANDROID_TARGETS := $(foreach t, $(BUILD_TYPES), \

IOS_TARGETS := ios/release

# These can be overriden on the command line, e.g. "make electron TARGET_ARCH=x86 CARGO_ARCH=i686-pc-windows-msvc"
TARGET_ARCH := x64
CARGO_ARCH := x86_64-pc-windows-msvc

help:
$(Q) echo "The following build targets are supported:"
$(Q) echo " ios -- download WebRTC and build for the iOS platform"
Expand Down Expand Up @@ -72,10 +76,10 @@ electron:
fi
$(Q) if [ "$(TYPE)" = "debug" ] ; then \
echo "Electron: Debug build" ; \
./bin/build-electron -d ; \
TARGET_ARCH=$(TARGET_ARCH) CARGO_ARCH=$(CARGO_ARCH) ./bin/build-electron -d ; \
else \
echo "Electron: Release build" ; \
./bin/build-electron -r ; \
TARGET_ARCH=$(TARGET_ARCH) CARGO_ARCH=$(CARGO_ARCH) ./bin/build-electron -r ; \
fi
$(Q) (cd src/node && yarn install && yarn build)

Expand Down
13 changes: 8 additions & 5 deletions bin/build-electron
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ set -e
BIN_DIR="$(realpath -e $(dirname $0))"
. "${BIN_DIR}/env.sh"

TARGET_ARCH=${TARGET_ARCH:-x64}
CARGO_ARCH=${CARGO_ARCH:-x86_64-pc-windows-msvc}

usage()
{
echo 'usage: build-electron [-d|-r|-c]
Expand Down Expand Up @@ -90,10 +93,10 @@ export MACOSX_DEPLOYMENT_TARGET="10.10"

if [ "${BUILD_TYPE}" = "debug" ]
then
gn gen -C out/Debug "--args=use_custom_libcxx=false rtc_build_examples=false rtc_build_tools=false rtc_include_tests=false rtc_enable_protobuf=false rtc_use_x11=false rtc_enable_sctp=false"
gn gen -C out/Debug "--args=use_custom_libcxx=false target_cpu=\"${TARGET_ARCH}\" rtc_build_examples=false rtc_build_tools=false rtc_include_tests=false rtc_enable_protobuf=false rtc_use_x11=false rtc_enable_sctp=false"
ninja -C out/Debug
else
gn gen -C out/Release "--args=use_custom_libcxx=false rtc_build_examples=false rtc_build_tools=false rtc_include_tests=false rtc_enable_protobuf=false rtc_use_x11=false is_debug=false rtc_enable_sctp=false"
gn gen -C out/Release "--args=use_custom_libcxx=false target_cpu=\"${TARGET_ARCH}\" rtc_build_examples=false rtc_build_tools=false rtc_include_tests=false rtc_enable_protobuf=false rtc_use_x11=false is_debug=false rtc_enable_sctp=false"
ninja -C out/Release
fi
)
Expand All @@ -104,9 +107,9 @@ export MACOSX_DEPLOYMENT_TARGET="10.10"

if [ "${BUILD_TYPE}" = "debug" ]
then
npm_config_arch=x64 npm_config_target_arch=x64 npm_config_disturl=https://atom.io/download/electron npm_config_runtime=electron npm_config_target=11.2.0 npm_config_build_from_source=true npm_config_devdir=~/.electron-gyp cargo build --features electron
npm_config_arch=${TARGET_ARCH} npm_config_target_arch=${TARGET_ARCH} npm_config_disturl=https://atom.io/download/electron npm_config_runtime=electron npm_config_target=11.2.0 npm_config_build_from_source=true npm_config_devdir=~/.electron-gyp cargo build --target ${CARGO_ARCH} --features electron
else
npm_config_arch=x64 npm_config_target_arch=x64 npm_config_disturl=https://atom.io/download/electron npm_config_runtime=electron npm_config_target=11.2.0 npm_config_build_from_source=true npm_config_devdir=~/.electron-gyp RUSTFLAGS="-C link-arg=-s" cargo build --features electron --release
npm_config_arch=${TARGET_ARCH} npm_config_target_arch=${TARGET_ARCH} npm_config_disturl=https://atom.io/download/electron npm_config_runtime=electron npm_config_target=11.2.0 npm_config_build_from_source=true npm_config_devdir=~/.electron-gyp RUSTFLAGS="-C link-arg=-s" cargo build --target ${CARGO_ARCH} --features electron --release
fi

if [ $DEFAULT_PLATFORM = "darwin" ]
Expand All @@ -116,7 +119,7 @@ export MACOSX_DEPLOYMENT_TARGET="10.10"
elif [ $DEFAULT_PLATFORM = "win32" ]
then
mkdir -p ../node/build/win32
cp -f target/${BUILD_TYPE}/ringrtc.dll ../node/build/win32/libringrtc.node
cp -f target/${CARGO_ARCH}/${BUILD_TYPE}/ringrtc.dll ../node/build/win32/libringrtc-${TARGET_ARCH}.node
elif [ $DEFAULT_PLATFORM = "linux" ]
then
mkdir -p ../node/build/linux
Expand Down

0 comments on commit 5e05c38

Please sign in to comment.