Skip to content

Commit

Permalink
mac arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
starpit committed Jun 10, 2021
1 parent 64fb028 commit 8c1766e
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 67 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ plugins/*/mdist
clients/**/mdist

# webpack-dev-server report
report.*.json
report.*.json

# packages/builder/dist/electron currently generates this and does not remove it
/kubectl-kui
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"test4": "PORT_OFFSET=3 npm run testv2",
"test5": "PORT_OFFSET=4 npm run testv2",
"build:electron:mac:amd64": "PLATFORM=mac ARCH=x64 kui-build-electron",
"build:electron:mac:arm64": "PLATFORM=mac ARCH=arm64 kui-build-electron",
"build:electron:osx:amd64": "npm run build:electron:mac:amd64",
"build:electron:osx:arm64": "npm run build:electron:mac:arm64",
"build:electron:linux:amd64": "PLATFORM=linux ARCH=x64 kui-build-electron",
"build:electron:linux:arm64": "PLATFORM=linux ARCH=arm64 kui-build-electron",
"build:electron:win32:amd64": "PLATFORM=win32 ARCH=x64 kui-build-electron",
Expand Down
38 changes: 38 additions & 0 deletions packages/builder/bin/nodepty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

#
# This utility can help with rebuilding the native node-pty modules on
# a given platform. On Linux and Mac, it should produce a file
# /tmp/pty.node
#
# Parameters:
# $1: [optional] major version of Electron to target default=11
#

set -e
set -o pipefail

# temporary directory
T=$(mktemp -d)

cd "$T"
npm init -y
npm install node-pty@0.10.1
cd node_modules/node-pty

cat <<EOF > .npmrc
runtime=electron
target=${1-11}.0.0
build_from_source=true
disturl=https://atom.io/download/electron
EOF

echo "Building pty.node in $(pwd)"
echo "Using this npmrc"
cat .npmrc

npm run install
cp build/Release/pty.node /tmp
ls -l /tmp/pty.node

echo "Successfully built /tmp/pty.node"
88 changes: 22 additions & 66 deletions packages/builder/dist/electron/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ Start-Process -NoNewWindow $ScriptDir/Kui.exe -ArgumentList $argv' >> kubectl-ku
#
if [ -z "$NO_INSTALLER" ]; then
echo "Zip build for win32"
(cd $BUILDDIR && zip -q -r "${CLIENT_NAME}-win32-$ARCH" "${CLIENT_NAME}-win32-$ARCH" -x \*~) &
WIN_ZIP_PID=$!
(cd $BUILDDIR && zip -q -r "${CLIENT_NAME}-win32-$ARCH" "${CLIENT_NAME}-win32-$ARCH" -x \*~)

# build squirrel and msi installers
# SETUP_ICON=$ICON_WIN32 node builders/squirrel.js
Expand All @@ -118,9 +117,13 @@ Start-Process -NoNewWindow $ScriptDir/Kui.exe -ArgumentList $argv' >> kubectl-ku
# deal with darwin/macOS packaging
#
function mac {
DESIRED_ARCH=$ARCH
local ARCH=$1

if [ "$PLATFORM" == "all" ] || [ "$PLATFORM" == "mac" ] || [ "$PLATFORM" == "macos" ] || [ "$PLATFORM" == "darwin" ] || [ "$PLATFORM" == "osx" ]; then
if [ -n "$DESIRED_ARCH" ] && [ "$ARCH" != "$DESIRED_ARCH" ]; then
return
fi
echo "Electron build darwin $ARCH"

if [ ! -f "$KUI_LAUNCHER" ]; then
Expand Down Expand Up @@ -183,10 +186,8 @@ fi
# fi

echo "TGZ build for darwin"
tar -C "$BUILDDIR" -jcf "$BUILDDIR/${CLIENT_NAME}-darwin-$ARCH.tar.bz2" "${CLIENT_NAME}-darwin-$ARCH" &
MAC_TAR_PID=$!
tar -C "$BUILDDIR" -jcf "$BUILDDIR/${CLIENT_NAME}-darwin-$ARCH.tar.bz2" "${CLIENT_NAME}-darwin-$ARCH"
fi

fi
}

Expand Down Expand Up @@ -228,66 +229,15 @@ SCRIPTDIR=$(cd $(dirname "$0") && pwd)

if [ -z "$NO_INSTALLER" ]; then
echo "Zip build for linux"
(cd $BUILDDIR && zip -q -r "${CLIENT_NAME}-linux-$ARCH" "${CLIENT_NAME}-linux-$ARCH" -x \*~) &
LINUX_ZIP_PID=$!
(cd $BUILDDIR && zip -q -r "${CLIENT_NAME}-linux-$ARCH" "${CLIENT_NAME}-linux-$ARCH" -x \*~)

echo "DEB build for linux"
ARCH=$ARCH "$BUILDER_HOME"/dist/electron/builders/deb.sh &
LINUX_DEB_PID=$!
# ARCH=$ARCH "$BUILDER_HOME"/dist/electron/builders/deb.sh &
# LINUX_DEB_PID=$!
fi
fi
}

function tarball {
# exit code; we'll check the builders in a second, and possibly alter
# the exit code based on their exit codes
CODE=0

# check to see if any of the builders failed; we backgrounded them, so
# this is a bit convulated, in bash
if [ -n "$WIN_ZIP_PID" ]; then
wait $WIN_ZIP_PID
if [ $? != 0 ]; then
echo "Error with windows zip build"
CODE=1
fi
fi

if [ -n "$MAC_DMG_PID" ]; then
wait $MAC_DMG_PID
if [ $? != 0 ]; then
echo "Error with mac dmg build"
CODE=1
fi
fi

if [ -n "$MAC_TAR_PID" ]; then
wait $MAC_TAR_PID
if [ $? != 0 ]; then
echo "Error with mac tar build"
CODE=1
fi
fi

if [ -n "$LINUX_ZIP_PID" ]; then
wait $LINUX_ZIP_PID
if [ $? != 0 ]; then
echo "Error with linux zip build"
CODE=1
fi
fi

if [ -n "$LINUX_DMG_PID" ]; then
wait $LINUX_DMG_PID
if [ $? != 0 ]; then
echo "Error with linux dmg build"
CODE=1
fi
fi

wait
}

# install the electron-packager dependencies
function builddeps {
(cd "$BUILDER_HOME/dist/electron" && npm ci)
Expand All @@ -306,18 +256,24 @@ function builddeps {
# this is the main routine
function build {
echo "builddeps" && builddeps
echo "win32" && win32 x64
echo "mac" && mac x64

win32 x64

if [ -z "$ARCH" ] || [ "$ARCH" = "all" ]; then
echo "Building all arch for linux"
echo "linux x64" && linux x64
echo "linux arm64" && linux arm64
echo "Building all arch for mac"
mac x64
mac arm64
else
echo "linux" && linux ${ARCH-x64}
mac ${ARCH-x64}
fi

echo "tarball" && tarball
if [ -z "$ARCH" ] || [ "$ARCH" = "all" ]; then
echo "Building all arch for linux"
linux x64
linux arm64
else
linux ${ARCH-x64}
fi
}

# line up the work
Expand Down
Binary file not shown.

0 comments on commit 8c1766e

Please sign in to comment.