Skip to content

Commit

Permalink
Merge pull request #68 from nim-lang/pr_update_macos
Browse files Browse the repository at this point in the history
choosenim supports macos arm64 nightlies
  • Loading branch information
ringabout authored Feb 6, 2025
2 parents a46c3e2 + 3170e0d commit 832d26b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion choosenim.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.8.10"
version = "0.8.12"
author = "Dominik Picheta"
description = "The Nim toolchain installer."
license = "BSD"
Expand Down
2 changes: 1 addition & 1 deletion src/choosenimpkg/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type
ChooseNimError* = object of NimbleError

const
chooseNimVersion* = "0.8.10"
chooseNimVersion* = "0.8.12"

proxies* = [
"nim",
Expand Down
31 changes: 30 additions & 1 deletion src/choosenimpkg/download.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import nimblepkg/[version, cli]
when defined(curl):
import libcurl except Version

import cliparams, common, utils
import cliparams, common, utils, switcher
# import telemetry

const
Expand All @@ -28,6 +28,35 @@ const # Windows-only
const
progressBarLength = 50


proc getNightliesUrl(parsedContents: JsonNode, arch: int): (string, string) =
let os =
when defined(windows): "windows"
elif defined(linux): "linux"
elif defined(macosx): "osx"
elif defined(freebsd): "freebsd"
for jn in parsedContents.getElems():
if jn["name"].getStr().contains("devel"):
let tagName = jn{"tag_name"}.getStr("")
for asset in jn["assets"].getElems():
let aname = asset["name"].getStr()
let url = asset{"browser_download_url"}.getStr("")
if os in aname:
when not defined(macosx):
if "x" & $arch in aname:
result = (url, tagName)
else:
if isAppleSilicon():
if "arm64" in aname:
result = (url, tagName)
else:
if "amd64" in aname:
result = (url, tagName)
if result[0].len != 0:
break
if result[0].len != 0:
break

proc showIndeterminateBar(progress, speed: BiggestInt, lastPos: var int) =
try:
eraseLine()
Expand Down
2 changes: 1 addition & 1 deletion src/choosenimpkg/switcher.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, strutils, osproc, pegs
import std/[os, strutils, osproc, pegs, json]

import nimblepkg/[cli, version, options]
from nimblepkg/tools import getNameVersionChecksum
Expand Down
26 changes: 0 additions & 26 deletions src/choosenimpkg/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,3 @@ proc getLatestCommit*(repo, branch: string): string =
break
else:
display("Warning", outp & "\ngit ls-remote failed", Warning, HighPriority)

proc getNightliesUrl*(parsedContents: JsonNode, arch: int): (string, string) =
let os =
when defined(windows): "windows"
elif defined(linux): "linux"
elif defined(macosx): "osx"
elif defined(freebsd): "freebsd"
for jn in parsedContents.getElems():
if jn["name"].getStr().contains("devel"):
let tagName = jn{"tag_name"}.getStr("")
for asset in jn["assets"].getElems():
let aname = asset["name"].getStr()
let url = asset{"browser_download_url"}.getStr("")
if os in aname:
when not defined(macosx):
if "x" & $arch in aname:
result = (url, tagName)
else:
# when choosenim become arm64 binary, isRosetta will be false. But we don't have nightlies for arm64 yet.
# So, we should check if choosenim is compiled as x86_64 (nim's system.hostCPU returns amd64 even on Apple Silicon machines)
if not isRosetta() and hostCPU == "amd64":
result = (url, tagName)
if result[0].len != 0:
break
if result[0].len != 0:
break

0 comments on commit 832d26b

Please sign in to comment.