Skip to content

Commit 1d6dfc1

Browse files
authored
Merge pull request #354 from desktop/macos-arm64-builds
2 parents f221234 + 3d467be commit 1d6dfc1

File tree

5 files changed

+53
-30
lines changed

5 files changed

+53
-30
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ jobs:
2727
matrix:
2828
os: [macos-10.15, windows-2019, ubuntu-18.04]
2929
arch: [32, 64]
30+
go: [1.16.3]
3031
include:
3132
- os: macos-10.15
3233
friendlyName: macOS
3334
targetPlatform: macOS
35+
- os: macos-10.15
36+
friendlyName: macOS
37+
targetPlatform: macOS
38+
arch: arm64
39+
go: 1.16.3
3440
- os: windows-2019
3541
friendlyName: Windows
3642
targetPlatform: win32
@@ -44,9 +50,9 @@ jobs:
4450
arch: 32
4551
timeout-minutes: 20
4652
steps:
47-
# We need to use Xcode 10.3 for maximum compatibility with older macOS
53+
# We need to use Xcode 10.3 for maximum compatibility with older macOS (x64)
4854
- name: Switch to Xcode 10.3
49-
if: matrix.targetPlatform == 'macOS'
55+
if: matrix.targetPlatform == 'macOS' && matrix.arch == 64
5056
run: |
5157
sudo xcode-select -s /Applications/Xcode_10.3.app/Contents/Developer/
5258
# Delete the command line tools to make sure they don't get our builds
@@ -57,6 +63,10 @@ jobs:
5763
submodules: recursive
5864
# Needed for script/package.sh to work
5965
fetch-depth: 0
66+
- name: Use go ${{ matrix.go }}
67+
uses: actions/setup-go@v2
68+
with:
69+
go-version: ${{ matrix.go }}
6070
- name: Install dependencies
6171
run: npm install
6272
- name: Check formatting
@@ -66,12 +76,22 @@ jobs:
6676
- name: Install extra dependencies for building Git on Ubuntu
6777
if: matrix.targetPlatform == 'ubuntu'
6878
run: sudo apt-get install libcurl4-openssl-dev libexpat1-dev gettext
69-
- name: Build
79+
- name: Build (except macOS arm64)
80+
if: matrix.targetPlatform != 'macOS' || matrix.arch != 'arm64'
81+
shell: bash
82+
run: script/build.sh
83+
env:
84+
TARGET_PLATFORM: ${{ matrix.targetPlatform }}
85+
TARGET_ARCH: ${{ matrix.arch }}
86+
- name: Build (macOS arm64)
87+
if: matrix.targetPlatform == 'macOS' && matrix.arch == 'arm64'
7088
shell: bash
7189
run: script/build.sh
7290
env:
7391
TARGET_PLATFORM: ${{ matrix.targetPlatform }}
7492
TARGET_ARCH: ${{ matrix.arch }}
93+
# Needed for macOS arm64 until hosted macos-11.0 runners become available
94+
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
7595
- name: Package
7696
shell: bash
7797
run: script/package.sh

dependencies.json

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,5 @@
4040
"checksum": "0e13b411ca6c2b2cfb3d82b67ae747ca5d055734d0ab2030d0823fc37ad48902"
4141
}
4242
]
43-
},
44-
"smimesign": {
45-
"version": "0.0.6",
46-
"files": [
47-
{
48-
"platform": "darwin",
49-
"arch": "amd64",
50-
"name": "smimesign-0.0.6-macos.tgz",
51-
"checksum": "771790f685176b132cb287302a9374120184f7f7973038a0232efee145781906"
52-
},
53-
{
54-
"platform": "windows",
55-
"arch": "amd64",
56-
"name": "smimesign-windows-amd64-0.0.6.zip",
57-
"checksum": "2a2f946e31f2d74eadcdcd97b7bfc69298cee2f11cf7cb03c604d28fa1b34cd3"
58-
},
59-
{
60-
"platform": "windows",
61-
"arch": "x86",
62-
"name": "smimesign-windows-386-0.0.6.zip",
63-
"checksum": "9a13d00aa02c0a5d277c030297d09f10a467f31e6740f1520a08e09a23046323"
64-
}
65-
]
6643
}
6744
}

script/build-macos.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ set -eu -o pipefail
77

88
MACOSX_BUILD_VERSION="10.9"
99

