Skip to content

Commit ab563e8

Browse files
Use csources_v2 when applicable (#9)
Based on dom96#317 --------- Co-authored-by: ringabout <[email protected]>
1 parent 13e851b commit ab563e8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/choosenimpkg/builder.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ proc buildCompiler(version: Version, params: CliParams) =
3030
display("Warning:", "Building from latest C sources. They may not be " &
3131
"compatible with the Nim version you have chosen to " &
3232
"install.", Warning, HighPriority)
33-
let path = downloadCSources(params)
33+
let path = downloadCSources(version, params)
3434
let extractDir = getCurrentDir() / "csources"
3535
extract(path, extractDir)
3636

src/choosenimpkg/download.nim

+11-3
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,19 @@ proc download*(version: Version, params: CliParams): string =
313313
raise newException(ChooseNimError, "Version $1 does not exist." %
314314
$version)
315315

316-
proc downloadCSources*(params: CliParams): string =
316+
template useCSourcesV2(version: Version): bool =
317+
$version in ["#head", "#devel", "#version-2-0"] or version >= parseVersion("2.0.0")
318+
319+
proc downloadCSources*(version: Version, params: CliParams): string =
320+
let csourcesAdaptedUrl =
321+
if useCSourcesV2(version):
322+
csourcesUrl & "_v2"
323+
else:
324+
csourcesUrl
317325
let
318-
commit = getLatestCommit(csourcesUrl, "master")
326+
commit = getLatestCommit(csourcesAdaptedUrl, "master")
319327
archive = if commit.len != 0: commit else: "master"
320-
csourcesArchiveUrl = $(parseUri(csourcesUrl) / (dlArchive % archive))
328+
csourcesArchiveUrl = $(parseUri(csourcesAdaptedUrl) / (dlArchive % archive))
321329

322330
var outputPath: string
323331
if not needsDownload(params, csourcesArchiveUrl, outputPath):

0 commit comments

Comments
 (0)