Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
heinthanth authored Jul 23, 2024
1 parent 26dbccf commit d78e520
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/choosenimpkg/switcher.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ proc isMacOSBelowBigSurCompileTime(): bool =
const (versionOutput, _) = gorgeEx("sw_vers -productVersion")
const currentVersion = versionOutput.split(".")

if currentVersion.len() < 1: return false # version should be at least 11, like this
if currentVersion.len() < 1: return false # version should be at least two digit like `11`
let twoVersion = parseFloat(
if currentVersion.len() == 1:
currentVersion[0].strip()
Expand All @@ -43,7 +43,7 @@ proc isMacOSBelowBigSur(): bool =
let currentVersion = versionOutput.split(".")

if currentVersion.len() < 1:
return false # version should be at least 11 like this
return false # version should be at least two digit like `11`
let twoVersion = parseFloat(
if currentVersion.len() == 1:
currentVersion[0].strip()
Expand All @@ -69,19 +69,20 @@ when defined(macosx):
when not isMacOSBelowBigSurCompileTime():
const embeddedProxyExeArm: string = staticRead("proxyexe-arm64".addFileExt(ExeExt))
else:
{.warning: "Since choosenim is compiled on macOS that doesn't support arm64, choosenim proxies won't be able to produce arm64 result.".}
{.warning: "Since choosenim is compiled on macOS version below BigSur, choosenim won't be able to produce arm64 proxies.".}
const embeddedProxyExe = staticRead("proxyexe-amd64".addFileExt(ExeExt))
else:
const embeddedproxyExe: string = staticRead("proxyexe".addFileExt(ExeExt))

proc proxyToUse(): string =
when defined(macosx):
# it's big sur and above, so have to check Apple Silicon
# if user machine is running big sur and above, we have to check if it's Apple Silicon
if not isMacOSBelowBigSur() and isAppleSilicon():
when declared(embeddedProxyExeArm): # embeddedProxyExeArm doesn't exist means choosenim was compiled on machine that doesn't support arm64
when declared(embeddedProxyExeArm):
display("Debug:", "Using arm64 proxy", Warning, DebugPriority)
return embeddedProxyExeArm
display("Warning:", "Since choosenim is compiled on macOS that doesn't support arm64, choosenim proxies won't be able to install arm64 proxies.", Warning, DebugPriority)
# embeddedProxyExeArm doesn't exist means choosenim was compiled on machine with macOS version below BigSur
display("Warning:", "Since choosenim is compiled on macOS version below BigSur, choosenim won't be able to install arm64 proxies.", Warning, DebugPriority)
# normal linux, windows build ( the same as macos amd64 )
display("Debug:", "Using x86_64 proxy", Warning, DebugPriority)
return embeddedProxyExe
Expand Down
4 changes: 2 additions & 2 deletions src/choosenimpkg/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ proc getNightliesUrl*(parsedContents: JsonNode, arch: int): (string, string) =
if "x" & $arch in aname:
result = (url, tagName)
else:
# when choosenim become arm64, isRosetta will be false, so, we have to guard that hostCPU is amd64 to use nightlies
# we don't have arm64 nightlies yet
# 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:
Expand Down

0 comments on commit d78e520

Please sign in to comment.