10+
if [ "$TARGET_ARCH" = "64" ]; then
11+
HOST_CPU=x86_64
12+
TARGET_CFLAGS="-target x86_64-apple-darwin"
13+
GOARCH=amd64
14+
else
15+
HOST_CPU=arm64
16+
TARGET_CFLAGS="-target arm64-apple-darwin"
17+
GOARCH=arm64
18+
fi
19+
1020
if [[ -z "${SOURCE}" ]]; then
1121
echo "Required environment variable SOURCE was not set"
1222
exit 1
@@ -43,7 +53,13 @@ echo "-- Building git at $SOURCE to $DESTINATION"
4353
# Reason: image not found
4454
#
4555
# For this reason we set CURL_CONFIG to the system version explicitly here.
56+
#
57+
# HACK: There is no way of adding additional CFLAGS without running the
58+
# configure script. However the Makefile prepends some developer CFLAGS that
59+
# we could use to select the right target CPU to cross-compile git.
4660
DESTDIR="$DESTINATION" make strip install prefix=/ \
61+
DEVELOPER_CFLAGS="$TARGET_CFLAGS" \
62+
HOST_CPU="$HOST_CPU" \
4763
CURL_CONFIG=/usr/bin/curl-config \
4864
NO_PERL=1 \
4965
NO_TCLTK=1 \
@@ -60,7 +76,16 @@ if [[ "$GIT_LFS_VERSION" ]]; then
6076
git clone -b "v$GIT_LFS_VERSION" "https://github.com/git-lfs/git-lfs"
6177
(
6278
cd git-lfs
63-
make CGO_CFLAGS="-mmacosx-version-min=$MACOSX_BUILD_VERSION" CGO_LDFLAGS="-mmacosx-version-min=$MACOSX_BUILD_VERSION" BUILTIN_LD_FLAGS="-linkmode external"
79+
80+
# HACK: When cross-compiling, there seems to be an issue when git-lfs attempts
81+
# to generate the manpage contents, and it seems that preffixing that command
82+
# with `GOARCH=` to use the host architecture fixes the issue.
83+
# This hack can be removed once the issue is fixed via the PR
84+
# https://github.com/git-lfs/git-lfs/pull/4492 or some other solution.
85+
GO_GENERATE_STRING="\$(GO) generate github.com\/git-lfs\/git-lfs\/commands"
86+
sed -i -e "s/$GO_GENERATE_STRING/GOARCH= $GO_GENERATE_STRING/" Makefile
87+
88+
make GOARCH="$GOARCH" CGO_CFLAGS="-mmacosx-version-min=$MACOSX_BUILD_VERSION" CGO_LDFLAGS="-mmacosx-version-min=$MACOSX_BUILD_VERSION" BUILTIN_LD_FLAGS="-linkmode external"
6489
)
6590
GIT_LFS_BINARY_PATH="git-lfs/bin/git-lfs"
6691
if test -f "$GIT_LFS_BINARY_PATH"; then

script/generate-release-notes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default class GenerateReleaseNotes {
77
// five targeted OS/arch combinations
88
// two files for each targeted OS/arch
99
// two checksum files for the previous
10-
private SUCCESSFUL_RELEASE_FILE_COUNT = 4 * 2 * 2
10+
private SUCCESSFUL_RELEASE_FILE_COUNT = 5 * 2 * 2
1111
private args = process.argv.slice(2)
1212
private expectedArgs = [
1313
{

script/package.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ if [ "$TARGET_PLATFORM" == "ubuntu" ]; then
3737
GZIP_FILE="dugite-native-$VERSION-$BUILD_HASH-ubuntu.tar.gz"
3838
LZMA_FILE="dugite-native-$VERSION-$BUILD_HASH-ubuntu.lzma"
3939
elif [ "$TARGET_PLATFORM" == "macOS" ]; then
40-
GZIP_FILE="dugite-native-$VERSION-$BUILD_HASH-macOS.tar.gz"
41-
LZMA_FILE="dugite-native-$VERSION-$BUILD_HASH-macOS.lzma"
40+
if [ "$TARGET_ARCH" -eq "64" ]; then ARCH="x64"; else ARCH="arm64"; fi
41+
GZIP_FILE="dugite-native-$VERSION-$BUILD_HASH-macOS-$ARCH.tar.gz"
42+
LZMA_FILE="dugite-native-$VERSION-$BUILD_HASH-macOS-$ARCH.lzma"
4243
elif [ "$TARGET_PLATFORM" == "win32" ]; then
4344
if [ "$TARGET_ARCH" -eq "64" ]; then ARCH="x64"; else ARCH="x86"; fi
4445
GZIP_FILE="dugite-native-$VERSION-$BUILD_HASH-windows-$ARCH.tar.gz"

0 commit comments

Comments
 (0)