Skip to content

Commit

Permalink
Use csources_v2 when applicable (#9)
Browse files Browse the repository at this point in the history
Based on dom96#317

---------

Co-authored-by: ringabout <[email protected]>
  • Loading branch information
ire4ever1190 and ringabout authored Jan 23, 2024
1 parent 13e851b commit ab563e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/choosenimpkg/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ proc buildCompiler(version: Version, params: CliParams) =
display("Warning:", "Building from latest C sources. They may not be " &
"compatible with the Nim version you have chosen to " &
"install.", Warning, HighPriority)
let path = downloadCSources(params)
let path = downloadCSources(version, params)
let extractDir = getCurrentDir() / "csources"
extract(path, extractDir)

Expand Down
14 changes: 11 additions & 3 deletions src/choosenimpkg/download.nim
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,19 @@ proc download*(version: Version, params: CliParams): string =
raise newException(ChooseNimError, "Version $1 does not exist." %
$version)

proc downloadCSources*(params: CliParams): string =
template useCSourcesV2(version: Version): bool =
$version in ["#head", "#devel", "#version-2-0"] or version >= parseVersion("2.0.0")

proc downloadCSources*(version: Version, params: CliParams): string =
let csourcesAdaptedUrl =
if useCSourcesV2(version):
csourcesUrl & "_v2"
else:
csourcesUrl
let
commit = getLatestCommit(csourcesUrl, "master")
commit = getLatestCommit(csourcesAdaptedUrl, "master")
archive = if commit.len != 0: commit else: "master"
csourcesArchiveUrl = $(parseUri(csourcesUrl) / (dlArchive % archive))
csourcesArchiveUrl = $(parseUri(csourcesAdaptedUrl) / (dlArchive % archive))

var outputPath: string
if not needsDownload(params, csourcesArchiveUrl, outputPath):
Expand Down

0 comments on commit ab563e8

Please sign in to comment.