Skip to content

Commit 832d26b

Browse files
authored
Merge pull request #68 from nim-lang/pr_update_macos
choosenim supports macos arm64 nightlies
2 parents a46c3e2 + 3170e0d commit 832d26b

File tree

5 files changed

+33
-30
lines changed

5 files changed

+33
-30
lines changed

choosenim.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.8.10"
3+
version = "0.8.12"
44
author = "Dominik Picheta"
55
description = "The Nim toolchain installer."
66
license = "BSD"

src/choosenimpkg/common.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type
44
ChooseNimError* = object of NimbleError
55

66
const
7-
chooseNimVersion* = "0.8.10"
7+
chooseNimVersion* = "0.8.12"
88

99
proxies* = [
1010
"nim",

src/choosenimpkg/download.nim

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import nimblepkg/[version, cli]
77
when defined(curl):
88
import libcurl except Version
99

10-
import cliparams, common, utils
10+
import cliparams, common, utils, switcher
1111
# import telemetry
1212

1313
const
@@ -28,6 +28,35 @@ const # Windows-only
2828
const
2929
progressBarLength = 50
3030

31+
32+
proc getNightliesUrl(parsedContents: JsonNode, arch: int): (string, string) =
33+
let os =
34+
when defined(windows): "windows"
35+
elif defined(linux): "linux"
36+
elif defined(macosx): "osx"
37+
elif defined(freebsd): "freebsd"
38+
for jn in parsedContents.getElems():
39+
if jn["name"].getStr().contains("devel"):
40+
let tagName = jn{"tag_name"}.getStr("")
41+
for asset in jn["assets"].getElems():
42+
let aname = asset["name"].getStr()
43+
let url = asset{"browser_download_url"}.getStr("")
44+
if os in aname:
45+
when not defined(macosx):
46+
if "x" & $arch in aname:
47+
result = (url, tagName)
48+
else:
49+
if isAppleSilicon():
50+
if "arm64" in aname:
51+
result = (url, tagName)
52+
else:
53+
if "amd64" in aname:
54+
result = (url, tagName)
55+
if result[0].len != 0:
56+
break
57+
if result[0].len != 0:
58+
break
59+
3160
proc showIndeterminateBar(progress, speed: BiggestInt, lastPos: var int) =
3261
try:
3362
eraseLine()

src/choosenimpkg/switcher.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os, strutils, osproc, pegs
1+
import std/[os, strutils, osproc, pegs, json]
22

33
import nimblepkg/[cli, version, options]
44
from nimblepkg/tools import getNameVersionChecksum

src/choosenimpkg/utils.nim

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -180,29 +180,3 @@ proc getLatestCommit*(repo, branch: string): string =
180180
break
181181
else:
182182
display("Warning", outp & "\ngit ls-remote failed", Warning, HighPriority)
183-
184-
proc getNightliesUrl*(parsedContents: JsonNode, arch: int): (string, string) =
185-
let os =
186-
when defined(windows): "windows"
187-
elif defined(linux): "linux"
188-
elif defined(macosx): "osx"
189-
elif defined(freebsd): "freebsd"
190-
for jn in parsedContents.getElems():
191-
if jn["name"].getStr().contains("devel"):
192-
let tagName = jn{"tag_name"}.getStr("")
193-
for asset in jn["assets"].getElems():
194-
let aname = asset["name"].getStr()
195-
let url = asset{"browser_download_url"}.getStr("")
196-
if os in aname:
197-
when not defined(macosx):
198-
if "x" & $arch in aname:
199-
result = (url, tagName)
200-
else:
201-
# when choosenim become arm64 binary, isRosetta will be false. But we don't have nightlies for arm64 yet.
202-
# So, we should check if choosenim is compiled as x86_64 (nim's system.hostCPU returns amd64 even on Apple Silicon machines)
203-
if not isRosetta() and hostCPU == "amd64":
204-
result = (url, tagName)
205-
if result[0].len != 0:
206-
break
207-
if result[0].len != 0:
208-
break

0 commit comments

Comments
 (0)